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