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 self.addOption ('ESModel', '', type=str,
36 info="flag for Egamma calibration. If left empty, use the current recommendations.")
37 self.addOption ('decorrelationModel', '1NP_v1', type=str,
38 info="decorrelation model for the EGamma energy scale. Supported choices are: `1NP_v1`, `FULL_v1`.")
39 self.addOption ('postfix', '', type=str,
40 info="a postfix to apply to decorations and algorithm names. Typically "
41 "not needed here since the calibration is common to all electrons.")
42 self.addOption ('crackVeto', False, type=bool,
43 info=r"whether to perform LAr crack veto based on the cluster $\eta$, "
44 r"i.e. remove electrons within $1.37<\vert\eta\vert<1.52$.")
45 self.addOption ('isolationCorrection', True, type=bool,
46 info="whether or not to perform isolation corrections (leakage "
47 "corrections), i.e. set up an instance of "
48 "`CP::EgammaIsolationCorrectionAlg`.",
49 expertMode=True)
50 self.addOption ('recalibratePhyslite', True, type=bool,
51 info="whether to run the `CP::EgammaCalibrationAndSmearingAlg` on "
52 "PHYSLITE derivations.")
53 self.addOption ('minPt', 4.5*GeV, type=float,
54 info=r"the minimum $p_\mathrm{T}$ cut (in MeV) to apply to calibrated electrons.")
55 self.addOption ('maxEta', 2.47, type=float,
56 info=r"maximum electron $\vert\eta\vert$.")
57 self.addOption ('forceFullSimConfigForP4', False, type=bool,
58 info="whether to force the tool to use the configuration meant for "
59 "full simulation samples for 4-vector corrections. Only for testing purposes.")
60 self.addOption ('forceFullSimConfigForIso', False, type=bool,
61 info="whether to force the tool to use the configuration meant for "
62 "full simulation samples for isolation corrections. Only for testing purposes.")
63 self.addOption ('splitCalibrationAndSmearing', False, type=bool,
64 info="EXPERIMENTAL: This splits the `EgammaCalibrationAndSmearingTool` "
65 " into two steps. The first step applies a baseline calibration that "
66 "is not affected by systematics. The second step then applies the "
67 "systematics-dependent corrections. The net effect is that the "
68 "slower first step only has to be run once, while the second is run "
69 "once per systematic. ATLASG-2358.",
70 expertMode=True)
71 self.addOption ('decorateTruth', False, type=bool,
72 info="decorate truth particle information on the reconstructed one.")
73 self.addOption ('decorateCaloClusterEta', False, type=bool,
74 info=r"decorate the calo cluster $\eta$.")
75 self.addOption ('decorateEmva', False, type=bool,
76 info="decorate `E_mva_only` on the electrons (needed for columnar tools/PHYSLITE).")
77 self.addOption ('decorateSamplingPattern', False, type=bool,
78 info="decorate `samplingPattern` on the clusters (meant for PHYSLITE).")
79 self.addOption ('addGlobalFELinksDep', False, type=bool,
80 info="whether to add dependencies for the global FE links (needed for PHYSLITE production)",
81 expertMode=True)
82

Member Function Documentation

◆ instanceName()

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

Definition at line 83 of file ElectronAnalysisConfig.py.

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

◆ makeAlgs()

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

Definition at line 129 of file ElectronAnalysisConfig.py.

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

◆ 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 87 of file ElectronAnalysisConfig.py.

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

Member Data Documentation

◆ addGlobalFELinksDep

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.addGlobalFELinksDep

Definition at line 167 of file ElectronAnalysisConfig.py.

◆ containerName

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.containerName

Definition at line 123 of file ElectronAnalysisConfig.py.

◆ crackVeto

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.crackVeto

Definition at line 178 of file ElectronAnalysisConfig.py.

◆ decorateCaloClusterEta

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.decorateCaloClusterEta

Definition at line 144 of file ElectronAnalysisConfig.py.

◆ decorateSamplingPattern

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.decorateSamplingPattern

Definition at line 151 of file ElectronAnalysisConfig.py.

◆ ESModel

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.ESModel

Definition at line 98 of file ElectronAnalysisConfig.py.

◆ forceFullSimConfigForP4

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.forceFullSimConfigForP4

Definition at line 131 of file ElectronAnalysisConfig.py.

◆ inputContainer

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.inputContainer

Definition at line 139 of file ElectronAnalysisConfig.py.

◆ isolationCorrection

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.isolationCorrection

Definition at line 244 of file ElectronAnalysisConfig.py.

◆ recalibratePhyslite

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.recalibratePhyslite

Definition at line 199 of file ElectronAnalysisConfig.py.

◆ splitCalibrationAndSmearing

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.splitCalibrationAndSmearing

Definition at line 196 of file ElectronAnalysisConfig.py.


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