95 """Create the calibration and smearing algorithm
97 Factoring this out into its own function, as we want to
98 instantiate it in multiple places"""
101 alg = config.createAlgorithm(
'CP::EgammaCalibrationAndSmearingAlg', name )
102 config.addPrivateTool(
'calibrationAndSmearingTool',
103 'CP::EgammaCalibrationAndSmearingTool' )
106 alg.calibrationAndSmearingTool.ESModel = self.
ESModel
108 if config.geometry()
is LHCPeriod.Run2:
109 alg.calibrationAndSmearingTool.ESModel =
'es2023_R22_Run2_v1'
110 elif config.geometry()
is LHCPeriod.Run3:
111 alg.calibrationAndSmearingTool.ESModel =
'es2024_Run3_v0'
112 elif config.geometry()
is LHCPeriod.Run4:
113 warnings.warn_explicit(
114 "No ESModel set for Run4, using Run3 model",
115 Run4FallbackWarning, filename=
'', lineno=0)
116 alg.calibrationAndSmearingTool.ESModel =
'es2024_Run3_v0'
118 raise ValueError (f
"Can't set up the PhotonCalibrationConfig with {config.geometry().value}, "
119 "there must be something wrong!")
121 alg.calibrationAndSmearingTool.decorrelationModel = self.decorrelationModel
122 alg.calibrationAndSmearingTool.useFastSim = (
124 else int( config.dataType()
is DataType.FastSim ))
125 alg.calibrationAndSmearingTool.decorateEmva = self.decorateEmva
127 alg.calibrationAndSmearingTool.DoElectronMVACalibration =
False
130 if 'egClusterL2_3Fix' in config.flags.Input.AODFixesDone :
131 alg.calibrationAndSmearingTool.FixForMissingCells =
False
134 alg.preselection = config.getPreselection (self.
containerName,
'')
136 config.setContainerMeta (self.
containerName,
'ESModel', alg.calibrationAndSmearingTool.ESModel, allowOverwrite=
True)
137 config.setContainerMeta (self.
containerName,
'decorrelationModel', alg.calibrationAndSmearingTool.decorrelationModel, allowOverwrite=
True)
144 postfix = self.postfix
145 if postfix !=
'' and postfix[0] !=
'_' :
146 postfix =
'_' + postfix
149 warnings.warn_explicit(
150 "You are running PhotonCalibrationConfig forcing"
151 " full sim config for P4 corrections."
152 " This is only intended to be used for testing purposes.",
153 TestingOnlyWarning, filename=
'', lineno=0)
155 if config.isPhyslite() :
160 cleaningWP =
'NoTime' if self.cleaningAllowLate
else ''
164 alg = config.createAlgorithm(
'CP::EgammaCaloClusterEtaAlg',
165 'PhotonEgammaCaloClusterEtaAlg',
168 config.addOutputVar (self.
containerName,
'caloEta2',
'caloEta2', noSys=
True, auxType=
'float')
172 alg = config.createAlgorithm(
'CP::AsgShallowCopyAlg',
'PhotonShallowCopyAlg' )
175 alg.outputType =
'xAOD::PhotonContainer'
176 decorationList = [
'DFCommonPhotonsCleaning',
177 'ptcone20_CloseByCorr',
178 'topoetcone20_CloseByCorr',
179 'topoetcone40_CloseByCorr']
181 decorationList += [
'neutralGlobalFELinks',
'chargedGlobalFELinks']
182 if config.dataType()
is not DataType.Data:
183 decorationList += [
'TruthLink']
184 alg.declareDecorations = decorationList
187 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonEtaCutAlg' )
188 alg.selectionDecoration =
'selectEta' + postfix +
',as_bits'
189 config.addPrivateTool(
'selectionTool',
'CP::AsgPtEtaSelectionTool' )
190 alg.selectionTool.maxEta = self.maxEta
192 alg.selectionTool.etaGapLow = 1.37
193 alg.selectionTool.etaGapHigh = 1.52
194 alg.selectionTool.useClusterEta =
True
196 alg.preselection = config.getPreselection (self.
containerName,
'')
197 config.addSelection (self.
containerName,
'', alg.selectionDecoration)
200 if self.recomputeIsEM
and config.dataType()
is DataType.FullSim:
201 alg = config.createAlgorithm(
'CP::PhotonShowerShapeFudgeAlg',
202 'PhotonShowerShapeFudgeAlg' )
203 config.addPrivateTool(
'showerShapeFudgeTool',
204 'ElectronPhotonVariableCorrectionTool' )
205 if config.geometry()
is LHCPeriod.Run2:
206 alg.showerShapeFudgeTool.ConfigFile = \
207 'EGammaVariableCorrection/TUNE25/ElPhVariableNominalCorrection.conf'
208 if config.geometry()
is LHCPeriod.Run3:
209 if config.campaign()
in (Campaign.MC23a, Campaign.MC23d):
210 alg.showerShapeFudgeTool.ConfigFile = \
211 'EGammaVariableCorrection/TUNE28AD/ElPhVariableNominalCorrection.conf'
213 alg.showerShapeFudgeTool.ConfigFile = \
214 'EGammaVariableCorrection/TUNE28EG/ElPhVariableNominalCorrection.conf'
217 alg.preselection = config.getPreselection (self.
containerName,
'')
220 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonObjectQualityAlg' )
221 config.setExtraInputs ({(
'xAOD::EventInfo',
'EventInfo.RandomRunNumber')})
222 alg.selectionDecoration =
'goodOQ' + postfix +
',as_bits'
223 config.addPrivateTool(
'selectionTool',
'CP::EgammaIsGoodOQSelectionTool' )
224 alg.selectionTool.Mask = xAOD.EgammaParameters.BADCLUSPHOTON
226 alg.preselection = config.getPreselection (self.
containerName,
'')
227 config.addSelection (self.
containerName,
'', alg.selectionDecoration)
231 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonCleaningAlg' )
232 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
233 alg.selectionDecoration =
'isClean' + postfix +
',as_bits'
234 alg.selectionTool.selectionFlags = [
'DFCommonPhotonsCleaning' + cleaningWP]
236 alg.preselection = config.getPreselection (self.
containerName,
'')
237 config.addSelection (self.
containerName,
'', alg.selectionDecoration)
242 alg = config.createAlgorithm(
'CP::PhotonOriginCorrectionAlg',
243 'PhotonOriginCorrectionAlg',
247 alg.preselection = config.getPreselection (self.
containerName,
'')
253 alg.skipNominal =
True
272 if not skipBaseStep :
276 alg.noToolSystematics =
True
278 alg.calibrationAndSmearingTool.doSmearing =
False
279 if config.dataType()
is DataType.FastSim :
281 alg.calibrationAndSmearingTool.useFastSim = 0
286 alg.calibrationAndSmearingTool.doScaleCorrection =
False
287 alg.calibrationAndSmearingTool.useMVACalibration =
False
288 alg.calibrationAndSmearingTool.decorateEmva =
False
289 if skipBaseStep
and config.dataType()
is not DataType.Data :
291 alg.calibrationAndSmearingTool.startFromEmva =
True
292 if config.dataType()
is DataType.Data :
294 alg.calibrationAndSmearingTool.useIntermoduleCorrection =
False
295 alg.calibrationAndSmearingTool.usePhiUniformCorrection =
False
296 alg.calibrationAndSmearingTool.useCaloDistPhiUnifCorrection =
False
297 alg.calibrationAndSmearingTool.doADCLinearityCorrection =
False
298 alg.calibrationAndSmearingTool.useGainCorrection =
False
301 warnings.warn_explicit(
302 "You are not applying the isolation corrections."
303 " This is only intended to be used for testing purposes.",
304 TestingOnlyWarning, filename=
'', lineno=0)
309 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonPtCutAlg' )
310 alg.selectionDecoration =
'selectPt' + postfix +
',as_bits'
311 config.addPrivateTool(
'selectionTool',
'CP::AsgPtEtaSelectionTool' )
312 alg.selectionTool.minPt = self.minPt
314 alg.preselection = config.getPreselection (self.
containerName,
'')
315 config.addSelection (self.
containerName,
'', alg.selectionDecoration,
322 warnings.warn_explicit(
323 "You are running PhotonCalibrationConfig forcing"
324 " full sim config for isolation corrections."
325 " This is only intended to be used for testing purposes.",
326 TestingOnlyWarning, filename=
'', lineno=0)
328 alg = config.createAlgorithm(
'CP::EgammaIsolationCorrectionAlg',
329 'PhotonIsolationCorrectionAlg' )
330 config.addPrivateTool(
'isolationCorrectionTool',
331 'CP::IsolationCorrectionTool' )
332 alg.isolationCorrectionTool.IsMC = config.dataType()
is not DataType.Data
333 alg.isolationCorrectionTool.AFII_corr = (
335 else config.dataType()
is DataType.FastSim)
336 AODfixes = config.flags.Input.AODFixesDone
337 if "egammatopoIsoFix" in AODfixes:
338 alg.isolationCorrectionTool.FixTimingIssueInCore =
False
340 alg.isolationCorrectionTool.FixTimingIssueInCore =
True
343 alg.preselection = config.getPreselection (self.
containerName,
'')
346 alg = config.createAlgorithm(
'CP::AsgEnergyDecoratorAlg',
'EnergyDecorator' )
349 config.addOutputVar (self.
containerName,
'pt',
'pt', auxType=
'float')
350 config.addOutputVar (self.
containerName,
'eta',
'eta', noSys=
True, auxType=
'float')
351 config.addOutputVar (self.
containerName,
'phi',
'phi', noSys=
True, auxType=
'float')
352 config.addOutputVar (self.
containerName,
'e_%SYS%',
'e', auxType=
'float')
353 config.addOutputVar (self.
containerName,
'caloClusterEnergyReso_%SYS%',
'caloClusterEnergyReso', noSys=
True, auxType=
'float')
356 if self.decorateTruth
and config.dataType()
is not DataType.Data:
357 config.addOutputVar (self.
containerName,
"truthType",
"truth_type", noSys=
True, auxType=
'int')
358 config.addOutputVar (self.
containerName,
"truthOrigin",
"truth_origin", noSys=
True, auxType=
'int')