ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEgammaFastElectronHypoTool.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3from AthenaCommon.Logging import logging
4from AthenaCommon.SystemOfUnits import GeV
5from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
6from 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, flags, 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 = flags.Trigger.egamma.enableFastElectronRinger
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 cuts=['Has Track','ptCalo','#Delta #eta', '#Delta #phi','etOverPt_low','etOverPt_high','TRTHitRatio']
144 monTool.defineHistogram('CutCounter', type='TH1I', path='EXPERT', title="FastElectron Hypo Cut Counter;Cut Counter", xbins=7, xmin=0, xmax=7, opt="kCumulative",xlabels=cuts)
145 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)
146 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)
147 monTool.defineHistogram('CaloTrackEoverP', type='TH1F', path='EXPERT', title="FastElectron Hypo E/p;E/p;Nevents", xbins=120, xmin=0, xmax=12)
148 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)
149 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)
150 monTool.defineHistogram('CaloEta', type='TH1F', path='EXPERT', title="FastElectron Hypo #eta^{calo} ; #eta^{calo};Nevents", xbins=200, xmin=-2.5, xmax=2.5)
151 monTool.defineHistogram('CaloPhi', type='TH1F', path='EXPERT', title="FastElectron Hypo #phi^{calo} ; #phi^{calo};Nevents", xbins=320, xmin=-3.2, xmax=3.2)
152 monTool.defineHistogram('d0Value', type="TH1F", path='EXPERT', title="FastElectron Hypo Track d0; d0 [mm]", xbins=100, xmin=-1, xmax=1)
153 if self.tool().DoRinger:
154 monTool.defineHistogram('NNOutput',type='TH1F', path='EXPERT',title="NN Output; NN; Count", xbins=17,xmin=-8,xmax=+8)
155
156 monTool.HistPath = 'FastElectronHypo/'+self.__name
157 self.tool().MonTool = monTool
158
159
160
161
162def _IncTool(flags, name, monGroups, cpart, tool=None):
163 config = TrigEgammaFastElectronHypoToolConfig(name, monGroups, cpart, flags, tool=tool)
164 config.compile(flags)
165 return config.tool()
166
167
168
169def TrigEgammaFastElectronHypoToolFromDict( flags, chainDict , tool=None):
170 """ Use menu decoded chain dictionary to configure the tool """
171 cparts = [i for i in chainDict['chainParts'] if (i['signature']=='Electron')]
172 return _IncTool( flags, chainDict['chainName'], chainDict['monGroups'], cparts[0] , tool=tool)
const bool debug
_IncTool(flags, name, monGroups, cpart, tool=None)
TrigEgammaFastElectronHypoToolFromDict(flags, chainDict, tool=None)