ATLAS Offline Software
LArNoiseCorrelationMon.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 from AthenaConfiguration.ComponentFactory import CompFactory
6 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
7 
8 if __name__=='__main__':
9 
10  import os,sys
11  import argparse
12  import subprocess
13  from AthenaCommon import Logging
14  log = Logging.logging.getLogger( 'LArNoiseCorrelation' )
15 
16  parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
17  parser.add_argument('-i','--indir', dest='indir', default="/eos/atlas/atlastier0/rucio/data_test/calibration_pulseall/00414414/data_test.00414414.calibration_pulseall.daq.RAW/", help='input files dir', type=str)
18  parser.add_argument('-p','--inprefix', dest='inpref', default="data_test", help='Input filenames prefix', type=str)
19  parser.add_argument('-y','--inppatt', dest='inppatt', default="lb3512", help='Input filenames pattern', type=str)
20  parser.add_argument('-l','--infile', dest='infile', default="", help='Input filename (if given indir and inprefix are ignored', type=str)
21  parser.add_argument('-r','--run', dest='run', default=0, help='Run number (if not given trying to judge from input file name)', type=int)
22  parser.add_argument('-n','--cnf', dest='cnf', default=False, action="store_true", help='Run also CNF computation')
23  parser.add_argument('-c','--calib', dest='calib', default=False, action="store_true", help='Is this calibration run ?')
24  parser.add_argument('-g','--gain', dest='gain', default="HIGH", help='Gain in case of calib. data', type=str)
25  parser.add_argument('-f','--febs', dest='febs', default=[], nargs="+", help='space-separated list of FEB names, which will be monitored', type=str)
26  parser.add_argument('-m','--maxev', dest='maxev', default=-1, help='Max number of events to dump', type=int)
27  parser.add_argument('-s','--skipev', dest='skipev', default=-1, help='events to skip', type=int)
28  parser.add_argument('-x','--outlevel', dest='olevel', default=3, help='OuputLevel for dumping algo', type=int)
29  parser.add_argument('-o','--outfile', dest='outfile', default="LArNoiseCorr.root", help='Output root filename', type=str)
30  parser.add_argument('-a','--postproc', dest='postp', default=False, action="store_true", help='Do a postprocessing ?')
31  parser.add_argument('-t','--FTs', dest='ft', default=[], nargs="+", type=int, help='list of FT which will be read out (space separated).')
32  parser.add_argument('-v','--posneg', dest='posneg', default=[], nargs="+", help='side to read out (-1 means both), can give multiple arguments (space separated). Default %(default)s.', type=int,choices=range(-1,2))
33  parser.add_argument('-b','--barrel_ec', dest='be', default=[], nargs="+", help='subdet to read out (-1 means both), can give multiple arguments (space separated) Default %(default)s.', type=int,choices=range(-1,2))
34 
35  args = parser.parse_args()
36  if args.help:
37  parser.print_help()
38  sys.exit(0)
39 
40  for _, value in args._get_kwargs():
41  if value is not None:
42  log.debug(value)
43 
44  # Import the flag-container that is the argument to the configuration methods
45  from AthenaConfiguration.AllConfigFlags import initConfigFlags
46  from LArMonitoring.LArMonConfigFlags import addLArMonFlags
47  from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
49  flags.addFlagsCategory("LArMon", addLArMonFlags)
50  addLArCalibFlags(flags)
51 
52 
53  if len(args.infile) > 0:
54  flags.Input.Files = [args.infile]
55  elif len(args.inppatt) > 0:
56  from LArCalibProcessing.GetInputFiles import GetInputFilesFromPattern
57  flags.Input.Files = GetInputFilesFromPattern(args.indir,args.inppatt)
58  else:
59  from LArCalibProcessing.GetInputFiles import GetInputFilesFromPrefix
60  flags.Input.Files = GetInputFilesFromPrefix(args.indir,args.inpref)
61 
62  if args.run != 0:
63  flags.Input.RunNumber = [args.run]
64 
65  if len(args.febs) > 0:
66  flags.LArMon.customFEBsToMonitor = args.febs
67 
68  if args.calib:
69  flags.LArMon.LArDigitKey = args.gain
70  flags.LArMon.calibRun = True
71  else:
72  flags.LArMon.LArDigitKey = 'FREE'
73 
74  if len(args.posneg) >= 0:
75  flags.LArCalib.Preselection.Side = args.posneg
76  if len(args.be) >=0:
77  flags.LArCalib.Preselection.BEC = args.be
78  if len(args.ft) > 0:
79  flags.LArCalib.Preselection.FT = args.ft
80 
81 
82  flags.Output.HISTFileName = args.outfile
83  flags.DQ.enableLumiAccess = False
84  flags.DQ.useTrigger = False
85  flags.lock()
86 
87  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
88  cfg = MainServicesCfg(flags)
89  from LArCalibProcessing.LArCalibBaseConfig import LArCalibBaseCfg
90  cfg.merge(LArCalibBaseCfg(flags))
91 
92  if args.calib:
93  from LArByteStream.LArRawCalibDataReadingConfig import LArRawCalibDataReadingCfg
94  cfg.merge(LArRawCalibDataReadingCfg(flags,gain=flags.LArMon.LArDigitKey,doDigit=True))
95  else:
96  from LArByteStream.LArRawDataReadingConfig import LArRawDataReadingCfg
97  cfg.merge(LArRawDataReadingCfg(flags,LArDigitKey=flags.LArMon.LArDigitKey))
98  if len(flags.LArCalib.Preselection.Side) > 0 or len(flags.LArCalib.Preselection.BEC) > 0 or len(flags.LArCalib.Preselection.FT) > 0:
99  log.warning('No preselection yet in reading physics data !!!')
100 
101  # we need pedestals
102  from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDBCfg
103  cfg.merge(LArElecCalibDBCfg(flags,["Pedestal"]))
104 
105  from LArMonitoring.LArNoiseCorrelationMonAlg import LArNoiseCorrelationMonConfig
106  cfg.merge(LArNoiseCorrelationMonConfig(flags))
107 
108  if args.cnf:
109  from LArMonitoring.LArNoiseCorrelationMonAlg import LArCoherentNoisefractionConfig
110  cfg.merge(LArCoherentNoisefractionConfig(flags))
111 
112  if args.postp:
113  # needs to add postprocessing
114  from DataQualityUtils.DQPostProcessingAlg import DQPostProcessingAlg
115  ppa = DQPostProcessingAlg("DQPostProcessingAlg")
116  ppa.Interval = 1000000 # Big number (>evtMax) to do postprocessing during finalization
117  rn=flags.Input.RunNumber[0]
118  ppa.FileKey = f'/{flags.DQ.FileKey}/run_{rn}/'
119  cfg.addEventAlgo(ppa, sequenceName='AthEndSeq')
120 
121  if args.skipev > 0:
122  cfg.getService("EventSelector").SkipEvents=int(args.skipev)
123 
124  # and run
125  cfg.run(args.maxev)
126 
python.LArElecCalibDBConfig.LArElecCalibDBCfg
def LArElecCalibDBCfg(flags, condObjs)
Definition: LArElecCalibDBConfig.py:47
python.LArRawCalibDataReadingConfig.LArRawCalibDataReadingCfg
def LArRawCalibDataReadingCfg(configFlags, gain="HIGH", doAccDigit=False, doAccCalibDigit=False, doCalibDigit=False, doDigit=False)
Definition: LArRawCalibDataReadingConfig.py:8
LArCoherentNoisefractionAlg.LArCoherentNoisefractionConfig
def LArCoherentNoisefractionConfig(inputFlags, groupsToMonitor=[])
Definition: LArCoherentNoisefractionAlg.py:10
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
LArNoiseCorrelationMonAlg.LArNoiseCorrelationMonConfig
def LArNoiseCorrelationMonConfig(flags)
Definition: LArNoiseCorrelationMonAlg.py:4
python.LArRawDataReadingConfig.LArRawDataReadingCfg
def LArRawDataReadingCfg(configFlags, **kwargs)
Definition: LArRawDataReadingConfig.py:10
python.GetInputFiles.GetInputFilesFromPrefix
def GetInputFilesFromPrefix(inputPath, prefix=".*")
Definition: GetInputFiles.py:37
python.LArCalibBaseConfig.LArCalibBaseCfg
def LArCalibBaseCfg(flags)
Definition: LArCalibBaseConfig.py:5
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
LArNoiseCorrelationMon.int
int
Definition: LArNoiseCorrelationMon.py:31
python.GetInputFiles.GetInputFilesFromPattern
def GetInputFilesFromPattern(inputPath, prefix=".*", trigger=".*")
Definition: GetInputFiles.py:32
python.LArCalibConfigFlags.addLArCalibFlags
def addLArCalibFlags(flags, isSC=False)
Definition: LArCalibConfigFlags.py:3