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
 forceFullSimConfigForP4
 inputContainer
 containerName
 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 125 of file ElectronAnalysisConfig.py.

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

◆ 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 return alg
123
124

Member Data Documentation

◆ addGlobalFELinksDep

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.addGlobalFELinksDep

Definition at line 163 of file ElectronAnalysisConfig.py.

◆ containerName

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.containerName

Definition at line 137 of file ElectronAnalysisConfig.py.

◆ crackVeto

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.crackVeto

Definition at line 174 of file ElectronAnalysisConfig.py.

◆ decorateCaloClusterEta

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.decorateCaloClusterEta

Definition at line 140 of file ElectronAnalysisConfig.py.

◆ decorateSamplingPattern

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.decorateSamplingPattern

Definition at line 147 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 127 of file ElectronAnalysisConfig.py.

◆ inputContainer

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.inputContainer

Definition at line 135 of file ElectronAnalysisConfig.py.

◆ isolationCorrection

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.isolationCorrection

Definition at line 240 of file ElectronAnalysisConfig.py.

◆ recalibratePhyslite

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.recalibratePhyslite

Definition at line 195 of file ElectronAnalysisConfig.py.

◆ splitCalibrationAndSmearing

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.splitCalibrationAndSmearing

Definition at line 192 of file ElectronAnalysisConfig.py.


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