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 
114  result.merge(addToESD(inputFlags, toESDAndAOD))
115  result.merge(addToAOD(inputFlags, toESDAndAOD))
116 
117  #If we read an ESD then we cannot run the thinning because e.g electrons in the ESD
118  #have links to the neutral particle flow objects. If we run the thinning, then those
119  #links become invalid.
120  if "StreamESD" not in inputFlags.Input.ProcessingTags:
121  from ThinningUtils.ThinNegativeEnergyNeutralPFOCfg import ThinNegativeEnergyNeutralPFOCfg
122  result.merge(ThinNegativeEnergyNeutralPFOCfg(inputFlags))
123 
124  if inputFlags.PF.addCPData:
125  result.addEventAlgo(CompFactory.PFlowCellCPDataDecoratorAlgorithm())
126 
127  return result
128 
129 #Configure tau-FE link algorithm - this cannot be in PFCfg because
130 #pflow runs before taus in standard serial reco. Thus the links
131 #between taus and FE must happen after tau reco.
132 def PFTauFELinkCfg(inputFlags,**kwargs):
133  result=ComponentAccumulator()
134  from eflowRec.PFCfg import getTauFlowElementAssocAlgorithm
135  result.addEventAlgo(getTauFlowElementAssocAlgorithm(inputFlags))
136  return result
137 
138 if __name__=="__main__":
139 
140  from AthenaConfiguration.AllConfigFlags import initConfigFlags
141  cfgFlags = initConfigFlags()
142  cfgFlags.Concurrency.NumThreads=8
143  cfgFlags.Input.isMC=True
144  cfgFlags.Input.Files = ["/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/RecExRecoTest/mc21_13p6TeV/ESDFiles/mc21_13p6TeV.421450.PhPy8EG_A14_ttbar_hdamp258p75_SingleLep_fct.recon.ESD.e8445_e8447_s3822_r13565/ESD.28877240._000046.pool.root.1"]
145  # Use latest MC21 tag to pick up latest muon folders apparently needed
146  cfgFlags.IOVDb.GlobalTag = "OFLCOND-MC21-SDR-RUN3-10"
147  cfgFlags.Output.AODFileName="output_AOD.root"
148  cfgFlags.Output.doWriteAOD=True
149  cfgFlags.fillFromArgs()
150  cfgFlags.lock()
151 
152  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
153  cfg=MainServicesCfg(cfgFlags)
154 
155  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
156  cfg.merge(PoolReadCfg(cfgFlags))
157  cfg.merge(PFFullCfg(cfgFlags))
158 
159  from eflowRec.PFRun3Remaps import ListRemaps
160 
161  list_remaps=ListRemaps()
162  for mapping in list_remaps:
163  cfg.merge(mapping)
164 
165  cfg.run()
PFCfg.getOfflinePFAlgorithm
def getOfflinePFAlgorithm(inputFlags)
Definition: PFCfg.py:431
PFRun3Config.PFFullCfg
def PFFullCfg(inputFlags, runTauReco=False, **kwargs)
Definition: PFRun3Config.py:8
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:179
PFCfg.PFTrackSelectorAlgCfg
def PFTrackSelectorAlgCfg(inputFlags, algName, useCaching=True)
Definition: PFCfg.py:6
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
PFRun3Config.PFTauFELinkCfg
def PFTauFELinkCfg(inputFlags, **kwargs)
Definition: PFRun3Config.py:132
python.CaloNoiseCondAlgConfig.CaloNoiseCondAlgCfg
def CaloNoiseCondAlgCfg(flags, noisetype="totalNoise")
Definition: CaloNoiseCondAlgConfig.py:11
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:256
PFCfg.getChargedFlowElementCreatorAlgorithm
def getChargedFlowElementCreatorAlgorithm(inputFlags, chargedFlowElementOutputName, nameSuffix="", eflowCaloObjectContainerName="eflowCaloObjects")
Definition: PFCfg.py:165
PFCfg.getEGamFlowElementAssocAlgorithm
def getEGamFlowElementAssocAlgorithm(inputFlags, algName="", **kwargs)
Definition: PFCfg.py:205
PFCfg.getMuonFlowElementAssocAlgorithm
def getMuonFlowElementAssocAlgorithm(inputFlags, algName="", **kwargs)
Definition: PFCfg.py:286
PFCfg.getLCNeutralFlowElementCreatorAlgorithm
def getLCNeutralFlowElementCreatorAlgorithm(inputFlags, neutralFlowElementOutputName)
Definition: PFCfg.py:194
python.OutputStreamConfig.addToESD
def addToESD(flags, itemOrList, **kwargs)
Definition: OutputStreamConfig.py:127
PFCfg.getTauFlowElementAssocAlgorithm
def getTauFlowElementAssocAlgorithm(inputFlags, algName="", **kwargs)
Definition: PFCfg.py:384
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:569
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