ATLAS Offline Software
SCTTracksMonAlg.py
Go to the documentation of this file.
1 #
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(
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  myMonGroup.defineHistogram(varname="trk_chi2", # ; means alias
94  type="TH1F",
95  title="Track #chi^{2} div ndf"+";Number of track #chi^{2}/NDF",
96  path="tracks", # path cannot be "".
97  xbins=150, xmin=0., xmax=150.)
98  myMonGroup.defineHistogram(varname="trk_d0", # ; means alias
99  type="TH1F",
100  title="Track d0"+";d0 [mm]",
101  path="tracks", # path cannot be "".
102  xbins=160, xmin=-40., xmax=40.)
103  myMonGroup.defineHistogram(varname="trk_z0", # ; means alias
104  type="TH1F",
105  title="Track z0"+";z0 [mm]",
106  path="tracks", # path cannot be "".
107  xbins=200, xmin=-200., xmax=200.)
108  myMonGroup.defineHistogram(varname="trk_phi", # ; means alias
109  type="TH1F",
110  title="Track Phi"+";#phi [rad]",
111  path="tracks", # path cannot be "".
112  xbins=160, xmin=-4., xmax=4.)
113  myMonGroup.defineHistogram(varname="trk_pt", # ; means alias
114  type="TH1F",
115  title="Track P_{T}"+";P_{T} [GeV]",
116  path="tracks", # path cannot be "".
117  xbins=150, xmin=0., xmax=150.)
118  myMonGroup.defineHistogram(varname="trk_sct_hits", # ; means alias
119  type="TH1F",
120  title="SCT HITS per single Track"+";Num of Hits",
121  path="tracks", # path cannot be "".
122  xbins=N_HIT_BINS, xmin=FIRST_HIT_BIN, xmax=LAST_HIT_BIN)
123  myMonGroup.defineHistogram(varname="trk_eta", # ; means alias
124  type="TH1F",
125  title="Track Eta"+";#eta",
126  path="tracks", # path cannot be "".
127  xbins=160, xmin=-4., xmax=4.)
128 
129  myMonGroup.defineHistogram(varname="trackTriggers", # ; means alias
130  type="TH1I",
131  title="Tracks for different trigger types",
132  path="tracks", # path cannot be "".
133  xbins=N_TRIGGER_TYPES, xmin=-0.5, xmax=7.5, xlabels=s_triggerNames)
134  myMonGroup.defineHistogram(varname="region"+","+"hitsRegion"+";"+"SCTTrackRate", # ; means alias
135  type="TProfile",
136  title="Track per event for SCT regions",
137  path="tracks", # path cannot be "".
138  xbins=3, xmin=0.0, xmax=3.0, xlabels=regionNames)
139  myMonGroup.defineHistogram(varname="tracksPerRegion", # ; means alias
140  type="TH1F",
141  title="Number of tracks in eta regions",
142  path="tracks", # path cannot be "".
143  xbins=N_REGIONS, xmin=0, xmax=N_REGIONS, xlabels=regionNames)
144 
145 
146  for region in regionNames:
147  myMonGroup.defineHistogram(varname="total"+region+"Residual",
148  title="Overall Residual Distribution for the "+region+";Residual [mm]",
149  type="TH1F", path="tracks",
150  xbins=100, xmin=-0.5, xmax=0.5)
151  myMonGroup.defineHistogram(varname="total"+region+"Pull",
152  title="Overall Pull Distribution for the "+region+";Pull",
153  type="TH1F", path="tracks",
154  xbins=100, xmin=-5, xmax=5)
155 
161 
162  # # Otherwise, merge with result object and return
163  result.merge(helper.result())
164  return result
165 
166 if __name__ == "__main__":
167  # Setup logs
168  from AthenaCommon.Logging import log
169  from AthenaCommon.Constants import INFO
170  log.setLevel(INFO)
171 
172  # Set the Athena configuration flags
173  from AthenaConfiguration.AllConfigFlags import initConfigFlags
174  flags = initConfigFlags()
175  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"]
176  flags.Input.isMC = True
177  flags.Output.HISTFileName = 'SCTTracksMonOutput.root'
178  flags.GeoModel.Align.Dynamic = False
179  flags.Detector.GeometryID = True
180  flags.Detector.GeometryPixel = True
181  flags.Detector.GeometrySCT = True
182  flags.Detector.GeometryTRT = True
183  flags.lock()
184 
185  # Initialize configuration object, add accumulator, merge, and run.
186  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
187  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
188  cfg = MainServicesCfg(flags)
189  cfg.merge(PoolReadCfg(flags))
190 
191  cfg.merge(SCTTracksMonAlgConfig(flags))
192 
193  cfg.run()
python.FilledBunchFilterToolConfig.FilledBunchFilterToolCfg
def FilledBunchFilterToolCfg(AthConfigFlags flags)
Definition: FilledBunchFilterToolConfig.py:9
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
SCTTracksMonAlg.SCTTracksMonAlgConfig
def SCTTracksMonAlgConfig(flags)
Definition: SCTTracksMonAlg.py:10
python.TrkTrackSummaryToolConfig.InDetTrackSummaryToolCfg
def InDetTrackSummaryToolCfg(flags, name='InDetTrackSummaryTool', **kwargs)
Definition: TrkTrackSummaryToolConfig.py:22
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.TrkResidualPullCalculatorConfig.ResidualPullCalculatorCfg
def ResidualPullCalculatorCfg(flags, name='ResidualPullCalculator', **kwargs)
Definition: TrkResidualPullCalculatorConfig.py:6
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69