89 """Create the calibration and smearing algorithm
91 Factoring this out into its own function, as we want to
92 instantiate it in multiple places"""
95 alg = config.createAlgorithm(
'CP::EgammaCalibrationAndSmearingAlg', name )
96 config.addPrivateTool(
'calibrationAndSmearingTool',
97 'CP::EgammaCalibrationAndSmearingTool' )
100 alg.calibrationAndSmearingTool.ESModel = self.
ESModel
102 if config.geometry()
is LHCPeriod.Run2:
103 alg.calibrationAndSmearingTool.ESModel =
'es2023_R22_Run2_v1'
104 elif config.geometry()
is LHCPeriod.Run3:
105 alg.calibrationAndSmearingTool.ESModel =
'es2024_Run3_v0'
106 elif config.geometry()
is LHCPeriod.Run4:
107 warnings.warn_explicit(
108 "No ESModel set for Run4, using Run3 model",
109 Run4FallbackWarning, filename=
'', lineno=0)
110 alg.calibrationAndSmearingTool.ESModel =
'es2024_Run3_v0'
112 raise ValueError (f
"Can't set up the PhotonCalibrationConfig with {config.geometry().value}, "
113 "there must be something wrong!")
115 alg.calibrationAndSmearingTool.decorrelationModel = self.decorrelationModel
116 alg.calibrationAndSmearingTool.useFastSim = (
118 else int( config.dataType()
is DataType.FastSim ))
119 alg.calibrationAndSmearingTool.decorateEmva = self.decorateEmva
122 alg.preselection = config.getPreselection (self.
containerName,
'')
124 config.setContainerMeta (self.
containerName,
'ESModel', alg.calibrationAndSmearingTool.ESModel, allowOverwrite=
True)
125 config.setContainerMeta (self.
containerName,
'decorrelationModel', alg.calibrationAndSmearingTool.decorrelationModel, allowOverwrite=
True)
132 postfix = self.postfix
133 if postfix !=
'' and postfix[0] !=
'_' :
134 postfix =
'_' + postfix
137 warnings.warn_explicit(
138 "You are running PhotonCalibrationConfig forcing"
139 " full sim config for P4 corrections."
140 " This is only intended to be used for testing purposes.",
141 TestingOnlyWarning, filename=
'', lineno=0)
143 if config.isPhyslite() :
148 cleaningWP =
'NoTime' if self.cleaningAllowLate
else ''
152 alg = config.createAlgorithm(
'CP::EgammaCaloClusterEtaAlg',
153 'PhotonEgammaCaloClusterEtaAlg',
156 config.addOutputVar (self.
containerName,
'caloEta2',
'caloEta2', noSys=
True)
160 alg = config.createAlgorithm(
'CP::AsgShallowCopyAlg',
'PhotonShallowCopyAlg' )
163 alg.outputType =
'xAOD::PhotonContainer'
164 decorationList = [
'DFCommonPhotonsCleaning',
165 'ptcone20_CloseByCorr',
166 'topoetcone20_CloseByCorr',
167 'topoetcone40_CloseByCorr']
169 decorationList += [
'neutralGlobalFELinks',
'chargedGlobalFELinks']
170 if config.dataType()
is not DataType.Data:
171 decorationList += [
'TruthLink']
172 alg.declareDecorations = decorationList
175 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonEtaCutAlg' )
176 alg.selectionDecoration =
'selectEta' + postfix +
',as_bits'
177 config.addPrivateTool(
'selectionTool',
'CP::AsgPtEtaSelectionTool' )
178 alg.selectionTool.maxEta = self.maxEta
180 alg.selectionTool.etaGapLow = 1.37
181 alg.selectionTool.etaGapHigh = 1.52
182 alg.selectionTool.useClusterEta =
True
184 alg.preselection = config.getPreselection (self.
containerName,
'')
185 config.addSelection (self.
containerName,
'', alg.selectionDecoration)
188 if self.recomputeIsEM
and config.dataType()
is DataType.FullSim:
189 alg = config.createAlgorithm(
'CP::PhotonShowerShapeFudgeAlg',
190 'PhotonShowerShapeFudgeAlg' )
191 config.addPrivateTool(
'showerShapeFudgeTool',
192 'ElectronPhotonVariableCorrectionTool' )
193 if config.geometry()
is LHCPeriod.Run2:
194 alg.showerShapeFudgeTool.ConfigFile = \
195 'EGammaVariableCorrection/TUNE25/ElPhVariableNominalCorrection.conf'
196 if config.geometry()
is LHCPeriod.Run3:
197 if config.campaign()
in (Campaign.MC23a, Campaign.MC23d):
198 alg.showerShapeFudgeTool.ConfigFile = \
199 'EGammaVariableCorrection/TUNE28AD/ElPhVariableNominalCorrection.conf'
201 alg.showerShapeFudgeTool.ConfigFile = \
202 'EGammaVariableCorrection/TUNE28EG/ElPhVariableNominalCorrection.conf'
205 alg.preselection = config.getPreselection (self.
containerName,
'')
208 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonObjectQualityAlg' )
209 config.setExtraInputs ({(
'xAOD::EventInfo',
'EventInfo.RandomRunNumber')})
210 alg.selectionDecoration =
'goodOQ' + postfix +
',as_bits'
211 config.addPrivateTool(
'selectionTool',
'CP::EgammaIsGoodOQSelectionTool' )
212 alg.selectionTool.Mask = xAOD.EgammaParameters.BADCLUSPHOTON
214 alg.preselection = config.getPreselection (self.
containerName,
'')
215 config.addSelection (self.
containerName,
'', alg.selectionDecoration)
219 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonCleaningAlg' )
220 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
221 alg.selectionDecoration =
'isClean' + postfix +
',as_bits'
222 alg.selectionTool.selectionFlags = [
'DFCommonPhotonsCleaning' + cleaningWP]
224 alg.preselection = config.getPreselection (self.
containerName,
'')
225 config.addSelection (self.
containerName,
'', alg.selectionDecoration)
230 alg = config.createAlgorithm(
'CP::PhotonOriginCorrectionAlg',
231 'PhotonOriginCorrectionAlg',
235 alg.preselection = config.getPreselection (self.
containerName,
'')
241 alg.skipNominal =
True
262 alg.noToolSystematics =
True
264 alg.calibrationAndSmearingTool.doSmearing =
False
269 alg.calibrationAndSmearingTool.doScaleCorrection =
False
270 alg.calibrationAndSmearingTool.useMVACalibration =
False
271 alg.calibrationAndSmearingTool.decorateEmva =
False
274 warnings.warn_explicit(
275 "You are not applying the isolation corrections."
276 " This is only intended to be used for testing purposes.",
277 TestingOnlyWarning, filename=
'', lineno=0)
282 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonPtCutAlg' )
283 alg.selectionDecoration =
'selectPt' + postfix +
',as_bits'
284 config.addPrivateTool(
'selectionTool',
'CP::AsgPtEtaSelectionTool' )
285 alg.selectionTool.minPt = self.minPt
287 alg.preselection = config.getPreselection (self.
containerName,
'')
288 config.addSelection (self.
containerName,
'', alg.selectionDecoration,
295 warnings.warn_explicit(
296 "You are running PhotonCalibrationConfig forcing"
297 " full sim config for isolation corrections."
298 " This is only intended to be used for testing purposes.",
299 TestingOnlyWarning, filename=
'', lineno=0)
301 alg = config.createAlgorithm(
'CP::EgammaIsolationCorrectionAlg',
302 'PhotonIsolationCorrectionAlg' )
303 config.addPrivateTool(
'isolationCorrectionTool',
304 'CP::IsolationCorrectionTool' )
305 alg.isolationCorrectionTool.IsMC = config.dataType()
is not DataType.Data
306 alg.isolationCorrectionTool.AFII_corr = (
308 else config.dataType()
is DataType.FastSim)
309 AODfixes = config.flags.Input.AODFixesDone
310 if "egammatopoIsoFix" in AODfixes:
311 alg.isolationCorrectionTool.FixTimingIssueInCore =
False
313 alg.isolationCorrectionTool.FixTimingIssueInCore =
True
316 alg.preselection = config.getPreselection (self.
containerName,
'')
319 alg = config.createAlgorithm(
'CP::AsgEnergyDecoratorAlg',
'EnergyDecorator' )
323 config.addOutputVar (self.
containerName,
'eta',
'eta', noSys=
True)
324 config.addOutputVar (self.
containerName,
'phi',
'phi', noSys=
True)
327 config.addOutputVar (self.
containerName,
'caloClusterEnergyReso_%SYS%',
'caloClusterEnergyReso', noSys=
True)
330 if self.decorateTruth
and config.dataType()
is not DataType.Data:
331 config.addOutputVar (self.
containerName,
"truthType",
"truth_type", noSys=
True)
332 config.addOutputVar (self.
containerName,
"truthOrigin",
"truth_origin", noSys=
True)