ATLAS Offline Software
TrigEgammaPrecisionPhotonCaloIsoHypoTool.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.SystemOfUnits import GeV
4 from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
5 from AthenaConfiguration.ComponentFactory import CompFactory
6 #
7 # photon hypo alg
8 #
9 def createTrigEgammaPrecisionPhotonCaloIsoHypoAlg(name, sequenceOut, sequenceIn):
10 
11  thePrecisionPhotonCaloIsoHypo = CompFactory.TrigEgammaPrecisionPhotonCaloIsoHypoAlg(name)
12  thePrecisionPhotonCaloIsoHypo.Photons = sequenceIn # Key of the input photon container
13  thePrecisionPhotonCaloIsoHypo.IsoPhotons = sequenceOut # key of the output isolated photon container
14  return thePrecisionPhotonCaloIsoHypo
15 
16 
17 #
18 # For photons
19 #
21 
22 
23  #Below are the configuration of the calorimeter isolation selections
24  # The dictionary key is the working point (icaloloose, icalo medium and icalotight
25  # the value is an array of three components where first component refers to a cut related to topoetcone20/pt, the second to topoetcone30/pt and third to topoetcone40/pt
26  # __caloIsolationCut is the cut on the variable topoetcone[x]/pt
27  # __caloEtconeCut is the cut on etcone[x]/pt Not used. But kept for backward compatibility
28  # __caloIsolationOffset is the offset applied to that cut
29  # so the selection is:
30  #
31 
32  __caloIsolationCut = {
33  None : [None, None, None],
34  'icaloloose' : [0.1 , 999., 999. ],
35  'icalomedium' : [0.075, 999., 999. ],
36  'icalotight' : [999. , 999., 0.03 ]
37  }
38 
39  __caloEtconeCut = {
40  None : [None, None, None],
41  'icaloloose' : [999., 999., 999.],
42  'icalomedium' : [999., 999., 999.],
43  'icalotight' : [999., 999., 999.]
44  }
45 
46  __caloIsolationOffset = {
47  None : [None, None, None],
48  'icaloloose' : [0.,0.,0.],
49  'icalomedium': [0.,0.,0],
50  'icalotight' : [0.,0.,2.45*GeV]
51  }
52 
53 
54  def __init__(self, name, monGroups, cpart, tool=None):
55 
56  from AthenaCommon.Logging import logging
57  self.__log = logging.getLogger('TrigEgammaPrecisionPhotonCaloIsoHypoTool')
58  self.__name = name
59  self.__isoinfo = cpart['isoInfo']
60  self.__monGroups = monGroups
61 
62  if not tool:
63  tool = CompFactory.TrigEgammaPrecisionPhotonCaloIsoHypoTool( name )
64 
65  tool.EtaBins = [0.0, 0.6, 0.8, 1.15, 1.37, 1.52, 1.81, 2.01, 2.37, 2.47]
66 
67  self.__tool = tool
68  self.__log.debug( 'Chain :%s', self.__name )
69  self.__log.debug( 'isoinfo :%s', self.__isoinfo )
70 
71 
72  def isoInfo(self):
73  return self.__isoinfo
74 
75  def tool(self):
76  return self.__tool
77 
78  #
79  # Isolation and nominal cut
80  #
81  def isoCut(self):
82 
83  if self.isoInfo() == 'noiso':
84  self.tool().AcceptAll = True
85  return
86  self.tool().RelTopoEtConeCut = self.__caloIsolationCut[self.isoInfo()]
87  self.tool().RelEtConeCut = self.__caloEtconeCut[self.isoInfo()]
88  self.tool().Offset = self.__caloIsolationOffset[self.isoInfo()]
89 
90 
91 
92 
93  #
94  # Compile the chain
95  #
96  def compile(self, flags):
97 
98  if self.isoInfo() != 'noiso':
99  if self.isoInfo() not in self.__caloIsolationCut.keys():
100  self.__log.error('Isolation cut %s not defined!', self.isoInfo())
101 
102  self.__log.debug('Configuring Isolation cut %s for [topoetcone20/et, topoetcone30/et, topoetcone40/et]', self.isoInfo())
103  self.__log.debug(' with values = %s and offsets = %s',
104  str(self.__caloIsolationCut[self.isoInfo()]),
105  str(self.__caloIsolationOffset[self.isoInfo()]))
106  else:
107  self.__log.debug('Configuring Isolation to AcceptAll (not applying any cut)')
108  self.isoCut()
109 
110 
111  if hasattr(self.tool(), "MonTool"):
112 
113  doValidationMonitoring = flags.Trigger.doValidationMonitoring # True to monitor all chains for validation purposes
114  monGroups = self.__monGroups
115 
116  if (any('egammaMon:online' in group for group in monGroups) or doValidationMonitoring):
117  self.addMonitoring(flags)
118 
119 
120  #
121  # Monitoring code
122  #
123  def addMonitoring(self, flags):
124 
125  monTool = GenericMonitoringTool(flags, "MonTool_"+self.__name,
126  HistPath = 'PrecisionPhotonCaloIsoHypo/'+self.__name)
127  monTool.defineHistogram('Et_em', type='TH1F', path='EXPERT', title="PrecisionPhotonCaloIso Hypo cluster E_{T}^{EM};E_{T}^{EM} [MeV]", xbins=50, xmin=-2000, xmax=100000)
128  monTool.defineHistogram('Eta', type='TH1F', path='EXPERT', title="PrecisionPhotonCaloIso Hypo entries per Eta;Eta", xbins=100, xmin=-2.5, xmax=2.5)
129  monTool.defineHistogram('Phi', type='TH1F', path='EXPERT', title="PrecisionPhotonCaloIso Hypo entries per Phi;Phi", xbins=128, xmin=-3.2, xmax=3.2)
130  monTool.defineHistogram('EtaBin', type='TH1I', path='EXPERT', title="PrecisionPhotonCaloIso Hypo entries per Eta bin;Eta bin no.", xbins=11, xmin=-0.5, xmax=10.5)
131 
132  cuts=['Input','eta','Calo Iso']
133 
134  monTool.defineHistogram('CutCounter', type='TH1I', path='EXPERT', title="PrecisionPhotonCaloIso Hypo Passed Cuts;Cut",
135  xbins=13, xmin=-1.5, xmax=12.5, opt="kCumulative", xlabels=cuts)
136 
137  if flags.Trigger.doValidationMonitoring:
138  monTool.defineHistogram('etcone20',type='TH1F',path='EXPERT',title= "PrecisionPhotonCaloIso Hypo etcone20; etcone20;", xbins=50, xmin=0, xmax=5.0)
139  monTool.defineHistogram('topoetcone20',type='TH1F',path='EXPERT',title= "PrecisionPhotonCaloIso Hypo; topoetcone20;", xbins=50, xmin=-10, xmax=10)
140  monTool.defineHistogram('reletcone20',type='TH1F',path='EXPERT',title= "PrecisionPhotonCaloIso Hypo etcone20/et; etcone20/et;", xbins=50, xmin=-0.5, xmax=0.5)
141  monTool.defineHistogram('reltopoetcone20',type='TH1F',path='EXPERT',title= "PrecisionPhotonCaloIso Hypo; topoetcone20/pt;", xbins=50, xmin=-0.5, xmax=0.5)
142 
143  self.tool().MonTool = monTool
144 
145 
146 
147 def _IncTool( flags, name, monGroups, cpart, tool=None ):
148  config = TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig(name, monGroups, cpart, tool=tool)
149  config.compile(flags)
150  return config.tool()
151 
152 
153 
155  """ Use menu decoded chain dictionary to configure the tool """
156  cparts = [i for i in d['chainParts'] if ((i['signature']=='Electron') or (i['signature']=='Photon'))]
157  return _IncTool( flags, d['chainName'], d['monGroups'], cparts[0], tool=tool )
SystemOfUnits
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:20
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig.__caloIsolationOffset
__caloIsolationOffset
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:46
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig.compile
def compile(self, flags)
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:96
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig.__tool
__tool
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:67
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig.__init__
def __init__(self, name, monGroups, cpart, tool=None)
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:54
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig.__caloEtconeCut
__caloEtconeCut
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:39
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig.__name
__name
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:58
GenericMonitoringTool
Definition: GenericMonitoringTool.py:1
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig.__caloIsolationCut
__caloIsolationCut
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:32
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig.__log
__log
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:57
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.createTrigEgammaPrecisionPhotonCaloIsoHypoAlg
def createTrigEgammaPrecisionPhotonCaloIsoHypoAlg(name, sequenceOut, sequenceIn)
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:9
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig.__monGroups
__monGroups
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:60
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig.isoCut
def isoCut(self)
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:81
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig.tool
def tool(self)
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:75
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolFromDict
def TrigEgammaPrecisionPhotonCaloIsoHypoToolFromDict(flags, d, tool=None)
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:154
str
Definition: BTagTrackIpAccessor.cxx:11
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig.__isoinfo
__isoinfo
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:59
error
Definition: IImpactPoint3dEstimator.h:70
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig.addMonitoring
def addMonitoring(self, flags)
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:123
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool.TrigEgammaPrecisionPhotonCaloIsoHypoToolConfig.isoInfo
def isoInfo(self)
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:72
python.TrigEgammaPrecisionPhotonCaloIsoHypoTool._IncTool
def _IncTool(flags, name, monGroups, cpart, tool=None)
Definition: TrigEgammaPrecisionPhotonCaloIsoHypoTool.py:147