ATLAS Offline Software
Loading...
Searching...
No Matches
PhotonChainConfiguration.py
Go to the documentation of this file.
2# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3#
4
5from AthenaCommon.Logging import logging
6logging.getLogger().info("Importing %s",__name__)
7log = logging.getLogger(__name__)
8
9from AthenaConfiguration.ComponentFactory import CompFactory
10from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool
11from ..Config.ChainConfigurationBase import ChainConfigurationBase
12from ..CommonSequences.CaloSequences import fastCaloSequenceGenCfg
13from ..Photon.FastPhotonMenuSequences import fastPhotonSequenceGenCfg
14from ..Photon.PrecisionPhotonCaloIsoMenuSequences import precisionPhotonCaloIsoSequenceGenCfg
15from ..Photon.PrecisionPhotonMenuSequences import precisionPhotonSequenceGenCfg
16from ..Photon.PrecisionCaloMenuSequences import precisionCaloSequenceGenCfg
17from ..Photon.HipTRTMenuSequences import TRTHitGeneratorSequenceGenCfg
18
19
20def _diPhotonComboHypoToolFromDict(flags, chainDict, lowermass=80000,uppermass=-999,dphi=1.5,applymass=False,applydphi=False):
21 name = chainDict['chainName']
22 monTool = GenericMonitoringTool(flags, "MonTool_"+name,
23 HistPath = 'EgammaMassHypo/'+name)
24 monTool.defineHistogram('DphiOfAccepted', type='TH1F', path='EXPERT', title="PrecisionCalo Hypo entries per Phi;Phi", xbins=128, xmin=-3.2, xmax=3.2)
25 monTool.defineHistogram('MassOfAccepted', type='TH1F', path='EXPERT', title="Mass in accepted combinations [MeV]", xbins=75, xmin=0, xmax=150000)
26
27 tool= CompFactory.TrigEgammaTopoHypoTool(name,
28 AcceptAll = False,
29 ApplyMassCut = applymass,
30 LowerMassEgammaClusterCut = lowermass,
31 UpperMassEgammaClusterCut = uppermass,
32 ApplyDPhiCut = applydphi,
33 ThresholdDPhiCut = dphi,
34 MonTool = monTool)
35 return tool
36
37def diphotonDPhiHypoToolFromDict(flags, chainDict):
38 return _diPhotonComboHypoToolFromDict(flags,chainDict,lowermass=80000,uppermass=-999,dphi=1.5,applymass=False,applydphi=True)
39
41 return _diPhotonComboHypoToolFromDict(flags,chainDict,lowermass=80000,uppermass=-999,dphi=1.5,applymass=True,applydphi=True)
42
43
44#----------------------------------------------------------------
45# Class to configure chain
46#----------------------------------------------------------------
47class PhotonChainConfiguration(ChainConfigurationBase):
48
49 def __init__(self, chainDict):
50 ChainConfigurationBase.__init__(self,chainDict)
51 self.chainDict = chainDict
52
53 # ----------------------
54 # Prepare the sequence
55 # ----------------------
56 def prepareSequence(self):
57 # This function prepares the list of step names from which assembleChainImpl would make the chain assembly from.
58
59 # --------------------
60 # define here the names of the steps and obtain the chainStep configuration
61 # --------------------
62
63 stepNames = [] # This will contain the name of the steps we will want to configure
64 # Put first fast Calo. Two possible variants now:
65 # Step 1
66 stepNames += ['getFastCalo']
67
68 # OK now, unless its a HipTRT chain we need to do fastPhoton here:
69 if self.chainPart['extra'] == 'hiptrt':
70 stepNames += ['getHipTRT']
71 # for hiptrt chains, there is noprecision Calo nor precision Photon so returning sequence here:
72 return stepNames
73
74 # Now we do fast Photon
75 # Step 2
76 stepNames += ['getFastPhoton']
77
78
79 # After we need to place precisionCalo. There is no chain (except hiptrt) that does not require precision calo. Otherwise please insert logic here:
80 # Step 3
81 stepNames += ['getPrecisionCaloPhoton']
82
83 # And we will do precisionPhoton UNLESS its an etcut chain
84 if 'etcut' in self.chainPart['IDinfo']:
85 # if its an etcut chain we return the sequence up to here
86 return stepNames
87
88
89 #Now its the turn of precision Photon. Here we apply cutbased identification
90 #Step 4
91 stepNames += ['getPrecisionPhoton']
92
93 # Finally we need to run isolaton *IF* its an isolated chain
94 # Step 5
95 if 'noiso' in self.chainPart['isoInfo'] or 'icaloloose' in self.chainPart['isoInfo'] or 'icalomedium' in self.chainPart['isoInfo'] or 'icalotight' in self.chainPart['isoInfo']:
96 stepNames += ['getPhotonCaloIso']
97
98 return stepNames
99
100
101
102 # ----------------------
103 # Assemble the chain depending on information from chainName
104 # ----------------------
105 def assembleChainImpl(self, flags):
106 chainSteps = []
107 log.debug("Assembling chain for %s", self.chainName)
108
109 # This will contain the name of the steps we will want to configure
110 steps = self.prepareSequence()
111
112 # This is it, lets print the list of stepNames
113 log.debug("stepNames: %s", steps)
114 for step in steps:
115 log.debug('Adding photon trigger step %s', step)
116 is_probe_leg = self.chainPart['tnpInfo']=='probe'
117 chainstep = getattr(self, step)(flags, is_probe_leg=is_probe_leg)
118 chainSteps+=[chainstep]
119
120 myChain = self.buildChain(chainSteps)
121
122 return myChain
123
124 # --------------------
125 # Configuration of steps
126 # --------------------
127 def getFastCalo(self, flags, is_probe_leg=False):
128 stepName = "PhotonFastCalo"
129
130 return self.getStep(flags, stepName,[fastCaloSequenceGenCfg], name='Photon', is_probe_leg=is_probe_leg)
131
132 def getFastPhoton(self, flags, is_probe_leg=False):
133 stepName = "FastPhoton"
134 return self.getStep(flags, stepName,[fastPhotonSequenceGenCfg], is_probe_leg=is_probe_leg)
135
136 def getPrecisionCaloPhoton(self, flags, is_probe_leg=False):
137 do_ion = 'ion' in self.chainPart['extra']
138 if do_ion:
139 stepName = "PhotonPrecisionHICalo"
140 else:
141 stepName = "PhotonPrecisionCalo"
142
143 return self.getStep(flags, stepName,[precisionCaloSequenceGenCfg], ion=do_ion, is_probe_leg=is_probe_leg)
144
145 def getHipTRT(self, flags, is_probe_leg=False):
146 stepName = "hipTRT"
147 return self.getStep(flags, stepName,[TRTHitGeneratorSequenceGenCfg], is_probe_leg=is_probe_leg)
148
149 def getPrecisionPhoton(self, flags, is_probe_leg=False):
150
151 stepName = "precision_photon"
152 do_ion = 'ion' in self.chainPart['extra'] == 'ion'
153
154 if do_ion:
155 stepName += '_ion'
156
157 return self.getStep(flags, stepName,sequenceCfgArray=[precisionPhotonSequenceGenCfg], ion=do_ion, is_probe_leg=is_probe_leg)
158
159 def getPhotonCaloIso(self, flags, is_probe_leg=False):
160
161 stepName = "precision_photon_CaloIso"
162 comboTools = []
163 do_ion = 'ion' in self.chainPart['extra']
164
165 if do_ion:
166 stepName += '_ion'
167
168 if "dPhi15" in self.chainDict["topo"]:
169 stepName+='_dPhi15'
170 if "m80" in self.chainDict["topo"]:
171 stepName+= '_m80'
172 comboTools.append(diphotonDPhiMassHypoToolFromDict)
173 else:
174 comboTools.append(diphotonDPhiHypoToolFromDict)
175
176 return self.getStep(flags, stepName,sequenceCfgArray=[precisionPhotonCaloIsoSequenceGenCfg], name='Photon', comboTools=comboTools, ion=do_ion, is_probe_leg=is_probe_leg)
diphotonDPhiMassHypoToolFromDict(flags, chainDict)
_diPhotonComboHypoToolFromDict(flags, chainDict, lowermass=80000, uppermass=-999, dphi=1.5, applymass=False, applydphi=False)
diphotonDPhiHypoToolFromDict(flags, chainDict)