ATLAS Offline Software
Loading...
Searching...
No Matches
SCTTracksMonAlg.py
Go to the documentation of this file.
2# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3#
4'''@file SCTTracksMonAlg.py
5@author Ken Kreul
6@date 2019-07-15
7@brief Based on AthenaMonitoring/ExampleMonitorAlgorithm.py
8'''
9
11 '''Function to configures some algorithms in the monitoring system.'''
12
15 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
16 result = ComponentAccumulator()
17
18 # The following class will make a sequence, configure algorithms, and link
19 # them to GenericMonitoringTools
20 from AthenaMonitoring import AthMonitorCfgHelper
21 helper = AthMonitorCfgHelper(flags, 'SCTTracksMonCfg')
22
23
24
30 from AthenaConfiguration.ComponentFactory import CompFactory
31 from TrkConfig.TrkResidualPullCalculatorConfig import (
32 ResidualPullCalculatorCfg)
33 myMonAlg = helper.addAlgorithm(CompFactory.SCTTracksMonAlg, 'SCTTracksMonAlg',
34 ResPullCalc = result.popToolsAndMerge(
35 ResidualPullCalculatorCfg(flags)))
36
37 from AthenaConfiguration.Enums import BeamType
38 if flags.Beam.Type is BeamType.Collisions:
39 from AthenaMonitoring.FilledBunchFilterToolConfig import FilledBunchFilterToolCfg
40 myMonAlg.FilterTools += [result.popToolsAndMerge(FilledBunchFilterToolCfg(flags))]
41
42 doTrigger = False
43 if not flags.Input.isMC:
44 if flags.Trigger.doHLT:
45 doTrigger = True
46 myMonAlg.doTrigger = doTrigger
47
48 # # If for some really obscure reason you need to instantiate an algorithm
49 # # yourself, the AddAlgorithm method will still configure the base
50 # # properties and add the algorithm to the monitoring sequence.
51 # helper.AddAlgorithm(myExistingAlg)
52
53
54
56 myMonAlg.TriggerChain = ''
57 # myMonAlg.RandomHist = True
58
59 from TrkConfig.TrkTrackSummaryToolConfig import InDetTrackSummaryToolCfg
60 myMonAlg.TrackSummaryTool = result.popToolsAndMerge(InDetTrackSummaryToolCfg(flags))
61
62
65
66 # # Then, add a tool that doesn't have its own configuration function. In
67 # # this example, no accumulator is returned, so no merge is necessary.
68 # from MyDomainPackage.MyDomainPackageConf import MyDomainTool
69 # myMonAlg.MyDomainTool = MyDomainTool()
70
71 # Add a generic monitoring tool (a "group" in old language). The returned
72 # object here is the standard GenericMonitoringTool.
73 myMonGroup = helper.addGroup(
74 myMonAlg,
75 "SCTTracksMonitor",
76 "SCT/GENERAL/"
77 )
78
79
81 regionNames = ["EndCapC", "Barrel", "EndCapA"]
82 N_REGIONS = len(regionNames)
83 s_triggerNames = ["RNDM", "BPTX", "L1CAL", "TGC", "RPC", "MBTS", "COSM", "Calib"]
84 N_TRIGGER_TYPES = len(s_triggerNames)
85 N_HIT_BINS = 50
86 FIRST_HIT_BIN = 0
87 LAST_HIT_BIN = N_HIT_BINS-FIRST_HIT_BIN-1 # This is already defined in SCT_MonitoringNumbers.h
88 myMonGroup.defineHistogram(varname="trk_N", # ; means alias
89 type="TH1F",
90 title="Number of tracks"+";Number of Tracks",
91 path="tracks", # path cannot be "".
92 xbins=400, xmin=0., xmax=4000.,
93 opt='kAlwaysCreate')
94 myMonGroup.defineHistogram(varname="trk_chi2", # ; means alias
95 type="TH1F",
96 title="Track #chi^{2} div ndf"+";Number of track #chi^{2}/NDF",
97 path="tracks", # path cannot be "".
98 xbins=150, xmin=0., xmax=150.,
99 opt='kAlwaysCreate')
100 myMonGroup.defineHistogram(varname="trk_d0", # ; means alias
101 type="TH1F",
102 title="Track d0"+";d0 [mm]",
103 path="tracks", # path cannot be "".
104 xbins=160, xmin=-40., xmax=40.,
105 opt='kAlwaysCreate')
106 myMonGroup.defineHistogram(varname="trk_z0", # ; means alias
107 type="TH1F",
108 title="Track z0"+";z0 [mm]",
109 path="tracks", # path cannot be "".
110 xbins=200, xmin=-200., xmax=200.,
111 opt='kAlwaysCreate')
112 myMonGroup.defineHistogram(varname="trk_phi", # ; means alias
113 type="TH1F",
114 title="Track Phi"+";#phi [rad]",
115 path="tracks", # path cannot be "".
116 xbins=160, xmin=-4., xmax=4.,
117 opt='kAlwaysCreate')
118 myMonGroup.defineHistogram(varname="trk_pt", # ; means alias
119 type="TH1F",
120 title="Track P_{T}"+";P_{T} [GeV]",
121 path="tracks", # path cannot be "".
122 xbins=150, xmin=0., xmax=150.,
123 opt='kAlwaysCreate')
124 myMonGroup.defineHistogram(varname="trk_sct_hits", # ; means alias
125 type="TH1F",
126 title="SCT HITS per single Track"+";Num of Hits",
127 path="tracks", # path cannot be "".
128 xbins=N_HIT_BINS, xmin=FIRST_HIT_BIN, xmax=LAST_HIT_BIN,
129 opt='kAlwaysCreate')
130 myMonGroup.defineHistogram(varname="trk_eta", # ; means alias
131 type="TH1F",
132 title="Track Eta"+";#eta",
133 path="tracks", # path cannot be "".
134 xbins=160, xmin=-4., xmax=4.,
135 opt='kAlwaysCreate')
136
137 myMonGroup.defineHistogram(varname="trackTriggers", # ; means alias
138 type="TH1I",
139 title="Tracks for different trigger types",
140 path="tracks", # path cannot be "".
141 xbins=N_TRIGGER_TYPES, xmin=-0.5, xmax=7.5, xlabels=s_triggerNames,
142 opt='kAlwaysCreate')
143 myMonGroup.defineHistogram(varname="region"+","+"hitsRegion"+";"+"SCTTrackRate", # ; means alias
144 type="TProfile",
145 title="Track per event for SCT regions",
146 path="tracks", # path cannot be "".
147 xbins=3, xmin=0.0, xmax=3.0, xlabels=regionNames,
148 opt='kAlwaysCreate')
149 myMonGroup.defineHistogram(varname="tracksPerRegion", # ; means alias
150 type="TH1F",
151 title="Number of tracks in eta regions",
152 path="tracks", # path cannot be "".
153 xbins=N_REGIONS, xmin=0, xmax=N_REGIONS, xlabels=regionNames,
154 opt='kAlwaysCreate')
155
156
157 for region in regionNames:
158 myMonGroup.defineHistogram(varname="total"+region+"Residual",
159 title="Overall Residual Distribution for the "+region+";Residual [mm]",
160 type="TH1F", path="tracks",
161 xbins=100, xmin=-0.5, xmax=0.5)
162 myMonGroup.defineHistogram(varname="total"+region+"Pull",
163 title="Overall Pull Distribution for the "+region+";Pull",
164 type="TH1F", path="tracks",
165 xbins=100, xmin=-5, xmax=5)
166
172
173 # # Otherwise, merge with result object and return
174 result.merge(helper.result())
175 return result
176
177if __name__ == "__main__":
178 # Setup logs
179 from AthenaCommon.Logging import log
180 from AthenaCommon.Constants import INFO
181 log.setLevel(INFO)
182
183 # Set the Athena configuration flags
184 from AthenaConfiguration.AllConfigFlags import initConfigFlags
185 flags = initConfigFlags()
186 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"]
187 flags.Input.isMC = True
188 flags.Output.HISTFileName = 'SCTTracksMonOutput.root'
189 flags.GeoModel.Align.Dynamic = False
190 flags.Detector.GeometryID = True
191 flags.Detector.GeometryPixel = True
192 flags.Detector.GeometrySCT = True
193 flags.Detector.GeometryTRT = True
194 flags.lock()
195
196 # Initialize configuration object, add accumulator, merge, and run.
197 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
198 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
199 cfg = MainServicesCfg(flags)
200 cfg.merge(PoolReadCfg(flags))
201
202 cfg.merge(SCTTracksMonAlgConfig(flags))
203
204 cfg.run()
SCTTracksMonAlgConfig(flags)