ATLAS Offline Software
TileTMDBMonitorAlgorithm.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 from TileConfiguration.TileConfigFlags import TileRunType
6 
7 '''
8 @file TileTMDBMonitorAlgorithm.py
9 @brief Python configuration of TileTMDBMonitorAlgorithm algorithm for the Run III
10 '''
11 
12 def TileTMDBMonitoringConfig(flags, **kwargs):
13  ''' Function to configure TileTMDBMonitorAlgorithm algorithm in the monitoring system.'''
14  histogram_limits = {
15  TileRunType.PHY: {
16  "Energy": [-100, 10000],
17  "Error": [-1010, 1010]
18  },
19  TileRunType.LAS: {
20  "Energy": [-5, 30],
21  "Error": [-10, 10]
22  },
23  TileRunType.BILAS: {
24  "Energy": [-1010, 1010],
25  "Error": [-1010, 1010]
26  },
27  TileRunType.CIS: {
28  "Energy": [-1, 10],
29  "Error": [-10, 10]
30  },
31  TileRunType.MONOCIS: {
32  "Energy": [-1, 10],
33  "Error": [-10, 10]
34  },
35  TileRunType.PED: {
36  "Energy": [-700, 700],
37  "Error": [-500, 500]
38  }
39  }
40 
41 
42  # Define one top-level monitoring algorithm. The new configuration
43  # framework uses a component accumulator.
44  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
45  result = ComponentAccumulator()
46 
47  from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
48  result.merge( TileCablingSvcCfg(flags) )
49 
50  from TileConditions.TileTMDBConfig import TileTMDBCondAlgCfg
51  result.merge( TileTMDBCondAlgCfg(flags) )
52 
53  kwargs.setdefault('fillDetailedHistograms', False)
54 
55  runType = flags.Tile.RunType
56  if runType is TileRunType.PHY:
57  kwargs.setdefault('PulseEnergyRange', [1000., 5000.])
58 
59  # The following class will make a sequence, configure algorithms, and link
60  # them to GenericMonitoringTools
61  from AthenaMonitoring import AthMonitorCfgHelper
62  helper = AthMonitorCfgHelper(flags,'TileTMDBMonitoring')
63 
64  # Adding an TileTMDBMonitorAlgorithm algorithm to the helper
65  from AthenaConfiguration.ComponentFactory import CompFactory
66  tileTMDBMonAlg = helper.addAlgorithm(CompFactory.TileTMDBMonitorAlgorithm, 'TileTMDBMonAlg')
67 
68  for k, v in kwargs.items():
69  setattr(tileTMDBMonAlg, k, v)
70 
71  run = str(flags.Input.RunNumbers[0])
72 
73  # Configure histogram with TileTMDBMonAlg algorithm execution time
74  executeTimeGroup = helper.addGroup(tileTMDBMonAlg, 'TileTMDBMonExecuteTime', 'Tile/')
75  executeTimeGroup.defineHistogram('TIME_execute', path = 'TMDB', type='TH1F',
76  title = 'Time for execute TileTMDBMonAlg algorithm;time [#ms]',
77  xbins = 100, xmin = 0, xmax = 100000)
78 
79  from TileMonitoring.TileMonitoringCfgHelper import addTileTMDB_1DHistogramsArray
80 
81  addTileTMDB_1DHistogramsArray(helper, tileTMDBMonAlg, name = 'TMDB_MeanPulse',
82  xvalue = 'sampleNumber', value = 'sample', path = 'Tile/TMDB/MeanPulse',
83  title = 'Mean pulse shape in TMDB;#sample;[ADC]', type = 'TProfile',
84  run = run, xbins = 7, xmin = -0.5, xmax = 6.5, perModule = True)
85 
86  addTileTMDB_1DHistogramsArray(helper, tileTMDBMonAlg, name = 'TMDB_Energy',
87  xvalue = 'energy', path = 'Tile/TMDB/NoiseAnalysis',
88  title = 'Energy in TMDB;E_{TMDB} [MeV]', type = 'TH1D', run = run,
89  xbins = 101,
90  xmin = histogram_limits[runType]["Energy"][0],
91  xmax = histogram_limits[runType]["Energy"][1], perModule = True)
92 
93  addTileTMDB_1DHistogramsArray(helper, tileTMDBMonAlg, name = 'TMDB_Peak',
94  xvalue = 'peak', path = 'Tile/TMDB/PeakPosition',
95  title = 'Peak Position in TMDB;E_{TMDB}', type = 'TH1D', run = run,
96  xbins = 7, xmin = 0, xmax = 7, perModule = True)
97 
98  from TileMonitoring.TileMonitoringCfgHelper import addTileTMDB2DScatterHistogramsArray
99 
100  addTileTMDB2DScatterHistogramsArray(helper, tileTMDBMonAlg, name = 'TMDB_ChanNoise',
101  xvalue = 'channX', yvalue = 'channY', path = 'Tile/TMDB/ChannelNoise',
102  title = 'Channel CrossProduct TMDB;', type = 'TH2D', run = run,
103  xbins = 101, xmin = 0, xmax = 255)
104 
105  errorTitle = 'Energy difference between TMDB and correspoding Tile Cell (D) PMT;E_{D_PMT} - E_{TMDB} [MeV]'
106  addTileTMDB_1DHistogramsArray(helper, tileTMDBMonAlg, name = 'TMDB_CalibrationError',
107  xvalue = 'error', path = 'Tile/TMDB/CalibError',
108  title = errorTitle, type = 'TH1D', run = run,
109  xbins = 101,
110  xmin = histogram_limits[runType]["Error"][0],
111  xmax = histogram_limits[runType]["Error"][1],
112  perModule = True)
113 
114  from TileMonitoring.TileMonitoringCfgHelper import addTileTMDB_2DHistogramsArray
115 
116  addTileTMDB_2DHistogramsArray(helper, tileTMDBMonAlg, name = 'TMDB_Energy',
117  value = 'energy', title = 'Energy [MeV] in TMDB',
118  path = 'Tile/TMDB', type='TProfile2D', run = run)
119 
120  addTileTMDB_2DHistogramsArray(helper, tileTMDBMonAlg, name = 'TMDB_PeakPosition',
121  value = 'peakPosition', title = 'Position of peak sample in TMDB',
122  path = 'Tile/TMDB', type='TProfile2D', run = run)
123 
124  accumalator = helper.result()
125  result.merge(accumalator)
126  return result
127 
128 if __name__=='__main__':
129 
130  # Setup logs
131  from AthenaCommon.Logging import log
132  from AthenaCommon.Constants import INFO
133  log.setLevel(INFO)
134 
135  # Set the Athena configuration flags
136  from AthenaConfiguration.AllConfigFlags import initConfigFlags
137  from AthenaConfiguration.TestDefaults import defaultGeometryTags, defaultTestFiles
138  flags = initConfigFlags()
139  flags.Input.Files = defaultTestFiles.RAW_RUN2
140  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
141  flags.Output.HISTFileName = 'TileTMDBMonitorOutput.root'
142  flags.DQ.useTrigger = False
143  flags.DQ.enableLumiAccess = False
144  flags.Exec.MaxEvents = 3
145  flags.fillFromArgs()
146  flags.lock()
147 
148 
149  # Initialize configuration object, add accumulator, merge, and run.
150  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
151  cfg = MainServicesCfg(flags)
152 
153  from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
154  cfg.merge( TileRawDataReadingCfg(flags, readDigits=False, readMuRcv=False,
155  readMuRcvDigits=True, readMuRcvRawCh=True) )
156 
157  cfg.merge( TileTMDBMonitoringConfig(flags) )
158 
159  cfg.printConfig(withDetails = True, summariseProps = True)
160  flags.dump()
161 
162  cfg.store( open('TileTMDBMonitorAlgorithm.pkl','wb') )
163 
164  sc = cfg.run()
165 
166  import sys
167  # Success should be 0
168  sys.exit(not sc.isSuccess())
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
TileTMDBMonitorAlgorithm.TileTMDBMonitoringConfig
def TileTMDBMonitoringConfig(flags, **kwargs)
Definition: TileTMDBMonitorAlgorithm.py:12
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
TileMonitoringCfgHelper.addTileTMDB_1DHistogramsArray
def addTileTMDB_1DHistogramsArray(helper, algorithm, name='', xvalue='', value='', title='', path='', xbins=0, xmin=0., xmax=0., type='TH1D', run='', perModule=False, isCorr=False)
Definition: TileMonitoringCfgHelper.py:673
TileMonitoringCfgHelper.addTileTMDB2DScatterHistogramsArray
def addTileTMDB2DScatterHistogramsArray(helper, algorithm, name='', xvalue='', yvalue='', xbins=0, xmin=0, xmax=0, title='', path='', type='TH2D', run='')
Definition: TileMonitoringCfgHelper.py:620
Trk::open
@ open
Definition: BinningType.h:40
python.TileTMDBConfig.TileTMDBCondAlgCfg
def TileTMDBCondAlgCfg(flags, **kwargs)
Definition: TileTMDBConfig.py:9
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
TileByteStreamConfig.TileRawDataReadingCfg
def TileRawDataReadingCfg(flags, readDigits=True, readRawChannel=True, readMuRcv=None, readMuRcvDigits=False, readMuRcvRawCh=False, readBeamElem=None, readLaserObj=None, readDigitsFlx=False, readL2=False, stateless=False, **kwargs)
Definition: TileByteStreamConfig.py:87
str
Definition: BTagTrackIpAccessor.cxx:11
TileMonitoringCfgHelper.addTileTMDB_2DHistogramsArray
def addTileTMDB_2DHistogramsArray(helper, algorithm, name='', value='', title='', path='', type='TH2D', run='')
Definition: TileMonitoringCfgHelper.py:652
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11