ATLAS Offline Software
egammaValidation/python/egammaMonitoringConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration.
2 
3 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 
6 def egammaMonitoringCfg(flags, particleType = 'electron',
7  outputFileName = 'Nightly-monitoring.hist',
8  addFwd = False):
9 
10  acc = ComponentAccumulator()
11 
12  # Preparing selection tools (ID and iso)
13  from ROOT import LikeEnum
14  from ElectronPhotonSelectorTools.EgammaPIDdefs import egammaPID
15 
16  eidWP = { 'Loose' : LikeEnum.Loose, 'Medium' : LikeEnum.Medium, 'Tight' : LikeEnum.Tight }
17  gidWP = { 'Loose' : egammaPID.PhotonIDLoose, 'Tight' : egammaPID.PhotonIDTight }
18  gisoWP = [ 'FixedCutTight', 'FixedCutLoose', 'TightCaloOnly' ]
19 
20  kwarg = {}
21 
22  if particleType == 'electron' or particleType == 'dataZ':
23  kwarg['ElectronsKey'] = 'Electrons'
24  kwarg['GSFTrackParticlesKey'] = 'GSFTrackParticles'
25 
26  if particleType == 'electron':
27  from ElectronPhotonSelectorTools.AsgElectronLikelihoodToolsConfig import (
28  AsgElectronLikelihoodToolCfg)
29  for k,w in eidWP.items():
30  t = AsgElectronLikelihoodToolCfg(flags, k+'LHSelector', w)
31  kwarg[k+'_Ele'] = t.popPrivateTools()
32  acc.merge(t)
33  if addFwd:
34  kwarg['FwdElectronsKey'] = 'ForwardElectrons'
35  from ElectronPhotonSelectorTools.AsgForwardElectronLikelihoodToolConfig import (
36  AsgForwardElectronLikelihoodToolCfg)
37  for k in eidWP.keys():
38  # do not use the WP name as mapping points to a corrupted ID (in main, 24/05/24)
39  # anyway, not appropriate for ITk but least corrupted within rel21.2/Run2
40  configFile = f'dev/ElectronPhotonSelectorTools/offline/mc16_20190729/FwdLH{k}Conf.conf'
41  t = AsgForwardElectronLikelihoodToolCfg(flags,k+'FwdSelector',
42  ConfigFile = configFile)
43  kwarg[k+'_FwdEle'] = t.popPrivateTools()
44  acc.merge(t)
45 
46  if particleType == 'gamma':
47  from ElectronPhotonSelectorTools.AsgPhotonIsEMSelectorsConfig import (
48  AsgPhotonIsEMSelectorCfg)
49  for k,w in gidWP.items():
50  t = AsgPhotonIsEMSelectorCfg(flags, k+'_Photon', w)
51  kwarg[k+'_Photon'] = t.popPrivateTools()
52  acc.merge(t)
53 
54  from IsolationSelection.IsolationSelectionConfig import IsolationSelectionToolCfg
55  for k in gisoWP:
56  t = IsolationSelectionToolCfg(flags, 'PhIso'+k, PhotonWP=k)
57  name = f'Iso{k}'
58  kwarg[name] = t.popPrivateTools()
59  acc.merge(t)
60  kwarg['PhotonsKey'] = 'Photons'
61 
62  # a Truth classifier
63  if particleType != 'dataZ':
64  from MCTruthClassifier.MCTruthClassifierConfig import MCTruthClassifierCfg
65  MCClassifier = acc.popToolsAndMerge(MCTruthClassifierCfg(flags))
66  kwarg['egammaTruthParticlesKey'] = 'egammaTruthParticles'
67  kwarg['truthParticlesKey'] = 'TruthParticles'
68  else:
69  MCClassifier = None
70 
71  from AthenaConfiguration.Enums import LHCPeriod
72  if flags.GeoModel.Run > LHCPeriod.Run3:
73  kwarg['hasTRT'] = False
74 
75  # The monitoring alg
76  egMon = CompFactory.EgammaMonitoring(
77  name = 'egammaMonitoringAlg',
78  sampleType = particleType,
79  MCTruthClassifier = MCClassifier,
80  **kwarg)
81  acc.addEventAlgo(egMon)
82 
83  # Add the histogram service
84  svc = CompFactory.THistSvc(name="THistSvc")
85  svc.Output = [f"MONITORING DATAFILE='{outputFileName}.root' OPT='RECREATE'"]
86  acc.addService(svc)
87 
88  return acc
MCTruthClassifierConfig.MCTruthClassifierCfg
def MCTruthClassifierCfg(flags, **kwargs)
Definition: MCTruthClassifier/python/MCTruthClassifierConfig.py:8
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.AsgElectronLikelihoodToolsConfig.AsgElectronLikelihoodToolCfg
def AsgElectronLikelihoodToolCfg(flag, name, quality, menu=electronLHmenu.offlineMC21)
Definition: AsgElectronLikelihoodToolsConfig.py:13
python.AsgForwardElectronLikelihoodToolConfig.AsgForwardElectronLikelihoodToolCfg
def AsgForwardElectronLikelihoodToolCfg(ConfigFlags, name, **kwargs)
Definition: AsgForwardElectronLikelihoodToolConfig.py:6
python.AsgPhotonIsEMSelectorsConfig.AsgPhotonIsEMSelectorCfg
def AsgPhotonIsEMSelectorCfg(flags, name, quality, menu=photonPIDmenu.menuCurrentCuts, trigger=False)
Definition: AsgPhotonIsEMSelectorsConfig.py:15
IsolationSelectionConfig.IsolationSelectionToolCfg
def IsolationSelectionToolCfg(flags, name="IsolationSelectionTool", **kwargs)
Definition: IsolationSelectionConfig.py:6
egammaMonitoringConfig.egammaMonitoringCfg
def egammaMonitoringCfg(flags, particleType='electron', outputFileName='Nightly-monitoring.hist', addFwd=False)
Definition: egammaValidation/python/egammaMonitoringConfig.py:6