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

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

Detailed Description

the ConfigBlock for the electron four-momentum correction

Definition at line 19 of file ElectronAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.ElectronAnalysisConfig.ElectronCalibrationConfig.__init__ ( self)

Definition at line 22 of file ElectronAnalysisConfig.py.

22 def __init__ (self) :
23 super (ElectronCalibrationConfig, 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 ('runTrackBiasing', False, type=bool,
68 info="EXPERIMENTAL: This enables the `InDetTrackBiasingTool`, for "
69 "tracks associated to electrons. The tool does not have Run 3 "
70 "recommendations yet.",
71 expertMode=True)
72 self.addOption ('decorateTruth', False, type=bool,
73 info="decorate truth particle information on the reconstructed one.")
74 self.addOption ('decorateCaloClusterEta', False, type=bool,
75 info=r"decorate the calo cluster $\eta$.")
76 self.addOption ('writeTrackD0Z0', False, type = bool,
77 info=r"save the $d_0$ significance and $z_0\sin\theta$ variables.")
78 self.addOption ('decorateEmva', False, type=bool,
79 info="decorate `E_mva_only` on the electrons (needed for columnar tools/PHYSLITE).")
80 self.addOption ('decorateSamplingPattern', False, type=bool,
81 info="decorate `samplingPattern` on the clusters (meant for PHYSLITE).")
82 self.addOption ('addGlobalFELinksDep', False, type=bool,
83 info="whether to add dependencies for the global FE links (needed for PHYSLITE production)",
84 expertMode=True)
85

Member Function Documentation

◆ instanceName()

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

Definition at line 86 of file ElectronAnalysisConfig.py.

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

◆ makeAlgs()

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

Definition at line 127 of file ElectronAnalysisConfig.py.

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

◆ makeCalibrationAndSmearingAlg()

python.ElectronAnalysisConfig.ElectronCalibrationConfig.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 90 of file ElectronAnalysisConfig.py.

90 def makeCalibrationAndSmearingAlg (self, config, name) :
91 """Create the calibration and smearing algorithm
92
93 Factoring this out into its own function, as we want to
94 instantiate it in multiple places"""
95 log = logging.getLogger('ElectronCalibrationConfig')
96
97 # Set up the calibration and smearing algorithm:
98 alg = config.createAlgorithm( 'CP::EgammaCalibrationAndSmearingAlg', name )
99 config.addPrivateTool( 'calibrationAndSmearingTool',
100 'CP::EgammaCalibrationAndSmearingTool' )
101 # Set default ESModel per period
102 if self.ESModel:
103 alg.calibrationAndSmearingTool.ESModel = self.ESModel
104 else:
105 if config.geometry() is LHCPeriod.Run2:
106 alg.calibrationAndSmearingTool.ESModel = 'es2023_R22_Run2_v1'
107 elif config.geometry() is LHCPeriod.Run3:
108 alg.calibrationAndSmearingTool.ESModel = 'es2024_Run3_v0'
109 elif config.geometry() is LHCPeriod.Run4:
110 log.warning("No ESModel set for Run4, using Run 3 model instead")
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 return alg
125
126

Member Data Documentation

◆ addGlobalFELinksDep

python.ElectronAnalysisConfig.ElectronCalibrationConfig.addGlobalFELinksDep

Definition at line 157 of file ElectronAnalysisConfig.py.

◆ containerName

python.ElectronAnalysisConfig.ElectronCalibrationConfig.containerName

Definition at line 138 of file ElectronAnalysisConfig.py.

◆ crackVeto

python.ElectronAnalysisConfig.ElectronCalibrationConfig.crackVeto

Definition at line 167 of file ElectronAnalysisConfig.py.

◆ decorateCaloClusterEta

python.ElectronAnalysisConfig.ElectronCalibrationConfig.decorateCaloClusterEta

Definition at line 141 of file ElectronAnalysisConfig.py.

◆ decorateSamplingPattern

python.ElectronAnalysisConfig.ElectronCalibrationConfig.decorateSamplingPattern

Definition at line 148 of file ElectronAnalysisConfig.py.

◆ ESModel

python.ElectronAnalysisConfig.ElectronCalibrationConfig.ESModel

Definition at line 102 of file ElectronAnalysisConfig.py.

◆ forceFullSimConfigForP4

python.ElectronAnalysisConfig.ElectronCalibrationConfig.forceFullSimConfigForP4

Definition at line 131 of file ElectronAnalysisConfig.py.

◆ inputContainer

python.ElectronAnalysisConfig.ElectronCalibrationConfig.inputContainer

Definition at line 136 of file ElectronAnalysisConfig.py.

◆ isolationCorrection

python.ElectronAnalysisConfig.ElectronCalibrationConfig.isolationCorrection

Definition at line 233 of file ElectronAnalysisConfig.py.

◆ recalibratePhyslite

python.ElectronAnalysisConfig.ElectronCalibrationConfig.recalibratePhyslite

Definition at line 188 of file ElectronAnalysisConfig.py.

◆ runTrackBiasing

python.ElectronAnalysisConfig.ElectronCalibrationConfig.runTrackBiasing

Definition at line 258 of file ElectronAnalysisConfig.py.

◆ splitCalibrationAndSmearing

python.ElectronAnalysisConfig.ElectronCalibrationConfig.splitCalibrationAndSmearing

Definition at line 185 of file ElectronAnalysisConfig.py.

◆ writeTrackD0Z0

python.ElectronAnalysisConfig.ElectronCalibrationConfig.writeTrackD0Z0

Definition at line 254 of file ElectronAnalysisConfig.py.


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