12def TileTBMonitoringConfig(flags, fragIDs=[0x100, 0x101, 0x200, 0x201, 0x402], **kwargs):
13
14 ''' Function to configure TileTBMonitorAlgorithm algorithm in the monitoring system.'''
15
16 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
17 result = ComponentAccumulator()
18
19 from TileGeoModel.TileGMConfig import TileGMCfg
20 result.merge(TileGMCfg(flags))
21
22 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
23 result.merge(LArGMCfg(flags))
24
25 from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
26 result.merge(TileCablingSvcCfg(flags))
27
28 from AthenaMonitoring import AthMonitorCfgHelper
29 helper = AthMonitorCfgHelper(flags, 'TileTBMonitoring')
30
31 from AthenaConfiguration.ComponentFactory import CompFactory
32 tileTBMonAlg = helper.addAlgorithm(CompFactory.TileTBMonitorAlgorithm, 'TileTBMonAlg')
33
34 tileTBMonAlg.TriggerChain = ''
35
36 kwargs.setdefault('BeamEnergy', flags.Beam.Energy)
37 kwargs.setdefault('CellEnergyThreshold', 0.1 * GeV)
38 energyThreshold = kwargs['CellEnergyThreshold']
39
40 masked = ['LBA01 0 ' + ",".join([str(channel) for channel in range(0, 48)]),
41 'LBA01 1 ' + ",".join([str(channel) for channel in range(0, 48)]),
42 'LBC01 0 36,37,38,39,40,41',
43 'LBC01 1 36,37,38,39,40,41']
44 kwargs.setdefault('Masked', masked)
45
46 from TileCalibBlobObjs.Classes import TileCalibUtils as Tile
47
48 modules = []
49 if fragIDs:
50 for fragID in fragIDs:
51 ros = fragID >> 8
52 drawer = fragID & 0x3F
53 modules += [Tile.getDrawerString(ros, drawer)]
54 else:
55 for ros in range(1, Tile.MAX_ROS):
56 for drawer in range(0, Tile.MAX_DRAWER):
57 fragIDs += [(ros << 8) | drawer]
58 modules += [Tile.getDrawerString(ros, drawer)]
59
60 tileTBMonAlg.TileFragIDs = fragIDs
61
62 for k, v in kwargs.items():
63 setattr(tileTBMonAlg, k, v)
64
65 run = str(flags.Input.RunNumbers[0])
66
67
68 executeTimeGroup = helper.addGroup(tileTBMonAlg, 'TileTBMonExecuteTime', 'TestBeam')
69 executeTimeGroup.defineHistogram('TIME_execute', path='', type='TH1F',
70 title='Time for execute TileTBMonAlg algorithm;time [#mus]',
71 xbins=100, xmin=0, xmax=10000)
72
73 totalEnergyGroup = helper.addGroup(tileTBMonAlg, 'TileTBTotalEventEnergy', 'TestBeam')
74 totalEnergyGroup.defineHistogram('energy;TileTBTotalEventEnergy', path='', type='TH1F',
75 title=f'Run {run}: Total TileCal Event Energy;Event Energy [pC]',
76 xbins=400, xmin=-2, xmax=200)
77
78 hotCellAGroup = helper.addGroup(tileTBMonAlg, 'TileTBHotCellA_LBC02', 'TestBeam')
79 hotCellAGroup.defineHistogram('tower;TileTBHotCellA_LBC02', path='', type='TH1F',
80 title=f'Run {run} LBC02: Tile TB Hot Cell A;Tower',
81 xbins=10, xmin=-0.5, xmax=9.5)
82
83 CtotGroup = helper.addGroup(tileTBMonAlg, 'TileTBCtot', 'TestBeam')
84 CtotGroup.defineHistogram('Ctot;TileTBCtot', path='', type='TH1F',
85 title=f'Run {run} LBC02: Tile TB Ctot;Ctot',
86 xbins=100, xmin=0.03, xmax=0.22)
87
88 ClongGroup = helper.addGroup(tileTBMonAlg, 'TileTBClong', 'TestBeam')
89 ClongGroup.defineHistogram('Clong;TileTBClong', path='', type='TH1F',
90 title=f'Run {run} LBC02: Tile TB Clong;Clong',
91 xbins=100, xmin=0., xmax=1.8)
92
93 CtotVsClongGroup = helper.addGroup(tileTBMonAlg, 'TileTBCtotVsClong', 'TestBeam')
94 CtotVsClongGroup.defineHistogram('Clong,Ctot;TileTBCtotVsClong', path='', type='TH2F',
95 title=f'Run {run} LBC02: Tile TB Ctot Vs Clong;Clong;Ctot',
96 xbins=100, xmin=0., xmax=1.8, ybins=100, ymin=0.03, ymax=0.22)
97
98
99 maxTotalEnergy = 150
100 nCellsVsEnergyGroup = helper.addGroup(tileTBMonAlg, 'TileTBCellsNumberVsTotalEnergy', 'TestBeam')
101 nCellsVsEnergyGroup.defineHistogram('nCells,energy;TileTBCellsNumberVsTotalEnergy', path='', type='TH2F',
102 title=f'Run {run}: Tile Event energy [C side] vs # cells with energy > {energyThreshold} pC;# Cells;Energy [pC]',
103 xbins=25, xmin=-0.5, xmax=24.5, ybins=maxTotalEnergy, ymin=0.0, ymax=maxTotalEnergy)
104
105 hitMapGroup = helper.addGroup(tileTBMonAlg, 'TileTBHitMap', 'TestBeam')
106 hitMapGroup.defineHistogram('side,module,energy;TileTBHitMap', path='', type='TProfile2D',
107 title=f'Run {run}: Tile TB setup map with average energy',
108 xlabels=['A Side', 'C side'], ylabels=['LB01', 'LB02', 'EB03'],
109 xbins=2, xmin=-0.5, xmax=1.5, ybins=3, ymin=-0.5, ymax=2.5)
110
111 timeArray = helper.addArray([modules], tileTBMonAlg, 'TileTBChannelTime', topPath='TestBeam')
112 for postfix, tool in timeArray.Tools.items():
113 moduleName = postfix[1:]
114 name = f'channel,time;TileTBChannelTime_{moduleName}'
115 fullTitle = f'Run {run} {moduleName}: Tile TB channel average time from cells;Channel;Time [ns]'
116 tool.defineHistogram(name, title=fullTitle, path='', type='TProfile',
117 xbins=Tile.MAX_CHAN, xmin=-0.5, xmax=Tile.MAX_CHAN-0.5)
118
119 maxSample = 3
120 maxTowerLB = 10
121 xCellLB = [[[] for tower in range(0, maxTowerLB)] for sample in range(0, maxSample)]
122 yCellLB = [[[] for tower in range(0, maxTowerLB)] for sample in range(0, maxSample)]
123
124 periodWidthLB = 18.22
125
126 nPeriodsLB = [[14, 13, 14, 14, 15, 16, 16, 17, 19, 16],
127 [16, 15, 16, 16, 17, 18, 18, 20, 18],
128 [18, 18, 18, 19, 19, 20, 22, 20],
129 [20, 0, 41, 0, 43, 0, 50]]
130
131 yLB = [0, 300, 690, 1140, 1520]
132 for sampleIndex in range(0, len(nPeriodsLB)):
133 sample = sampleIndex if sampleIndex < 2 else sampleIndex - 1
134 cellOffsetX = 0.0
135 for tower in range(0, len(nPeriodsLB[sampleIndex])):
136 cellWidth = nPeriodsLB[sampleIndex][tower] * periodWidthLB
137 x1 = cellOffsetX + 9
138 x2 = cellOffsetX + cellWidth
139 while x1 < x2:
140 xCellLB[sample][tower] += [x1]
141 yCellLB[sample][tower] += [yLB[sampleIndex]]
142 x1 += periodWidthLB
143
144 cellOffsetX += cellWidth
145
146 tileTBMonAlg.xCellLongBarrelSampleA = xCellLB[0]
147 tileTBMonAlg.xCellLongBarrelSampleBC = xCellLB[1]
148 tileTBMonAlg.xCellLongBarrelSampleD = xCellLB[2]
149
150 tileTBMonAlg.yCellLongBarrelSampleA = yCellLB[0]
151 tileTBMonAlg.yCellLongBarrelSampleBC = yCellLB[1]
152 tileTBMonAlg.yCellLongBarrelSampleD = yCellLB[2]
153
154 maxTowerEB = 16
155 periodWidthEB = 18.28
156 xCellEB = [[[] for tower in range(0, maxTowerEB)] for sample in range(0, maxSample)]
157 yCellEB = [[[] for tower in range(0, maxTowerEB)] for sample in range(0, maxSample)]
158
159 yEB = [0, 300, 690, 840, 840, 1140, 1520]
160
161 nPeriodsEB = [[17, 0, 0, 9, 25, 28, 30, 48],
162 [17, 0, 16, 27, 30, 32, 35],
163 [12, 5, 16, 27, 30, 32, 35],
164 [12, 5],
165 [0, 17, 65, 0, 75],
166 [17, 0, 65, 0, 75]]
167
168 samples = [0, 1, 1, 1, 2, 2]
169 for sampleIndex in range(0, len(nPeriodsEB)):
170 sample = samples[sampleIndex]
171 cellOffsetX = 0.0
172 for tower in range(0, len(nPeriodsEB[sampleIndex])):
173 cellWidth = nPeriodsEB[sampleIndex][tower] * periodWidthEB
174 x1 = cellOffsetX + 9
175 x2 = cellOffsetX + cellWidth
176 while x1 < x2:
177 xCellEB[sample][tower + 8] += [x1]
178 yCellEB[sample][tower + 8] += [yEB[sampleIndex]]
179 x1 += periodWidthEB
180
181 cellOffsetX += cellWidth
182
183 tileTBMonAlg.xCellExtendedBarrelSampleA = xCellEB[0]
184 tileTBMonAlg.xCellExtendedBarrelSampleBC = xCellEB[1]
185 tileTBMonAlg.xCellExtendedBarrelSampleD = xCellEB[2]
186
187 tileTBMonAlg.yCellExtendedBarrelSampleA = yCellEB[0]
188 tileTBMonAlg.yCellExtendedBarrelSampleBC = yCellEB[1]
189 tileTBMonAlg.yCellExtendedBarrelSampleD = yCellEB[2]
190
191 xBinsLB = [x * periodWidthLB for x in range(0, sum(nPeriodsLB[0]) + 1)]
192 yBinsLB = [0, 300, 690, 1140, 1520]
193
194 xBinsEB = [x * periodWidthEB for x in range(0, sum(nPeriodsEB[0]) + 1)]
195 yBinsEB = [0, 300, 690, 840, 1140, 1520]
196 cellMapArray = helper.addArray([modules], tileTBMonAlg, 'TileTBCellMap', topPath='TestBeam')
197 for postfix, tool in cellMapArray.Tools.items():
198 moduleName = postfix[1:]
199 name = f'x,y,energy;TileTBCellMap_{moduleName}'
200 fullTitle = f'Run {run} {moduleName}: Tile TB cell map with average energy;z [mm];x [mm];Energy [pc]'
201 tool.defineHistogram(name, title=fullTitle, path='', type='TProfile2D',
202 xbins=xBinsLB if moduleName.startswith('LB') else xBinsEB,
203 ybins=yBinsLB if moduleName.startswith('LB') else yBinsEB)
204
205 accumalator = helper.result()
206 result.merge(accumalator)
207 return result
208
209