5 @file TileTBMonitorAlgorithm.py
6 @brief Python configuration of TileTBMonitorAlgorithm algorithm for the Run III
9 from AthenaConfiguration.Enums
import Format
14 ''' Function to configure TileTBMonitorAlgorithm algorithm in the monitoring system.'''
16 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
19 from TileGeoModel.TileGMConfig
import TileGMCfg
22 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
25 from TileConditions.TileCablingSvcConfig
import TileCablingSvcCfg
28 from AthenaMonitoring
import AthMonitorCfgHelper
29 helper = AthMonitorCfgHelper(flags,
'TileTBMonitoring')
31 from AthenaConfiguration.ComponentFactory
import CompFactory
32 tileTBMonAlg = helper.addAlgorithm(CompFactory.TileTBMonitorAlgorithm,
'TileTBMonAlg')
34 tileTBMonAlg.TriggerChain =
''
36 kwargs.setdefault(
'BeamEnergy', flags.Beam.Energy)
37 kwargs.setdefault(
'CellEnergyThreshold', 0.1 * GeV)
38 energyThreshold = kwargs[
'CellEnergyThreshold']
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)
46 from TileCalibBlobObjs.Classes
import TileCalibUtils
as Tile
50 for fragID
in fragIDs:
52 drawer = fragID & 0x3F
53 modules += [Tile.getDrawerString(ros, drawer)]
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)]
60 tileTBMonAlg.TileFragIDs = fragIDs
62 for k, v
in kwargs.items():
63 setattr(tileTBMonAlg, k, v)
65 run =
str(flags.Input.RunNumbers[0])
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)]
124 periodWidthLB = 18.22
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]]
131 yLB = [0, 300, 690, 1140, 1520]
132 for sampleIndex
in range(0, len(nPeriodsLB)):
133 sample = sampleIndex
if sampleIndex < 2
else sampleIndex - 1
135 for tower
in range(0, len(nPeriodsLB[sampleIndex])):
136 cellWidth = nPeriodsLB[sampleIndex][tower] * periodWidthLB
138 x2 = cellOffsetX + cellWidth
140 xCellLB[sample][tower] += [x1]
141 yCellLB[sample][tower] += [yLB[sampleIndex]]
144 cellOffsetX += cellWidth
146 tileTBMonAlg.xCellLongBarrelSampleA = xCellLB[0]
147 tileTBMonAlg.xCellLongBarrelSampleBC = xCellLB[1]
148 tileTBMonAlg.xCellLongBarrelSampleD = xCellLB[2]
150 tileTBMonAlg.yCellLongBarrelSampleA = yCellLB[0]
151 tileTBMonAlg.yCellLongBarrelSampleBC = yCellLB[1]
152 tileTBMonAlg.yCellLongBarrelSampleD = yCellLB[2]
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)]
159 yEB = [0, 300, 690, 840, 840, 1140, 1520]
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],
168 samples = [0, 1, 1, 1, 2, 2]
169 for sampleIndex
in range(0, len(nPeriodsEB)):
170 sample = samples[sampleIndex]
172 for tower
in range(0, len(nPeriodsEB[sampleIndex])):
173 cellWidth = nPeriodsEB[sampleIndex][tower] * periodWidthEB
175 x2 = cellOffsetX + cellWidth
177 xCellEB[sample][tower + 8] += [x1]
178 yCellEB[sample][tower + 8] += [yEB[sampleIndex]]
181 cellOffsetX += cellWidth
183 tileTBMonAlg.xCellExtendedBarrelSampleA = xCellEB[0]
184 tileTBMonAlg.xCellExtendedBarrelSampleBC = xCellEB[1]
185 tileTBMonAlg.xCellExtendedBarrelSampleD = xCellEB[2]
187 tileTBMonAlg.yCellExtendedBarrelSampleA = yCellEB[0]
188 tileTBMonAlg.yCellExtendedBarrelSampleBC = yCellEB[1]
189 tileTBMonAlg.yCellExtendedBarrelSampleD = yCellEB[2]
191 xBinsLB = [x * periodWidthLB
for x
in range(0,
sum(nPeriodsLB[0]) + 1)]
192 yBinsLB = [0, 300, 690, 1140, 1520]
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)
205 accumalator = helper.result()
206 result.merge(accumalator)
210 if __name__ ==
'__main__':
213 from AthenaCommon.Logging
import log
218 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
219 from AthenaConfiguration.TestDefaults
import defaultTestFiles
222 parser = flags.getArgumentParser()
223 parser.add_argument(
'--postExec', help=
'Code to execute after setup')
224 parser.add_argument(
'--digits', default=
"TileDigitsCnt", help=
'Tile digits container')
225 parser.add_argument(
'--channels', default=
"TileRawChannelCnt",
226 help=
'Tile raw channel container, if empty they will be reconstructed from digits')
227 parser.add_argument(
'--cells', default=
"AllCalo",
228 help=
'Calo Cells container, if empty they will be reconstructed from channels')
229 parser.add_argument(
'--frag-ids', dest=
'fragIDs', nargs=
"*", default=[
'0x100',
'0x101',
'0x200',
'0x201',
'0x402'],
230 help=
'Tile Frag IDs of modules to be monitored. Empty=ALL')
231 parser.add_argument(
'--demo-cabling', dest=
'demoCabling', type=int, default=2018, help=
'Time Demonatrator cabling to be used')
232 parser.add_argument(
'--nsamples', type=int, default=15, help=
'Number of samples')
233 parser.add_argument(
'--use-sqlite', dest=
'useSqlite', default=
'/afs/cern.ch/user/t/tiledemo/public/efmon/condb/tileSqlite.db',
234 help=
'Providing local SQlite file, conditions constants will be used from it')
235 args, _ = parser.parse_known_args()
237 fragIDs = [
int(fragID, base=16)
for fragID
in args.fragIDs]
239 flags.Input.Files = defaultTestFiles.ESD
240 flags.Output.HISTFileName =
'TileTBMonitorOutput.root'
241 flags.DQ.useTrigger =
False
242 flags.DQ.enableLumiAccess =
False
243 flags.Exec.MaxEvents = 3
244 flags.Common.isOnline =
True
246 flags.Tile.doFit =
True
247 flags.Tile.useDCS =
False
248 flags.Tile.NoiseFilter = 0
249 flags.Tile.correctTime =
False
250 flags.Tile.correctTimeJumps =
False
251 flags.Tile.BestPhaseFromCOOL =
False
252 flags.Tile.doOverflowFit =
False
255 flags.fillFromArgs(parser=parser)
258 flags.dump(pattern=
'Tile.*|Input.*|Exec.*|IOVDb.[D|G].*', evaluate=
True)
261 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
264 rawChannels = args.channels
266 if flags.Input.Format
is Format.BS:
267 readDigitsFlx =
'Flx' in args.digits
268 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
270 readDigits=(
not readDigitsFlx),
271 readDigitsFlx=readDigitsFlx) )
274 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
279 rawChannels = flags.Tile.RawChannelContainer
281 from TileRecUtils.TileRawChannelMakerConfig
import TileRawChannelMakerCfg
283 if args.threads
and (args.threads > 1):
284 rawChMaker = cfg.getEventAlgo(
'TileRChMaker')
285 rawChMaker.Cardinality = args.threads
288 cfg.getService(
'IOVDbSvc').overrideTags += [
289 f
'<prefix>/TILE</prefix> <db>sqlite://;schema={args.useSqlite};dbname={flags.IOVDb.DatabaseInstance}</db>'
295 from TileRecUtils.TileCellMakerConfig
import TileCellMakerCfg
296 cfg.merge(
TileCellMakerCfg(flags, maskBadChannels=
False, mergeChannels=
False, UseDemoCabling=args.demoCabling))
300 from TileConditions.TileInfoLoaderConfig
import TileInfoLoaderCfg
302 tileInfoLoader = cfg.getService(
'TileInfoLoader')
303 tileInfoLoader.NSamples = args.nsamples
304 tileInfoLoader.TrigSample = (args.nsamples - 1) // 2
308 log.info(
'Executing postExec: %s', args.postExec)
311 cfg.printConfig(withDetails=
True, summariseProps=
True)
313 cfg.store(
open(
'TileTBMonitorAlgorithm.pkl',
'wb'))
319 sys.exit(
not sc.isSuccess())