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

Public Member Functions

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

Public Attributes

 ESModel
 containerName
 forceFullSimConfigForP4
 inputContainer
 decorateCaloClusterEta
 decorateSamplingPattern
 addGlobalFELinksDep
 crackVeto
 splitCalibrationAndSmearing
 recalibratePhyslite
 isolationCorrection

Detailed Description

the ConfigBlock for the electron four-momentum correction

Definition at line 23 of file ElectronAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.__init__ ( self)

Definition at line 26 of file ElectronAnalysisConfig.py.

26 def __init__ (self) :
27 super (ElectronMomentumCalibrationConfig, self).__init__ ()
28 self.setBlockName('Electrons')
29 self.addOption ('inputContainer', '', type=str,
30 info="the name of the input electron container. If left empty, automatically defaults "
31 "to `AnalysisElectrons` for PHYSLITE or `Electrons` otherwise.")
32 self.addOption ('containerName', '', type=str,
33 noneAction='error',
34 info="the name of the output container after calibration.",
35 meta={'role':'container'})
36 self.addOption ('ESModel', '', type=str,
37 info="flag for Egamma calibration. If left empty, use the current recommendations.")
38 self.addOption ('decorrelationModel', '1NP_v1', type=str,
39 info="decorrelation model for the EGamma energy scale. Supported choices are: `1NP_v1`, `FULL_v1`.",
40 meta={'choices':(['1NP_v1','FULL_v1'],1)})
41 self.addOption ('postfix', '', type=str,
42 info="a postfix to apply to decorations and algorithm names. Typically "
43 "not needed here since the calibration is common to all electrons.")
44 self.addOption ('crackVeto', False, type=bool,
45 info=r"whether to perform LAr crack veto based on the cluster $\eta$, "
46 r"i.e. remove electrons within $1.37<\vert\eta\vert<1.52$.")
47 self.addOption ('isolationCorrection', True, type=bool,
48 info="whether or not to perform isolation corrections (leakage "
49 "corrections), i.e. set up an instance of "
50 "`CP::EgammaIsolationCorrectionAlg`.",
51 expertMode=True)
52 self.addOption ('recalibratePhyslite', True, type=bool,
53 info="whether to run the `CP::EgammaCalibrationAndSmearingAlg` on "
54 "PHYSLITE derivations.")
55 self.addOption ('minPt', 4.5*GeV, type=float,
56 info=r"the minimum $p_\mathrm{T}$ cut (in MeV) to apply to calibrated electrons.")
57 self.addOption ('maxEta', 2.47, type=float,
58 info=r"maximum electron $\vert\eta\vert$.")
59 self.addOption ('forceFullSimConfigForP4', False, type=bool,
60 info="whether to force the tool to use the configuration meant for "
61 "full simulation samples for 4-vector corrections. Only for testing purposes.")
62 self.addOption ('forceFullSimConfigForIso', False, type=bool,
63 info="whether to force the tool to use the configuration meant for "
64 "full simulation samples for isolation corrections. Only for testing purposes.")
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 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 electrons (needed for columnar tools/PHYSLITE).")
79 self.addOption ('decorateSamplingPattern', False, type=bool,
80 info="decorate `samplingPattern` on the clusters (meant for PHYSLITE).")
81 self.addOption ('addGlobalFELinksDep', False, type=bool,
82 info="whether to add dependencies for the global FE links (needed for PHYSLITE production)",
83 expertMode=True)
84

Member Function Documentation

◆ instanceName()

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.instanceName ( self)
Return the instance name for this block

Definition at line 85 of file ElectronAnalysisConfig.py.

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

◆ makeAlgs()

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.makeAlgs ( self,
config )

Definition at line 131 of file ElectronAnalysisConfig.py.

