86 """Create the calibration and smearing algorithm
88 Factoring this out into its own function, as we want to
89 instantiate it in multiple places"""
92 alg = config.createAlgorithm(
'CP::EgammaCalibrationAndSmearingAlg', name )
93 config.addPrivateTool(
'calibrationAndSmearingTool',
94 'CP::EgammaCalibrationAndSmearingTool' )
97 alg.calibrationAndSmearingTool.ESModel = self.
ESModel
99 if config.geometry()
is LHCPeriod.Run2:
100 alg.calibrationAndSmearingTool.ESModel =
'es2023_R22_Run2_v1'
101 elif config.geometry()
is LHCPeriod.Run3:
102 alg.calibrationAndSmearingTool.ESModel =
'es2024_Run3_v0'
103 elif config.geometry()
is LHCPeriod.Run4:
104 warnings.warn_explicit(
105 "No ESModel set for Run4, using Run3 model",
106 Run4FallbackWarning, filename=
'', lineno=0)
107 alg.calibrationAndSmearingTool.ESModel =
'es2024_Run3_v0'
109 raise ValueError (f
"Can't set up the ElectronCalibrationConfig with {config.geometry().value}, "
110 "there must be something wrong!")
112 alg.calibrationAndSmearingTool.decorrelationModel = self.decorrelationModel
113 alg.calibrationAndSmearingTool.useFastSim = (
115 else int( config.dataType()
is DataType.FastSim ))
116 alg.calibrationAndSmearingTool.decorateEmva = self.decorateEmva
119 alg.preselection = config.getPreselection (self.
containerName,
'')
125 postfix = self.postfix
126 if postfix !=
'' and postfix[0] !=
'_' :
127 postfix =
'_' + postfix
130 warnings.warn_explicit(
131 "You are running PhotonCalibrationConfig forcing"
132 " full sim config for P4 corrections."
133 " This is only intended to be used for testing purposes.",
134 TestingOnlyWarning, filename=
'', lineno=0)
136 if config.isPhyslite() :
141 cleaningWP =
'NoTime' if self.cleaningAllowLate
else ''
145 alg = config.createAlgorithm(
'CP::EgammaCaloClusterEtaAlg',
146 'ElectronEgammaCaloClusterEtaAlg',
149 config.addOutputVar (self.
containerName,
'caloEta2',
'caloEta2', noSys=
True)
153 alg = config.createAlgorithm(
'CP::AsgShallowCopyAlg',
'PhotonShallowCopyAlg' )
156 alg.outputType =
'xAOD::PhotonContainer'
157 decorationList = [
'DFCommonPhotonsCleaning',
158 'ptcone20_CloseByCorr',
159 'topoetcone20_CloseByCorr',
160 'topoetcone40_CloseByCorr']
162 decorationList += [
'neutralGlobalFELinks',
'chargedGlobalFELinks']
163 if config.dataType()
is not DataType.Data:
164 decorationList += [
'TruthLink']
165 alg.declareDecorations = decorationList
168 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonEtaCutAlg' )
169 alg.selectionDecoration =
'selectEta' + postfix +
',as_bits'
170 config.addPrivateTool(
'selectionTool',
'CP::AsgPtEtaSelectionTool' )
171 alg.selectionTool.maxEta = self.maxEta
173 alg.selectionTool.etaGapLow = 1.37
174 alg.selectionTool.etaGapHigh = 1.52
175 alg.selectionTool.useClusterEta =
True
177 alg.preselection = config.getPreselection (self.
containerName,
'')
178 config.addSelection (self.
containerName,
'', alg.selectionDecoration)
181 if self.recomputeIsEM
and config.dataType()
is DataType.FullSim:
182 alg = config.createAlgorithm(
'CP::PhotonShowerShapeFudgeAlg',
183 'PhotonShowerShapeFudgeAlg' )
184 config.addPrivateTool(
'showerShapeFudgeTool',
185 'ElectronPhotonVariableCorrectionTool' )
186 if config.geometry()
is LHCPeriod.Run2:
187 alg.showerShapeFudgeTool.ConfigFile = \
188 'EGammaVariableCorrection/TUNE25/ElPhVariableNominalCorrection.conf'
189 if config.geometry()
is LHCPeriod.Run3:
190 alg.showerShapeFudgeTool.ConfigFile = \
191 'EGammaVariableCorrection/TUNE23/ElPhVariableNominalCorrection.conf'
194 alg.preselection = config.getPreselection (self.
containerName,
'')
197 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonObjectQualityAlg' )
198 config.setExtraInputs ({(
'xAOD::EventInfo',
'EventInfo.RandomRunNumber')})
199 alg.selectionDecoration =
'goodOQ,as_bits'
200 config.addPrivateTool(
'selectionTool',
'CP::EgammaIsGoodOQSelectionTool' )
201 alg.selectionTool.Mask = xAOD.EgammaParameters.BADCLUSPHOTON
203 alg.preselection = config.getPreselection (self.
containerName,
'')
204 config.addSelection (self.
containerName,
'', alg.selectionDecoration)
208 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonCleaningAlg' )
209 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
210 alg.selectionDecoration =
'isClean,as_bits'
211 alg.selectionTool.selectionFlags = [
'DFCommonPhotonsCleaning' + cleaningWP]
213 alg.preselection = config.getPreselection (self.
containerName,
'')
214 config.addSelection (self.
containerName,
'', alg.selectionDecoration)
219 alg = config.createAlgorithm(
'CP::PhotonOriginCorrectionAlg',
220 'PhotonOriginCorrectionAlg',
224 alg.preselection = config.getPreselection (self.
containerName,
'')
230 alg.skipNominal =
True
251 alg.noToolSystematics =
True
253 alg.calibrationAndSmearingTool.doSmearing =
False
258 alg.calibrationAndSmearingTool.doScaleCorrection =
False
259 alg.calibrationAndSmearingTool.useMVACalibration =
False
260 alg.calibrationAndSmearingTool.decorateEmva =
False
263 warnings.warn_explicit(
264 "You are not applying the isolation corrections."
265 " This is only intended to be used for testing purposes.",
266 TestingOnlyWarning, filename=
'', lineno=0)
271 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonPtCutAlg' )
272 alg.selectionDecoration =
'selectPt' + postfix +
',as_bits'
273 config.addPrivateTool(
'selectionTool',
'CP::AsgPtEtaSelectionTool' )
274 alg.selectionTool.minPt = self.minPt
276 alg.preselection = config.getPreselection (self.
containerName,
'')
277 config.addSelection (self.
containerName,
'', alg.selectionDecoration,
284 warnings.warn_explicit(
285 "You are running PhotonCalibrationConfig forcing"
286 " full sim config for isolation corrections."
287 " This is only intended to be used for testing purposes.",
288 TestingOnlyWarning, filename=
'', lineno=0)
290 alg = config.createAlgorithm(
'CP::EgammaIsolationCorrectionAlg',
291 'PhotonIsolationCorrectionAlg' )
292 config.addPrivateTool(
'isolationCorrectionTool',
293 'CP::IsolationCorrectionTool' )
294 alg.isolationCorrectionTool.IsMC = config.dataType()
is not DataType.Data
295 alg.isolationCorrectionTool.AFII_corr = (
297 else config.dataType()
is DataType.FastSim)
298 alg.isolationCorrectionTool.FixTimingIssueInCore =
True
301 alg.preselection = config.getPreselection (self.
containerName,
'')
304 alg = config.createAlgorithm(
'CP::AsgEnergyDecoratorAlg',
'EnergyDecorator' )
308 config.addOutputVar (self.
containerName,
'eta',
'eta', noSys=
True)
309 config.addOutputVar (self.
containerName,
'phi',
'phi', noSys=
True)
311 config.addOutputVar (self.
containerName,
'caloClusterEnergyReso_%SYS%',
'caloClusterEnergyReso', noSys=
True)
314 if self.decorateTruth
and config.dataType()
is not DataType.Data:
315 config.addOutputVar (self.
containerName,
"truthType",
"truth_type", noSys=
True)
316 config.addOutputVar (self.
containerName,
"truthOrigin",
"truth_origin", noSys=
True)