295 def makeAlgs (self, config) :
297 log = logging.getLogger(
'PhotonWorkingPointConfig')
300 if config.geometry()
is LHCPeriod.Run1:
301 raise ValueError (
"Can't set up the PhotonWorkingPointConfig with %s, there must be something wrong!" % config.geometry().value)
303 if self.forceFullSimConfig:
304 log.warning(
"You are running PhotonWorkingPointConfig forcing full sim config")
305 log.warning(
"This is only intended to be used for testing purposes")
307 postfix = self.postfix
308 if postfix !=
'' and postfix[0] !=
'_' :
309 postfix =
'_' + postfix
311 if self.qualityWP ==
'Tight' :
312 quality = ROOT.egammaPID.PhotonTight
313 elif self.qualityWP ==
'Medium' :
314 quality = ROOT.egammaPID.PhotonMedium
315 elif self.qualityWP ==
'Loose' :
316 quality = ROOT.egammaPID.PhotonLoose
318 raise Exception (
'unknown photon quality working point "' + self.qualityWP +
'" should be Tight, Medium or Loose')
321 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'PhotonIsEMSelectorAlg' + postfix )
322 alg.selectionDecoration =
'selectEM' + postfix +
',as_bits'
323 if self.recomputeIsEM:
325 config.addPrivateTool(
'selectionTool',
'AsgPhotonIsEMSelector' )
326 alg.selectionTool.isEMMask = quality
327 if config.geometry()
is LHCPeriod.Run2:
328 if self.qualityWP ==
'Tight':
329 alg.selectionTool.ConfigFile =
'ElectronPhotonSelectorTools/offline/mc20_20240510/PhotonIsEMTightSelectorCutDefs_pTdep_mc20_smooth.conf'
330 elif self.qualityWP ==
'Loose':
331 alg.selectionTool.ConfigFile =
'ElectronPhotonSelectorTools/offline/mc15_20150712/PhotonIsEMLooseSelectorCutDefs.conf'
332 elif self.qualityWP ==
'Medium':
333 alg.selectionTool.ConfigFile =
'ElectronPhotonSelectorTools/offline/mc20_20240510/PhotonIsEMMediumSelectorCutDefs_pTdep_smooth.conf'
334 if config.geometry()
is LHCPeriod.Run3:
335 if self.qualityWP ==
'Tight':
336 alg.selectionTool.ConfigFile =
'ElectronPhotonSelectorTools/offline/20180825/PhotonIsEMTightSelectorCutDefs.conf'
337 elif self.qualityWP ==
'Loose':
338 alg.selectionTool.ConfigFile =
'ElectronPhotonSelectorTools/offline/mc15_20150712/PhotonIsEMLooseSelectorCutDefs.conf'
339 elif self.qualityWP ==
'Medium':
340 raise ValueError(
'No Medium menu available for Run-3. Please get in contact with egamma')
343 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
344 dfFlag =
'DFCommonPhotonsIsEM' + self.qualityWP
345 alg.selectionTool.selectionFlags = [ dfFlag ]
346 alg.particles = config.readName (self.containerName)
347 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
348 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration)
351 if self.doFSRSelection :
353 wpFlag = alg.selectionDecoration.split(
",")[0]
354 alg = config.createAlgorithm(
'CP::EgammaFSRForMuonsCollectorAlg',
'EgammaFSRForMuonsCollectorAlg' + postfix +
'_ph')
355 alg.selectionDecoration = wpFlag
356 alg.ElectronOrPhotonContKey = config.readName (self.containerName)
359 if self.isolationWP !=
'NonIso' :
360 alg = config.createAlgorithm(
'CP::EgammaIsolationSelectionAlg',
361 'PhotonIsolationSelectionAlg' + postfix )
362 alg.selectionDecoration =
'isolated' + postfix +
',as_bits'
363 config.addPrivateTool(
'selectionTool',
'CP::IsolationSelectionTool' )
364 alg.selectionTool.PhotonWP = self.isolationWP
365 if self.closeByCorrection:
366 alg.selectionTool.IsoDecSuffix =
"CloseByCorr"
368 alg.egammas = config.readName (self.containerName)
369 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
370 config.addSelection (self.containerName, self.selectionName, alg.selectionDecoration)
373 if config.dataType()
is not DataType.Data
and not self.noEffSF:
374 alg = config.createAlgorithm(
'CP::PhotonEfficiencyCorrectionAlg',
375 'PhotonEfficiencyCorrectionAlgID' + postfix )
376 config.addPrivateTool(
'efficiencyCorrectionTool',
377 'AsgPhotonEfficiencyCorrectionTool' )
378 alg.scaleFactorDecoration =
'ph_id_effSF' + postfix +
'_%SYS%'
379 if config.dataType()
is DataType.FastSim:
380 alg.efficiencyCorrectionTool.ForceDataType = (
381 PATCore.ParticleDataType.Full
if self.forceFullSimConfig
else
382 PATCore.ParticleDataType.Fast)
383 elif config.dataType()
is DataType.FullSim:
384 alg.efficiencyCorrectionTool.ForceDataType = \
385 PATCore.ParticleDataType.Full
386 if config.geometry() >= LHCPeriod.Run2:
387 alg.efficiencyCorrectionTool.MapFilePath =
'PhotonEfficiencyCorrection/2015_2025/rel22.2/2022_Summer_Prerecom_v1/map0.txt'
388 alg.outOfValidity = 2
389 alg.outOfValidityDeco =
'ph_id_bad_eff' + postfix
390 alg.photons = config.readName (self.containerName)
391 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
392 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
'id_effSF' + postfix)
395 if config.dataType()
is not DataType.Data
and self.isolationWP !=
'NonIso' and not self.noEffSF:
396 alg = config.createAlgorithm(
'CP::PhotonEfficiencyCorrectionAlg',
397 'PhotonEfficiencyCorrectionAlgIsol' + postfix )
398 config.addPrivateTool(
'efficiencyCorrectionTool',
399 'AsgPhotonEfficiencyCorrectionTool' )
400 alg.scaleFactorDecoration =
'ph_isol_effSF' + postfix +
'_%SYS%'
401 if config.dataType()
is DataType.FastSim:
402 alg.efficiencyCorrectionTool.ForceDataType = (
403 PATCore.ParticleDataType.Full
if self.forceFullSimConfig
else
404 PATCore.ParticleDataType.Fast)
405 elif config.dataType()
is DataType.FullSim:
406 alg.efficiencyCorrectionTool.ForceDataType = \
407 PATCore.ParticleDataType.Full
408 alg.efficiencyCorrectionTool.IsoKey = self.isolationWP.
replace(
"FixedCut",
"")
409 if config.geometry() >= LHCPeriod.Run2:
410 alg.efficiencyCorrectionTool.MapFilePath =
'PhotonEfficiencyCorrection/2015_2025/rel22.2/2022_Summer_Prerecom_v1/map0.txt'
411 alg.outOfValidity = 2
412 alg.outOfValidityDeco =
'ph_isol_bad_eff' + postfix
413 alg.photons = config.readName (self.containerName)
414 alg.preselection = config.getPreselection (self.containerName, self.selectionName)
415 config.addOutputVar (self.containerName, alg.scaleFactorDecoration,
'isol_effSF' + postfix)