ATLAS Offline Software
Loading...
Searching...
No Matches
python.PhotonAnalysisConfig.PhotonCalibrationConfig Class Reference
Inheritance diagram for python.PhotonAnalysisConfig.PhotonCalibrationConfig:
Collaboration diagram for python.PhotonAnalysisConfig.PhotonCalibrationConfig:

Public Member Functions

 __init__ (self)
 instanceName (self)
 makeCalibrationAndSmearingAlg (self, config, name)
 makeAlgs (self, config)

Public Attributes

 ESModel
 containerName
 forceFullSimConfigForP4
 decorateCaloClusterEta
 addGlobalFELinksDep
 crackVeto
 enableCleaning
 splitCalibrationAndSmearing
 recalibratePhyslite
 applyIsolationCorrection
 forceFullSimConfigForIso

Detailed Description

the ConfigBlock for the photon four-momentum correction

Definition at line 20 of file PhotonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.PhotonAnalysisConfig.PhotonCalibrationConfig.__init__ ( self)

Definition at line 23 of file PhotonAnalysisConfig.py.

23 def __init__ (self) :
24 super (PhotonCalibrationConfig, self).__init__ ()
25 self.setBlockName('Photons')
26 self.addOption ('containerName', '', type=str,
27 noneAction='error',
28 info="the name of the output container after calibration.",
29 meta={'role':'container'})
30 self.addOption ('ESModel', '', type=str,
31 info="flag for EGamma calibration. If left empty, uses the current recommendations.")
32 self.addOption ('decorrelationModel', '1NP_v1', type=str,
33 info="decorrelation model for the EGamma energy scale. Supported choices are: `FULL_v1`, `1NP_v1`.",
34 meta={'choices':(['FULL_v1','1NP_v1'],1)})
35 self.addOption ('postfix', '', type=str,
36 info="a postfix to apply to decorations and algorithm names. "
37 "Typically not needed here since the calibration is common to "
38 "all photons.")
39 self.addOption ('crackVeto', False, type=bool,
40 info=r"whether to perform LAr crack veto based on the cluster $\eta$, "
41 r"i.e. remove photons within $1.37<\vert\eta\vert<1.52$.")
42 self.addOption ('enableCleaning', True, type=bool,
43 info="whether to enable photon cleaning (`DFCommonPhotonsCleaning`).")
44 self.addOption ('cleaningAllowLate', False, type=bool,
45 info="whether to ignore timing information in cleaning "
46 "(`DFCommonPhotonsCleaningNoTime`).")
47 self.addOption ('recomputeIsEM', False, type=bool,
48 info="whether to recompute the photon shower shape fudge "
49 "corrections (sets up an instance of `CP::PhotonShowerShapeFudgeAlg`) or rely on derivation flags.")
50 self.addOption ('recalibratePhyslite', True, type=bool,
51 info="whether to run the `CP::EgammaCalibrationAndSmearingAlg` on "
52 "PHYSLITE derivations.")
53 self.addOption ('minPt', 10*GeV, type=float,
54 info=r"the minimum $p_\mathrm{T}$ cut (in MeV) to apply to calibrated photons.")
55 self.addOption ('maxEta', 2.37, type=float,
56 info=r"maximum photon $\vert\eta\vert$.")
57 self.addOption ('forceFullSimConfigForP4', False, type=bool,
58 info="whether to force the tool to use the configuration meant for "
59 "full simulation samples for 4-vector corrections. Only for testing purposes.")
60 self.addOption ('forceFullSimConfigForIso', False, type=bool,
61 info="whether to force the tool to use the configuration meant for "
62 "full simulation samples for isolation corrections. Only for testing purposes.")
63 self.addOption ('applyIsolationCorrection', True, type=bool,
64 info="whether to apply the isolation corrections.")
65 self.addOption ('splitCalibrationAndSmearing', False, type=bool,
66 info="EXPERIMENTAL: This splits the `EgammaCalibrationAndSmearingTool` "
67 " into two steps. The first step applies a baseline calibration that "
68 "is not affected by systematics. The second step then applies the "
69 "systematics dependent corrections. The net effect is that the "
70 "slower first step only has to be run once, while the second is run "
71 "once per systematic. ATLASG-2358.",
72 expertMode=True)
73 self.addOption ('decorateTruth', False, type=bool,
74 info="decorate the truth particle information on the reconstructed one.")
75 self.addOption ('decorateCaloClusterEta', False, type=bool,
76 info=r"decorate the calo-cluster $\eta$.")
77 self.addOption ('decorateEmva', False, type=bool,
78 info="decorate `E_mva_only` on the photons (needed for columnar tools/PHYSLITE).")
79 self.addOption ('addGlobalFELinksDep', False, type=bool,
80 info="whether to add dependencies for the global FE links (needed for PHYSLITE production)",
81 expertMode=True)
82

