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
 crackVeto
 splitCalibrationAndSmearing
 recalibratePhyslite
 isolationCorrection
 writeTrackD0Z0
 runTrackBiasing

Detailed Description

the ConfigBlock for the electron four-momentum correction

Definition at line 18 of file ElectronAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.ElectronAnalysisConfig.ElectronCalibrationConfig.__init__ ( self)

Definition at line 21 of file ElectronAnalysisConfig.py.

21 def __init__ (self) :
22 super (ElectronCalibrationConfig, self).__init__ ()
23 self.setBlockName('Electrons')
24 self.addOption ('inputContainer', '', type=str,
25 info="select electron input container, by default set to Electrons")
26 self.addOption ('containerName', '', type=str,
27 noneAction='error',
28 info="the name of the output container after calibration.")
29 self.addOption ('ESModel', '', type=str,
30 info="flag of egamma calibration recommendation.")
31 self.addOption ('decorrelationModel', '1NP_v1', type=str,
32 info="egamma energy scale decorrelationModel. The default is 1NP_v1. "
33 "Supported Model: 1NP_v1, FULL_v1.")
34 self.addOption ('postfix', '', type=str,
35 info="a postfix to apply to decorations and algorithm names. Typically "
36 "not needed here since the calibration is common to all electrons.")
37 self.addOption ('crackVeto', False, type=bool,
38 info="whether to perform LAr crack veto based on the cluster eta, "
39 "i.e. remove electrons within 1.37<|eta|<1.52. The default "
40 "is False.")
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 self.addOption ('recalibratePhyslite', True, type=bool,
46 info="whether to run the CP::EgammaCalibrationAndSmearingAlg on "
47 "PHYSLITE derivations. The default is True.")
48 self.addOption ('minPt', 4.5*GeV, type=float,
49 info="the minimum pT cut to apply to calibrated electrons. "
50 "The default is 4.5 GeV.")
51 self.addOption ('maxEta', 2.47, type=float,
52 info="maximum electron |eta| (float). The default is 2.47.")
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 P4 corrections. Only for testing purposes. "
56 "The default is False.")
57 self.addOption ('forceFullSimConfigForIso', False, type=bool,
58 info="whether to force the tool to use the configuration meant for "
59 "full simulation samples for isolation corrections. Only for testing purposes. "
60 "The default is False.")
61 self.addOption ('splitCalibrationAndSmearing', False, type=bool,
62 info="EXPERIMENTAL: This splits the EgammaCalibrationAndSmearingTool "
63 " into two steps. The first step applies a baseline calibration that "
64 "is not affected by systematics. The second step then applies the "
65 "systematics dependent corrections. The net effect is that the "
66 "slower first step only has to be run once, while the second is run "
67 "once per systematic. ATLASG-2358",
68 expertMode=True)
69 self.addOption ('runTrackBiasing', False, type=bool,
70 info="EXPERIMENTAL: This enables the InDetTrackBiasingTool, for "
71 "tracks associated to Electrons. The the tool does not have run 3 "
72 "recommendations yet.",
73 expertMode=True)
74
75 self.addOption ('decorateTruth', False, type=bool,
76 info="decorate truth particle information on the reconstructed one")
77 self.addOption ('decorateCaloClusterEta', False, type=bool,
78 info="decorate the calo cluster eta on the reconstructed one")
79 self.addOption ('writeTrackD0Z0', False, type = bool,
80 info="save the d0 significance and z0sinTheta variables so they can be written out")
81 self.addOption ('decorateEmva', False, type=bool,
82 info="decorate E_mva_only on the objects (needed for columnar tools/PHYSLITE)")
83
84 self.addOption ('decorateSamplingPattern', False, type=bool,
85 info="add samplingPattern decorations to clusters as part of PHYSLITE")
86

Member Function Documentation

◆ instanceName()

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

Definition at line 87 of file ElectronAnalysisConfig.py.

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

◆ makeAlgs()

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

Definition at line 128 of file ElectronAnalysisConfig.py.

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

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

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

Member Data Documentation

◆ containerName

python.ElectronAnalysisConfig.ElectronCalibrationConfig.containerName

Definition at line 139 of file ElectronAnalysisConfig.py.

◆ crackVeto

python.ElectronAnalysisConfig.ElectronCalibrationConfig.crackVeto

Definition at line 163 of file ElectronAnalysisConfig.py.

◆ decorateCaloClusterEta

python.ElectronAnalysisConfig.ElectronCalibrationConfig.decorateCaloClusterEta

Definition at line 142 of file ElectronAnalysisConfig.py.

◆ decorateSamplingPattern

python.ElectronAnalysisConfig.ElectronCalibrationConfig.decorateSamplingPattern

Definition at line 149 of file ElectronAnalysisConfig.py.

◆ ESModel

python.ElectronAnalysisConfig.ElectronCalibrationConfig.ESModel

Definition at line 103 of file ElectronAnalysisConfig.py.

◆ forceFullSimConfigForP4

python.ElectronAnalysisConfig.ElectronCalibrationConfig.forceFullSimConfigForP4

Definition at line 132 of file ElectronAnalysisConfig.py.

◆ inputContainer

python.ElectronAnalysisConfig.ElectronCalibrationConfig.inputContainer

Definition at line 137 of file ElectronAnalysisConfig.py.

◆ isolationCorrection

python.ElectronAnalysisConfig.ElectronCalibrationConfig.isolationCorrection

Definition at line 228 of file ElectronAnalysisConfig.py.

◆ recalibratePhyslite

python.ElectronAnalysisConfig.ElectronCalibrationConfig.recalibratePhyslite

Definition at line 183 of file ElectronAnalysisConfig.py.

◆ runTrackBiasing

python.ElectronAnalysisConfig.ElectronCalibrationConfig.runTrackBiasing

Definition at line 252 of file ElectronAnalysisConfig.py.

◆ splitCalibrationAndSmearing

python.ElectronAnalysisConfig.ElectronCalibrationConfig.splitCalibrationAndSmearing

Definition at line 180 of file ElectronAnalysisConfig.py.

◆ writeTrackD0Z0

python.ElectronAnalysisConfig.ElectronCalibrationConfig.writeTrackD0Z0

Definition at line 248 of file ElectronAnalysisConfig.py.


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