ATLAS Offline Software
TrigEgammaFastElectronHypoTool.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaCommon.Logging import logging
4 from AthenaCommon.SystemOfUnits import GeV
5 from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 
8 #
9 # For electrons
10 #
12 
13  __operation_points = [ 'tight' ,
14  'medium' ,
15  'loose' ,
16  'vloose' ,
17  'lhtight' ,
18  'lhmedium' ,
19  'lhloose' ,
20  'lhvloose' ,
21  'mergedtight',
22  'dnntight' ,
23  'dnnmedium',
24  'dnnloose' ,
25  'dnnvloose',
26  ]
27 
28  __trigElectronLrtd0Cut = { 'lrtloose' :2.0,
29  'lrtmedium':3.0,
30  'lrttight' :5.0,
31  'lrtxtight':10.0,
32  'lrtvxtight':20.0
33  }
34 
35  def __init__(self, name, monGroups, cpart, tool=None):
36 
37  self.__log = logging.getLogger('TrigEgammaFastElectronHypoTool')
38  self.__name = name
39  self.__threshold = float(cpart['threshold'])
40  self.__sel = cpart['addInfo'][0] if cpart['addInfo'] else cpart['IDinfo']
41  self.__idperfInfo = cpart['idperfInfo']
42  self.__lrtInfo = cpart['lrtInfo']
43  self.__monGroups = monGroups
44 
45  if not tool:
46  tool = CompFactory.TrigEgammaFastElectronHypoTool(name)
47 
48  self.__tool = tool
49  tool.AcceptAll = False
50  tool.DoRinger = False
51  tool.TrackPt = 0.0
52  tool.CaloTrackdETA = 0.2
53  tool.CaloTrackdPHI = 990.
54  tool.CaloTrackdEoverPLow = 0.0
55  tool.CaloTrackdEoverPHigh = 999.0
56  tool.TRTRatio = -999.
57  tool.PidName = ""
58 
59  self.__log.debug( 'Chain :%s', self.__name )
60  self.__log.debug( 'Threshold :%s', self.__threshold )
61  self.__log.debug( 'Pidname :%s', self.__sel )
62 
63 
64  def chain(self):
65  return self.__name
66 
67  def pidname( self ):
68  return self.__sel
69 
70  def etthr(self):
71  return self.__threshold
72 
73  def lrtInfo(self):
74  return self.__lrtInfo
75 
76  def idperfInfo(self):
77  return self.__idperfInfo
78 
79  def tool(self):
80  return self.__tool
81 
82 
83  def nocut(self):
84  self.tool().AcceptAll = True
85 
86  #
87  # Apply NN ringer selection
88  #
89  def ringer(self):
90  self.tool().DoRinger = True
91  self.tool().PidName = self.pidname()
92 
93 
94  def nominal(self):
95  if self.etthr() < 15:
96  self.tool().TrackPt = 1.0 * GeV
97  elif self.etthr() >= 15 and self.etthr() < 20:
98  self.tool().TrackPt = 2.0 * GeV
99  elif self.etthr() >= 20 and self.etthr() < 50:
100  self.tool().TrackPt = 3.0 * GeV
101  elif self.etthr() >= 50:
102  self.tool().TrackPt = 5.0 * GeV
103  self.tool().CaloTrackdETA = 999.
104  self.tool().CaloTrackdPHI = 999.
105 
106 
107  def addLRTCut(self):
108  self.tool().DoLRT = True
109  self.tool().d0Cut=self.__trigElectronLrtd0Cut[self.lrtInfo()]
110 
111 
112  #
113  # Compile the chain
114  #
115  def compile(self, flags):
116 
117  if 'idperf' in self.idperfInfo():
118  self.nocut()
119  else:
120  self.nominal()
121 
122  # secondary extra cut
123  if self.lrtInfo() in self.__trigElectronLrtd0Cut.keys():
124  self.addLRTCut()
125 
126 
127  # add mon tool
128  if hasattr(self.tool(), "MonTool"):
129 
130  doValidationMonitoring = flags.Trigger.doValidationMonitoring # True to monitor all chains for validation purposes
131  monGroups = self.__monGroups
132 
133  if (any('egammaMon:online' in group for group in monGroups) or doValidationMonitoring):
134  self.addMonitoring(flags)
135 
136 
137  #
138  # Monitoring code
139  #
140  def addMonitoring(self, flags):
141 
142  monTool = GenericMonitoringTool(flags, "MonTool"+self.__name)
143  monTool.defineHistogram('CutCounter', type='TH1I', path='EXPERT', title="FastElectron Hypo Cut Counter;Cut Counter", xbins=8, xmin=-1.5, xmax=7.5, opt="kCumulative")
144  monTool.defineHistogram('CaloTrackdEta', type='TH1F', path='EXPERT', title="FastElectron Hypo #Delta #eta between cluster and track;#Delta #eta;Nevents", xbins=80, xmin=-0.4, xmax=0.4)
145  monTool.defineHistogram('CaloTrackdPhi', type='TH1F', path='EXPERT', title="FastElectron Hypo #Delta #phi between cluster and track;#Delta #phi;Nevents", xbins=80, xmin=-0.4, xmax=0.4)
146  monTool.defineHistogram('CaloTrackEoverP', type='TH1F', path='EXPERT', title="FastElectron Hypo E/p;E/p;Nevents", xbins=120, xmin=0, xmax=12)
147  monTool.defineHistogram('PtTrack', type='TH1F', path='EXPERT', title="FastElectron Hypo p_{T}^{track} [MeV];p_{T}^{track} [MeV];Nevents", xbins=50, xmin=0, xmax=100000)
148  monTool.defineHistogram('PtCalo', type='TH1F', path='EXPERT', title="FastElectron Hypo p_{T}^{calo} [MeV];p_{T}^{calo} [MeV];Nevents", xbins=50, xmin=0, xmax=100000)
149  monTool.defineHistogram('CaloEta', type='TH1F', path='EXPERT', title="FastElectron Hypo #eta^{calo} ; #eta^{calo};Nevents", xbins=200, xmin=-2.5, xmax=2.5)
150  monTool.defineHistogram('CaloPhi', type='TH1F', path='EXPERT', title="FastElectron Hypo #phi^{calo} ; #phi^{calo};Nevents", xbins=320, xmin=-3.2, xmax=3.2)
151  monTool.defineHistogram('d0Value', type="TH1F", path='EXPERT', title="FastElectron Hypo Track d0; d0 [mm]", xbins=100, xmin=-1, xmax=1)
152  if self.tool().DoRinger:
153  monTool.defineHistogram('NNOutput',type='TH1F', path='EXPERT',title="NN Output; NN; Count", xbins=17,xmin=-8,xmax=+8)
154 
155  monTool.HistPath = 'FastElectronHypo/'+self.__name
156  self.tool().MonTool = monTool
157 
158 
159 
160 
161 def _IncTool(flags, name, monGroups, cpart, tool=None):
162  config = TrigEgammaFastElectronHypoToolConfig(name,monGroups, cpart, tool=tool)
163  config.compile(flags)
164  return config.tool()
165 
166 
167 
168 def TrigEgammaFastElectronHypoToolFromDict( flags, chainDict , tool=None):
169  """ Use menu decoded chain dictionary to configure the tool """
170  cparts = [i for i in chainDict['chainParts'] if (i['signature']=='Electron')]
171  return _IncTool( flags, chainDict['chainName'], chainDict['monGroups'], cparts[0] , tool=tool)
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.etthr
def etthr(self)
Definition: TrigEgammaFastElectronHypoTool.py:70
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.__sel
__sel
Definition: TrigEgammaFastElectronHypoTool.py:40
SystemOfUnits
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.tool
def tool(self)
Definition: TrigEgammaFastElectronHypoTool.py:79
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.__init__
def __init__(self, name, monGroups, cpart, tool=None)
Definition: TrigEgammaFastElectronHypoTool.py:35
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.ringer
def ringer(self)
Definition: TrigEgammaFastElectronHypoTool.py:89
python.TrigEgammaFastElectronHypoTool._IncTool
def _IncTool(flags, name, monGroups, cpart, tool=None)
Definition: TrigEgammaFastElectronHypoTool.py:161
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolFromDict
def TrigEgammaFastElectronHypoToolFromDict(flags, chainDict, tool=None)
Definition: TrigEgammaFastElectronHypoTool.py:168
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.__lrtInfo
__lrtInfo
Definition: TrigEgammaFastElectronHypoTool.py:42
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.__log
__log
Definition: TrigEgammaFastElectronHypoTool.py:37
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.__idperfInfo
__idperfInfo
Definition: TrigEgammaFastElectronHypoTool.py:41
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.chain
def chain(self)
Definition: TrigEgammaFastElectronHypoTool.py:64
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.__threshold
__threshold
Definition: TrigEgammaFastElectronHypoTool.py:39
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.__name
__name
Definition: TrigEgammaFastElectronHypoTool.py:38
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.__monGroups
__monGroups
Definition: TrigEgammaFastElectronHypoTool.py:43
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.__tool
__tool
Definition: TrigEgammaFastElectronHypoTool.py:48
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.addMonitoring
def addMonitoring(self, flags)
Definition: TrigEgammaFastElectronHypoTool.py:140
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.nominal
def nominal(self)
Definition: TrigEgammaFastElectronHypoTool.py:94
GenericMonitoringTool
Definition: GenericMonitoringTool.py:1
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.nocut
def nocut(self)
Definition: TrigEgammaFastElectronHypoTool.py:83
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.lrtInfo
def lrtInfo(self)
Definition: TrigEgammaFastElectronHypoTool.py:73
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig
Definition: TrigEgammaFastElectronHypoTool.py:11
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.__trigElectronLrtd0Cut
__trigElectronLrtd0Cut
Definition: TrigEgammaFastElectronHypoTool.py:28
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.pidname
def pidname(self)
Definition: TrigEgammaFastElectronHypoTool.py:67
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.compile
def compile(self, flags)
Definition: TrigEgammaFastElectronHypoTool.py:115
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.idperfInfo
def idperfInfo(self)
Definition: TrigEgammaFastElectronHypoTool.py:76
python.TrigEgammaFastElectronHypoTool.TrigEgammaFastElectronHypoToolConfig.addLRTCut
def addLRTCut(self)
Definition: TrigEgammaFastElectronHypoTool.py:107
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
readCCLHist.float
float
Definition: readCCLHist.py:83