ATLAS Offline Software
UFOAccumulator.py
Go to the documentation of this file.
1 #Matt A's custom python accumulator for R22
2 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 
6 #Trigger xAODType.ObjectType dict entry loading
7 import cppyy
8 try:
9  cppyy.load_library('libxAODBaseObjectTypeDict')
10 except Exception:
11  pass
12 from ROOT import xAODType
13 xAODType.ObjectType
14 
15 def config_CHS_CSSK(flags,**kwargs):
16 
17  #Trigger xAODType.ObjectType dict entry loading
18  import cppyy
19  try:
20  cppyy.load_library('libxAODBaseObjectTypeDict')
21  except Exception:
22  pass
23  from ROOT import xAODType
24  xAODType.ObjectType
25  CHS_CSSK_CA=ComponentAccumulator()
26  # add storegate
27  StoreGateSvc=CompFactory.StoreGateSvc
28  CHS_CSSK_CA.addService(StoreGateSvc("DetectorStore"))
29  from JetRec.JetRecStandardToolManager import jtm
30  from JetRecTools.ConstitToolManager import ctm
31  from JetRecTools.JetRecToolsConf import CorrectPFOTool
32  ctm.add( CorrectPFOTool("CorrectPFOTool",
33  WeightPFOTool = jtm.pflowweighter,
34  InputIsEM = True,
35  CalibratePFO = False,
36  UseChargedWeights = True,
37  InputType = xAODType.FlowElement
38  ),
39  alias = 'correctPFO' )
40 
41  jtm += ctm.buildConstitModifSequence( "JetConstitSeq_PFlowCHS",
42  InputContainer = "JetETMiss",
43  OutputContainer = "CHS", #"ParticleFlowObjects" will be appended later
44  modList = ['correctPFO', 'chsPFO'] )
45 
46  CHS_CSSK_CA.merge(jtm)
47  return CHS_CSSK_CA
48 
49 
50 
51 def UFOConfig(flags, **kwargs):
52  # Configure UFO reconstruction algorithm instead of TCC
53  UFO_CA=ComponentAccumulator()
54  #add Storegate
55  StoreGateSvc=CompFactory.StoreGateSvc
56 
57  UFO_CA.addService(StoreGateSvc("DetectorStore"))
58  from TrackCaloClusterRecTools.TrackCaloClusterConfig import runUFOReconstruction_redux
59  from JetRecConfig.StandardJetConstits import stdConstitDic as cst
60  constituents=cst.EMPFlow
61  UFO_reco=runUFOReconstruction_redux(flags,constits=constituents,charged=True)
62  UFO_CA.merge(UFO_reco)
63 
64  return UFO_CA
65 
66 
67 
68 if __name__=="__main__":
69  from AthenaConfiguration.AllConfigFlags import initConfigFlags
70  flags = initConfigFlags()
71  flags.Input.isMC=True
72  flags.Input.Format="AOD"
73  # flags.Input.Files=["/scratch/anthony/TEST_AOD/TCC/mc16_13TeV.410470.PhPy8EG_A14_ttbar_hdamp258p75_nonallhad.recon.AOD.e6337_s3126_r10724/mc16_13TeV/AOD.14795494._007454.pool.root.1"]
74  # flags.Input.Files=["/scratch/anthony/TEST_AOD/TCC/valid1_test/valid1/AOD.24855256._000001.pool.root.1"]
75  flags.Input.Files=["/scratch/anthony/GPF_CODE//TCC_STUDIES/CustomAlg/myAOD.root"]
76  flags.Output.AODFileName="/scratch/anthony/GPF_CODE/TCC_STUDIES/CustomAlg/output_AOD.root"
77  flags.Exec.MaxEvents=20
78  flags.Output.doWriteAOD=True
79  flags.Common.ProductionStep=""
80  flags.dump()
81  flags.lock()
82 
83 
84  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
85  cfg=MainServicesCfg(flags)
86 
87  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
88  inputList=["xAOD::TrackParticleContainer#InDetTrackParticles", "xAOD::TrackParticleAuxContainer#InDetTrackParticlesAux."]
89  inputList.append("xAOD::FlowElementContainer#JetETMissChargedParticleFlowObjects")
90  inputList.append("xAOD::FlowElementContainer#JetETMissNeutralParticleFlowObjects")
91  inputList.append("xAOD::FlowElementAuxContainer#JetETMissNeutralParticleFlowObjectsAux.")
92  inputList.append("xAOD::FlowElementAuxContainer#JetETMissChargedParticleFlowObjectsAux.")
93  inputList.append("xAOD::FlowElementContainer#TrackCaloClustersCharged")
94  inputList.append("xAOD::FlowElementAuxContainer#TrackCaloClustersChargedAux.")
95  inputList.append("xAOD::FlowElementContainer#TrackCaloClustersNeutral")
96  inputList.append("xAOD::FlowElementAuxContainer#TrackCaloClustersNeutralAux.")
97 
98  inputList.append("xAOD::MuonContainer#Muons")
99  inputList.append("xAOD::MuonAuxContainer#*")
100  inputList.append("xAOD::PhotonContainer#Photons")
101  inputList.append("xAOD::PhotonAuxContainer#*")
102  inputList.append("xAOD::ElectronContainer#Electrons")
103  inputList.append("xAOD::ElectronAuxContainer#*")
104  inputList.append("xAOD::TauJetContainer#*")
105  inputList.append("xAOD::TauJetAuxContainer#*")
106 
107 
108  cfg.merge(OutputStreamCfg(flags,"AOD",ItemList=inputList))
109 
110  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
111 
112 
113  cfg.merge(PoolReadCfg(flags))
114  #cfg.merge(config_CHS_CSSK(flags)) # this config doesn't work
115  cfg.merge(UFOConfig(flags))
116  print("MASTER CA CONFIG")
117  print(cfg)
118  cfg.printConfig()
119 
120  cfg.run()
121 
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
UFOAccumulator.UFOConfig
def UFOConfig(flags, **kwargs)
Definition: UFOAccumulator.py:51
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
CorrectPFOTool
Definition: CorrectPFOTool.h:32
UFOAccumulator.config_CHS_CSSK
def config_CHS_CSSK(flags, **kwargs)
Definition: UFOAccumulator.py:15
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69