12 def TileTBCellMonitoringConfig(flags, timeRange=[-100, 100], fragIDs=[0x100, 0x101, 0x200, 0x201, 0x402], useDemoCabling=2018, useFELIX=False, **kwargs):
14 ''' Function to configure TileTBCellMonitorAlgorithm algorithm in the monitoring system.'''
16 suffix =
"Flx" if useFELIX
else ""
17 basePath =
'TestBeam/' + (
'Felix' if useFELIX
else 'Legacy') +
'/Cell'
19 cellContainer = kwargs.pop(
'CaloCellContainer', f
'AllCalo{suffix}')
20 kwargs.setdefault(
'ScaleFactor', 0.25
if useFELIX
else 1.0)
21 kwargs.setdefault(
'EnergyThresholdForTime', 1 * GeV)
23 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
26 from TileGeoModel.TileGMConfig
import TileGMCfg
29 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
32 from TileConditions.TileCablingSvcConfig
import TileCablingSvcCfg
35 from TileConditions.TileInfoLoaderConfig
import TileInfoLoaderCfg
38 from AthenaMonitoring
import AthMonitorCfgHelper
39 helper = AthMonitorCfgHelper(flags, f
'TileTBCell{suffix}Monitoring')
41 demoCabling = kwargs.pop(
'useDemoCabling', 2018)
42 from TileCalibBlobObjs.Classes
import TileCalibUtils
as Tile
46 for fragID
in fragIDs:
48 drawer = fragID & 0x3F
49 modules += [Tile.getDrawerString(ros, drawer)]
51 for ros
in range(1, Tile.MAX_ROS):
52 for drawer
in range(0, Tile.MAX_DRAWER):
53 fragIDs += [(ros << 8) | drawer]
54 modules += [Tile.getDrawerString(ros, drawer)]
56 cellMonAlgorithms = []
57 gains = [
'HG',
'LG']
if flags.Tile.RunType.isBiGain()
else [
""]
58 from AthenaConfiguration.ComponentFactory
import CompFactory
60 cellMonAlg = helper.addAlgorithm(CompFactory.TileTBCellMonitorAlgorithm, f
'TileTBCell{suffix}{gain}MonAlg')
61 cellMonAlg.CaloCellContainer = f
'{cellContainer}{gain}'
62 cellMonAlg.TriggerChain =
''
63 cellMonAlg.TileFragIDs = fragIDs
65 for k, v
in kwargs.items():
66 setattr(cellMonAlg, k, v)
68 cellMonAlgorithms += [cellMonAlg]
70 towersLB = [[tower
for tower
in range(0, 10)],
71 [tower
for tower
in range(0, 9)],
72 [tower*2
for tower
in range(0, 4)]]
74 towersEB = [[tower
for tower
in range(11, 16)],
75 [tower
for tower
in range(9, 15)],
76 [tower*2
for tower
in range(4, 7)]]
78 def getCellNameFromSampleAndTower(sample, tower):
79 ''' The function to get Tile cell name from sample and tower'''
80 sampleName = {0:
'A', 1:
'B', 2:
'D'}[sample]
86 cellName = f
'{sampleName}{tower + 1}' if sample < 2
else f
'{sampleName}{int(tower / 2)}'
89 def addCellHistogramsArray(helper, modules, algorithm, name, title, path='', type='TH1D',
90 xbins=100, xmin=-100, xmax=100, ybins=None, ymin=None, ymax=None,
91 run='', xvalue='', yvalue=None, aliasPrefix='', xtitle='', ytitle=''):
92 ''' This function configures 1D or 2D histograms with monitored value per Tile module and cell '''
94 cellArray = helper.addArray([modules], algorithm, name, topPath=path)
95 for postfix, tool
in cellArray.Tools.items():
96 moduleName = postfix[1:]
97 partition = moduleName[:3]
98 towers = towersLB
if moduleName.startswith(
'L')
else towersEB
99 for sample
in range(0, 3):
100 for tower
in towers[sample]:
101 cellName = getCellNameFromSampleAndTower(sample, tower)
102 fullPath = f
'{partition}/{moduleName}'
103 name = f
'{xvalue}_{sample}_{tower}'
105 name += f
',{yvalue}_{sample}_{tower}'
106 name += f
';{aliasPrefix}{cellName}_{moduleName}'
107 fullTitle = f
'Run {run} {moduleName} {cellName}: {title};{xtitle};{ytitle}'
108 tool.defineHistogram(name, title=fullTitle, path=fullPath, type=type,
109 xbins=xbins, xmin=xmin, xmax=xmax,
110 ybins=ybins, ymin=ymin, ymax=ymax)
113 from TileMonitoring.TileMonitoringCfgHelper
import getCellName
114 from TileMonitoring.TileMonitoringCfgHelper
import getLegacyChannelForDemonstrator
116 def addChannelHistogramsArray(helper, modules, algorithm, name, title, path='', type='TH1D',
117 xbins=100, xmin=-100, xmax=100, xvalue='', xtitle='', ytitle='',
118 run='', aliasPrefix='', useDemoCabling=demoCabling):
119 ''' This function configures 1D histograms with Tile monitored value per module and channel '''
121 channelArray = helper.addArray([modules], algorithm, name, topPath=path)
122 for postfix, tool
in channelArray.Tools.items():
123 moduleName = postfix[1:]
124 partition = moduleName[:3]
125 module =
int(moduleName[3:]) - 1
126 for channel
in range(0, Tile.MAX_CHAN):
130 cellName = cell.replace(
'B',
'BC')
if (partition
in [
'LBA',
'LBC']
and cell
and cell[0] ==
'B' and cell !=
'B9')
else cell
131 fullPath = f
'{partition}/{moduleName}'
132 name = f
'{xvalue}_{channel};{aliasPrefix}_{moduleName}_{cellName}_ch_{channel}'
133 fullTitle = f
'Run {run} {moduleName} {cellName} Channel {channel}: {title};{xtitle};{ytitle}'
134 tool.defineHistogram(name, title=fullTitle, path=fullPath, type=type,
135 xbins=xbins, xmin=xmin, xmax=xmax)
138 totalEnergy =
min(flags.Beam.Energy / GeV, 300)
139 nEnergyBins =
int(totalEnergy * 2)
140 run =
str(flags.Input.RunNumbers[0])
141 nTimeBins = timeRange[1] - timeRange[0]
143 for cellMonAlg
in cellMonAlgorithms:
144 topPath = f
'{basePath}/LG' if 'LG' in cellMonAlg.name
else basePath
147 executeTimeGroup = helper.addGroup(cellMonAlg,
'TileTBCellMonExecuteTime', topPath)
148 executeTimeGroup.defineHistogram(
'TIME_execute', path=
'', type=
'TH1F',
149 title=f
'Time for execute TileTBCell{suffix}MonAlg algorithm;time [#mus]',
150 xbins=100, xmin=0, xmax=10000)
152 sampleEnergyArray = helper.addArray([modules], cellMonAlg,
'TileSampleEnergy', topPath=topPath)
153 for postfix, tool
in sampleEnergyArray.Tools.items():
154 moduleName = postfix[1:]
155 partition = moduleName[:3]
156 fullPath = f
'{partition}/{moduleName}'
157 titlePrefix = f
'Run {run} {moduleName}:'
159 tool.defineHistogram(f
'energy;EnergyTotal_{moduleName}', path=fullPath, type=
'TH1D',
160 title=f
'{titlePrefix} Total energy;Energy [pC];Entries',
161 xbins=nEnergyBins, xmin=0.0, xmax=totalEnergy)
163 tool.defineHistogram(f
'energyA,energyBC;EnergyTotalSampleBCVsA_{moduleName}', path=fullPath, type=
'TH2D',
164 title=f
'{titlePrefix} Total energy in sample BC vs sample A;Sample A Energy [pC];Sample B Energy [pC]',
165 xbins=nEnergyBins, xmin=0.0, xmax=totalEnergy, ybins=nEnergyBins, ymin=0.0, ymax=totalEnergy)
167 tool.defineHistogram(f
'energyD;EnergyTotalSampleD_{moduleName}', path=fullPath, type=
'TH1D',
168 title=f
'{titlePrefix} Total energy in sample D;Sample D Energy [pC];Entries',
169 xbins=nEnergyBins, xmin=0.0, xmax=totalEnergy)
171 addCellHistogramsArray(helper, modules, cellMonAlg, name=
'TileCellEnergy', path=topPath, xvalue=
'energy',
172 title=
'Tile Cell Energy', xbins=nEnergyBins, xmin=0, xmax=totalEnergy,
173 run=run, aliasPrefix=
'CellEnergy', xtitle=
'Energy [pC]', ytitle=
'Entries')
175 addCellHistogramsArray(helper, modules, cellMonAlg, name=
'TileCellEnergyDiff', path=topPath, xvalue=
'energyDiff',
176 title=
'Tile Cell Energy difference between PMTs', xbins=nEnergyBins, xmin=-totalEnergy, xmax=totalEnergy,
177 run=run, aliasPrefix=
'CellEnergyDiff', xtitle=
'Energy [pC]', ytitle=
'Entries')
179 addCellHistogramsArray(helper, modules, cellMonAlg, name=
'TileCellTime', path=topPath, xvalue=
'time',
180 title=
'Tile Cell Time', xbins=nTimeBins, xmin=timeRange[0], xmax=timeRange[1],
181 run=run, aliasPrefix=
'CellTime', xtitle=
'Time [ns]', ytitle=
'Entries')
183 addCellHistogramsArray(helper, modules, cellMonAlg, name=
'TileCellTimeDiff', path=topPath,
184 xvalue=
'timeDiff', title=
'Tile Cell Time difference between PMTs',
185 xbins=nTimeBins, xmin=timeRange[0], xmax=timeRange[1],
186 run=run, aliasPrefix=
'CellTimeDiff', xtitle=
'Time [ns]', ytitle=
'Entries')
188 addCellHistogramsArray(helper, modules, cellMonAlg, name=
'TileCellEnergyLeftVsRightPMT', path=topPath, type=
'TH2D',
189 xvalue=
'energy1', yvalue=
'energy2', title=
'Tile Cell PMT2 vs PMT1 Energy',
190 xbins=nEnergyBins, xmin=0, xmax=totalEnergy, ybins=nEnergyBins, ymin=0, ymax=totalEnergy,
191 run=run, aliasPrefix=
'CellEnergyLeftVsRightPMT',
192 xtitle=
'Energy [pC]', ytitle=
'Energy [pC]')
194 addCellHistogramsArray(helper, modules, cellMonAlg, name=
'TileCellTimeLeftVsRightPMT', path=topPath, type=
'TH2D',
195 xvalue=
'time1', yvalue=
'time2', title=
'Tile Cell PMT2 vs PMT1 Time',
196 xbins=nTimeBins, xmin=timeRange[0], xmax=timeRange[1], ybins=nTimeBins, ymin=timeRange[0], ymax=timeRange[1],
197 run=run, aliasPrefix=
'CellTimeLeftVsRightPMT', xtitle=
'Time [ns]', ytitle=
'Time [ns]')
199 addChannelHistogramsArray(helper, modules, cellMonAlg, name=
'TileChannelEnergy', path=f
'{topPath}/ChannelEnergy', type=
'TH1D',
200 xvalue=
'energy', title=
'Tile channel energy', xbins=nEnergyBins, xmin=0, xmax=totalEnergy,
201 run=run, aliasPrefix=
'ChannelEnergy', xtitle=
'Energy [pC]', ytitle=
'Entries')
203 addChannelHistogramsArray(helper, modules, cellMonAlg, name=
'TileChannelTime', path=f
'{topPath}/ChannelTime', type=
'TH1D',
204 xvalue=
'time', title=
'Tile channel time', xbins=nTimeBins, xmin=timeRange[0], xmax=timeRange[1],
205 run=run, aliasPrefix=
'ChannelTime', xtitle=
'Time [ns]', ytitle=
'Entries')
207 accumalator = helper.result()
208 result.merge(accumalator)