88 """Create the calibration and smearing algorithm
90 Factoring this out into its own function, as we want to
91 instantiate it in multiple places"""
94 alg = config.createAlgorithm(
'CP::EgammaCalibrationAndSmearingAlg', name )
95 config.addPrivateTool(
'calibrationAndSmearingTool',
96 'CP::EgammaCalibrationAndSmearingTool' )
99 alg.calibrationAndSmearingTool.ESModel = self.
ESModel
101 if config.geometry()
is LHCPeriod.Run2:
102 alg.calibrationAndSmearingTool.ESModel =
'es2023_R22_Run2_v1'
103 elif config.geometry()
is LHCPeriod.Run3:
104 alg.calibrationAndSmearingTool.ESModel =
'es2024_Run3_v0'
105 elif config.geometry()
is LHCPeriod.Run4:
106 warnings.warn_explicit(
107 "No ESModel set for Run4, using Run3 model",
108 Run4FallbackWarning, filename=
'', lineno=0)
109 alg.calibrationAndSmearingTool.ESModel =
'es2024_Run3_v0'
111 raise ValueError (f
"Can't set up the ElectronCalibrationConfig with {config.geometry().value}, "
112 "there must be something wrong!")
114 alg.calibrationAndSmearingTool.decorrelationModel = self.decorrelationModel
115 alg.calibrationAndSmearingTool.useFastSim = (
117 else int( config.dataType()
is DataType.FastSim ))
118 alg.calibrationAndSmearingTool.decorateEmva = self.decorateEmva
121 alg.preselection = config.getPreselection (self.
containerName,
'')
127 postfix = self.postfix
128 if postfix !=
'' and postfix[0] !=
'_' :
129 postfix =
'_' + postfix
132 warnings.warn_explicit(
133 "You are running PhotonCalibrationConfig forcing"
134 " full sim config for P4 corrections."
135 " This is only intended to be used for testing purposes.",
136 TestingOnlyWarning, filename=
'', lineno=0)
138 if config.isPhyslite() :
143 cleaningWP =
'NoTime' if self.cleaningAllowLate
else ''
147 alg = config.createAlgorithm(
'CP::EgammaCaloClusterEtaAlg',
148 'ElectronEgammaCaloClusterEtaAlg',
151 config.addOutputVar (self.
containerName,
'caloEta2',
'caloEta2', noSys=
True)
155 alg = config.createAlgorithm(
'CP::AsgShallowCopyAlg',
'PhotonShallowCopyAlg' )
158 alg.outputType =
'xAOD::PhotonContainer'
159 decorationList = [
'DFCommonPhotonsCleaning',
160 'ptcone20_CloseByCorr',
161 'topoetcone20_CloseByCorr',
162 'topoetcone40_CloseByCorr']
164 decorationList += [
'neutralGlobalFELinks',
'chargedGlobalFELinks']
165 if config.dataType()
is not DataType.Data:
166 decorationList += [
'TruthLink']
167 alg.declareDecorations = decorationList
170 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonEtaCutAlg' )
171 alg.selectionDecoration =
'selectEta' + postfix +
',as_bits'
172 config.addPrivateTool(
'selectionTool',
'CP::AsgPtEtaSelectionTool' )
173 alg.selectionTool.maxEta = self.maxEta
175 alg.selectionTool.etaGapLow = 1.37
176 alg.selectionTool.etaGapHigh = 1.52
177 alg.selectionTool.useClusterEta =
True
179 alg.preselection = config.getPreselection (self.
containerName,
'')
180 config.addSelection (self.
containerName,
'', alg.selectionDecoration)
183 if self.recomputeIsEM
and config.dataType()
is DataType.FullSim:
184 alg = config.createAlgorithm(
'CP::PhotonShowerShapeFudgeAlg',
185 'PhotonShowerShapeFudgeAlg' )
186 config.addPrivateTool(
'showerShapeFudgeTool',
187 'ElectronPhotonVariableCorrectionTool' )
188 if config.geometry()
is LHCPeriod.Run2:
189 alg.showerShapeFudgeTool.ConfigFile = \
190 'EGammaVariableCorrection/TUNE25/ElPhVariableNominalCorrection.conf'
191 if config.geometry()
is LHCPeriod.Run3:
192 alg.showerShapeFudgeTool.ConfigFile = \
193 'EGammaVariableCorrection/TUNE23/ElPhVariableNominalCorrection.conf'
196 alg.preselection = config.getPreselection (self.
containerName,
'')
199 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonObjectQualityAlg' )
200 config.setExtraInputs ({(
'xAOD::EventInfo',
'EventInfo.RandomRunNumber')})
201 alg.selectionDecoration =
'goodOQ,as_bits'
202 config.addPrivateTool(
'selectionTool',
'CP::EgammaIsGoodOQSelectionTool' )
203 alg.selectionTool.Mask = xAOD.EgammaParameters.BADCLUSPHOTON
205 alg.preselection = config.getPreselection (self.
containerName,
'')
206 config.addSelection (self.
containerName,
'', alg.selectionDecoration)
210 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonCleaningAlg' )
211 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
212 alg.selectionDecoration =
'isClean,as_bits'
213 alg.selectionTool.selectionFlags = [
'DFCommonPhotonsCleaning' + cleaningWP]
215 alg.preselection = config.getPreselection (self.
containerName,
'')
216 config.addSelection (self.
containerName,
'', alg.selectionDecoration)
221 alg = config.createAlgorithm(
'CP::PhotonOriginCorrectionAlg',
222 'PhotonOriginCorrectionAlg',
226 alg.preselection = config.getPreselection (self.
containerName,
'')
232 alg.skipNominal =
True
253 alg.noToolSystematics =
True
255 alg.calibrationAndSmearingTool.doSmearing =
False
260 alg.calibrationAndSmearingTool.doScaleCorrection =
False
261 alg.calibrationAndSmearingTool.useMVACalibration =
False
262 alg.calibrationAndSmearingTool.decorateEmva =
False
265 warnings.warn_explicit(
266 "You are not applying the isolation corrections."
267 " This is only intended to be used for testing purposes.",
268 TestingOnlyWarning, filename=
'', lineno=0)
273 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonPtCutAlg' )
274 alg.selectionDecoration =
'selectPt' + postfix +
',as_bits'
275 config.addPrivateTool(
'selectionTool',
'CP::AsgPtEtaSelectionTool' )
276 alg.selectionTool.minPt = self.minPt
278 alg.preselection = config.getPreselection (self.
containerName,
'')
279 config.addSelection (self.
containerName,
'', alg.selectionDecoration,
286 warnings.warn_explicit(
287 "You are running PhotonCalibrationConfig forcing"
288 " full sim config for isolation corrections."
289 " This is only intended to be used for testing purposes.",
290 TestingOnlyWarning, filename=
'', lineno=0)
292 alg = config.createAlgorithm(
'CP::EgammaIsolationCorrectionAlg',
293 'PhotonIsolationCorrectionAlg' )
294 config.addPrivateTool(
'isolationCorrectionTool',
295 'CP::IsolationCorrectionTool' )
296 alg.isolationCorrectionTool.IsMC = config.dataType()
is not DataType.Data
297 alg.isolationCorrectionTool.AFII_corr = (
299 else config.dataType()
is DataType.FastSim)
300 alg.isolationCorrectionTool.FixTimingIssueInCore =
True
303 alg.preselection = config.getPreselection (self.
containerName,
'')
306 alg = config.createAlgorithm(
'CP::AsgEnergyDecoratorAlg',
'EnergyDecorator' )
310 config.addOutputVar (self.
containerName,
'eta',
'eta', noSys=
True)
311 config.addOutputVar (self.
containerName,
'phi',
'phi', noSys=
True)
313 config.addOutputVar (self.
containerName,
'caloClusterEnergyReso_%SYS%',
'caloClusterEnergyReso', noSys=
True)
316 if self.decorateTruth
and config.dataType()
is not DataType.Data:
317 config.addOutputVar (self.
containerName,
"truthType",
"truth_type", noSys=
True)
318 config.addOutputVar (self.
containerName,
"truthOrigin",
"truth_origin", noSys=
True)