Member Function Documentation

◆ instanceName()

python.PhotonAnalysisConfig.PhotonCalibrationConfig.instanceName ( self)
Return the instance name for this block

Definition at line 83 of file PhotonAnalysisConfig.py.

83 def instanceName (self) :
84 """Return the instance name for this block"""
85 return self.containerName + self.postfix
86
87

◆ makeAlgs()

python.PhotonAnalysisConfig.PhotonCalibrationConfig.makeAlgs ( self,
config )

Definition at line 132 of file PhotonAnalysisConfig.py.

132 def makeAlgs (self, config) :
133
134 postfix = self.postfix
135 if postfix != '' and postfix[0] != '_' :
136 postfix = '_' + postfix
137
138 if self.forceFullSimConfigForP4:
139 warnings.warn_explicit(
140 "You are running PhotonCalibrationConfig forcing"
141 " full sim config for P4 corrections."
142 " This is only intended to be used for testing purposes.",
143 TestingOnlyWarning, filename='', lineno=0)
144
145 if config.isPhyslite() :
146 config.setSourceName (self.containerName, "AnalysisPhotons")
147 else :
148 config.setSourceName (self.containerName, "Photons")
149
150 cleaningWP = 'NoTime' if self.cleaningAllowLate else ''
151
152 # Decorate calo cluster eta if required
153 if self.decorateCaloClusterEta:
154 alg = config.createAlgorithm( 'CP::EgammaCaloClusterEtaAlg',
155 'PhotonEgammaCaloClusterEtaAlg',
156 reentrant=True )
157 alg.particles = config.readName(self.containerName)
158 config.addOutputVar (self.containerName, 'caloEta2', 'caloEta2', noSys=True, auxType='float')
159
160 # Set up a shallow copy to decorate
161 if config.wantCopy (self.containerName) :
162 alg = config.createAlgorithm( 'CP::AsgShallowCopyAlg', 'PhotonShallowCopyAlg' )
163 alg.input = config.readName (self.containerName)
164 alg.output = config.copyName (self.containerName)
165 alg.outputType = 'xAOD::PhotonContainer'
166 decorationList = ['DFCommonPhotonsCleaning',
167 'ptcone20_CloseByCorr',
168 'topoetcone20_CloseByCorr',
169 'topoetcone40_CloseByCorr']
170 if self.addGlobalFELinksDep:
171 decorationList += ['neutralGlobalFELinks', 'chargedGlobalFELinks']
172 if config.dataType() is not DataType.Data:
173 decorationList += ['TruthLink']
174 alg.declareDecorations = decorationList
175
176 # Set up the eta-cut on all photons prior to everything else
177 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'PhotonEtaCutAlg' )
178 alg.selectionDecoration = 'selectEta' + postfix + ',as_bits'
179 config.addPrivateTool( 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
180 alg.selectionTool.maxEta = self.maxEta
181 if self.crackVeto:
182 alg.selectionTool.etaGapLow = 1.37
183 alg.selectionTool.etaGapHigh = 1.52
184 alg.selectionTool.useClusterEta = True
185 alg.particles = config.readName (self.containerName)
186 alg.preselection = config.getPreselection (self.containerName, '')
187 config.addSelection (self.containerName, '', alg.selectionDecoration)
188
189 # Setup shower shape fudge
190 if self.recomputeIsEM and config.dataType() is DataType.FullSim:
191 alg = config.createAlgorithm( 'CP::PhotonShowerShapeFudgeAlg',
192 'PhotonShowerShapeFudgeAlg' )
193 config.addPrivateTool( 'showerShapeFudgeTool',
194 'ElectronPhotonVariableCorrectionTool' )
195 if config.geometry() is LHCPeriod.Run2:
196 alg.showerShapeFudgeTool.ConfigFile = \
197 'EGammaVariableCorrection/TUNE25/ElPhVariableNominalCorrection.conf'
198 if config.geometry() is LHCPeriod.Run3:
199 if config.campaign() in (Campaign.MC23a, Campaign.MC23d):
200 alg.showerShapeFudgeTool.ConfigFile = \
201 'EGammaVariableCorrection/TUNE28AD/ElPhVariableNominalCorrection.conf'
202 else:
203 alg.showerShapeFudgeTool.ConfigFile = \
204 'EGammaVariableCorrection/TUNE28EG/ElPhVariableNominalCorrection.conf'
205 alg.photons = config.readName (self.containerName)
206 alg.photonsOut = config.copyName (self.containerName)
207 alg.preselection = config.getPreselection (self.containerName, '')
208
209 # Select photons only with good object quality.
210 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'PhotonObjectQualityAlg' )
211 config.setExtraInputs ({('xAOD::EventInfo', 'EventInfo.RandomRunNumber')})
212 alg.selectionDecoration = 'goodOQ' + postfix + ',as_bits'
213 config.addPrivateTool( 'selectionTool', 'CP::EgammaIsGoodOQSelectionTool' )
214 alg.selectionTool.Mask = xAOD.EgammaParameters.BADCLUSPHOTON
215 alg.particles = config.readName (self.containerName)
216 alg.preselection = config.getPreselection (self.containerName, '')
217 config.addSelection (self.containerName, '', alg.selectionDecoration)
218
219 # Select clean photons
220 if self.enableCleaning:
221 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'PhotonCleaningAlg' )
222 config.addPrivateTool( 'selectionTool', 'CP::AsgFlagSelectionTool' )
223 alg.selectionDecoration = 'isClean' + postfix + ',as_bits'
224 alg.selectionTool.selectionFlags = ['DFCommonPhotonsCleaning' + cleaningWP]
225 alg.particles = config.readName (self.containerName)
226 alg.preselection = config.getPreselection (self.containerName, '')
227 config.addSelection (self.containerName, '', alg.selectionDecoration)
228
229 # Change the origin of Photons from (0,0,0) to (0,0,z)
230 # where z comes from the position of a vertex
231 # Default the one tagged as Primary
232 alg = config.createAlgorithm( 'CP::PhotonOriginCorrectionAlg',
233 'PhotonOriginCorrectionAlg',
234 reentrant=True )
235 alg.photons = config.readName (self.containerName)
236 alg.photonsOut = config.copyName (self.containerName)
237 alg.preselection = config.getPreselection (self.containerName, '')
238
239 if not self.splitCalibrationAndSmearing :
240 # Set up the calibration and smearing algorithm:
241 alg = self.makeCalibrationAndSmearingAlg (config, 'PhotonCalibrationAndSmearingAlg')
242 if config.isPhyslite() and not self.recalibratePhyslite :
243 alg.skipNominal = True
244 else:
245 # This splits the EgammaCalibrationAndSmearingTool into two
246 # steps. The first step applies a baseline calibration that
247 # is not affected by systematics. The second step then
248 # applies the systematics dependent corrections. The net
249 # effect is that the slower first step only has to be run
250 # once, while the second is run once per systematic.
251 #
252 # For now (22 May 24) this has to happen in the same job, as
253 # the output of the first step is not part of PHYSLITE, and
254 # even for the nominal the output of the first and second
255 # step are different. In the future the plan is to put both
256 # the output of the first and second step into PHYSLITE,
257 # allowing to skip the first step when running on PHYSLITE.
258 #
259 # WARNING: All of this is experimental, see: ATLASG-2358
260
261 # Set up the calibration algorithm:
262 alg = self.makeCalibrationAndSmearingAlg (config, 'PhotonBaseCalibrationAlg')
263 # turn off systematics for the calibration step
264 alg.noToolSystematics = True
265 # turn off smearing for the calibration step
266 alg.calibrationAndSmearingTool.doSmearing = False
267
268 # Set up the smearing algorithm:
269 alg = self.makeCalibrationAndSmearingAlg (config, 'PhotonCalibrationSystematicsAlg')
270 # turn off scale corrections for the smearing step
271 alg.calibrationAndSmearingTool.doScaleCorrection = False
272 alg.calibrationAndSmearingTool.useMVACalibration = False
273 alg.calibrationAndSmearingTool.decorateEmva = False
274
275 if not self.applyIsolationCorrection:
276 warnings.warn_explicit(
277 "You are not applying the isolation corrections."
278 " This is only intended to be used for testing purposes.",
279 TestingOnlyWarning, filename='', lineno=0)
280
281 if self.minPt > 0:
282
283 # Set up the the pt selection
284 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'PhotonPtCutAlg' )
285 alg.selectionDecoration = 'selectPt' + postfix + ',as_bits'
286 config.addPrivateTool( 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
287 alg.selectionTool.minPt = self.minPt
288 alg.particles = config.readName (self.containerName)
289 alg.preselection = config.getPreselection (self.containerName, '')
290 config.addSelection (self.containerName, '', alg.selectionDecoration,
291 preselection=True)
292
293 # Set up the isolation correction algorithm.
294 if self.applyIsolationCorrection:
295
296 if self.forceFullSimConfigForIso:
297 warnings.warn_explicit(
298 "You are running PhotonCalibrationConfig forcing"
299 " full sim config for isolation corrections."
300 " This is only intended to be used for testing purposes.",
301 TestingOnlyWarning, filename='', lineno=0)
302
303 alg = config.createAlgorithm( 'CP::EgammaIsolationCorrectionAlg',
304 'PhotonIsolationCorrectionAlg' )
305 config.addPrivateTool( 'isolationCorrectionTool',
306 'CP::IsolationCorrectionTool' )
307 alg.isolationCorrectionTool.IsMC = config.dataType() is not DataType.Data
308 alg.isolationCorrectionTool.AFII_corr = (
309 0 if self.forceFullSimConfigForIso
310 else config.dataType() is DataType.FastSim)
311 AODfixes = config.flags.Input.AODFixesDone
312 if "egammatopoIsoFix" in AODfixes:
313 alg.isolationCorrectionTool.FixTimingIssueInCore = False
314 else:
315 alg.isolationCorrectionTool.FixTimingIssueInCore = True
316 alg.egammas = config.readName (self.containerName)
317 alg.egammasOut = config.copyName (self.containerName)
318 alg.preselection = config.getPreselection (self.containerName, '')
319
320 # Additional decorations
321 alg = config.createAlgorithm( 'CP::AsgEnergyDecoratorAlg', 'EnergyDecorator' )
322 alg.particles = config.readName (self.containerName)
323
324 config.addOutputVar (self.containerName, 'pt', 'pt', auxType='float')
325 config.addOutputVar (self.containerName, 'eta', 'eta', noSys=True, auxType='float')
326 config.addOutputVar (self.containerName, 'phi', 'phi', noSys=True, auxType='float')
327 config.addOutputVar (self.containerName, 'e_%SYS%', 'e', auxType='float')
328 if self.splitCalibrationAndSmearing or not (config.isPhyslite() and not self.recalibratePhyslite) :
329 config.addOutputVar (self.containerName, 'caloClusterEnergyReso_%SYS%', 'caloClusterEnergyReso', noSys=True, auxType='float')
330
331 # decorate truth information on the reconstructed object:
332 if self.decorateTruth and config.dataType() is not DataType.Data:
333 config.addOutputVar (self.containerName, "truthType", "truth_type", noSys=True, auxType='int')
334 config.addOutputVar (self.containerName, "truthOrigin", "truth_origin", noSys=True, auxType='int')
335
336

◆ makeCalibrationAndSmearingAlg()

python.PhotonAnalysisConfig.PhotonCalibrationConfig.makeCalibrationAndSmearingAlg ( self,
config,
name )
Create the calibration and smearing algorithm

Factoring this out into its own function, as we want to
instantiate it in multiple places

Definition at line 88 of file PhotonAnalysisConfig.py.

88 def makeCalibrationAndSmearingAlg (self, config, name) :
89 """Create the calibration and smearing algorithm
90
91 Factoring this out into its own function, as we want to
92 instantiate it in multiple places"""
93
94 # Set up the calibration and smearing algorithm:
95 alg = config.createAlgorithm( 'CP::EgammaCalibrationAndSmearingAlg', name )
96 config.addPrivateTool( 'calibrationAndSmearingTool',
97 'CP::EgammaCalibrationAndSmearingTool' )
98 # Set default ESModel per period
99 if self.ESModel:
100 alg.calibrationAndSmearingTool.ESModel = self.ESModel
101 else:
102 if config.geometry() is LHCPeriod.Run2:
103 alg.calibrationAndSmearingTool.ESModel = 'es2023_R22_Run2_v1'
104 elif config.geometry() is LHCPeriod.Run3:
105 alg.calibrationAndSmearingTool.ESModel = 'es2024_Run3_v0'
106 elif config.geometry() is LHCPeriod.Run4:
107 warnings.warn_explicit(
108 "No ESModel set for Run4, using Run3 model",
109 Run4FallbackWarning, filename='', lineno=0)
110 alg.calibrationAndSmearingTool.ESModel = 'es2024_Run3_v0'
111 else:
112 raise ValueError (f"Can't set up the PhotonCalibrationConfig with {config.geometry().value}, "
113 "there must be something wrong!")
114
115 alg.calibrationAndSmearingTool.decorrelationModel = self.decorrelationModel
116 alg.calibrationAndSmearingTool.useFastSim = (
117 0 if self.forceFullSimConfigForP4
118 else int( config.dataType() is DataType.FastSim ))
119 alg.calibrationAndSmearingTool.decorateEmva = self.decorateEmva
120 # only photons are calibrated here, so skip loading the electron BDTs
121 alg.calibrationAndSmearingTool.DoElectronMVACalibration = False
122 alg.egammas = config.readName (self.containerName)
123 alg.egammasOut = config.copyName (self.containerName)
124 alg.preselection = config.getPreselection (self.containerName, '')
125
126 config.setContainerMeta (self.containerName, 'ESModel', alg.calibrationAndSmearingTool.ESModel, allowOverwrite=True)
127 config.setContainerMeta (self.containerName, 'decorrelationModel', alg.calibrationAndSmearingTool.decorrelationModel, allowOverwrite=True)
128
129 return alg
130
131

Member Data Documentation

◆ addGlobalFELinksDep

python.PhotonAnalysisConfig.PhotonCalibrationConfig.addGlobalFELinksDep

Definition at line 170 of file PhotonAnalysisConfig.py.

◆ applyIsolationCorrection

python.PhotonAnalysisConfig.PhotonCalibrationConfig.applyIsolationCorrection

Definition at line 275 of file PhotonAnalysisConfig.py.

◆ containerName

python.PhotonAnalysisConfig.PhotonCalibrationConfig.containerName

Definition at line 126 of file PhotonAnalysisConfig.py.

◆ crackVeto

python.PhotonAnalysisConfig.PhotonCalibrationConfig.crackVeto

Definition at line 181 of file PhotonAnalysisConfig.py.

◆ decorateCaloClusterEta

python.PhotonAnalysisConfig.PhotonCalibrationConfig.decorateCaloClusterEta

Definition at line 153 of file PhotonAnalysisConfig.py.

◆ enableCleaning

python.PhotonAnalysisConfig.PhotonCalibrationConfig.enableCleaning

Definition at line 220 of file PhotonAnalysisConfig.py.

◆ ESModel

python.PhotonAnalysisConfig.PhotonCalibrationConfig.ESModel

Definition at line 99 of file PhotonAnalysisConfig.py.

◆ forceFullSimConfigForIso

python.PhotonAnalysisConfig.PhotonCalibrationConfig.forceFullSimConfigForIso

Definition at line 296 of file PhotonAnalysisConfig.py.

◆ forceFullSimConfigForP4

python.PhotonAnalysisConfig.PhotonCalibrationConfig.forceFullSimConfigForP4

Definition at line 138 of file PhotonAnalysisConfig.py.

◆ recalibratePhyslite

python.PhotonAnalysisConfig.PhotonCalibrationConfig.recalibratePhyslite

Definition at line 242 of file PhotonAnalysisConfig.py.

◆ splitCalibrationAndSmearing

python.PhotonAnalysisConfig.PhotonCalibrationConfig.splitCalibrationAndSmearing

Definition at line 239 of file PhotonAnalysisConfig.py.


The documentation for this class was generated from the following file: