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 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

Member Function Documentation

◆ instanceName()

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

Definition at line 76 of file PhotonAnalysisConfig.py.

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

◆ makeAlgs()

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

Definition at line 118 of file PhotonAnalysisConfig.py.

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

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

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

Member Data Documentation

◆ applyIsolationCorrection

python.PhotonAnalysisConfig.PhotonCalibrationConfig.applyIsolationCorrection

Definition at line 247 of file PhotonAnalysisConfig.py.

◆ containerName

python.PhotonAnalysisConfig.PhotonCalibrationConfig.containerName

Definition at line 131 of file PhotonAnalysisConfig.py.

◆ crackVeto

python.PhotonAnalysisConfig.PhotonCalibrationConfig.crackVeto

Definition at line 157 of file PhotonAnalysisConfig.py.

◆ decorateCaloClusterEta

python.PhotonAnalysisConfig.PhotonCalibrationConfig.decorateCaloClusterEta

Definition at line 138 of file PhotonAnalysisConfig.py.

◆ enableCleaning

python.PhotonAnalysisConfig.PhotonCalibrationConfig.enableCleaning

Definition at line 192 of file PhotonAnalysisConfig.py.

◆ ESModel

python.PhotonAnalysisConfig.PhotonCalibrationConfig.ESModel

Definition at line 93 of file PhotonAnalysisConfig.py.

◆ forceFullSimConfigForIso

python.PhotonAnalysisConfig.PhotonCalibrationConfig.forceFullSimConfigForIso

Definition at line 266 of file PhotonAnalysisConfig.py.

◆ forceFullSimConfigForP4

python.PhotonAnalysisConfig.PhotonCalibrationConfig.forceFullSimConfigForP4

Definition at line 126 of file PhotonAnalysisConfig.py.

◆ recalibratePhyslite

python.PhotonAnalysisConfig.PhotonCalibrationConfig.recalibratePhyslite

Definition at line 214 of file PhotonAnalysisConfig.py.

◆ splitCalibrationAndSmearing

python.PhotonAnalysisConfig.PhotonCalibrationConfig.splitCalibrationAndSmearing

Definition at line 211 of file PhotonAnalysisConfig.py.


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