131 def makeAlgs (self, config) :
132
133 if self.forceFullSimConfigForP4:
134 warnings.warn_explicit(
135 "You are running ElectronCalibrationConfig forcing full sim"
136 " config. This is only intended to be used for testing"
137 " purposes.",
138 TestingOnlyWarning, filename='', lineno=0)
139
140 inputContainer = "AnalysisElectrons" if config.isPhyslite() else "Electrons"
141 if self.inputContainer:
142 inputContainer = self.inputContainer
143 config.setSourceName (self.containerName, inputContainer)
144
145 # Decorate calo cluster eta if required
146 if self.decorateCaloClusterEta:
147 alg = config.createAlgorithm( 'CP::EgammaCaloClusterEtaAlg',
148 'ElectronEgammaCaloClusterEtaAlg',
149 reentrant=True )
150 alg.particles = config.readName(self.containerName)
151 config.addOutputVar (self.containerName, 'caloEta2', 'caloEta2', noSys=True)
152
153 if self.decorateSamplingPattern:
154 config.createAlgorithm( 'CP::EgammaSamplingPatternDecoratorAlg', 'EgammaSamplingPatternDecoratorAlg' )
155
156 # Set up a shallow copy to decorate
157 if config.wantCopy (self.containerName) :
158 alg = config.createAlgorithm( 'CP::AsgShallowCopyAlg', 'ElectronShallowCopyAlg' )
159 alg.input = config.readName (self.containerName)
160 alg.output = config.copyName (self.containerName)
161 alg.outputType = 'xAOD::ElectronContainer'
162 decorationList = ['DFCommonElectronsLHLoose',
163 'neflowisol20',
164 'ptcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt500',
165 'ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt500',
166 'ptcone20_Nonprompt_All_MaxWeightTTVALooseCone_pt1000_CloseByCorr',
167 'ptvarcone30_Nonprompt_All_MaxWeightTTVALooseCone_pt1000_CloseByCorr',
168 'topoetcone20_CloseByCorr','DFCommonAddAmbiguity']
169 if self.addGlobalFELinksDep:
170 decorationList += ['neutralGlobalFELinks', 'chargedGlobalFELinks']
171 if config.dataType() is not DataType.Data:
172 decorationList += ['TruthLink']
173 alg.declareDecorations = decorationList
174
175 # Set up the eta-cut on all electrons prior to everything else
176 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronEtaCutAlg' )
177 alg.selectionDecoration = 'selectEta' + self.postfix + ',as_bits'
178 config.addPrivateTool( 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
179 alg.selectionTool.maxEta = self.maxEta
180 if self.crackVeto:
181 alg.selectionTool.etaGapLow = 1.37
182 alg.selectionTool.etaGapHigh = 1.52
183 alg.selectionTool.useClusterEta = True
184 alg.particles = config.readName (self.containerName)
185 alg.preselection = config.getPreselection (self.containerName, '')
186 config.addSelection (self.containerName, '', alg.selectionDecoration)
187
188 # Select electrons only with good object quality.
189 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronObjectQualityAlg' )
190 config.setExtraInputs ({('xAOD::EventInfo', 'EventInfo.RandomRunNumber')})
191 alg.selectionDecoration = 'goodOQ' + self.postfix + ',as_bits'
192 config.addPrivateTool( 'selectionTool', 'CP::EgammaIsGoodOQSelectionTool' )
193 alg.selectionTool.Mask = xAOD.EgammaParameters.BADCLUSELECTRON
194 alg.particles = config.readName (self.containerName)
195 alg.preselection = config.getPreselection (self.containerName, '')
196 config.addSelection (self.containerName, '', alg.selectionDecoration)
197
198 if not self.splitCalibrationAndSmearing :
199 # Set up the calibration and smearing algorithm:
200 alg = self.makeCalibrationAndSmearingAlg (config, 'ElectronCalibrationAndSmearingAlg')
201 if config.isPhyslite() and not self.recalibratePhyslite :
202 alg.skipNominal = True
203 else:
204 # This splits the EgammaCalibrationAndSmearingTool into two
205 # steps. The first step applies a baseline calibration that
206 # is not affected by systematics. The second step then
207 # applies the systematics dependent corrections. The net
208 # effect is that the slower first step only has to be run
209 # once, while the second is run once per systematic.
210 #
211 # For now (22 May 24) this has to happen in the same job, as
212 # the output of the first step is not part of PHYSLITE, and
213 # even for the nominal the output of the first and second
214 # step are different. In the future the plan is to put both
215 # the output of the first and second step into PHYSLITE,
216 # allowing to skip the first step when running on PHYSLITE.
217 #
218 # WARNING: All of this is experimental, see: ATLASG-2358
219
220 # Set up the calibration algorithm:
221 alg = self.makeCalibrationAndSmearingAlg (config, 'ElectronBaseCalibrationAlg')
222 # turn off systematics for the calibration step
223 alg.noToolSystematics = True
224 # turn off smearing for the calibration step
225 alg.calibrationAndSmearingTool.doSmearing = False
226
227 # Set up the smearing algorithm:
228 alg = self.makeCalibrationAndSmearingAlg (config, 'ElectronCalibrationSystematicsAlg')
229 # turn off scale corrections for the smearing step
230 alg.calibrationAndSmearingTool.doScaleCorrection = False
231 alg.calibrationAndSmearingTool.useMVACalibration = False
232 alg.calibrationAndSmearingTool.decorateEmva = False
233
234 if self.minPt > 0 :
235 # Set up the the pt selection
236 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'ElectronPtCutAlg' )
237 alg.selectionDecoration = 'selectPt' + self.postfix + ',as_bits'
238 config.addPrivateTool( 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
239 alg.selectionTool.minPt = self.minPt
240 alg.particles = config.readName (self.containerName)
241 alg.preselection = config.getPreselection (self.containerName, '')
242 config.addSelection (self.containerName, '', alg.selectionDecoration,
243 preselection=True)
244
245 # Set up the isolation correction algorithm:
246 if self.isolationCorrection:
247 alg = config.createAlgorithm( 'CP::EgammaIsolationCorrectionAlg',
248 'ElectronIsolationCorrectionAlg' )
249 config.addPrivateTool( 'isolationCorrectionTool',
250 'CP::IsolationCorrectionTool' )
251 alg.isolationCorrectionTool.IsMC = config.dataType() is not DataType.Data
252 alg.isolationCorrectionTool.AFII_corr = (
253 0 if self.forceFullSimConfigForIso
254 else config.dataType() is DataType.FastSim)
255 AODfixes = config.flags.Input.AODFixesDone
256 if "egammatopoIsoFix" in AODfixes:
257 alg.isolationCorrectionTool.FixTimingIssueInCore = False
258 else:
259 alg.isolationCorrectionTool.FixTimingIssueInCore = True
260 alg.isolationCorrectionTool.ToolVer = "REL22"
261 alg.isolationCorrectionTool.CorrFile = "IsolationCorrections/v6/isolation_ptcorrections_rel22_mc20.root"
262 alg.egammas = config.readName (self.containerName)
263 alg.egammasOut = config.copyName (self.containerName)
264 alg.egammasType = 'xAOD::ElectronContainer'
265 alg.preselection = config.getPreselection (self.containerName, '')
266 else:
267 warnings.warn_explicit(
268 "You are not applying the isolation corrections."
269 " This is only intended to be used for testing purposes.",
270 TestingOnlyWarning, filename='', lineno=0)
271
272 alg = config.createAlgorithm( 'CP::AsgEnergyDecoratorAlg', 'EnergyDecorator' )
273 alg.particles = config.readName(self.containerName)
274
275 config.addOutputVar (self.containerName, 'pt', 'pt')
276 config.addOutputVar (self.containerName, 'eta', 'eta', noSys=True)
277 config.addOutputVar (self.containerName, 'phi', 'phi', noSys=True)
278 config.addOutputVar (self.containerName, 'e_%SYS%', 'e')
279 config.addOutputVar (self.containerName, 'charge', 'charge', noSys=True)
280 config.addOutputVar (self.containerName, 'caloClusterEnergyReso_%SYS%', 'caloClusterEnergyReso', noSys=True)
281
282 # decorate truth information on the reconstructed object:
283 if self.decorateTruth and config.dataType() is not DataType.Data:
284 config.addOutputVar (self.containerName, "truthType", "truth_type", noSys=True, auxType='int')
285 config.addOutputVar (self.containerName, "truthOrigin", "truth_origin", noSys=True, auxType='int')
286
287 config.addOutputVar (self.containerName, "firstEgMotherPdgId", "truth_firstEgMotherPdgId", noSys=True, auxType='int')
288 config.addOutputVar (self.containerName, "firstEgMotherTruthOrigin", "truth_firstEgMotherTruthOrigin", noSys=True, auxType='int')
289 config.addOutputVar (self.containerName, "firstEgMotherTruthType", "truth_firstEgMotherTruthType", noSys=True, auxType='int')
290
291

◆ makeCalibrationAndSmearingAlg()

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.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 89 of file ElectronAnalysisConfig.py.

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

Member Data Documentation

◆ addGlobalFELinksDep

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.addGlobalFELinksDep

Definition at line 169 of file ElectronAnalysisConfig.py.

◆ containerName

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.containerName

Definition at line 125 of file ElectronAnalysisConfig.py.

◆ crackVeto

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.crackVeto

Definition at line 180 of file ElectronAnalysisConfig.py.

◆ decorateCaloClusterEta

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.decorateCaloClusterEta

Definition at line 146 of file ElectronAnalysisConfig.py.

◆ decorateSamplingPattern

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.decorateSamplingPattern

Definition at line 153 of file ElectronAnalysisConfig.py.

◆ ESModel

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.ESModel

Definition at line 100 of file ElectronAnalysisConfig.py.

◆ forceFullSimConfigForP4

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.forceFullSimConfigForP4

Definition at line 133 of file ElectronAnalysisConfig.py.

◆ inputContainer

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.inputContainer

Definition at line 141 of file ElectronAnalysisConfig.py.

◆ isolationCorrection

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.isolationCorrection

Definition at line 246 of file ElectronAnalysisConfig.py.

◆ recalibratePhyslite

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.recalibratePhyslite

Definition at line 201 of file ElectronAnalysisConfig.py.

◆ splitCalibrationAndSmearing

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.splitCalibrationAndSmearing

Definition at line 198 of file ElectronAnalysisConfig.py.


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