5 @file TileTBBeamMonitorAlgorithm.py
6 @brief Python configuration of TileTBBeamMonitorAlgorithm algorithm for the Run III
9 from AthenaConfiguration.Enums
import Format
14 ''' Function to configure TileTBBeamMonitorAlgorithm algorithm in the monitoring system.'''
16 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
19 from TileGeoModel.TileGMConfig
import TileGMCfg
22 from TileConditions.TileCablingSvcConfig
import TileCablingSvcCfg
25 from AthenaMonitoring
import AthMonitorCfgHelper
26 helper = AthMonitorCfgHelper(flags,
'TileTBBeamMonitoring')
28 from AthenaConfiguration.ComponentFactory
import CompFactory
29 tileTBBeamMonAlg = helper.addAlgorithm(CompFactory.TileTBBeamMonitorAlgorithm,
'TileTBBeamMonAlg')
31 tileTBBeamMonAlg.TriggerChain =
''
33 kwargs.setdefault(
'CaloCellContainer',
'AllCalo')
34 cellContainer = kwargs[
'CaloCellContainer']
36 kwargs.setdefault(
'TBperiod', 2023)
37 kwargs.setdefault(
'MaskMuonPMTs', [7])
38 kwargs.setdefault(
'TOFDifferencePairs', [[2, 1], [2, 3], [3, 1]])
40 from TileCalibBlobObjs.Classes
import TileCalibUtils
as Tile
44 for fragID
in fragIDs:
46 drawer = fragID & 0x3F
47 modules += [Tile.getDrawerString(ros, drawer)]
49 for ros
in range(1, Tile.MAX_ROS):
50 for drawer
in range(0, Tile.MAX_DRAWER):
51 fragIDs += [(ros << 8) | drawer]
52 modules += [Tile.getDrawerString(ros, drawer)]
54 tileTBBeamMonAlg.TileFragIDs = fragIDs
56 for k, v
in kwargs.items():
57 setattr(tileTBBeamMonAlg, k, v)
59 from TileMonitoring.TileTBBeamChambersCalibration
import updateBeamChambersCalibrations
62 run =
str(flags.Input.RunNumbers[0])
65 executeTimeGroup = helper.addGroup(tileTBBeamMonAlg,
'TileTBBeamMonExecuteTime',
'TestBeam')
66 executeTimeGroup.defineHistogram(
'TIME_execute', path=
'BeamElements', type=
'TH1F',
67 title=
'Time for execute TileTBBeamMonAlg algorithm;time [#mus]',
68 xbins=100, xmin=0, xmax=10000)
71 muonWallPMTArray = helper.addArray([nMuonWallPMT], tileTBBeamMonAlg,
'MuonWallPMT', topPath=
'TestBeam')
72 for postfix, tool
in muonWallPMTArray.Tools.items():
73 pmt =
int(postfix[1:]) + 1
74 title = f
'Run {run}: Muon Wall PMT{pmt} Amplitude;Amplitude [ADC];Counts'
75 name = f
'amplitude;MuonWallPMT{pmt}'
76 tool.defineHistogram(name, title=title, path=
'BeamElements', type=
'TH1F',
77 xbins=410, xmin=0, xmax=4096)
79 totalMuEnergyGroup = helper.addGroup(tileTBBeamMonAlg,
'TileTBTotalMuonEnergy',
'TestBeam')
80 totalMuEnergyGroup.defineHistogram(
'TotalMuonEnergy', path=
'BeamElements', type=
'TH1F',
81 title=f
'Run {run}: Muon Wall Total Energy; [ADC]',
82 xbins=1500, xmin=0, xmax=10000)
85 sCountersArray = helper.addArray([nScounters], tileTBBeamMonAlg,
'Scounter', topPath=
'TestBeam')
86 for postfix, tool
in sCountersArray.Tools.items():
87 counter =
int(postfix[1:]) + 1
88 title = f
'Run {run}: S{counter} Counter Amplitude;Amplitude [ADC];Counts'
89 name = f
'amplitude;S{counter}hist'
90 tool.defineHistogram(name, title=title, path=
'BeamElements', type=
'TH1F',
91 xbins=410, xmin=0, xmax=4096)
94 cherenkovArray = helper.addArray([nCherenkov], tileTBBeamMonAlg,
'Cherenkov', topPath=
'TestBeam')
95 for postfix, tool
in cherenkovArray.Tools.items():
96 cherenkov =
int(postfix[1:]) + 1
97 title = f
'Run {run}: Cherenkov {cherenkov} Amplitude;Amplitude [ADC];Counts'
98 name = f
'amplitude;Cher{cherenkov}hist'
99 tool.defineHistogram(name, title=title, path=
'BeamElements', type=
'TH1F',
100 xbins=410, xmin=0, xmax=4096)
103 cherCompGroup = helper.addGroup(tileTBBeamMonAlg,
'CherCompare',
'TestBeam')
104 cherCompGroup.defineHistogram(
'amplitude1,amplitude2;CherCompare', path=
'BeamElements', type=
'TH2F',
105 title=f
'Run {run}: Cherenkov2 vs Cherenkov1;Amplitude [ADC];Amplitude [ADC]',
106 xbins=410, xmin=0, xmax=4096, ybins=410, ymin=0, ymax=4096)
109 tofArray = helper.addArray([nTOF], tileTBBeamMonAlg,
'TOF', topPath=
'TestBeam')
110 for postfix, tool
in tofArray.Tools.items():
111 tof =
int(postfix[1:]) + 1
112 title = f
'Run {run}: TOF{tof};[ADC];Counts'
113 name = f
'amplitude;TOF{tof}'
114 tool.defineHistogram(name, title=title, path=
'BeamElements', type=
'TH1F',
115 xbins=4096, xmin=-0.5, xmax=4095.5)
117 tofDiffPairs = kwargs[
'TOFDifferencePairs']
118 tofDiffArray = helper.addArray([len(tofDiffPairs)], tileTBBeamMonAlg,
'TOFDiff', topPath=
'TestBeam')
119 for postfix, tool
in tofDiffArray.Tools.items():
120 pairIdx =
int(postfix.split(
'_').pop())
121 tof1,tof2 = tofDiffPairs[pairIdx]
122 title = f
'Run {run}: TOF{tof1} - TOF{tof2} Amplitude difference;[ADC];Counts'
123 tool.defineHistogram(f
'TOFDiff;TOFDiff{tof1}{tof2}', title=title, path=
'BeamElements',
124 type=
'TH1F', xbins=4096, xmin=-0.5, xmax=4095.5)
126 cherenkovVsTOFArray = helper.addArray([nTOF, nCherenkov], tileTBBeamMonAlg,
'CherenkovVsTOF', topPath=
'TestBeam')
127 for postfix, tool
in cherenkovVsTOFArray.Tools.items():
128 cherenkovTof = postfix.split(
'_')
129 cherenkov =
int(cherenkovTof.pop()) + 1
130 tof =
int(cherenkovTof.pop()) + 1
131 title = f
'Run {run}: Cherenkov {cherenkov} Amplitude vs TOF{tof} Amplitude'
132 title += f
';TOF{tof} Amplitude [ADC];Cherenkov{cherenkov} Amplitude [ADC]'
133 name = f
'amplitudeTOF,amplitudeCherenkov;Cher{cherenkov}TOF{tof}'
134 tool.defineHistogram(name, title=title, path=
'BeamElements', type=
'TH2F',
135 xbins=410, xmin=0, xmax=4096, ybins=410, ymin=0, ymax=4096)
137 pmtHitMapGroup = helper.addGroup(tileTBBeamMonAlg,
'PMTHitMap',
'TestBeam')
138 pmtHitMapGroup.defineHistogram(
'column,row,amplitude;PMTHitMap', path=
'BeamElements', type=
'TProfile2D',
139 title=f
'Run {run}: Muon Wall PMT Hit Map',
140 xbins=4, xmin=0, xmax=4, ybins=2, ymin=0, ymax=2)
143 scalerArray = helper.addArray([nScaler], tileTBBeamMonAlg,
'Scaler', topPath=
'TestBeam')
144 for postfix, tool
in scalerArray.Tools.items():
145 scaler =
int(postfix[1:]) + 1
146 title = f
'Run {run}: Scaler S{scaler};Counts;# Events'
147 name = f
'counts;Scaler{scaler}'
148 tool.defineHistogram(name, title=title, path=
'BeamElements', type=
'TH1F',
149 xbins=20000, xmin=-0.5, xmax=19999.5)
151 scalerCoincedenceGroup = helper.addGroup(tileTBBeamMonAlg,
'Scaler12',
'TestBeam')
152 scalerCoincedenceGroup.defineHistogram(
'counts12;Scaler12', path=
'BeamElements', type=
'TH1F',
153 title=f
'Run {run}: Scaler S1 and S2 coincedence;counts;# Events',
154 xbins=20000, xmin=-0.5, xmax=19999.5)
157 beamChambers = [
'BC1',
'BC2']
158 beamChambersArray = helper.addArray([beamChambers], tileTBBeamMonAlg,
'BeamChamber', topPath=
'TestBeam')
159 for postfix, tool
in beamChambersArray.Tools.items():
160 beamChamber = postfix[1:]
162 for coordinate
in [
'X',
'Y']:
163 title = f
'Run {run}: {beamChamber}{coordinate} Coordinate;{coordinate}[mm];Counts'
164 name = f
'{beamChamber}{coordinate};{beamChamber}{coordinate}hist'
165 tool.defineHistogram(name, title=title, path=
'BeamElements', type=
'TH1F',
166 xbins=201, xmin=-100.5, xmax=100.5)
168 tool.defineHistogram(f
'{beamChamber}X,{beamChamber}Y;{beamChamber}Profile', path=
'BeamElements',
169 type=
'TH2D', title=f
'Run {run}: {beamChamber} Beam Profile;X[mm];Y[mm]',
170 xbins=1000, xmin=-100, xmax=100, ybins=1000, ymin=-100, ymax=100)
172 tool.defineHistogram(f
'{beamChamber}Xsum,{beamChamber}Ysum;{beamChamber}ProfileSum', path=
'BeamElements',
173 type=
'TH2D', title=f
'Run {run}: {beamChamber} Beam Profile Sum;X [mm];Y [mm]',
174 xbins=1000, xmin=-300, xmax=0, ybins=1000, ymin=-300, ymax=0)
177 impactProfileGroup = helper.addGroup(tileTBBeamMonAlg,
'ImpactProfile',
'TestBeam')
178 impactProfileGroup.defineHistogram(
'Ximp,Yimp;ImpactProfile', path=
'BeamElements', type=
'TH2F',
179 title=f
'Run {run}: {beamChamber} Impact Profile;X [mm];Y [mm]',
180 xbins=200, xmin=-100, xmax=100, ybins=200, ymin=-100, ymax=100)
184 cherenkovEnergyArray = helper.addArray([nCherenkov], tileTBBeamMonAlg,
'CherenkovVsEnergy', topPath=
'TestBeam')
185 for postfix, tool
in cherenkovEnergyArray.Tools.items():
186 cherenkov =
int(postfix[1:]) + 1
187 title = f
'Run {run}: Cherenkov {cherenkov} Amplitude vs Total Energy;Energy [pC]; Amplitude [ADC]'
188 name = f
'totalEnergy,amplitude;Cher{cherenkov}Energy'
189 tool.defineHistogram(name, title=title, path=
'BeamElements', type=
'TH2F',
190 xbins=150, xmin=0, xmax=150, ybins=410, ymin=0, ymax=4096)
192 cellEneXimpGroup = helper.addGroup(tileTBBeamMonAlg,
'CellEnergyImpactX',
'TestBeam')
193 cellEneXimpGroup.defineHistogram(
'Ximp,cellEnergy;CellEnergyImpactX', path=
'BeamElements', type=
'TH2F',
194 title=f
'Run {run}: Maximum Cell Energy vs Impact X;X [mm];Cell Energy [pc]',
195 xbins=200, xmin=-100, xmax=100, ybins=150, ymin=0, ymax=150)
197 cellEneYimpGroup = helper.addGroup(tileTBBeamMonAlg,
'CellEnergyImpactY',
'TestBeam')
198 cellEneYimpGroup.defineHistogram(
'Yimp,cellEnergy;CellEnergyImpactY', path=
'BeamElements', type=
'TH2F',
199 title=f
'Run {run}: Maximum Cell Energy vs Impact Y;Y [mm];Cell Energy [pc]',
200 xbins=200, xmin=-100, xmax=100, ybins=150, ymin=0, ymax=150)
202 totalEneXimpGroup = helper.addGroup(tileTBBeamMonAlg,
'TotalEnergyImpactX',
'TestBeam')
203 totalEneXimpGroup.defineHistogram(
'Ximp,totalEnergy;TotalEnergyImpactX', path=
'BeamElements', type=
'TH2F',
204 title=f
'Run {run}: Total Energy vs Impact X;X [mm];Total Energy [pc]',
205 xbins=200, xmin=-100, xmax=100, ybins=150, ymin=0, ymax=150)
207 totalEneYimpGroup = helper.addGroup(tileTBBeamMonAlg,
'TotalEnergyImpactY',
'TestBeam')
208 totalEneYimpGroup.defineHistogram(
'Yimp,totalEnergy;TotalEnergyImpactY', path=
'BeamElements', type=
'TH2F',
209 title=f
'Run {run}: Total Energy vs Impact Y;Y [mm];Total Energy [pc]',
210 xbins=200, xmin=-100, xmax=100, ybins=150, ymin=0, ymax=150)
213 totalEneS1Group = helper.addGroup(tileTBBeamMonAlg,
'ScinCalEnergy',
'TestBeam')
214 totalEneS1Group.defineHistogram(
'amplitude,totalEnergy;ScinCalEnergy', path=
'BeamElements', type=
'TH2F',
215 title=f
'Run {run}: Total Energy vs S1 amplitude; Amplitude [ADC];Total Energy [pc]',
216 xbins=410, xmin=0, xmax=4096, ybins=150, ymin=0, ymax=150)
219 accumalator = helper.result()
220 result.merge(accumalator)
224 if __name__==
'__main__':
227 from AthenaCommon.Logging
import log
232 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
233 from AthenaConfiguration.TestDefaults
import defaultTestFiles, defaultGeometryTags
236 parser = flags.getArgumentParser()
237 parser.add_argument(
'--postExec', help=
'Code to execute after setup')
238 parser.add_argument(
'--digits', default=
"TileDigitsCnt", help=
'Tile digits container')
239 parser.add_argument(
'--channels', default=
"TileRawChannelCnt",
240 help=
'Tile raw channel container, if empty they will be reconstructed from digits')
241 parser.add_argument(
'--cells', default=
"AllCalo",
242 help=
'Calo Cells container, if empty they will be reconstructed from channels')
243 parser.add_argument(
'--frag-ids', dest=
'fragIDs', nargs=
"*", default=[
'0x100',
'0x101',
'0x200',
'0x201',
'0x402'],
244 help=
'Tile Frag IDs of modules to be monitored. Empty=ALL')
245 parser.add_argument(
'--demo-cabling', dest=
'demoCabling', type=int, default=2018, help=
'Time Demonatrator cabling to be used')
246 parser.add_argument(
'--nsamples', type=int, default=15, help=
'Number of samples')
247 parser.add_argument(
'--use-sqlite', dest=
'useSqlite', default=
'/afs/cern.ch/user/t/tiledemo/public/efmon/condb/tileSqlite.db',
248 help=
'Providing local SQlite file, conditions constants will be used from it')
249 args, _ = parser.parse_known_args()
251 fragIDs = [
int(fragID, base=16)
for fragID
in args.fragIDs]
253 flags.Input.Files = defaultTestFiles.RAW_RUN2
254 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
255 flags.Output.HISTFileName =
'TileTBBeamMonitorOutput.root'
256 flags.DQ.useTrigger =
False
257 flags.DQ.enableLumiAccess =
False
258 flags.Exec.MaxEvents = 3
259 flags.Common.isOnline =
True
261 flags.Tile.doFit =
True
262 flags.Tile.useDCS =
False
263 flags.Tile.NoiseFilter = 0
264 flags.Tile.correctTime =
False
265 flags.Tile.correctTimeJumps =
False
266 flags.Tile.BestPhaseFromCOOL =
False
267 flags.Tile.doOverflowFit =
False
270 flags.Tile.RawChannelContainer = args.channels
272 flags.fillFromArgs(parser=parser)
275 flags.dump(pattern=
'Tile.*|Input.*|Exec.*|IOVDb.[D|G].*', evaluate=
True)
278 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
281 rawChannels = args.channels
283 if flags.Input.Format
is Format.BS:
284 readDigitsFlx =
'Flx' in args.digits
285 from TileByteStream.TileByteStreamConfig
import TileRawDataReadingCfg
287 readDigits=(
not readDigitsFlx),
288 readDigitsFlx=readDigitsFlx,
291 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
296 rawChannels = flags.Tile.RawChannelContainer
298 from TileRecUtils.TileRawChannelMakerConfig
import TileRawChannelMakerCfg
300 if args.threads
and (args.threads > 1):
301 rawChMaker = cfg.getEventAlgo(
'TileRChMaker')
302 rawChMaker.Cardinality = args.threads
305 cfg.getService(
'IOVDbSvc').overrideTags += [
306 f
'<prefix>/TILE</prefix> <db>sqlite://;schema={args.useSqlite};dbname={flags.IOVDb.DatabaseInstance}</db>'
313 from TileRecUtils.TileCellMakerConfig
import TileCellMakerCfg
314 cfg.merge(
TileCellMakerCfg(flags, maskBadChannels=
False, mergeChannels=
False, UseDemoCabling=args.demoCabling))
319 from TileConditions.TileInfoLoaderConfig
import TileInfoLoaderCfg
321 tileInfoLoader = cfg.getService(
'TileInfoLoader')
322 tileInfoLoader.NSamples = args.nsamples
323 tileInfoLoader.TrigSample = (args.nsamples - 1) // 2
327 log.info(
'Executing postExec: %s', args.postExec)
330 cfg.printConfig(withDetails=
True, summariseProps=
True)
332 cfg.store(
open(
'TileTBBeamMonitorAlgorithm.pkl',
'wb'))
338 sys.exit(
not sc.isSuccess())