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

Constructor & Destructor Documentation

◆ __init__()

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.__init__ ( self)

Definition at line 22 of file ElectronAnalysisConfig.py.

22 def __init__ (self) :
23 super (ElectronMomentumCalibrationConfig, self).__init__ ()
24 self.setBlockName('Electrons')
25 self.addOption ('inputContainer', '', type=str,
26 info="the name of the input electron container. If left empty, automatically defaults "
27 "to `AnalysisElectrons` for PHYSLITE or `Electrons` otherwise.")
28 self.addOption ('containerName', '', type=str,
29 noneAction='error',
30 info="the name of the output container after calibration.")
31 self.addOption ('ESModel', '', type=str,
32 info="flag for Egamma calibration. If left empty, use the current recommendations.")
33 self.addOption ('decorrelationModel', '1NP_v1', type=str,
34 info="decorrelation model for the EGamma energy scale. Supported choices are: `1NP_v1`, `FULL_v1`.")
35 self.addOption ('postfix', '', type=str,
36 info="a postfix to apply to decorations and algorithm names. Typically "
37 "not needed here since the calibration is common to all electrons.")
38 self.addOption ('crackVeto', False, type=bool,
39 info=r"whether to perform LAr crack veto based on the cluster $\eta$, "
40 r"i.e. remove electrons within $1.37<\vert\eta\vert<1.52$.")
41 self.addOption ('isolationCorrection', True, type=bool,
42 info="whether or not to perform isolation corrections (leakage "
43 "corrections), i.e. set up an instance of "
44 "`CP::EgammaIsolationCorrectionAlg`.",
45 expertMode=True)
46 self.addOption ('recalibratePhyslite', True, type=bool,
47 info="whether to run the `CP::EgammaCalibrationAndSmearingAlg` on "
48 "PHYSLITE derivations.")
49 self.addOption ('minPt', 4.5*GeV, type=float,
50 info=r"the minimum $p_\mathrm{T}$ cut (in MeV) to apply to calibrated electrons.")
51 self.addOption ('maxEta', 2.47, type=float,
52 info=r"maximum electron $\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 ('splitCalibrationAndSmearing', False, type=bool,
60 info="EXPERIMENTAL: This splits the `EgammaCalibrationAndSmearingTool` "
61 " into two steps. The first step applies a baseline calibration that "
62 "is not affected by systematics. The second step then applies the "
63 "systematics-dependent corrections. The net effect is that the "
64 "slower first step only has to be run once, while the second is run "
65 "once per systematic. ATLASG-2358.",
66 expertMode=True)
67 self.addOption ('decorateTruth', False, type=bool,
68 info="decorate truth particle information on the reconstructed one.")
69 self.addOption ('decorateCaloClusterEta', False, type=bool,
70 info=r"decorate the calo cluster $\eta$.")
71 self.addOption ('decorateEmva', False, type=bool,
72 info="decorate `E_mva_only` on the electrons (needed for columnar tools/PHYSLITE).")
73 self.addOption ('decorateSamplingPattern', False, type=bool,
74 info="decorate `samplingPattern` on the clusters (meant for PHYSLITE).")
75 self.addOption ('addGlobalFELinksDep', False, type=bool,
76 info="whether to add dependencies for the global FE links (needed for PHYSLITE production)",
77 expertMode=True)
78

Member Function Documentation

◆ instanceName()

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

Definition at line 79 of file ElectronAnalysisConfig.py.

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

◆ makeAlgs()

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

Definition at line 120 of file ElectronAnalysisConfig.py.

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

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

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

Member Data Documentation

◆ addGlobalFELinksDep

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.addGlobalFELinksDep

Definition at line 157 of file ElectronAnalysisConfig.py.

◆ containerName

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.containerName

Definition at line 131 of file ElectronAnalysisConfig.py.

◆ crackVeto

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.crackVeto

Definition at line 168 of file ElectronAnalysisConfig.py.

◆ decorateCaloClusterEta

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.decorateCaloClusterEta

Definition at line 134 of file ElectronAnalysisConfig.py.

◆ decorateSamplingPattern

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.decorateSamplingPattern

Definition at line 141 of file ElectronAnalysisConfig.py.

◆ ESModel

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.ESModel

Definition at line 95 of file ElectronAnalysisConfig.py.

◆ forceFullSimConfigForP4

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.forceFullSimConfigForP4

Definition at line 124 of file ElectronAnalysisConfig.py.

◆ inputContainer

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.inputContainer

Definition at line 129 of file ElectronAnalysisConfig.py.

◆ isolationCorrection

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.isolationCorrection

Definition at line 234 of file ElectronAnalysisConfig.py.

◆ recalibratePhyslite

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.recalibratePhyslite

Definition at line 189 of file ElectronAnalysisConfig.py.

◆ splitCalibrationAndSmearing

python.ElectronAnalysisConfig.ElectronMomentumCalibrationConfig.splitCalibrationAndSmearing

Definition at line 186 of file ElectronAnalysisConfig.py.


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