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
 crackVeto
 enableCleaning
 splitCalibrationAndSmearing
 recalibratePhyslite
 applyIsolationCorrection
 forceFullSimConfigForIso

Detailed Description

the ConfigBlock for the photon four-momentum correction

Definition at line 17 of file PhotonAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.PhotonAnalysisConfig.PhotonCalibrationConfig.__init__ ( self)

Definition at line 20 of file PhotonAnalysisConfig.py.

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

Member Function Documentation

◆ instanceName()

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

Definition at line 75 of file PhotonAnalysisConfig.py.

75 def instanceName (self) :
76 """Return the instance name for this block"""
77 return self.containerName + self.postfix
78
79

◆ makeAlgs()

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

Definition at line 117 of file PhotonAnalysisConfig.py.

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

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

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

Member Data Documentation

◆ applyIsolationCorrection

python.PhotonAnalysisConfig.PhotonCalibrationConfig.applyIsolationCorrection

Definition at line 244 of file PhotonAnalysisConfig.py.

◆ containerName

python.PhotonAnalysisConfig.PhotonCalibrationConfig.containerName

Definition at line 130 of file PhotonAnalysisConfig.py.

◆ crackVeto

python.PhotonAnalysisConfig.PhotonCalibrationConfig.crackVeto

Definition at line 155 of file PhotonAnalysisConfig.py.

◆ decorateCaloClusterEta

python.PhotonAnalysisConfig.PhotonCalibrationConfig.decorateCaloClusterEta

Definition at line 137 of file PhotonAnalysisConfig.py.

◆ enableCleaning

python.PhotonAnalysisConfig.PhotonCalibrationConfig.enableCleaning

Definition at line 189 of file PhotonAnalysisConfig.py.

◆ ESModel

python.PhotonAnalysisConfig.PhotonCalibrationConfig.ESModel

Definition at line 92 of file PhotonAnalysisConfig.py.

◆ forceFullSimConfigForIso

python.PhotonAnalysisConfig.PhotonCalibrationConfig.forceFullSimConfigForIso

Definition at line 263 of file PhotonAnalysisConfig.py.

◆ forceFullSimConfigForP4

python.PhotonAnalysisConfig.PhotonCalibrationConfig.forceFullSimConfigForP4

Definition at line 125 of file PhotonAnalysisConfig.py.

◆ recalibratePhyslite

python.PhotonAnalysisConfig.PhotonCalibrationConfig.recalibratePhyslite

Definition at line 211 of file PhotonAnalysisConfig.py.

◆ splitCalibrationAndSmearing

python.PhotonAnalysisConfig.PhotonCalibrationConfig.splitCalibrationAndSmearing

Definition at line 208 of file PhotonAnalysisConfig.py.


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