ATLAS Offline Software
TrigEgammaPrecisionPhotonHypoTool.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaCommon.SystemOfUnits import GeV
4 from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
5 from ElectronPhotonSelectorTools.EgammaPIDdefs import egammaPID
6 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
7 from AthenaConfiguration.ComponentFactory import CompFactory
8 #
9 # photon hypo alg
10 #
11 
12 def TrigEgammaPrecisionPhotonHypoAlgCfg(flags, name, sequenceOut,**kwargs ):
13  acc = ComponentAccumulator()
14  from ElectronPhotonSelectorTools.AsgPhotonIsEMSelectorsConfig import (AsgPhotonIsEMSelectorCfg)
15  from TriggerMenuMT.HLT.Photon.TriggerPhotonIsEMSelectorMapping import (triggerPhotonPIDmenu)
16 
17  if "PhotonIsEMSelectorTools" not in kwargs:
18  LoosePhotonSelector = acc.popToolsAndMerge(AsgPhotonIsEMSelectorCfg(flags, "LoosePhotonSelector", egammaPID.PhotonIDLoose, triggerPhotonPIDmenu.menuCurrentCuts, trigger = True))
19  MediumPhotonSelector = acc.popToolsAndMerge(AsgPhotonIsEMSelectorCfg(flags, "MediumPhotonSelector", egammaPID.PhotonIDMedium, triggerPhotonPIDmenu.menuCurrentCuts, trigger = True))
20  TightPhotonSelector = acc.popToolsAndMerge(AsgPhotonIsEMSelectorCfg(flags, "TightPhotonSelector", egammaPID.PhotonIDTight, triggerPhotonPIDmenu.menuCurrentCuts, trigger = True))
21  kwargs["PhotonIsEMSelectorTools"] = [TightPhotonSelector, MediumPhotonSelector, LoosePhotonSelector]
22  if "IsEMNames" not in kwargs:
23  kwargs["IsEMNames"]=['tight','medium','loose']
24 
25  if "Photons" not in kwargs:
26  kwargs["Photons"] = sequenceOut
27 
28  hypoAlg = CompFactory.TrigEgammaPrecisionPhotonHypoAlg(name, **kwargs)
29  acc.addEventAlgo( hypoAlg )
30  return acc
31 
32 
33 def same( val , tool):
34  return [val]*( len( tool.EtaBins ) - 1 )
35 
36 
37 #
38 # For photons
39 #
41 
42  __operation_points = [ 'tight' ,
43  'medium' ,
44  'loose' ,
45  'nopid' ,
46  ]
47 
48  def __init__(self, name, monGroups, cpart, tool=None):
49 
50  from AthenaCommon.Logging import logging
51  self.__log = logging.getLogger('TrigEgammaPrecisionPhotonHypoTool')
52  self.__name = name
53  self.__threshold = float(cpart['threshold'])
54  self.__sel = cpart['addInfo'][0] if cpart['addInfo'] else cpart['IDinfo']
55  self.__monGroups = monGroups
56 
57  if not tool:
58  tool = CompFactory.TrigEgammaPrecisionPhotonHypoTool( name )
59 
60  tool.EtaBins = [0.0, 0.6, 0.8, 1.15, 1.37, 1.52, 1.81, 2.01, 2.37, 2.47]
61  tool.ETthr = same( self.__threshold*GeV , tool)
62  tool.dETACLUSTERthr = 0.1
63  tool.dPHICLUSTERthr = 0.1
64  tool.PidName = ""
65  tool.DoNoPid = False
66 
67  self.__tool = tool
68  self.__log.debug( 'Chain :%s', self.__name )
69  self.__log.debug( 'Threshold :%s', self.__threshold )
70  self.__log.debug( 'Pidname :%s', self.__sel )
71 
72 
73  def chain(self):
74  return self.__name
75 
76  def pidname( self ):
77  return self.__sel
78 
79  def etthr(self):
80  return self.__threshold
81 
82  def tool(self):
83  return self.__tool
84 
85 
86  def etcut(self):
87  self.__log.debug( 'Configure etcut' )
88  self.tool().ETthr = same( ( self.etthr() - 3 )*GeV, self.tool() )
89  # No other cuts applied
90  self.tool().dETACLUSTERthr = 9999.
91  self.tool().dPHICLUSTERthr = 9999.
92 
93  def noPid(self):
94  self.tool().DoNoPid = True
95  self.__log.debug( 'Configure noPid' )
96  self.tool().ETthr = same( self.etthr()*GeV, self.tool())
97  # No other cuts applied
98  self.tool().dETACLUSTERthr = 9999.
99  self.tool().dPHICLUSTERthr = 9999.
100 
101  def nominal(self):
102  if not self.pidname() in self.__operation_points:
103  self.__log.fatal("Bad selection name: %s" % self.pidname())
104  self.tool().PidName = self.pidname()
105 
106 
107  #
108  # Compile the chain
109  #
110  def compile(self, flags):
111 
112  if 'etcut' == self.pidname():
113  self.etcut()
114  elif 'nopid' == self.pidname():
115  self.noPid()
116 
117  else:
118  self.nominal()
119 
120  if hasattr(self.tool(), "MonTool"):
121 
122  doValidationMonitoring = flags.Trigger.doValidationMonitoring # True to monitor all chains for validation purposes
123  monGroups = self.__monGroups
124 
125  if (any('egammaMon:online' in group for group in monGroups) or doValidationMonitoring):
126  self.addMonitoring(flags)
127 
128 
129  #
130  # Monitoring code
131  #
132  def addMonitoring(self, flags):
133 
134  monTool = GenericMonitoringTool(flags, "MonTool_"+self.__name,
135  HistPath = 'PrecisionPhotonHypo/'+self.__name)
136  monTool.defineHistogram('dEta', type='TH1F', path='EXPERT', title="PrecisionPhoton Hypo #Delta#eta_{EF L1}; #Delta#eta_{EF L1}", xbins=80, xmin=-0.01, xmax=0.01)
137  monTool.defineHistogram('dPhi', type='TH1F', path='EXPERT', title="PrecisionPhoton Hypo #Delta#phi_{EF L1}; #Delta#phi_{EF L1}", xbins=80, xmin=-0.01, xmax=0.01)
138  monTool.defineHistogram('Et_em', type='TH1F', path='EXPERT', title="PrecisionPhoton Hypo cluster E_{T}^{EM};E_{T}^{EM} [MeV]", xbins=50, xmin=-2000, xmax=100000)
139  monTool.defineHistogram('Eta', type='TH1F', path='EXPERT', title="PrecisionPhoton Hypo entries per Eta;Eta", xbins=100, xmin=-2.5, xmax=2.5)
140  monTool.defineHistogram('Phi', type='TH1F', path='EXPERT', title="PrecisionPhoton Hypo entries per Phi;Phi", xbins=128, xmin=-3.2, xmax=3.2)
141  monTool.defineHistogram('EtaBin', type='TH1I', path='EXPERT', title="PrecisionPhoton Hypo entries per Eta bin;Eta bin no.", xbins=11, xmin=-0.5, xmax=10.5)
142 
143  cuts=['Input','#Delta #eta EF-L1', '#Delta #phi EF-L1','eta','E_{T}^{EM}']
144 
145  monTool.defineHistogram('CutCounter', type='TH1I', path='EXPERT', title="PrecisionPhoton Hypo Passed Cuts;Cut",
146  xbins=13, xmin=-1.5, xmax=12.5, opt="kCumulative", xlabels=cuts)
147 
148  if flags.Trigger.doValidationMonitoring:
149  monTool.defineHistogram('etcone20',type='TH1F',path='EXPERT',title= "PrecisionPhoton Hypo etcone20; etcone20;", xbins=50, xmin=0, xmax=5.0)
150  monTool.defineHistogram('topoetcone20',type='TH1F',path='EXPERT',title= "PrecisionPhoton Hypo; topoetcone20;", xbins=50, xmin=-10, xmax=10)
151  monTool.defineHistogram('reletcone20',type='TH1F',path='EXPERT',title= "PrecisionPhoton Hypo etcone20/et; etcone20/et;", xbins=50, xmin=-0.5, xmax=0.5)
152  monTool.defineHistogram('reltopoetcone20',type='TH1F',path='EXPERT',title= "PrecisionPhoton Hypo; topoetcone20/pt;", xbins=50, xmin=-0.5, xmax=0.5)
153 
154  self.tool().MonTool = monTool
155 
156 
157 
158 def _IncTool( flags, name, monGroups, cpart, tool=None ):
159  config = TrigEgammaPrecisionPhotonHypoToolConfig(name, monGroups, cpart, tool=tool)
160  config.compile(flags)
161  return config.tool()
162 
163 
164 
166  """ Use menu decoded chain dictionary to configure the tool """
167  cparts = [i for i in d['chainParts'] if ((i['signature']=='Electron') or (i['signature']=='Photon'))]
168  return _IncTool( flags, d['chainName'], d['monGroups'], cparts[0], tool=tool )
169 
170 
171 
SystemOfUnits
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.pidname
def pidname(self)
Definition: TrigEgammaPrecisionPhotonHypoTool.py:76
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolFromDict
def TrigEgammaPrecisionPhotonHypoToolFromDict(flags, d, tool=None)
Definition: TrigEgammaPrecisionPhotonHypoTool.py:165
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.addMonitoring
def addMonitoring(self, flags)
Definition: TrigEgammaPrecisionPhotonHypoTool.py:132
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.chain
def chain(self)
Definition: TrigEgammaPrecisionPhotonHypoTool.py:73
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.nominal
def nominal(self)
Definition: TrigEgammaPrecisionPhotonHypoTool.py:101
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.__monGroups
__monGroups
Definition: TrigEgammaPrecisionPhotonHypoTool.py:55
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig
Definition: TrigEgammaPrecisionPhotonHypoTool.py:40
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.tool
def tool(self)
Definition: TrigEgammaPrecisionPhotonHypoTool.py:82
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.__operation_points
__operation_points
Definition: TrigEgammaPrecisionPhotonHypoTool.py:42
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.__threshold
__threshold
Definition: TrigEgammaPrecisionPhotonHypoTool.py:53
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.__name
__name
Definition: TrigEgammaPrecisionPhotonHypoTool.py:52
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.__log
__log
Definition: TrigEgammaPrecisionPhotonHypoTool.py:51
python.TrigEgammaPrecisionPhotonHypoTool.same
def same(val, tool)
Definition: TrigEgammaPrecisionPhotonHypoTool.py:33
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.etcut
def etcut(self)
Definition: TrigEgammaPrecisionPhotonHypoTool.py:86
python.AsgPhotonIsEMSelectorsConfig.AsgPhotonIsEMSelectorCfg
def AsgPhotonIsEMSelectorCfg(flags, name, quality, menu=photonPIDmenu.menuCurrentCuts, trigger=False)
Definition: AsgPhotonIsEMSelectorsConfig.py:15
GenericMonitoringTool
Definition: GenericMonitoringTool.py:1
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.compile
def compile(self, flags)
Definition: TrigEgammaPrecisionPhotonHypoTool.py:110
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.noPid
def noPid(self)
Definition: TrigEgammaPrecisionPhotonHypoTool.py:93
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.__init__
def __init__(self, name, monGroups, cpart, tool=None)
Definition: TrigEgammaPrecisionPhotonHypoTool.py:48
python.TrigEgammaPrecisionPhotonHypoTool._IncTool
def _IncTool(flags, name, monGroups, cpart, tool=None)
Definition: TrigEgammaPrecisionPhotonHypoTool.py:158
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.etthr
def etthr(self)
Definition: TrigEgammaPrecisionPhotonHypoTool.py:79
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.__tool
__tool
Definition: TrigEgammaPrecisionPhotonHypoTool.py:67
readCCLHist.float
float
Definition: readCCLHist.py:83
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoToolConfig.__sel
__sel
Definition: TrigEgammaPrecisionPhotonHypoTool.py:54
python.TrigEgammaPrecisionPhotonHypoTool.TrigEgammaPrecisionPhotonHypoAlgCfg
def TrigEgammaPrecisionPhotonHypoAlgCfg(flags, name, sequenceOut, **kwargs)
Definition: TrigEgammaPrecisionPhotonHypoTool.py:12