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
 forceFullSimConfigForP4
 containerName
 decorateCaloClusterEta
 addGlobalFELinksDep
 crackVeto
 enableCleaning
 splitCalibrationAndSmearing
 recalibratePhyslite
 applyIsolationCorrection
 forceFullSimConfigForIso

Detailed Description

the ConfigBlock for the photon four-momentum correction

Definition at line 19 of file PhotonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.PhotonAnalysisConfig.PhotonCalibrationConfig.__init__ ( self)

Definition at line 22 of file PhotonAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

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

Definition at line 80 of file PhotonAnalysisConfig.py.

80 def instanceName (self) :
81 """Return the instance name for this block"""
82 return self.containerName + self.postfix
83
84

◆ makeAlgs()

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

Definition at line 123 of file PhotonAnalysisConfig.py.

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

◆ 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 85 of file PhotonAnalysisConfig.py.

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

Member Data Documentation

◆ addGlobalFELinksDep

python.PhotonAnalysisConfig.PhotonCalibrationConfig.addGlobalFELinksDep

Definition at line 161 of file PhotonAnalysisConfig.py.

◆ applyIsolationCorrection

python.PhotonAnalysisConfig.PhotonCalibrationConfig.applyIsolationCorrection

Definition at line 262 of file PhotonAnalysisConfig.py.

◆ containerName

python.PhotonAnalysisConfig.PhotonCalibrationConfig.containerName

Definition at line 137 of file PhotonAnalysisConfig.py.

◆ crackVeto

python.PhotonAnalysisConfig.PhotonCalibrationConfig.crackVeto

Definition at line 172 of file PhotonAnalysisConfig.py.

◆ decorateCaloClusterEta

python.PhotonAnalysisConfig.PhotonCalibrationConfig.decorateCaloClusterEta

Definition at line 144 of file PhotonAnalysisConfig.py.

◆ enableCleaning

python.PhotonAnalysisConfig.PhotonCalibrationConfig.enableCleaning

Definition at line 207 of file PhotonAnalysisConfig.py.

◆ ESModel

python.PhotonAnalysisConfig.PhotonCalibrationConfig.ESModel

Definition at line 96 of file PhotonAnalysisConfig.py.

◆ forceFullSimConfigForIso

python.PhotonAnalysisConfig.PhotonCalibrationConfig.forceFullSimConfigForIso

Definition at line 283 of file PhotonAnalysisConfig.py.

◆ forceFullSimConfigForP4

python.PhotonAnalysisConfig.PhotonCalibrationConfig.forceFullSimConfigForP4

Definition at line 129 of file PhotonAnalysisConfig.py.

◆ recalibratePhyslite

python.PhotonAnalysisConfig.PhotonCalibrationConfig.recalibratePhyslite

Definition at line 229 of file PhotonAnalysisConfig.py.

◆ splitCalibrationAndSmearing

python.PhotonAnalysisConfig.PhotonCalibrationConfig.splitCalibrationAndSmearing

Definition at line 226 of file PhotonAnalysisConfig.py.


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