ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEgammaFastPhotonHypoTool.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3from AthenaCommon.SystemOfUnits import GeV
4from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
5
6#
7# For photons
8#
10
11 __operation_points = [ 'tight' ,
12 'medium' ,
13 'loose' ,
14 'etcut' ,
15 'nopid' ,
16 ]
17
18 def same( self, val ):
19 return [val]*( len( self.tool().EtaBins ) - 1 )
20
21 def __init__(self, name,monGroups, cpart, tool=None):
22
23 from AthenaCommon.Logging import logging
24 self.__log = logging.getLogger('TrigEgammaFastPhotonHypoTool')
25 self.__name = name
26 self.__threshold = float(cpart['threshold'])
27 self.__sel = 'ion' if 'ion' in cpart['extra'] else (cpart['addInfo'][0] if cpart['addInfo'] else cpart['IDinfo'])
28 self.__monGroups = monGroups
29
30 if not tool:
31 from AthenaConfiguration.ComponentFactory import CompFactory
32 tool = CompFactory.TrigEgammaFastPhotonHypoTool(name)
33
34 self.__tool = tool
35
36 tool.EtaBins = [0.0, 0.6, 0.8, 1.15, 1.37, 1.52, 1.81, 2.01, 2.37, 2.47]
37 tool.ETthr = self.same( 0.0 )
38 tool.CARCOREthr = self.same( 0.0 )
39 tool.CAERATIOthr = self.same( 0.0)
40 tool.F1thr = self.same( 0.005 )
41 tool.ET2thr = self.same( 90.0 * GeV )
42 tool.HADET2thr = self.same( 999. * GeV )
43 tool.HADETthr = self.same( 999. * GeV )
44
45
46
47
48 self.__log.debug( 'Chain :%s', self.__name )
49 self.__log.debug( 'Threshold :%s', self.__threshold )
50 self.__log.debug( 'Pidname :%s', self.__sel )
51
52
53
54 def chain(self):
55 return self.__name
56
57 def pidname( self ):
58 return self.__sel
59
60 def etthr(self):
61 return self.__threshold
62
63 def tool(self):
64 return self.__tool
65
66 def etcut(self):
67 self.__log.debug( 'Chain :%s configured with etcut selection', self.chain() )
68 self.tool().ETthr = self.same( self.etthr() *GeV - 3.* GeV) # Set the eT cut 3 GeV below HLT threshold
69
70 def nocut(self):
71 self.__log.debug( 'Chain :%s configured with nocut selection', self.chain() )
72 self.tool().AcceptAll = True
73
74 def nominal(self):
75 from TrigEgammaHypo.TrigEgammaFastCutDefs import TrigFastPhotonCutMaps
76 self.__log.debug( 'Chain :%s configured with nominal selection', self.chain() )
77 self.tool().ETthr = self.same( self.etthr() *GeV - 3.* GeV) # Set the eT cut 3 GeV below HLT threshold
78 self.tool().CARCOREthr = TrigFastPhotonCutMaps( self.etthr() ).MapsCARCOREthr[ self.pidname() ]
79 self.tool().CAERATIOthr = TrigFastPhotonCutMaps( self.etthr() ).MapsCAERATIOthr [ self.pidname() ]
80 self.tool().HADETthr = TrigFastPhotonCutMaps( self.etthr() ).MapsHADETthr[ self.pidname() ]
81 self.tool().HADET2thr = self.same(999.0 * GeV)
82 self.tool().F1thr = self.same(0.005)
83 self.tool().ET2thr = self.same( 90.0*GeV )
84
85
86 #
87 # Compile the chain
88 #
89 def compile(self, flags):
90 if self.pidname() in ('etcut', 'ion', 'nopid'):
91 self.etcut()
92 elif 'noalg' == self.pidname():
93 self.nocut()
94 elif 0 == self.etthr():
95 self.nocut()
96 else:
97 self.nominal()
98
99
100 # add mon tool
101 if hasattr(self.tool(), "MonTool"):
102
103 doValidationMonitoring = flags.Trigger.doValidationMonitoring # True to monitor all chains for validation purposes
104 monGroups = self.__monGroups
105
106 if (any('egammaMon:online' in group for group in monGroups) or doValidationMonitoring):
107 self.addMonitoring(flags)
108
109
110 #
111 # Monitoring code
112 #
113 def addMonitoring(self, flags):
114
115 monTool = GenericMonitoringTool(flags, "MonTool"+self.chain(),
116 HistPath = 'FastPhotonHypo/'+self.chain())
117 monTool.defineHistogram('CutCounter', type='TH1I', path='EXPERT', title="FastPhoton Hypo Cut Counter;Cut Counter", xbins=8, xmin=-1.5, xmax=7.5, opt="kCumulative")
118 monTool.defineHistogram('Et', type='TH1F', path='EXPERT', title="FastPhoton Hypo E_{T}^{EM};E_{T}^{EM} [MeV]",xbins=50, xmin=-2000, xmax=100000)
119 monTool.defineHistogram('Eta', type='TH1F', path='EXPERT', title="FastPhoton Hypo #eta^{calo} ; #eta^{calo};Nevents", xbins=200, xmin=-2.5, xmax=2.5)
120 monTool.defineHistogram('Phi', type='TH1F', path='EXPERT', title="FastPhoton Hypo #phi^{calo} ; #phi^{calo};Nevents", xbins=320, xmin=-3.2, xmax=3.2)
121 monTool.defineHistogram('Rcore', type='TH1F', path='EXPERT', title="FastPhoton Hypo R_{core};E^{3x7}/E^{7x7} in sampling 2",xbins=48, xmin=-0.1, xmax=1.1)
122 monTool.defineHistogram('Eratio', type='TH1F', path='EXPERT',title="FastPhoton Hypo E_{ratio};E^{max1}-E^{max2}/E^{max1}+E^{max2} in sampling 1 (excl.crack)",xbins=64, xmin=-0.1, xmax=1.5)
123 monTool.defineHistogram('Et_had', type='TH1F', path='EXPERT', title="FastPhoton Hypo E_{T}^{had} in first layer;E_{T}^{had} [MeV]",xbins=50, xmin=-2000, xmax=100000)
124 monTool.defineHistogram('F1', type='TH1F', path='EXPERT', title="FastPhoton Hypo f_{1};f_{1}", xbins=34, xmin=-0.5, xmax=1.2)
125
126 self.__tool.MonTool = monTool
127
128
129
130
131def _IncTool(flags, name, monGroups, cpart, tool=None):
132 config = TrigEgammaFastPhotonHypoToolConfig(name,monGroups, cpart, tool=tool)
133 config.compile(flags)
134 return config.tool()
135
136
137
138def TrigEgammaFastPhotonHypoToolFromDict(flags, chainDict, tool=None):
139 """ Use menu decoded chain dictionary to configure the tool """
140 cparts = [i for i in chainDict['chainParts'] if i['signature']=='Photon' ]
141 return _IncTool( flags, chainDict['chainName'], chainDict['monGroups'], cparts[0] , tool=tool)
const bool debug
TrigEgammaFastPhotonHypoToolFromDict(flags, chainDict, tool=None)
_IncTool(flags, name, monGroups, cpart, tool=None)