ATLAS Offline Software
RunTileCalibRec.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 #
5 '''@file RunTileCalibRec.py
6 @brief Script to run Tile Reconstrcution/Monitoring for calibration runs
7 '''
8 
9 from TileRecEx import TileInputFiles
10 from AthenaConfiguration.Enums import Format
11 from TileConfiguration.TileConfigFlags import TileRunType
12 from AthenaCommon.SystemOfUnits import MeV
13 
14 epiLog = """
15 Examples:
16 
17  RunTileCalibRec.py --run RUNNUMBER --evtMax 1 --pedestals --loglevel WARNING IOVDb.GlobalTag='CONDBR2-BLKPA-2018-13'
18  RunTileCalibRec.py --filesInput=FILE1,FILE2 Tile.RunType=TileRunType.LAS Tile.correctTime=True Exec.SkipEvents=100
19  RunTileCalibRec.py --run RUNNUMBER --cis --postExec='useTagFor("RUN2-HLT-UPD1-00", "/TILE/OFL02/TIME/CHANNELOFFSET/CIS");'
20  RunTileCalibRec.py --run RUNNUMBER --laser --postExec='useSqliteFor("tileSqlite.db", "/TILE");'
21 
22  RunTileCalibRec.py --run RUNNUMBER @options.txt
23 
24  where "options.txt" is text file which can contain all arguments and Athen configuration flags (one per line), e.g.:
25  --run2
26  --upd4
27  --laser
28  --loglevel=INFO
29  --postExec=useSqliteAndTagFor("tileSqlite.db", "RUN2-HLT-UPD1-00", "/TILE/OFL02/TIME/CHANNELOFFSET/LAS");
30  Tile.correctTime=True
31  Exec.SkipEvents=100
32 
33 At least one should provide the following arguments or Athena configuration flags (flags have higher priority):
34  Input file(s), e.g.: --run RUNNUMBER | --filesInput=FILE1,FILE2 | Input.Files="['FILE1','FILE2']"
35  Tile Run Type, e.g.: --cis | --laser | --pedestals | --physics | Tile.RunType=TileRunType.PHY
36 """
37 
38 
39 def getArgumentParser(flags):
40  """ Function to return command line arguments parser for reconstuction of Tile calibration runs """
41 
42  parserParents = [flags.getArgumentParser(), TileInputFiles.getArgumentParser(add_help=False)]
43 
44  import argparse
45  parser= argparse.ArgumentParser(parents=parserParents, add_help=False, fromfile_prefix_chars='@', epilog=epiLog, formatter_class=argparse.RawTextHelpFormatter)
46 
47  parser.add_argument('--preExec', help='Code to execute before locking configs')
48  parser.add_argument('--postExec', help='Code to execute after setup')
49  parser.add_argument('--printDetailedConfig', action='store_true', help='Print detailed Athena configuration')
50  parser.add_argument('--dumpArguments', action='store_true', help='Print arguments and exit')
51  parser.add_argument('--outputDirectory', default='.', help='Output directory for produced files')
52 
53  parser.add_argument('--outputVersion', type=str, default='0', help='Version to be used in output files for ntuple and monitoring')
54 
55  parser.add_argument('--calib', default=False, help='Calculate calibration constants and store them in ROOT file', action=argparse.BooleanOptionalAction)
56  parser.add_argument('--tmdb', default=None, help='Enable TMDB', action=argparse.BooleanOptionalAction)
57  parser.add_argument('--cells', help='Reconstruct Tile cells (default depends on if they are needed)', action=argparse.BooleanOptionalAction)
58  parser.add_argument('--clusters', default=False, help='Reconstruct Tile clusters', action=argparse.BooleanOptionalAction)
59  parser.add_argument('--towers', default=False, help='Reconstruct Tile towers', action=argparse.BooleanOptionalAction)
60  parser.add_argument('--muonfit', default=False, help='Reconstruct Tile MuonFit', action=argparse.BooleanOptionalAction)
61  parser.add_argument('--muid', default=False, help='Reconstruct Tile MuID', action=argparse.BooleanOptionalAction)
62  parser.add_argument('--pool', default=False, help='Create output POOL file', action=argparse.BooleanOptionalAction)
63  parser.add_argument('--jivexml', default=False, help='Create output Jive XML files for Atlantis', action=argparse.BooleanOptionalAction)
64  parser.add_argument('--d3pd', default=False, help='Create output D3PD file', action=argparse.BooleanOptionalAction)
65 
66  # Set up Tile h2000 ntuple
67  ntuple = parser.add_argument_group('Tile h2000 ntuple')
68  ntuple.add_argument('--ntuple', default=True, help='Create Tile h2000 ntuple', action=argparse.BooleanOptionalAction)
69  ntuple.add_argument('--reduced-ntuple', dest='reduced_ntuple', action='store_true', help='No Tile raw cahnnel container (including DSP) in h2000 ntuple')
70 
71  # Set up Tile monitoring
72  mon = parser.add_argument_group('Tile monitoring')
73  mon.add_argument('--mon', default=False, help='Run Tile monitoring', action=argparse.BooleanOptionalAction)
74  mon.add_argument('--postprocessing', default=True, help='Run Tile monitoring postprocessing', action=argparse.BooleanOptionalAction)
75  mon.add_argument('--digits-mon', dest='digits_mon', default=True, help='Run Tile digits monitoring', action=argparse.BooleanOptionalAction)
76  mon.add_argument('--channel-mon', dest='channel_mon', default=True, help='Run Tile raw channles monitoring', action=argparse.BooleanOptionalAction)
77  mon.add_argument('--channel-time-mon', dest='channel_time_mon', default=None, help='Run Tile raw channles time monitoring', action=argparse.BooleanOptionalAction)
78  mon.add_argument('--tmdb-mon', dest='tmdb_mon', default=True, help='Run TMDB monitoring', action=argparse.BooleanOptionalAction)
79  mon.add_argument('--tmdb-digits-mon', dest='tmdb_digits_mon', default=True, help='Run TMDB digits monitoring', action=argparse.BooleanOptionalAction)
80  mon.add_argument('--tmdb-channel-mon', dest='tmdb_channel_mon', default=True, help='Run TMDB raw channels monitoring', action=argparse.BooleanOptionalAction)
81  mon.add_argument('--digi-noise-mon', dest='digi_noise_mon', help='Run Tile digi noise monitoring (default: True for pedestals run)', action=argparse.BooleanOptionalAction)
82  mon.add_argument('--cell-mon', dest='cell_mon', help='Run Tile Cell monitoring (default: True for physics run)', action=argparse.BooleanOptionalAction)
83  mon.add_argument('--dq-mon', dest='dq_mon', default=True, help='Run Tile DQ monitoring for physics run', action=argparse.BooleanOptionalAction)
84 
85  # Set up Tile run type
86  run_type_group = parser.add_argument_group('Tile Run Type')
87  run_type = run_type_group.add_mutually_exclusive_group()
88  run_type.add_argument('--cis', action='store_true', help='Tile CIS run type')
89  run_type.add_argument('--mono-cis', action='store_true', dest='mono_cis', help='Tile mono CIS run type')
90  run_type.add_argument('--gap-cis', action='store_true', dest='gap_cis', help='Tile gap CIS run type')
91  run_type.add_argument('--laser', action='store_true', help='Tile laser run type')
92  run_type.add_argument('--gap-laser', action='store_true', dest='gap_laser', help='Tile gap laser run type')
93  run_type.add_argument('--pedestals', action='store_true', help='Tile pedestals run type')
94  run_type.add_argument('--physics', action='store_true', help='Tile physics run type')
95 
96  # Set up Tile reconstuction method
97  method = parser.add_argument_group('Tile reconstuction method')
98  method.add_argument('--opt2', default=True, help='Use Tile Opt2 reconstuction method', action=argparse.BooleanOptionalAction)
99  method.add_argument('--opt-atlas', dest='opt_atlas', default=True, help='Use Tile OptATLAS reconstuction method', action=argparse.BooleanOptionalAction)
100  method.add_argument('--fit', default=True, help='Use Tile Fit reconstuction method', action=argparse.BooleanOptionalAction)
101  method.add_argument('--of1', default=False, help='Use Tile OF1 reconstuction method', action=argparse.BooleanOptionalAction)
102  method.add_argument('--mf', default=False, help='Use Tile MF reconstuction method', action=argparse.BooleanOptionalAction)
103 
104  run_period_group = parser.add_argument_group('LHC Run period')
105  run_period = run_period_group.add_mutually_exclusive_group()
106  run_period.add_argument('--run2', action='store_true', help='LHC Run2 period')
107  run_period.add_argument('--run3', action='store_true', help='LHC Run3 period')
108 
109  parser.add_argument('--upd4', action='store_true', help='Use UPD4 conditions')
110 
111  return parser
112 
113 
114 def useTagFor(tag, folder):
115  ''' Function to override tag for DB folder (it should be used in --postExec) '''
116  fullTag = f'{folder.title().replace("/","")}-{tag}' if folder.startswith('/TILE') and not tag.startswith('Tile') else tag
117  from AthenaCommon.Logging import log
118  log.info(f'Use tag {fullTag} for folder: {folder}')
119  cfg.getService('IOVDbSvc').overrideTags += [f'<prefix>{folder}</prefix> <tag>{fullTag}</tag>']
120 
121 def useSqliteFor(sqliteFile, folder):
122  ''' Function to use Sqlite file for DB folder (it should be used in --postExec) '''
123  iovDbSvc = cfg.getService('IOVDbSvc')
124  from AthenaCommon.Logging import log
125  log.info(f'Use Sqlite file {sqliteFile} for folder: {folder}')
126  iovDbSvc.overrideTags += [f'<prefix>{folder}</prefix> <db>sqlite://;schema={sqliteFile};dbname={iovDbSvc.DBInstance}</db>']
127 
128 def useSqliteAndTagFor(sqliteFile, tag, folder):
129  ''' Function to use tag from Sqlite file for DB folder (it should be used in --postExec) '''
130  useSqliteFor(sqliteFile, folder)
131  useTagFor(tag, folder)
132 
133 if __name__=='__main__':
134  import sys,os
135 
136  from AthenaConfiguration.AllConfigFlags import initConfigFlags
137  flags = initConfigFlags()
138 
139  # Setup logs
140  from AthenaCommon.Logging import log
141  from AthenaCommon import Constants
142  log.setLevel(Constants.INFO)
143 
144  parser = getArgumentParser(flags)
145  args, _ = parser.parse_known_args()
146 
147  # Initially the following flags are not set up (they must be provided)
148  flags.Input.Files = []
149  flags.Tile.RunType = TileRunType.UNDEFINED
150 
151  # Initial configuration flags from command line arguments (to be used to set up defaults)
152  flags.fillFromArgs(parser=parser)
153 
154  # =======>>> Set up the Athena configuration flags to defaults (can be overriden via comand line)
155 
156  # Set up the Tile input files
157  if not flags.Input.Files and args.run:
158  flags.Input.Files = TileInputFiles.findFilesFromAgruments(args)
159  if not flags.Input.Files:
160  log.error('Input files must be provided! For example: --filesInput=file1,file2,... or --run RUNNUMBER')
161  sys.exit(-1)
162 
163  # Set up the Tile run type using arguments if it was not set up via configuration flags
164  if flags.Tile.RunType is TileRunType.UNDEFINED:
165  if args.cis:
166  flags.Tile.RunType = TileRunType.CIS
167  elif args.mono_cis:
168  flags.Tile.RunType = TileRunType.MONOCIS
169  elif args.gap_cis:
170  flags.Tile.RunType = TileRunType.GAPCIS
171  elif args.laser:
172  flags.Tile.RunType = TileRunType.LAS
173  elif args.gap_laser:
174  flags.Tile.RunType = TileRunType.GAPLAS
175  elif args.pedestals:
176  flags.Tile.RunType = TileRunType.PED
177  elif args.physics:
178  flags.Tile.RunType = TileRunType.PHY
179  else:
180  log.error('The Tile Run Type must be provided! For example: --laser or --cis, ..., or Tile.RunType=TileRunType.PED')
181  sys.exit(-1)
182 
183  if flags.Tile.RunType not in [TileRunType.PHY, TileRunType.CIS]:
184  flags.Exec.SkipEvents = 1
185  elif flags.Tile.RunType is TileRunType.CIS:
186  flags.Exec.SkipEvents = 192 # skip all events when just one channel is fired (4*48)
187 
188  # Set up Tile reconstuction method
189  flags.Tile.doOpt2 = args.opt2
190  flags.Tile.doOptATLAS = args.opt_atlas
191  flags.Tile.doFit = args.fit
192  flags.Tile.doOF1 = args.of1
193  flags.Tile.doMF = args.mf
194 
195  flags.Tile.BestPhaseFromCOOL = True
196  flags.Tile.NoiseFilter = 0 # disable noise filter by default
197  flags.Tile.doOverflowFit = False
198  flags.Tile.correctAmplitude = False
199  flags.Tile.correctTime = flags.Tile.RunType in [TileRunType.PHY, TileRunType.GAPLAS, TileRunType.GAPCIS]
200  flags.Tile.OfcFromCOOL = flags.Tile.RunType in [TileRunType.PHY, TileRunType.PED]
201 
202  runNumber = flags.Input.RunNumbers[0]
203 
204  # Set up LHC Run period
205  if not any([args.run2, args.run3]):
206  if not flags.Input.isMC:
207  if runNumber >= 411938:
208  args.run3 = True
209  elif any([args.year and args.year > 2014, runNumber > 232000, flags.Input.ProjectName.startswith("data15_")]):
210  args.run2 = True
211 
212  # Set up the DB global conditions tag
213  if flags.Input.Format is Format.BS:
214  if args.run3:
215  condDbTag = 'CONDBR2-BLKPA-2023-01' if args.upd4 else 'CONDBR2-ES1PA-2023-01'
216  detDescrVersion = 'ATLAS-R3S-2021-03-01-00'
217  elif args.run2:
218  condDbTag = 'CONDBR2-BLKPA-2018-16' if args.upd4 else 'CONDBR2-ES1PA-2018-05'
219  detDescrVersion = 'ATLAS-R2-2016-01-00-01'
220  else:
221  condDbTag = 'COMCOND-BLKPA-RUN1-06' if (args.upd4 and runNumber > 141066) else 'COMCOND-ES1PA-006-05'
222  detDescrVersion = 'ATLAS-R1-2012-03-02-00'
223 
224  flags.IOVDb.GlobalTag = condDbTag
225  flags.GeoModel.AtlasVersion = detDescrVersion
226 
227  if args.mon:
228  flags.DQ.useTrigger = False
229  flags.DQ.enableLumiAccess = False
230  if not flags.Output.HISTFileName:
231  flags.Output.HISTFileName = f'{args.outputDirectory}/tilemon_{runNumber}_{args.outputVersion}.root'
232 
233  if args.tmdb is None:
234  args.tmdb = not flags.Input.isMC
235 
236  if args.channel_time_mon is None:
237  args.channel_time_mon = flags.Tile.RunType in [TileRunType.GAPLAS, TileRunType.GAPCIS] and (args.run2 or args.run3) and flags.Tile.doFit
238 
239  if args.pool:
240  flags.Output.ESDFileName = f'tile_{runNumber}_{args.outputVersion}.pool.root'
241 
242  if args.jivexml:
243  flags.Output.doJiveXML = True
244 
245  # Override default configuration flags from command line arguments
246  flags.fillFromArgs(parser=parser)
247 
248  if args.dumpArguments:
249  log.info('=====>>> FINAL ARGUMENTS FOLLOW:')
250  print('{:40} : {}'.format('Argument Name', 'Value'))
251  for a,v in (vars(args)).items():
252  print(f'{a:40} : {v}')
253  sys.exit(0)
254 
255  flags.needFlagsCategory('Tile')
256 
257  if args.preExec:
258  log.info('Executing preExec: %s', args.preExec)
259  exec(args.preExec)
260 
261  flags.lock()
262 
263  log.info('=====>>> FINAL CONFIG FLAGS SETTINGS FOLLOW:')
264  flags.dump(pattern='Tile.*|Input.*|Exec.*|IOVDb.[D|G].*', evaluate=True)
265 
266  biGainRun = flags.Tile.RunType.isBiGain()
267 
268  # =======>>> Set up default arguments
269  cellsAvailable = (flags.Input.Format is Format.POOL and 'AllCalo' in flags.Input.Collections)
270  if args.cells is None:
271  args.cells = not cellsAvailable and (args.towers or args.clusters or args.muid or args.muonfit
272  or args.jivexml or args.d3pd or args.pool
273  or flags.Tile.RunType is TileRunType.PHY)
274  cellsAvailable = cellsAvailable or args.cells
275 
276  if args.cell_mon is None:
277  args.cell_mon = cellsAvailable and flags.Tile.RunType is TileRunType.PHY
278 
279  if args.digi_noise_mon is None:
280  args.digi_noise_mon = flags.Tile.RunType is TileRunType.PED
281 
282  # Initialize configuration object, add accumulator, merge, and run.
283  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
284  cfg = MainServicesCfg(flags)
285 
286  # =======>>> Set up the File (BS | POOL) reading
287  if flags.Input.Format is Format.BS:
288  # Configure reading the Tile BS files
289  from TileByteStream.TileByteStreamConfig import TileRawDataReadingCfg
290  cfg.merge( TileRawDataReadingCfg(flags, readMuRcv=args.ntuple,
291  readMuRcvDigits=any([args.tmdb_digits_mon, args.tmdb_mon, args.ntuple]),
292  readMuRcvRawCh=any([args.tmdb_channel_mon, args.tmdb_mon, args.ntuple])) )
293 
294  else:
295  # Configure reading POOL files
296  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
297  cfg.merge(PoolReadCfg(flags))
298 
299  # =======>>> Set up the Tile raw channel maker only if readDigits is set
300  if flags.Tile.readDigits:
301  from TileRecUtils.TileRawChannelMakerConfig import TileRawChannelMakerCfg
302  cfg.merge( TileRawChannelMakerCfg(flags) )
303  rawChMaker = cfg.getEventAlgo('TileRChMaker')
304  if args.threads and (args.threads > 1):
305  rawChMaker.Cardinality = args.threads
306  for builderTool in rawChMaker.TileRawChannelBuilder:
307  builderTool.UseDSPCorrection = not biGainRun
308 
309  # =======>>> Set up the Tile cell maker
310  if args.cells:
311  from TileRecUtils.TileCellMakerConfig import TileCellMakerCfg
312  if biGainRun:
313  cfg.merge( TileCellMakerCfg(flags, SkipGain=0, mergeChannels=False) )
314  cfg.merge( TileCellMakerCfg(flags, SkipGain=1, mergeChannels=False) )
315  else:
316  cfg.merge( TileCellMakerCfg(flags, mergeChannels=False) )
317 
318  # =======>>> Set up the Tile clusters maker
319  if args.clusters:
320  from TileMonitoring.TileTopoClusterConfig import TileTopoClusterCfg
321  cfg.merge( TileTopoClusterCfg(flags) )
322 
323  # =======>>> Set up the Tile muon fitter
324  if args.muonfit:
325  from TileCosmicAlgs.TileMuonFitterConfig import TileMuonFitterCfg
326  cfg.merge( TileMuonFitterCfg(flags) )
327 
328  # =======>>> Set up the Tile muon ID reconstuction
329  if args.muid:
330  from TileMuId.TileMuIdConfig import TileLookForMuAlgCfg
331  cfg.merge( TileLookForMuAlgCfg(flags) )
332 
333  # =======>>> Set up the Tile raw channel to hit algorithm
334  if flags.Output.doWriteESD:
335  from TileRecAlgs.TileRawChannelToHitConfig import TileRawChannelToHitCfg
336  cfg.merge( TileRawChannelToHitCfg(flags) )
337 
338  # =======>>> Set up the Tile Ntuple
339  if args.ntuple:
340  ntupleFile = f'{args.outputDirectory}/tile_{runNumber}_{args.outputVersion}.aan.root'
341  from TileRec.TileAANtupleConfig import TileAANtupleCfg
342  cfg.merge( TileAANtupleCfg(flags, outputFile=ntupleFile) )
343  tileNtuple = cfg.getEventAlgo('TileNtuple')
344  # CompressionSettings: algorithm * 100 + level
345  tileNtuple.CompressionSettings = 204
346  tileNtuple.SkipEvents = 4 if flags.Tile.RunType is TileRunType.LAS else 0
347  tileNtuple.TileRawChannelContainerOpt = "TileRawChannelOpt2" if flags.Tile.doOpt2 else ""
348  tileNtuple.TileRawChannelContainerDsp = "" if biGainRun else "TileRawChannelCnt"
349  if args.reduced_ntuple:
350  tileNtuple.Reduced = True
351  tileNtuple.TileRawChannelContainer = ""
352  if flags.Tile.RunType is TileRunType.LAS:
353  tileNtuple.OfflineUnits = 1 # use pCb units for ntuple
354  if flags.Tile.RunType in [TileRunType.GAPLAS, TileRunType.GAPCIS]:
355  tileNtuple.TileDigitsContainerFlt = "TileDigitsCnt"
356  tileNtuple.TileDigitsContainer = "" # do not save various error bits
357 
358  # =======>>> Set up the Tile monitoring
359  if args.mon:
360 
362  for tool in alg.GMTools:
363  tool.Histograms = [h.replace('OFFLINE','ONLINE') for h in tool.Histograms]
364 
365  if args.digits_mon:
366  from TileMonitoring.TileDigitsMonitorAlgorithm import TileDigitsMonitoringConfig
367  cfg.merge(TileDigitsMonitoringConfig(flags))
368  setOnlineEnvironment(cfg.getEventAlgo('TileDigitsMonAlg'))
369 
370  if args.channel_mon:
371  from TileMonitoring.TileRawChannelMonitorAlgorithm import TileRawChannelMonitoringConfig
372  cfg.merge(TileRawChannelMonitoringConfig(flags))
373  setOnlineEnvironment(cfg.getEventAlgo('TileRawChannelMonAlg'))
374 
375  if args.channel_time_mon:
376  from TileMonitoring.TileRawChannelTimeMonitorAlgorithm import TileRawChannelTimeMonitoringConfig
377  cfg.merge(TileRawChannelTimeMonitoringConfig(flags))
378  setOnlineEnvironment(cfg.getEventAlgo('TileRawChanTimeMonAlg'))
379 
380  if args.tmdb_digits_mon:
381  from TileMonitoring.TileTMDBDigitsMonitorAlgorithm import TileTMDBDigitsMonitoringConfig
382  cfg.merge(TileTMDBDigitsMonitoringConfig(flags))
383  setOnlineEnvironment(cfg.getEventAlgo('TileTMDBDigitsMonAlg'))
384 
385  if args.tmdb_channel_mon:
386  from TileMonitoring.TileTMDBRawChannelMonitorAlgorithm import TileTMDBRawChannelMonitoringConfig
387  cfg.merge(TileTMDBRawChannelMonitoringConfig(flags))
388  setOnlineEnvironment(cfg.getEventAlgo('TileTMDBRawChanDspMonAlg'))
389 
390  if args.tmdb_mon:
391  from TileMonitoring.TileTMDBMonitorAlgorithm import TileTMDBMonitoringConfig
392  cfg.merge(TileTMDBMonitoringConfig(flags))
393  setOnlineEnvironment(cfg.getEventAlgo('TileTMDBMonAlg'))
394 
395  if args.dq_mon and flags.Tile.RunType is TileRunType.PHY and flags.Tile.readDigits:
396  from TileMonitoring.TileDQFragMonitorAlgorithm import TileDQFragMonitoringConfig
397  cfg.merge(TileDQFragMonitoringConfig(flags))
398  setOnlineEnvironment(cfg.getEventAlgo('TileDQMonAlg'))
399 
400  if args.cell_mon:
401  from TileMonitoring.TileCellMonitorAlgorithm import TileCellMonitoringConfig
402  if biGainRun:
403  cfg.merge(TileCellMonitoringConfig(flags, CaloCellContainer='AllCaloHG'))
404  else:
405  cfg.merge(TileCellMonitoringConfig(flags, fillTimeHistograms=True,
406  EnergyThresholdForTime=150.0*MeV))
407  setOnlineEnvironment(cfg.getEventAlgo('TileCellMonAlg'))
408 
409  if args.digi_noise_mon:
410  from TileMonitoring.TileDigiNoiseMonitorAlgorithm import TileDigiNoiseMonitoringConfig
411  triggerTypes = [0x82] if flags.Tile.RunType is TileRunType.PHY else []
412  cfg.merge(TileDigiNoiseMonitoringConfig(flags, TriggerTypes=triggerTypes))
413  setOnlineEnvironment(cfg.getEventAlgo('TileDigiNoiseMonAlg'))
414 
415  if any([args.tmdb_digits_mon, args.tmdb_mon]) and args.postprocessing:
416  from AthenaCommon.Utils.unixtools import find_datafile
417  configurations = []
418  dataPath = find_datafile('TileMonitoring')
419  if any([args.tmdb_digits_mon, args.tmdb_mon]):
420  configurations += [os.path.join(dataPath, 'TileTMDBPostProc.yaml')]
421  if args.digits_mon:
422  configurations += [os.path.join(dataPath, 'TileDigitsPostProc.yaml')]
423  if args.channel_mon:
424  if flags.Tile.RunType in [TileRunType.CIS]:
425  configurations += [os.path.join(dataPath, 'TileRawChanCisPostProc.yaml')]
426  else:
427  configurations += [os.path.join(dataPath, 'TileRawChanPostProc.yaml')]
428  if flags.Tile.RunType is TileRunType.LAS:
429  configurations += [os.path.join(dataPath, 'TileRawChanLasPostProc.yaml')]
430  if not biGainRun:
431  configurations += [os.path.join(dataPath, 'TileRawChanDspPostProc.yaml')]
432 
433  from DataQualityUtils.DQPostProcessingAlg import DQPostProcessingAlg
434  class TileMonPostProcessingAlg(DQPostProcessingAlg):
435  def initialize(self):
436  if hasattr(self, 'OutputLevel'):
437  self.msg.setLevel(self.OutputLevel)
438  return super(TileMonPostProcessingAlg, self).initialize()
439 
440  ppa = TileMonPostProcessingAlg("TileMonPostProcessingAlg")
441  ppa.OutputLevel = flags.Exec.OutputLevel
442  ppa.ExtraInputs = {( 'xAOD::EventInfo' , 'StoreGateSvc+EventInfo' )}
443  ppa.Interval = 1000000 # Big number (>evtMax) to do postprocessing during finalization
444  ppa.ConfigFiles = configurations
445  ppa._ctr = 1 # Start postprocessing only after specified number of events (not during the first one)
446  ppa.FileKey = f'/{flags.DQ.FileKey}/'
447 
448  cfg.addEventAlgo(ppa, sequenceName='AthEndSeq')
449 
450 
451  # =======>>> Set up the Tile calibration
452  if args.calib:
453  if flags.Tile.RunType is TileRunType.LAS:
454  laserCalibFile = f'tileCalibLAS_{runNumber}_{args.outputVersion}.root'
455  from TileCalibAlgs.TileLaserCalibAlgConfig import TileLaserCalibAlgCfg
456  cfg.merge( TileLaserCalibAlgCfg(flags, FileName=laserCalibFile) )
457 
458  elif flags.Tile.RunType is TileRunType.CIS:
459  cisCalibFile = f'tileCalibCIS_{runNumber}_{args.outputVersion}.root'
460  from TileCalibAlgs.TileCisCalibAlgConfig import TileCisCalibAlgCfg
461  cfg.merge( TileCisCalibAlgCfg(flags, FileName=cisCalibFile) )
462 
463  elif flags.Tile.RunType in [TileRunType.PHY, TileRunType.PED]:
464  defaultVersions = ['0', 'Ped.0', 'Ped']
465 
466  fileVersion = f'_{flags.Tile.NoiseFilter}' if flags.Tile.NoiseFilter > 0 else ""
467  if args.outputVersion not in defaultVersions:
468  fileVersion = f'_{args.outputVersion}_tnf{flags.Tile.NoiseFilter}'
469 
470  from TileCalibAlgs.TileRawChNoiseCalibAlgConfig import TileRawChNoiseCalibAlgCfg
471  cfg.merge( TileRawChNoiseCalibAlgCfg(flags) )
472  rawChanNoiseCalibAlg = cfg.getEventAlgo('TileRawChNoiseCalibAlg')
473  rawChanNoiseCalibAlg.FileNamePrefix = f'{args.outputDirectory}/RawCh_NoiseCalib{fileVersion}'
474  if flags.Input.isMC:
475  rawChanNoiseCalibAlg.doFit = False
476  rawChanNoiseCalibAlg.doFixed = False
477  rawChanNoiseCalibAlg.doOpt = False
478  rawChanNoiseCalibAlg.doDsp = True
479  rawChanNoiseCalibAlg.UseforCells = 3 # i.e. from TileRawChannelCnt (like DSP)
480  else:
481  rawChanNoiseCalibAlg.doDsp = (flags.Tile.RunType is TileRunType.PHY)
482  rawChanNoiseCalibAlg.UseforCells = 1 # 1= Fixed , 2= Opt2
483 
484  # Produce digi noise ntuple only for default version
485  if args.outputVersion in defaultVersions:
486  from TileCalibAlgs.TileDigiNoiseCalibAlgConfig import TileDigiNoiseCalibAlgCfg
487  cfg.merge( TileDigiNoiseCalibAlgCfg(flags) )
488  digiNoiseCalibAlg = cfg.getEventAlgo('TileDigiNoiseCalibAlg')
489  digiNoiseCalibAlg.DoAvgCorr = False # False=> Full AutoCorr matrix calculation
490  rawChanNoiseCalibAlg.FileNamePrefix = f'{args.outputDirectory}/Digi_NoiseCalib{fileVersion}'
491 
492 
493  # =======>>> Set up the Tile output Jive XML files
494  if flags.Output.doJiveXML:
495  from TileMonitoring.TileJiveXMLConfig import TileAlgoJiveXMLCfg
496  cfg.merge(TileAlgoJiveXMLCfg(flags))
497 
498 
499  # =======>>> Set up the Tile output D3PD file
500  if args.d3pd:
501  d3pdFile = f'{args.outputDirectory}/tile_{runNumber}_{args.outputVersion}.aan.root'
502  from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
503  D3PDMakerFlags.DoTruth = flags.Input.isMC
504  from TileRecEx.TileD3PDConfig import TileD3PDCfg
505  cfg.merge( TileD3PDCfg(flags,
506  outputFile=d3pdFile,
507  saveCells=cellsAvailable,
508  saveMBTS=cellsAvailable,
509  saveE4pr=args.run2,
510  saveMuId=args.muid,
511  saveMuonFitter=args.muonfit,
512  saveClusters=args.clusters,
513  saveEventInfo=(flags.Tile.RunType is TileRunType.PHY)) )
514 
515  # =======>>> Set up the Tile output POOL file
516  if flags.Output.doWriteESD:
517  outputItemList = ["TileHitVector#*"]
518  outputItemList += ["TileDigitsContainer#*"]
519  outputItemList += ["TileBeamElemContainer#*"]
520  outputItemList += ["TileRawChannelContainer#*"]
521  outputItemList += ["TileCellContainer#*"]
522  outputItemList += ["CaloCellContainer#*"]
523  outputItemList += [ "TileMuContainer#*" ]
524  outputItemList += [ "TileL2Container#*" ]
525  outputItemList += [ "TileCosmicMuonContainer#*" ]
526 
527  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
528  cfg.merge( OutputStreamCfg(flags, streamName='ESD', ItemList=outputItemList) )
529 
530  # =======>>> Any last things to do?
531  if args.postExec:
532  log.info('Executing postExec: %s', args.postExec)
533  exec(args.postExec)
534 
535  cfg.printConfig(withDetails=args.printDetailedConfig)
536 
537  sc = cfg.run()
538  sys.exit(0 if sc.isSuccess() else 1)
TileInputFiles.getArgumentParser
def getArgumentParser(**kwargs)
Definition: TileInputFiles.py:144
TileRawChannelToHitConfig.TileRawChannelToHitCfg
def TileRawChannelToHitCfg(flags, **kwargs)
Definition: TileRawChannelToHitConfig.py:9
RunTileCalibRec.getArgumentParser
def getArgumentParser(flags)
Definition: RunTileCalibRec.py:39
SystemOfUnits
TileTMDBRawChannelMonitorAlgorithm.TileTMDBRawChannelMonitoringConfig
def TileTMDBRawChannelMonitoringConfig(flags, MuRcvRawChCnt="MuRcvRawChCnt", FillRawChannelHistograms=True, FillEfficiencyHistograms=False, **kwargs)
Definition: TileTMDBRawChannelMonitorAlgorithm.py:48
vtune_athena.format
format
Definition: vtune_athena.py:14
TileAANtupleConfig.TileAANtupleCfg
def TileAANtupleCfg(flags, outputFile='', saveTMDB=True, **kwargs)
Definition: TileAANtupleConfig.py:15
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
TileJiveXMLConfig.TileAlgoJiveXMLCfg
def TileAlgoJiveXMLCfg(flags, TileDigitsContainer=None, TileRawChannelContainer=None, CaloClusterContainer='TileTopoCluster', **kwargs)
Definition: TileJiveXMLConfig.py:57
TileRawChNoiseCalibAlgConfig.TileRawChNoiseCalibAlgCfg
def TileRawChNoiseCalibAlgCfg(flags, **kwargs)
Definition: TileRawChNoiseCalibAlgConfig.py:8
RunTileCalibRec.setOnlineEnvironment
def setOnlineEnvironment(alg)
Definition: RunTileCalibRec.py:361
TileLaserCalibAlgConfig.TileLaserCalibAlgCfg
def TileLaserCalibAlgCfg(flags, **kwargs)
Definition: TileLaserCalibAlgConfig.py:55
TileTMDBMonitorAlgorithm.TileTMDBMonitoringConfig
def TileTMDBMonitoringConfig(flags, **kwargs)
Definition: TileTMDBMonitorAlgorithm.py:12
TileDigitsMonitorAlgorithm.TileDigitsMonitoringConfig
def TileDigitsMonitoringConfig(flags, **kwargs)
Definition: TileDigitsMonitorAlgorithm.py:11
TileCellMakerConfig.TileCellMakerCfg
def TileCellMakerCfg(flags, mergeChannels=True, **kwargs)
Definition: TileCellMakerConfig.py:32
RunTileCalibRec.TileMonPostProcessingAlg
Definition: RunTileCalibRec.py:434
TileRawChannelMonitorAlgorithm.TileRawChannelMonitoringConfig
def TileRawChannelMonitoringConfig(flags, overlapHistograms=None, **kwargs)
Definition: TileRawChannelMonitorAlgorithm.py:11
pool::DbPrintLvl::setLevel
void setLevel(MsgLevel l)
Definition: DbPrint.h:32
RunTileCalibRec.useTagFor
def useTagFor(tag, folder)
Definition: RunTileCalibRec.py:114
TileInputFiles.findFilesFromAgruments
def findFilesFromAgruments(args)
Definition: TileInputFiles.py:133
RunTileCalibRec.TileMonPostProcessingAlg.initialize
def initialize(self)
Definition: RunTileCalibRec.py:435
LArG4FSStartPointFilter.exec
exec
Definition: LArG4FSStartPointFilter.py:103
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
TileCellMonitorAlgorithm.TileCellMonitoringConfig
def TileCellMonitoringConfig(flags, **kwargs)
Definition: TileCellMonitorAlgorithm.py:8
TileCisCalibAlgConfig.TileCisCalibAlgCfg
def TileCisCalibAlgCfg(flags, **kwargs)
Definition: TileCisCalibAlgConfig.py:43
TileTopoClusterConfig.TileTopoClusterCfg
def TileTopoClusterCfg(flags, **kwargs)
Definition: TileTopoClusterConfig.py:11
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
TileDigiNoiseCalibAlgConfig.TileDigiNoiseCalibAlgCfg
def TileDigiNoiseCalibAlgCfg(flags, **kwargs)
Definition: TileDigiNoiseCalibAlgConfig.py:8
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
TileD3PDConfig.TileD3PDCfg
def TileD3PDCfg(flags, outputFile=None, saveCells=True, saveMBTS=True, saveE4pr=False, saveClusters=False, saveMuId=False, saveMuonFit=False, savePosition=True, saveEventInfo=False, **kwargs)
Definition: TileD3PDConfig.py:24
RunTileCalibRec.useSqliteFor
def useSqliteFor(sqliteFile, folder)
Definition: RunTileCalibRec.py:121
TileDigiNoiseMonitorAlgorithm.TileDigiNoiseMonitoringConfig
def TileDigiNoiseMonitoringConfig(flags, **kwargs)
Definition: TileDigiNoiseMonitorAlgorithm.py:8
TileTMDBDigitsMonitorAlgorithm.TileTMDBDigitsMonitoringConfig
def TileTMDBDigitsMonitoringConfig(flags)
Definition: TileTMDBDigitsMonitorAlgorithm.py:10
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
TileDQFragMonitorAlgorithm.TileDQFragMonitoringConfig
def TileDQFragMonitoringConfig(flags, **kwargs)
Definition: TileDQFragMonitorAlgorithm.py:10
TileByteStreamConfig.TileRawDataReadingCfg
def TileRawDataReadingCfg(flags, readDigits=True, readRawChannel=True, readMuRcv=None, readMuRcvDigits=False, readMuRcvRawCh=False, readBeamElem=None, readLaserObj=None, readDigitsFlx=False, readL2=False, stateless=False, **kwargs)
Definition: TileByteStreamConfig.py:87
RunTileCalibRec.useSqliteAndTagFor
def useSqliteAndTagFor(sqliteFile, tag, folder)
Definition: RunTileCalibRec.py:128
TileRawChannelMakerConfig.TileRawChannelMakerCfg
def TileRawChannelMakerCfg(flags, **kwargs)
Definition: TileRawChannelMakerConfig.py:10
TileMuIdConfig.TileLookForMuAlgCfg
def TileLookForMuAlgCfg(flags, **kwargs)
Definition: TileMuIdConfig.py:12
TileMuonFitterConfig.TileMuonFitterCfg
def TileMuonFitterCfg(flags, **kwargs)
Definition: TileMuonFitterConfig.py:12
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
python.Utils.unixtools.find_datafile
def find_datafile(fname, pathlist=None, access=os.R_OK)
pathresolver-like helper function --------------------------------------—
Definition: unixtools.py:67
TileRawChannelTimeMonitorAlgorithm.TileRawChannelTimeMonitoringConfig
def TileRawChannelTimeMonitoringConfig(flags, amplitudeFragIDs=None, **kwargs)
Definition: TileRawChannelTimeMonitorAlgorithm.py:11