ATLAS Offline Software
Loading...
Searching...
No Matches
SCTHitEffMonAlg.py
Go to the documentation of this file.
2# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3#
4'''@file SCTHitEffMonAlg.py
5@author Ken Kreul
6@date 2019-10-30
7@brief Based on AthenaMonitoring/ExampleMonitorAlgorithm.py
8'''
9
10def dedicatedTitle(i, isub):
11 m_element = i
12 m_layerStr = i / 2
13 m_region = isub
14 if m_region == 1 :
15 return "Layer " + str(m_layerStr) + " Side " + str((m_element % 2 + 1) % 2)
16 else:
17 return "Disk " + str(m_layerStr) + " Side " + str((m_element % 2 + 1) % 2)
18
20 '''Function to configures some algorithms in the monitoring system.'''
21
24 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
25 result = ComponentAccumulator()
26
27 # The following class will make a sequence, configure algorithms, and link
28 # them to GenericMonitoringTools
29 from AthenaMonitoring import AthMonitorCfgHelper
30 helper = AthMonitorCfgHelper(flags, 'SCTHitEffMonCfg')
31
32
33
39 from AthenaConfiguration.ComponentFactory import CompFactory
40 from InDetConfig.InDetTrackHoleSearchConfig import (
41 InDetTrackHoleSearchToolCfg)
42 from InDetConfig.SiClusterOnTrackTool_SCTStripConfig import (
43 InDetSCT_ClusterOnTrackToolCfg)
44 from TrkConfig.TrkResidualPullCalculatorConfig import (
45 ResidualPullCalculatorCfg)
46
47 myMonAlg = helper.addAlgorithm(
48 CompFactory.SCTHitEffMonAlg,
49 'SCTHitEffMonAlg',
50 HoleSearch = result.popToolsAndMerge(
51 InDetTrackHoleSearchToolCfg(flags)),
52 ROTCreator = result.popToolsAndMerge(
53 InDetSCT_ClusterOnTrackToolCfg(flags)),
54 ResPullCalc = result.popToolsAndMerge(
55 ResidualPullCalculatorCfg(flags))
56 )
57
58 # # If for some really obscure reason you need to instantiate an algorithm
59 # # yourself, the AddAlgorithm method will still configure the base
60 # # properties and add the algorithm to the monitoring sequence.
61 # helper.AddAlgorithm(myExistingAlg)
62
63
64
66 myMonAlg.TriggerChain = ''
67
68
71
72 # set up geometry / conditions
73 from LumiBlockComps.BunchCrossingCondAlgConfig import BunchCrossingCondAlgCfg
74 result.merge(BunchCrossingCondAlgCfg(flags))
75 from MagFieldServices.MagFieldServicesConfig import AtlasFieldCacheCondAlgCfg
76 result.merge(AtlasFieldCacheCondAlgCfg(flags))
77 from SCT_ConditionsAlgorithms.SCT_ConditionsAlgorithmsConfig import SCT_DetectorElementCondAlgCfg
78 result.merge(SCT_DetectorElementCondAlgCfg(flags))
79
80 # Add a generic monitoring tool (a "group" in old language). The returned
81 # object here is the standard GenericMonitoringTool.
82
83 from ROOT import SCT_Monitoring as sctMon
84
85 myMonGroup = [
86 helper.addGroup(
87 myMonAlg,
88 "SCTHitEffMonitorEC",
89 "SCT/SCTEC/"
90 ),
91 helper.addGroup(
92 myMonAlg,
93 "SCTHitEffMonitorB",
94 "SCT/SCTB/"
95 ),
96 helper.addGroup(
97 myMonAlg,
98 "SCTHitEffMonitorEA",
99 "SCT/SCTEA/"
100 ),
101 helper.addGroup(
102 myMonAlg,
103 "SCTHitEffMonitor",
104 "SCT/GENERAL/"
105 )
106 ]
107
108
110
111 # Conversion of ROOT.vector of ROOT.TString to list of str
112 subDetName = []
113 for i in range(len(sctMon.subDetName)):
114 subDetName.append(sctMon.subDetName[i].Data())
115
116 mapName = ["m_eff_", "eff_", "p_eff_"]
117 ineffmapName = ["ineffm_", "ineff_", "ineffp_"]
118
119 sumEff = ["summaryeffm", "summaryeff", "summaryeffp"]
120 sumEffTitle = ["Summary Module Efficiency in Endcap C",
121 "Summary Module Efficiency in Barrel",
122 "Summary Module Efficiency in Endcap A"]
123
124 limit = [sctMon.N_DISKS*2, sctMon.N_BARRELS*2, sctMon.N_DISKS*2]
125
126 # GENERAL
127 myMonGroup[sctMon.GENERAL_INDEX].defineHistogram(varname= "isub, eff;" + "SctTotalEff",
128 type= "TProfile",
129 title= "SCT Total Efficiency",
130 path="eff",
131 xbins=sctMon.N_REGIONS,
132 xmin=0.,
133 xmax=sctMon.N_REGIONS,
134 xlabels=subDetName,
135 opt='kAlwaysCreate')
136
137 myMonGroup[sctMon.GENERAL_INDEX].defineHistogram(varname= "isub, eff;" + "SctTotalEffBCID",
138 type= "TProfile",
139 title= "SCT Total Efficiency for First BCID",
140 path="eff",
141 xbins=sctMon.N_REGIONS,
142 xmin=0.,
143 xmax=sctMon.N_REGIONS,
144 xlabels=subDetName,
145 cutmask="isFirstBCID",
146 opt='kAlwaysCreate')
147
148 myMonGroup[sctMon.GENERAL_INDEX].defineHistogram(varname= "sideHash, eff;" + "effHashCode",
149 type= "TProfile",
150 title= "Efficiency vs module Hash code" + ";Module Hash Code;Efficiency",
151 path="eff",
152 xbins=sctMon.n_mod[sctMon.GENERAL_INDEX] * 2,
153 xmin=-0.5,
154 xmax=sctMon.n_mod[sctMon.GENERAL_INDEX] * 2 -0.5,
155 opt='kAlwaysCreate')
156
157 myMonGroup[sctMon.GENERAL_INDEX].defineHistogram(varname= "LumiBlock, eff;" + "effLumiBlock",
158 type= "TProfile",
159 title= "Efficiency vs Luminosity block"+";;Efficiency",
160 path="eff",
161 xbins=sctMon.NBINS_LBs,
162 xmin=0.5,
163 xmax=sctMon.NBINS_LBs + 0.5,
164 opt='kAlwaysCreate')
165
166
174
175 # SCTEC, SCTB, SCTEA
176 for isub in range(sctMon.N_REGIONS):
177 profileLabels = list(range(limit[isub]))
178 for k in range(limit[isub]):
179 profileLabels[k] = dedicatedTitle(k, isub)
180 # Efficiency
181 myMonGroup[isub].defineHistogram(varname= "layerPlusHalfSide, eff;" + sumEff[isub],
182 type= "TProfile",
183 title= sumEffTitle[isub]+ ";;Efficiency",
184 path="eff",
185 xbins=2*sctMon.n_layers[isub],
186 xmin=0.,
187 xmax=sctMon.n_layers[isub],
188 xlabels=profileLabels,
189 opt='kAlwaysCreate')
190 # Efficiency for first BCIDs
191 myMonGroup[isub].defineHistogram(varname= "layerPlusHalfSide, eff;" + sumEff[isub] + "BCID",
192 type= "TProfile",
193 title= sumEffTitle[isub]+" for First BC" + ";;Efficiency",
194 path="eff",
195 xbins=2*sctMon.n_layers[isub],
196 xmin=0.,
197 xmax=sctMon.n_layers[isub],
198 xlabels=profileLabels,
199 cutmask="isFirstBCID",
200 opt='kAlwaysCreate')
201 # Efficiency as a function of LB
202 myMonGroup[isub].defineHistogram(varname= "LumiBlock, eff;"+"effLumiBlock", #different names for fill
203 type= "TProfile",
204 title= "Efficiency vs Luminosity block in "+subDetName[isub]+";Luminosity block"+";Efficiency",
205 path="eff",
206 xbins=sctMon.NBINS_LBs,
207 xmin=0.5,
208 xmax=sctMon.NBINS_LBs + 0.5,
209 opt='kAlwaysCreate')
210
211 # Disks for SCTEC and SCTEA and layers for SCTB
212 for layer_disk in range(sctMon.n_layers[isub]):
213 for side in range(2):
214 etaPhiSuffix = "_" + str(layer_disk) + "_" + str(side)
215 effName = mapName[isub] + str(layer_disk) + "_" + str(side)
216 ineffName = ineffmapName[isub] + str(layer_disk) + "_" + str(side)
217 # Efficiency
218 myMonGroup[isub].defineHistogram(varname="ieta" + etaPhiSuffix + ",iphi" + etaPhiSuffix + ",eff;" + effName,
219 type= "TProfile2D",
220 title="Hit efficiency of" + sctMon.layerName[isub].Data() + str(layer_disk) + " / side " + str(side) + " in " + subDetName[isub] + ";Index in the direction of #eta;Index in the direction of #phi",
221 path="eff",
222 xbins=sctMon.n_etabins[isub], xmin=sctMon.f_etabin[isub] - .5, xmax=sctMon.l_etabin[isub] + .5,
223 ybins=sctMon.n_phibins[isub], ymin=sctMon.f_phibin[isub] - .5, ymax=sctMon.l_phibin[isub] + .5,
224 opt='kAlwaysCreate')
225 # Efficiency for first BCIDs
226 myMonGroup[isub].defineHistogram(varname="ieta" + etaPhiSuffix + ",iphi" + etaPhiSuffix + ",eff;" + effName + "_bcid",
227 type= "TProfile2D",
228 title="Hit efficiency of" + sctMon.layerName[isub].Data() + str(layer_disk) + " / side " + str(side) + " in " + subDetName[isub] + " for first BCID" + ";Index in the direction of #eta;Index in the direction of #phi",
229 path="eff",
230 xbins=sctMon.n_etabins[isub], xmin=sctMon.f_etabin[isub] - .5, xmax=sctMon.l_etabin[isub] + .5,
231 ybins=sctMon.n_phibins[isub], ymin=sctMon.f_phibin[isub] - .5, ymax=sctMon.l_phibin[isub] + .5,
232 cutmask="isFirstBCID",
233 opt='kAlwaysCreate')
234 # Inefficiency
235 myMonGroup[isub].defineHistogram(varname="ieta" + etaPhiSuffix + ",iphi" + etaPhiSuffix + ",ineff;" + ineffName,
236 type= "TProfile2D",
237 title="Hit inefficiency of" + sctMon.layerName[isub].Data() + str(layer_disk) + " / side " + str(side) + " in " + subDetName[isub] + ";Index in the direction of #eta;Index in the direction of #phi",
238 path="eff",
239 xbins=sctMon.n_etabins[isub], xmin=sctMon.f_etabin[isub] - .5, xmax=sctMon.l_etabin[isub] + .5,
240 ybins=sctMon.n_phibins[isub], ymin=sctMon.f_phibin[isub] - .5, ymax=sctMon.l_phibin[isub] + .5,
241 opt='kAlwaysCreate')
242
243 # Merge with result object and return
244 result.merge(helper.result())
245 return result
246
247if __name__ == "__main__":
248 # Setup logs
249 from AthenaCommon.Logging import log
250 from AthenaCommon.Constants import INFO
251 log.setLevel(INFO)
252
253 # Set the Athena configuration flags
254 from AthenaConfiguration.AllConfigFlags import initConfigFlags
255 flags = initConfigFlags()
256 flags.Input.Files = ["/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/RecExRecoTest/mc16_13TeV.361022.Pythia8EvtGen_A14NNPDF23LO_jetjet_JZ2W.recon.ESD.e3668_s3170_r10572_homeMade.pool.root"]
257 flags.Input.isMC = True
258 flags.Output.HISTFileName = 'SCTHitEffMonOutput.root'
259 flags.GeoModel.Align.Dynamic = False
260 flags.Detector.GeometryID = True
261 flags.Detector.GeometryPixel = True
262 flags.Detector.GeometrySCT = True
263 flags.Detector.GeometryTRT = True
264 flags.lock()
265
266 # Initialize configuration object, add accumulator, merge, and run.
267 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
268 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
269 cfg = MainServicesCfg(flags)
270 cfg.merge(PoolReadCfg(flags))
271
272 cfg.merge(SCTHitEffMonAlgConfig(flags))
273
274 cfg.run()
@ Data
Definition BaseObject.h:11
SCTHitEffMonAlgConfig(flags)
dedicatedTitle(i, isub)