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