ATLAS Offline Software
TCCAccumulator.py
Go to the documentation of this file.
1 #Matt A's custom python accumulator for R22
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 from pprint import pprint
6 
7 
8 
9 def MyAlgConfigNeutral(inputFlags,**kwargs,):
10  # this is based on the PFRun3Config, so parts of it are gonna be used as is
11  result=ComponentAccumulator()
12 
13  StoreGateSvc=CompFactory.StoreGateSvc
14 
15  result.addService(StoreGateSvc("DetectorStore"))
16 
17  #need to setup the track to vertex association tool (TTVA).
18  # seems you can do this from the AOD
19  # from TrackVertexAssociationTool.TTVAToolConfig import usedInFitDecoratorCfg
20  # result.addEventAlgo(usedInFitDecoratorCfg(cfgFlags, "TTVA"))
21 
22 
23  from TrackCaloClusterRecTools.TrackCaloClusterConfig import runTCCReconstruction
24  TCCReco=runTCCReconstruction(inputFlags, outputTCCName="TrackCaloClusters",doNeutral=True,doCharged=False,doCombined=False)
25  result.merge(TCCReco)
26 
27  StoreGateSvc.Dump = True
28  return result
29 
30 
31 
32 
33 def MyAlgConfigCharged(inputFlags,**kwargs,):
34  # this is based on the PFRun3Config, so parts of it are gonna be used as is
35  result=ComponentAccumulator()
36 
37  StoreGateSvc=CompFactory.StoreGateSvc
38 
39  result.addService(StoreGateSvc("DetectorStore"))
40 
41  #need to setup the track to vertex association tool (TTVA).
42  # seems you can do this from the AOD
43  # from TrackVertexAssociationTool.TTVAToolConfig import usedInFitDecoratorCfg
44  # result.addEventAlgo(usedInFitDecoratorCfg(cfgFlags, "TTVA"))
45 
46 
47  from TrackCaloClusterRecTools.TrackCaloClusterConfig import runTCCReconstruction
48  TCCReco=runTCCReconstruction(inputFlags, outputTCCName="TrackCaloClusters",doNeutral=False,doCharged=True,doCombined=False)
49  result.merge(TCCReco)
50 
51  StoreGateSvc.Dump = True
52  return result
53 
54 
55 def LinkerAlgConfig(inputFlags,**kwargs):
57  StoreGateSvc=CompFactory.StoreGateSvc
58  CA.addService(StoreGateSvc("DetectorStore"))
59 
60  from eflowRec.PFCfg import getEGamFlowElementAssocAlgorithm
61  from eflowRec.PFCfg import getMuonFlowElementAssocAlgorithm
62 
63  CA.addEventAlgo(getEGamFlowElementAssocAlgorithm(inputFlags,AODTest=False,doTCC=True))
64  CA.addEventAlgo(getMuonFlowElementAssocAlgorithm(inputFlags,LinkNeutralFEClusters=False,useMuonTopoClusters=False,AODTest=False,doTCC=True))
65  CA.printConfig()
66  #print("IO")
67  # iolist=result.getIO()
68  # for param in iolist:
69  # key=param["key"]
70  # prop=param["prop"]
71  # print(key,prop)
72 
73  return CA
74 
75 
76 def TauLinkerConfig(inputFlags, **kwargs):
77  #separate linker, can merge to main one for no loss of generality
78  TauLinkerCA=ComponentAccumulator()
79  # add Storegate
80  StoreGateSvc=CompFactory.StoreGateSvc
81  TauLinkerCA.addService(StoreGateSvc("DetectorStore"))
82 
83  from eflowRec.PFCfg import getTauFlowElementAssocAlgorithm
84  TauLinkerCA.addEventAlgo(getTauFlowElementAssocAlgorithm(inputFlags,doTCC=True))
85  return TauLinkerCA
86 
87 
88 
89 if __name__=="__main__":
90  from AthenaConfiguration.AllConfigFlags import initConfigFlags
91  cfgFlags = initConfigFlags()
92  cfgFlags.Input.isMC=True
93  cfgFlags.Input.Format="AOD"
94  # cfgFlags.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"]
95  # cfgFlags.Input.Files=["/scratch/anthony/TEST_AOD/TCC/valid1_test/valid1/AOD.24855256._000001.pool.root.1"]
96  cfgFlags.Input.Files=["/scratch/anthony/GPF_CODE//TCC_STUDIES/CustomAlg/myAOD.root"]
97  cfgFlags.Output.AODFileName="/scratch/anthony/GPF_CODE/TCC_STUDIES/CustomAlg/output_AOD.root"
98  cfgFlags.Exec.MaxEvents=20
99  cfgFlags.Output.doWriteAOD=True
100  cfgFlags.Common.ProductionStep=""
101  cfgFlags.dump()
102  cfgFlags.lock()
103 
104 
105  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
106  cfg=MainServicesCfg(cfgFlags)
107 
108  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
109  inputList=["xAOD::TrackParticleContainer#InDetTrackParticles", "xAOD::TrackParticleAuxContainer#InDetTrackParticlesAux."]
110  inputList.append("xAOD::FlowElementContainer#JetETMissChargedParticleFlowObjects")
111  inputList.append("xAOD::FlowElementContainer#JetETMissNeutralParticleFlowObjects")
112  inputList.append("xAOD::FlowElementAuxContainer#JetETMissNeutralParticleFlowObjectsAux.")
113  inputList.append("xAOD::FlowElementAuxContainer#JetETMissChargedParticleFlowObjectsAux.")
114  inputList.append("xAOD::FlowElementContainer#TrackCaloClustersCharged")
115  inputList.append("xAOD::FlowElementAuxContainer#TrackCaloClustersChargedAux.")
116  inputList.append("xAOD::FlowElementContainer#TrackCaloClustersNeutral")
117  inputList.append("xAOD::FlowElementAuxContainer#TrackCaloClustersNeutralAux.")
118 
119  inputList.append("xAOD::MuonContainer#Muons")
120  inputList.append("xAOD::MuonAuxContainer#*")
121  inputList.append("xAOD::PhotonContainer#Photons")
122  inputList.append("xAOD::PhotonAuxContainer#*")
123  inputList.append("xAOD::ElectronContainer#Electrons")
124  inputList.append("xAOD::ElectronAuxContainer#*")
125  inputList.append("xAOD::TauJetContainer#*")
126  inputList.append("xAOD::TauJetAuxContainer#*")
127 
128 
129  cfg.merge(OutputStreamCfg(cfgFlags,"AOD",ItemList=inputList))
130 
131  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
132 
133 
134  cfg.merge(PoolReadCfg(cfgFlags))
135  cfg.merge(MyAlgConfigNeutral(cfgFlags))
136  cfg.merge(MyAlgConfigCharged(cfgFlags))
137  cfg.merge(LinkerAlgConfig(cfgFlags)) # El/Phot/Muon linkers
138  #cfg.merge(TauLinkerConfig(cfgFlags)) # Tau linkers
139 
140  cfg.printConfig() # print full CA
141 
142  cfg.run()
143 
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
TCCAccumulator.MyAlgConfigNeutral
def MyAlgConfigNeutral(inputFlags, **kwargs)
Definition: TCCAccumulator.py:9
TCCAccumulator.MyAlgConfigCharged
def MyAlgConfigCharged(inputFlags, **kwargs)
Definition: TCCAccumulator.py:33
TCCAccumulator.LinkerAlgConfig
def LinkerAlgConfig(inputFlags, **kwargs)
Definition: TCCAccumulator.py:55
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:259
PFCfg.getEGamFlowElementAssocAlgorithm
def getEGamFlowElementAssocAlgorithm(inputFlags, algName="", **kwargs)
Definition: PFCfg.py:218
PFCfg.getMuonFlowElementAssocAlgorithm
def getMuonFlowElementAssocAlgorithm(inputFlags, algName="", **kwargs)
Definition: PFCfg.py:299
PFCfg.getTauFlowElementAssocAlgorithm
def getTauFlowElementAssocAlgorithm(inputFlags, algName="", **kwargs)
Definition: PFCfg.py:397
TCCAccumulator.TauLinkerConfig
def TauLinkerConfig(inputFlags, **kwargs)
Definition: TCCAccumulator.py:76
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
TrackCaloClusterConfig.runTCCReconstruction
def runTCCReconstruction(flags, caloClusterName="CaloCalTopoClusters", detectorEtaName="default", trackParticleName="InDetTrackParticles", assocPostfix="TCC", doCombined=False, doCharged=False, doNeutral=True, outputTCCName="TrackCaloClusters")
Definition: TrackCaloClusterConfig.py:80
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69