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

Constructor & Destructor Documentation

◆ __init__()

python.PhotonAnalysisConfig.PhotonCalibrationConfig.__init__ ( self)

Definition at line 21 of file PhotonAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

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

Definition at line 79 of file PhotonAnalysisConfig.py.

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

◆ makeAlgs()

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

Definition at line 121 of file PhotonAnalysisConfig.py.

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

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

84 def makeCalibrationAndSmearingAlg (self, config, name) :
85 """Create the calibration and smearing algorithm
86
87 Factoring this out into its own function, as we want to
88 instantiate it in multiple places"""
89 log = logging.getLogger('PhotonCalibrationConfig')
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 log.warning("No ESModel set for Run4, using Run3 model")
105 alg.calibrationAndSmearingTool.ESModel = 'es2024_Run3_v0'
106 else:
107 raise ValueError (f"Can't set up the ElectronCalibrationConfig with {config.geometry().value}, "
108 "there must be something wrong!")
109
110 alg.calibrationAndSmearingTool.decorrelationModel = self.decorrelationModel
111 alg.calibrationAndSmearingTool.useFastSim = (
112 0 if self.forceFullSimConfigForP4
113 else int( config.dataType() is DataType.FastSim ))
114 alg.calibrationAndSmearingTool.decorateEmva = self.decorateEmva
115 alg.egammas = config.readName (self.containerName)
116 alg.egammasOut = config.copyName (self.containerName)
117 alg.preselection = config.getPreselection (self.containerName, '')
118 return alg
119
120

Member Data Documentation

◆ addGlobalFELinksDep

python.PhotonAnalysisConfig.PhotonCalibrationConfig.addGlobalFELinksDep

Definition at line 158 of file PhotonAnalysisConfig.py.

◆ applyIsolationCorrection

python.PhotonAnalysisConfig.PhotonCalibrationConfig.applyIsolationCorrection

Definition at line 259 of file PhotonAnalysisConfig.py.

◆ containerName

python.PhotonAnalysisConfig.PhotonCalibrationConfig.containerName

Definition at line 134 of file PhotonAnalysisConfig.py.

◆ crackVeto

python.PhotonAnalysisConfig.PhotonCalibrationConfig.crackVeto

Definition at line 169 of file PhotonAnalysisConfig.py.

◆ decorateCaloClusterEta

python.PhotonAnalysisConfig.PhotonCalibrationConfig.decorateCaloClusterEta

Definition at line 141 of file PhotonAnalysisConfig.py.

◆ enableCleaning

python.PhotonAnalysisConfig.PhotonCalibrationConfig.enableCleaning

Definition at line 204 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 278 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 226 of file PhotonAnalysisConfig.py.

◆ splitCalibrationAndSmearing

python.PhotonAnalysisConfig.PhotonCalibrationConfig.splitCalibrationAndSmearing

Definition at line 223 of file PhotonAnalysisConfig.py.


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