ATLAS Offline Software
Loading...
Searching...
No Matches
SCTLorentzMonAlg.py
Go to the documentation of this file.
2# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3#
4
5'''@file SCTLorentzMonAlg.py
6@author Susumu Oda
7@date 2019-04-02
8@brief Based on AthenaMonitoring/ExampleMonitorAlgorithm.py
9'''
10
12
13
16 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
17 result = ComponentAccumulator()
18
19 # The following class will make a sequence, configure algorithms, and link
20 # them to GenericMonitoringTools
21 from AthenaMonitoring import AthMonitorCfgHelper
22 helper = AthMonitorCfgHelper(flags, 'SCTLorentzMonCfg')
23
24
25
31 from AthenaConfiguration.ComponentFactory import CompFactory
32 from InDetConfig.InDetAssociationToolsConfig import InDetPRDtoTrackMapToolGangedPixelsCfg
33 from InDetConfig.InDetTrackHoleSearchConfig import InDetTrackHoleSearchToolCfg
34 from TrkConfig.TrkTrackSummaryToolConfig import InDetTrackSummaryToolCfg
35
36 myMonAlg = helper.addAlgorithm(
37 CompFactory.SCTLorentzMonAlg,
38 'SCTLorentzMonAlg',
39 HoleSearch = result.popToolsAndMerge(
40 InDetTrackHoleSearchToolCfg(flags)),
41 AssociationTool = result.popToolsAndMerge(
42 InDetPRDtoTrackMapToolGangedPixelsCfg(flags)),
43 TrackSummaryTool = result.popToolsAndMerge(
44 InDetTrackSummaryToolCfg(flags)))
45
46 # # If for some really obscure reason you need to instantiate an algorithm
47 # # yourself, the AddAlgorithm method will still configure the base
48 # # properties and add the algorithm to the monitoring sequence.
49 # helper.AddAlgorithm(myExistingAlg)
50
51
52
54 myMonAlg.TriggerChain = ''
55 # myMonAlg.RandomHist = True
56
57
60
61
62 # set up conditions
63 from SCT_ConditionsAlgorithms.SCT_ConditionsAlgorithmsConfig import SCT_DetectorElementCondAlgCfg
64 from BeamSpotConditions.BeamSpotConditionsConfig import BeamSpotCondAlgCfg
65
66 result.merge(SCT_DetectorElementCondAlgCfg(flags))
67 result.merge(BeamSpotCondAlgCfg(flags))
68
69 # # Then, add a tool that doesn't have its own configuration function. In
70 # # this example, no accumulator is returned, so no merge is necessary.
71 # from MyDomainPackage.MyDomainPackageConf import MyDomainTool
72 # myMonAlg.MyDomainTool = MyDomainTool()
73
74 # Add a generic monitoring tool (a "group" in old language). The returned
75 # object here is the standard GenericMonitoringTool.
76 myMonGroup = helper.addGroup(
77 myMonAlg,
78 "SCTLorentzMonitor",
79 "SCT/GENERAL/"
80 )
81
82
84 N_BARRELS = 4
85 nSides = 2 # 0: Side 0, 1: Side 1
86 nSurfaces = 2 # 0: 100, 1: 111
87 surfaceNames = ["_100", "_111"]
88 surfaceNames2 = ["_100_", "_111_"]
89 surfaceTitles = ["100 - ", "111 - "]
90 sideNames = ["_0", "_1"]
91 for l in range(N_BARRELS):
92 for iSurface in range(nSurfaces):
93 for side in range(nSides):
94 xVar = "phiToWafer_"+str(l)+surfaceNames[iSurface]+sideNames[side]
95 yVar = "nStrip_"+str(l)+surfaceNames[iSurface]+sideNames[side]
96 histTitle = surfaceTitles[iSurface]+"Inc. Angle vs nStrips for Layer Side"+str(l)+str(side)
97 histName = "h_phiVsNstrips"+surfaceNames2[iSurface]+str(l)+"Side"+str(side)
98 myMonGroup.defineHistogram(varname=xVar+","+yVar+";"+histName, # ; means alias
99 type="TProfile",
100 title=histTitle+";#phi to Wafer;Num of Strips",
101 path="lorentz", # path cannot be "".
102 xbins=360, xmin=-90., xmax=90.)
103
104 myMonGroup.defineHistogram(varname=xVar+","+yVar+";"+histName + "_e0p5", # ; means alias
105 type="TProfile",
106 title=histTitle+"(|#eta| < 0.5);#phi to Wafer;Num of Strips",
107 path="lorentz", # path cannot be "".
108 xbins=360, xmin=-90., xmax=90.,
109 cutmask="isCentral")
110 nEndcaps = 2
111 nDisks = 9
112 nSides = 2 # 0: Side 0, 1: Side 1
113 nEta = 3 # outer, middle, inner
114 endcapNames = ["ECA", "ECC"]
115 etaNames = ["outer", "middle", "inner"]
116 sideNames = ["_0", "_1"]
117 for e in range(nEndcaps):
118 for d in range(nDisks):
119 for iEta in range(nEta):
120 sensorType = "HPK"
121 if ((d == 1 and iEta == 1) or
122 (d == 3 and iEta == 1) or
123 (d == 4 and iEta >= 1) or
124 (d == 5 and iEta == 2) or
125 (d == 7 and iEta == 1)):
126 sensorType = "CiS"
127 elif (d == 2 and iEta == 1):
128 sensorType = "Both"
129
130 for side in range(nSides):
131 xVar = "phiToWafer_"+endcapNames[e]+str(d)+"_"+etaNames[iEta]+sideNames[side]
132 yVar = "nStrip_"+endcapNames[e]+str(d)+"_"+etaNames[iEta]+sideNames[side]
133 histTitle = "111 (" + sensorType + ") - Inc. Angle vs nStrips for " + endcapNames[e] + " Disk Eta Side"+str(d)+str(iEta)+str(side)
134 histName = "h_phiVsNstrips_"+endcapNames[e]+str(d)+"_"+etaNames[iEta]+"_Side"+str(side)
135 myMonGroup.defineHistogram(varname=xVar+","+yVar+";"+histName, # ; means alias
136 type="TProfile",
137 title=histTitle+";#phi to Wafer;Num of Strips",
138 path="lorentz", # path cannot be "".
139 xbins=360, xmin=-90., xmax=90.)
140
141
147
148 # # Otherwise, merge with result object and return
149 result.merge(helper.result())
150 return result
151
152if __name__ == "__main__":
153 # Setup logs
154 from AthenaCommon.Logging import log
155 from AthenaCommon.Constants import INFO
156 log.setLevel(INFO)
157
158 # Set the Athena configuration flags
159 from AthenaConfiguration.AllConfigFlags import initConfigFlags
160 flags = initConfigFlags()
161 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"]
162 flags.Input.isMC = True
163 flags.Output.HISTFileName = 'SCTLorentzMonOutput.root'
164 flags.GeoModel.Align.Dynamic = False
165 flags.Detector.GeometryPixel = True
166 flags.Detector.GeometrySCT = True
167 flags.Detector.GeometryTRT = True
168 flags.Detector.GeometryCalo = False
169 flags.Detector.GeometryMuon = True
170 flags.lock()
171
172 # Initialize configuration object, add accumulator, merge, and run.
173 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
174 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
175 cfg = MainServicesCfg(flags)
176 cfg.merge(PoolReadCfg(flags))
177
178 cfg.merge(SCTLorentzMonAlgConfig(flags))
179
180 cfg.run()