ATLAS Offline Software
PFRun3Config.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
3 from AthenaConfiguration.ComponentFactory import CompFactory
4 from AthenaConfiguration.Enums import Format
5 
6 
7 #This configures pflow + everything it needs
8 def PFFullCfg(inputFlags,runTauReco=False,**kwargs):
9 
10  result=ComponentAccumulator()
11 
12  StoreGateSvc=CompFactory.StoreGateSvc
13  result.addService(StoreGateSvc("DetectorStore"))
14 
15  #Alias calibrated topoclusters, if they exist already, such that overwrite won't fial
16  from SGComps.AddressRemappingConfig import InputRenameCfg
17  result.merge(InputRenameCfg("xAOD::CaloClusterContainer","CaloCalTopoClusters",""))
18 
19  #setup magnetic field service
20  from MagFieldServices.MagFieldServicesConfig import AtlasFieldCacheCondAlgCfg
21  result.merge(AtlasFieldCacheCondAlgCfg(inputFlags))
22 
23  #Configure topocluster algorithmsm, and associated conditions
24  from CaloRec.CaloTopoClusterConfig import CaloTopoClusterCfg
25  result.merge(CaloTopoClusterCfg(inputFlags))
26 
27  from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
28  result.merge(CaloNoiseCondAlgCfg(inputFlags,"totalNoise"))
29  result.merge(CaloNoiseCondAlgCfg(inputFlags,"electronicNoise"))
30 
31  #Cache the track extrapolations
32  from TrackToCalo.CaloExtensionBuilderAlgCfg import CaloExtensionBuilderAlgCfg
33  # FIXME: This inversion to merge in CAs is a workaround, which can be removed once SiDetElementCondAlgs
34  # don't depend on Muons/TRT/alignment/otherSiSubdetectorAlignment anymore.
35  tempCA = CaloExtensionBuilderAlgCfg(inputFlags)
36  tempCA.merge(result)
37  result = tempCA
38 
39  from OutputStreamAthenaPool.OutputStreamConfig import addToAOD, addToESD
40  #PFlow requires tracks, electrons, photons, muons and taus in order to have valid links to them. So lets add these objects to the AOD and ESD
41  #PFlow also requires calo clusters for links to work, but these are added to output streams elsewhere already
42  toESDAndAOD = ["xAOD::TrackParticleContainer#InDetTrackParticles","xAOD::TrackParticleAuxContainer#InDetTrackParticlesAux."]
43  toESDAndAOD += ["xAOD::ElectronContainer#Electrons","xAOD::ElectronAuxContainer#ElectronsAux."]
44  toESDAndAOD += ["xAOD::PhotonContainer#Photons","xAOD::PhotonAuxContainer#PhotonsAux."]
45  toESDAndAOD += ["xAOD::MuonContainer#Muons","xAOD::MuonAuxContainer#MuonsAux."]
46  #If we rerun tau reco then it adds taus to the output itself, which results in an error message
47  #because you cannot mix +ve and -ve aux attributes (the below is considered +ve as a default).
48  if not runTauReco:
49  toESDAndAOD += ["xAOD::TauJetContainer#TauJets","xAOD::TauJetAuxContainer#TauJetsAux."]
50 
51  result.merge(addToESD(inputFlags, toESDAndAOD))
52  result.merge(addToAOD(inputFlags, toESDAndAOD))
53 
54  result.merge(PFCfg(inputFlags))
55  return result
56 
57 #Configures only the pflow algorithms and tools - to be used from RecExCommon to avoid
58 #conflicts or if you only want to configure just the pflow algorithms and tools
59 def PFCfg(inputFlags,**kwargs):
60 
61  result=ComponentAccumulator()
62 
63  #Configure the pflow algorithms
64  PFLeptonSelectorFactory=CompFactory.PFLeptonSelector
65  PFLeptonSelector = PFLeptonSelectorFactory("PFLeptonSelector")
66  PFLeptonSelector.selectElectrons=False
67  PFLeptonSelector.selectMuons=False
68  result.addEventAlgo(PFLeptonSelector)
69 
70  from eflowRec.PFCfg import PFTrackSelectorAlgCfg
71  useCaching = True
72  #If reading ESD/AOD do not make use of caching of track extrapolations.
73  if inputFlags.Input.Format is Format.POOL and "StreamRDO" not in inputFlags.Input.ProcessingTags:
74  useCaching = False
75  result.merge(PFTrackSelectorAlgCfg(inputFlags,"PFTrackSelector",useCaching))
76 
77  from eflowRec.PFCfg import getOfflinePFAlgorithm
78  result.merge(getOfflinePFAlgorithm(inputFlags))
79 
80  from eflowRec.PFCfg import getChargedFlowElementCreatorAlgorithm,getNeutralFlowElementCreatorAlgorithm,getLCNeutralFlowElementCreatorAlgorithm
81  result.addEventAlgo(getChargedFlowElementCreatorAlgorithm(inputFlags,""))
82  result.addEventAlgo(getNeutralFlowElementCreatorAlgorithm(inputFlags,""))
83  result.addEventAlgo(getLCNeutralFlowElementCreatorAlgorithm(inputFlags,""))
84 
85  #Only do linking if not in eoverp mode
86  if not inputFlags.PF.EOverPMode:
87  if inputFlags.PF.useElPhotLinks:
88  from eflowRec.PFCfg import getEGamFlowElementAssocAlgorithm
89  result.addEventAlgo(getEGamFlowElementAssocAlgorithm(inputFlags))
90 
91  if inputFlags.PF.useMuLinks and inputFlags.Detector.GeometryMuon:
92  from eflowRec.PFCfg import getMuonFlowElementAssocAlgorithm
93  result.addEventAlgo(getMuonFlowElementAssocAlgorithm(inputFlags))
94 
95  from OutputStreamAthenaPool.OutputStreamConfig import addToAOD, addToESD
96  toESDAndAOD = ""
97  if(inputFlags.PF.EOverPMode):
98  toESDAndAOD = ["xAOD::FlowElementContainer#EOverPChargedParticleFlowObjects","xAOD::FlowElementAuxContainer#EOverPChargedParticleFlowObjectsAux."]
99  toESDAndAOD += ["xAOD::FlowElementContainer#EOverPNeutralParticleFlowObjects","xAOD::FlowElementAuxContainer#EOverPNeutralParticleFlowObjectsAux."]
100  else:
101  toESDAndAOD = ["xAOD::FlowElementContainer#JetETMissChargedParticleFlowObjects", "xAOD::FlowElementAuxContainer#JetETMissChargedParticleFlowObjectsAux."]
102  toESDAndAOD += ["xAOD::FlowElementContainer#JetETMissNeutralParticleFlowObjects","xAOD::FlowElementAuxContainer#JetETMissNeutralParticleFlowObjectsAux.-FEShowerSubtractedClusterLink"]
103  toESDAndAOD += ["xAOD::FlowElementContainer#JetETMissLCNeutralParticleFlowObjects","xAOD::ShallowAuxContainer#JetETMissLCNeutralParticleFlowObjectsAux."]
104 
105  if inputFlags.PF.addCPData:
106  #if CPData mode, then add PFCaloCluster to ESD and AOD
107  #PFCaloCluster are the clusters modified by the PFlow algorithm
108  toESDAndAOD += ["xAOD::CaloClusterContainer#PFCaloCluster","xAOD::CaloClusterAuxContainer#PFCaloClusterAux."]
109  #also schedule an algoroithm to decorate each calo cluster with the cluster width in eta and phi
110  #this allows clients of the AOD to calculate deltaRPrime for track-calocluster pairs.
111  PFClusterWidthDecorator = CompFactory.PFClusterWidthDecorator()
112  result.addEventAlgo(PFClusterWidthDecorator)
113  #For the CP data we need to keep all the CaloCells and write to AOD
114  from TrigGepPerf.KeepCellsConfig import KeepCellsCfg
115  result.merge(KeepCellsCfg(inputFlags))
116  toESDAndAOD += ["CaloCellContainer#AllCalo"]
117 
118  result.merge(addToESD(inputFlags, toESDAndAOD))
119  result.merge(addToAOD(inputFlags, toESDAndAOD))
120 
121  #If we read an ESD then we cannot run the thinning because e.g electrons in the ESD
122  #have links to the neutral particle flow objects. If we run the thinning, then those
123  #links become invalid.
124  if "StreamESD" not in inputFlags.Input.ProcessingTags:
125  from ThinningUtils.ThinNegativeEnergyNeutralPFOCfg import ThinNegativeEnergyNeutralPFOCfg
126  result.merge(ThinNegativeEnergyNeutralPFOCfg(inputFlags))
127 
128  return result
129 
130 #Configure tau-FE link algorithm - this cannot be in PFCfg because
131 #pflow runs before taus in standard serial reco. Thus the links
132 #between taus and FE must happen after tau reco.
133 def PFTauFELinkCfg(inputFlags,**kwargs):
134  result=ComponentAccumulator()
135  from eflowRec.PFCfg import getTauFlowElementAssocAlgorithm
136  result.addEventAlgo(getTauFlowElementAssocAlgorithm(inputFlags))
137  return result
138 
139 # Run with python -m eflowRec.PFRun3Config
140 def PFRun3ConfigTest(flags=None):
141 
142  if flags is None:
143  from AthenaConfiguration.AllConfigFlags import initConfigFlags
144  flags = initConfigFlags()
145 
146  from AthenaConfiguration.TestDefaults import defaultTestFiles, defaultConditionsTags
147  flags.Input.Files = defaultTestFiles.ESD_RUN3_MC
148  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN3_MC
149  flags.Output.doWriteAOD=True
150  flags.Output.AODFileName="output_AOD.root"
151 
152  flags.fillFromArgs()
153  flags.lock()
154 
155  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
156  cfg=MainServicesCfg(flags)
157 
158  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
159  cfg.merge(PoolReadCfg(flags))
160  cfg.merge(PFFullCfg(flags))
161 
162  from eflowRec.PFRun3Remaps import ListRemaps
163 
164  list_remaps=ListRemaps()
165  for mapping in list_remaps:
166  cfg.merge(mapping)
167 
168  cfg.run()
169 
170 if __name__=="__main__":
PFCfg.getOfflinePFAlgorithm
def getOfflinePFAlgorithm(inputFlags)
Definition: PFCfg.py:444
PFRun3Config.PFFullCfg
def PFFullCfg(inputFlags, runTauReco=False, **kwargs)
Definition: PFRun3Config.py:8
KeepCellsConfig.KeepCellsCfg
def KeepCellsCfg(flags, streamName='StreamAOD')
Definition: KeepCellsConfig.py:6
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
PFRun3Config.PFCfg
def PFCfg(inputFlags, **kwargs)
Definition: PFRun3Config.py:59
PFCfg.getNeutralFlowElementCreatorAlgorithm
def getNeutralFlowElementCreatorAlgorithm(inputFlags, neutralFlowElementOutputName, nameSuffix="", eflowCaloObjectContainerName="eflowCaloObjects")
Definition: PFCfg.py:192
PFCfg.PFTrackSelectorAlgCfg
def PFTrackSelectorAlgCfg(inputFlags, algName, useCaching=True)
Definition: PFCfg.py:6
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
PFRun3Config.PFTauFELinkCfg
def PFTauFELinkCfg(inputFlags, **kwargs)
Definition: PFRun3Config.py:133
python.CaloNoiseCondAlgConfig.CaloNoiseCondAlgCfg
def CaloNoiseCondAlgCfg(flags, noisetype="totalNoise")
Definition: CaloNoiseCondAlgConfig.py:11
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
PFCfg.getChargedFlowElementCreatorAlgorithm
def getChargedFlowElementCreatorAlgorithm(inputFlags, chargedFlowElementOutputName, nameSuffix="", eflowCaloObjectContainerName="eflowCaloObjects")
Definition: PFCfg.py:178
PFCfg.getEGamFlowElementAssocAlgorithm
def getEGamFlowElementAssocAlgorithm(inputFlags, algName="", **kwargs)
Definition: PFCfg.py:218
PFCfg.getMuonFlowElementAssocAlgorithm
def getMuonFlowElementAssocAlgorithm(inputFlags, algName="", **kwargs)
Definition: PFCfg.py:299
PFCfg.getLCNeutralFlowElementCreatorAlgorithm
def getLCNeutralFlowElementCreatorAlgorithm(inputFlags, neutralFlowElementOutputName)
Definition: PFCfg.py:207
python.OutputStreamConfig.addToESD
def addToESD(flags, itemOrList, **kwargs)
Definition: OutputStreamConfig.py:127
PFCfg.getTauFlowElementAssocAlgorithm
def getTauFlowElementAssocAlgorithm(inputFlags, algName="", **kwargs)
Definition: PFCfg.py:397
python.CaloTopoClusterConfig.CaloTopoClusterCfg
def CaloTopoClusterCfg(flags, cellsname="AllCalo", clustersname=None, clustersnapname="CaloTopoClusters")
Definition: CaloTopoClusterConfig.py:318
CaloExtensionBuilderAlgCfg
Definition: CaloExtensionBuilderAlgCfg.py:1
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.OutputStreamConfig.addToAOD
def addToAOD(flags, itemOrList, **kwargs)
Definition: OutputStreamConfig.py:142
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
PFRun3Config.PFRun3ConfigTest
def PFRun3ConfigTest(flags=None)
Definition: PFRun3Config.py:140
python.MagFieldServicesConfig.AtlasFieldCacheCondAlgCfg
def AtlasFieldCacheCondAlgCfg(flags, **kwargs)
Definition: MagFieldServicesConfig.py:8
PFRun3Remaps.ListRemaps
def ListRemaps()
Definition: PFRun3Remaps.py:3
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
python.ThinNegativeEnergyNeutralPFOCfg.ThinNegativeEnergyNeutralPFOCfg
def ThinNegativeEnergyNeutralPFOCfg(flags, StreamName="StreamAOD")
Definition: ThinNegativeEnergyNeutralPFOCfg.py:7
PFCfg
Definition: PFCfg.py:1
AddressRemappingConfig.InputRenameCfg
def InputRenameCfg(type, from_name, to_name)
Definition: AddressRemappingConfig.py:28