ATLAS Offline Software
Loading...
Searching...
No Matches
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
5from AthenaConfiguration.ComponentFactory import CompFactory
6from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
7
8if __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
37 for _, value in args._get_kwargs():
38 if value is not None:
39 log.debug(value)
40
41 # Import the flag-container that is the argument to the configuration methods
42 from AthenaConfiguration.AllConfigFlags import initConfigFlags
43 from LArMonitoring.LArMonConfigFlags import addLArMonFlags
44 from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
45 flags=initConfigFlags()
46 flags.addFlagsCategory("LArMon", addLArMonFlags)
47 addLArCalibFlags(flags)
48
49 flags.GeoModel.AtlasVersion = 'ATLAS-R3S-2021-03-02-00'
50 flags.IOVDb.GlobalTag = 'CONDBR2-BLKPA-2023-03'
51
52 if len(args.infile) > 0:
53 flags.Input.Files = [args.infile]
54 elif len(args.inppatt) > 0:
55 from LArCalibProcessing.GetInputFiles import GetInputFilesFromPattern
56 flags.Input.Files = GetInputFilesFromPattern(args.indir,args.inppatt)
57 else:
58 from LArCalibProcessing.GetInputFiles import GetInputFilesFromPrefix
59 flags.Input.Files = GetInputFilesFromPrefix(args.indir,args.inpref)
60
61 if args.run != 0:
62 flags.Input.RunNumbers = [args.run]
63
64 if len(args.febs) > 0:
65 flags.LArMon.customFEBsToMonitor = args.febs
66
67 if args.calib:
68 flags.LArMon.LArDigitKey = args.gain
69 flags.LArMon.calibRun = True
70 else:
71 flags.LArMon.LArDigitKey = 'FREE'
72
73 if len(args.posneg) >= 0:
74 flags.LArCalib.Preselection.Side = args.posneg
75 if len(args.be) >=0:
76 flags.LArCalib.Preselection.BEC = args.be
77 if len(args.ft) > 0:
78 flags.LArCalib.Preselection.FT = args.ft
79
80
81 flags.Output.HISTFileName = args.outfile
82 flags.DQ.enableLumiAccess = False
83 flags.DQ.useTrigger = False
84 flags.lock()
85
86 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
87 cfg = MainServicesCfg(flags)
88 from LArCalibProcessing.LArCalibBaseConfig import LArCalibBaseCfg
89 cfg.merge(LArCalibBaseCfg(flags))
90
91 if args.calib:
92 from LArByteStream.LArRawCalibDataReadingConfig import LArRawCalibDataReadingCfg
93 cfg.merge(LArRawCalibDataReadingCfg(flags,gain=flags.LArMon.LArDigitKey,doDigit=True))
94 else:
95 from LArByteStream.LArRawDataReadingConfig import LArRawDataReadingCfg
96 cfg.merge(LArRawDataReadingCfg(flags,LArDigitKey=flags.LArMon.LArDigitKey))
97 if len(flags.LArCalib.Preselection.Side) > 0 or len(flags.LArCalib.Preselection.BEC) > 0 or len(flags.LArCalib.Preselection.FT) > 0:
98 log.warning('No preselection yet in reading physics data !!!')
99
100 # we need pedestals
101 from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDBCfg
102 cfg.merge(LArElecCalibDBCfg(flags,["Pedestal"]))
103
104 from LArMonitoring.LArNoiseCorrelationMonAlg import LArNoiseCorrelationMonConfig
105 cfg.merge(LArNoiseCorrelationMonConfig(flags))
106
107 if args.cnf:
108 from LArMonitoring.LArNoiseCorrelationMonAlg import LArCoherentNoisefractionConfig
109 cfg.merge(LArCoherentNoisefractionConfig(flags))
110
111 if args.postp:
112 # needs to add postprocessing
113 from DataQualityUtils.DQPostProcessingAlg import DQPostProcessingAlg
114 ppa = DQPostProcessingAlg("DQPostProcessingAlg")
115 ppa.Interval = 1000000 # Big number (>evtMax) to do postprocessing during finalization
116 rn=flags.Input.RunNumber[0]
117 ppa.FileKey = f'/{flags.DQ.FileKey}/run_{rn}/'
118 cfg.addEventAlgo(ppa, sequenceName='AthEndSeq')
119
120 if args.skipev > 0:
121 cfg.getService("EventSelector").SkipEvents=int(args.skipev)
122
123 # and run
124 cfg.run(args.maxev)
125