48def TileTMDBRawChannelMonitoringConfig(flags, MuRcvRawChCnt = "MuRcvRawChCnt", FillRawChannelHistograms = True, FillEfficiencyHistograms = False, **kwargs):
49
50 '''Function to configure Tile TMDB raw channel monitoring algorithm.'''
51 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
52 result = ComponentAccumulator()
53
54 from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
55 result.merge( TileCablingSvcCfg(flags) )
56
57 from AthenaConfiguration.Enums import Format
58 if flags.Input.Format == Format.BS:
59 from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
60 result.merge(TileRawDataReadingCfg(flags, readDigits=False, readRawChannel=False,
61 readMuRcv=True, readMuRcvDigits=True, readMuRcvRawCh=True))
62
63 isDSP = (MuRcvRawChCnt == "MuRcvRawChCnt")
64 if not isDSP:
65 result.merge(TileMuRcvRawChannelMakerCfg(flags, MuRcvRawChCnt = MuRcvRawChCnt))
66
67 name = kwargs.get('name', 'TileTMDBRawChanDspMonAlg' if isDSP else 'TileTMDBRawChanMonAlg')
68
69 from AthenaMonitoring import AthMonitorCfgHelper
70 helper = AthMonitorCfgHelper(flags, 'TileTMDBRawChannelDspMonitoring' if isDSP else 'TileTMDBRawChannelMonitoring')
71
72 from AthenaConfiguration.ComponentFactory import CompFactory
73 tileTMDBRawChanMonAlg = helper.addAlgorithm(CompFactory.TileTMDBRawChannelMonitorAlgorithm, name)
74 tileTMDBRawChanMonAlg.TriggerChain = ''
75 tileTMDBRawChanMonAlg.MuRcvRawChCnt = MuRcvRawChCnt
76 tileTMDBRawChanMonAlg.DSP = isDSP
77 tileTMDBRawChanMonAlg.FillEfficiencyHistograms = FillEfficiencyHistograms
78 tileTMDBRawChanMonAlg.FillRawChannelHistograms = FillRawChannelHistograms
79
80 topPath = 'Tile/TMDBRawChannel/DSP' if isDSP else 'Tile/TMDBRawChannel'
81 run = str(flags.Input.RunNumbers[0])
82
83 if FillRawChannelHistograms:
84
85 if isDSP:
86 minAmplitude = 0
87 maxAmplitude = 80000
88 else:
89 minAmplitude = -20.5
90 maxAmplitude = 255.5
91
92 from TileMonitoring.TileMonitoringCfgHelper import addTileTMDB_1DHistogramsArray, addTileTMDB_2DHistogramsArray
93
94 addTileTMDB_2DHistogramsArray(helper, tileTMDBRawChanMonAlg, name = 'TMDB_RawAmplitude',
95 value = 'amplitude', title = 'Amplitude Map',
96 path = topPath, type='TProfile2D', run = run)
97
98 addTileTMDB_2DHistogramsArray(helper, tileTMDBRawChanMonAlg, name = 'TMDB_RawTime',
99 value = 'time', title = 'Time Map',
100 path = topPath, type='TProfile2D', run = run)
101
102 addTileTMDB_1DHistogramsArray(helper, tileTMDBRawChanMonAlg, name = 'TMDB_RawCellTime',
103 xvalue = 'time', title = 'Time;[ns]',
104 path = topPath, type='TH1D', run = run,
105 xbins = 120, xmin = -60, xmax = 60)
106
107 addTileTMDB_1DHistogramsArray(helper, tileTMDBRawChanMonAlg, name = 'TMDB_RawCellAmplitude',
108 xvalue = 'amplitude', title = 'Amplitude;[ADC]',
109 path = topPath, type='TH1D', run = run,
110 xbins = 276, xmin = minAmplitude, xmax = maxAmplitude)
111
112
113 if FillEfficiencyHistograms:
114
115 from TileConditions.TileTMDBConfig import TileTMDBCondAlgCfg
116 result.merge( TileTMDBCondAlgCfg(flags) )
117
118 from TileCalibBlobObjs.Classes import TileCalibUtils as Tile
119 from TileMonitoring.TileMonitoringCfgHelper import getLabels, getPartitionName
120
121 arrayTGC = helper.addArray([2], tileTMDBRawChanMonAlg, 'TGC_TrSec_number_Good_Muons')
122 for postfix, tool in arrayTGC.Tools.items():
123 ros = int(postfix.split('_').pop()) + 3
124 partition = getPartitionName(ros)
125
126 fullName = 'sector;TGC_TrSec_number_Good_Muons_{}'.format(partition)
127 fullTitle = 'Number of Good Muons in TGC trigger sectors {}'.format(partition)
128
129 tool.defineHistogram(fullName, path = topPath, type = 'TH1D', title = fullTitle,
130 xbins = 48, xmin = -0.5, xmax = 47.5)
131
132
133 cells = ['D6', 'D5+D6']
134 thresholds = ['500MeV','600MeV']
135 tileTMDBRawChanMonAlg.NumberOfThresholds = len(thresholds)
136 arrayThreshD = helper.addArray([2, len(thresholds), len(cells)], tileTMDBRawChanMonAlg, 'TMDB_coincidence_threshold')
137 for postfix, tool in arrayThreshD.Tools.items():
138 elements = postfix.split('_')
139 cell = int(elements.pop())
140 threshold = int(elements.pop())
141 ros = int(elements.pop()) + 3
142 partition = getPartitionName(ros)
143
144 labels = getLabels(('modules'), partition)
145
146 fullName = 'module;TMDB_{}_{}_coincidence_{}'.format(partition, cells[cell], thresholds[threshold])
147 fullTitle = 'Number coincidence from all Good Muons in TMDB {} {} over {} threshold'.format(partition, cells[cell], thresholds[threshold])
148
149 tool.defineHistogram(fullName, path = topPath, type = 'TH1D', title = fullTitle, xlabels = labels,
150 xbins = Tile.MAX_DRAWER, xmin = -0.5, xmax = Tile.MAX_DRAWER - 0.5)
151
152
153 accumalator = helper.result()
154 result.merge(accumalator)
155 return result
156
157
158