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('-d','--grps', dest='grps', default=[], nargs="+", help='space-separated list of group names, which will be monitored', type=str)
24 parser.add_argument('-c','--calib', dest='calib', default=False, action="store_true", help='Is this calibration run ?')
25 parser.add_argument('-e','--trigsel', dest='trigsel', default=False, action="store_true", help='Do a trigger selection ijn physics runs ')
26 parser.add_argument('-g','--gain', dest='gain', default="HIGH", help='Gain in case of calib. data', type=str)
27 parser.add_argument('-f','--febs', dest='febs', default=[], nargs="+", help='space-separated list of FEB names, which will be monitored', type=str)
28 parser.add_argument('-m','--maxev', dest='maxev', default=-1, help='Max number of events to dump', type=int)
29 parser.add_argument('-s','--skipev', dest='skipev', default=-1, help='events to skip', type=int)
30 parser.add_argument('-x','--outlevel', dest='olevel', default=3, help='OuputLevel for dumping algo', type=int)
31 parser.add_argument('-o','--outfile', dest='outfile', default="LArNoiseCorr.root", help='Output root filename', type=str)
32 parser.add_argument('-a','--postproc', dest='postp', default=False, action="store_true", help='Do a postprocessing ?')
33 parser.add_argument('-t','--FTs', dest='ft', default=[], nargs="+", type=int, help='list of FT which will be read out (space separated).')
34 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))
35 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))
36
37 args = parser.parse_args()
38 if help in args and args.help is not None and args.help:
39 parser.print_help()
40 sys.exit(0)
41
42 for _, value in args._get_kwargs():
43 if value is not None:
44 log.debug(value)
45
46 # Import the flag-container that is the argument to the configuration methods
47 from AthenaConfiguration.AllConfigFlags import initConfigFlags
48 from LArMonitoring.LArMonConfigFlags import addLArMonFlags
49 from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
50 flags=initConfigFlags()
51 flags.addFlagsCategory("LArMon", addLArMonFlags)
52 addLArCalibFlags(flags)
53
54 flags.GeoModel.AtlasVersion = 'ATLAS-R3S-2021-03-02-00'
55 flags.IOVDb.GlobalTag = 'CONDBR2-BLKPA-2023-03'
56
57 if len(args.infile) > 0:
58 flags.Input.Files = [args.infile]
59 elif len(args.inppatt) > 0:
60 from LArCalibProcessing.GetInputFiles import GetInputFilesFromPattern
61 flags.Input.Files = GetInputFilesFromPattern(args.indir,args.inppatt)
62 else:
63 from LArCalibProcessing.GetInputFiles import GetInputFilesFromPrefix
64 flags.Input.Files = GetInputFilesFromPrefix(args.indir,args.inpref)
65
66 if args.run != 0:
67 flags.Input.RunNumbers = [args.run]
68
69 if len(args.febs) > 0:
70 flags.LArMon.customFEBsToMonitor = args.febs
71 elif len(args.posneg) > 0 or len(args.be) > 0 or len(args.ft) > 0:
72 if len(args.be) > 0 and -1 not in args.be:
73 be=args.be
74 else:
75 be=[0,1]
76 if len(args.posneg) > 0 and -1 not in args.posneg:
77 posneg=args.posneg
78 else:
79 be=[0,1]
80
81 if len(args.ft) > 0 and -1 not in args.ft:
82 ft=args.ft
83 else:
84 ft=[-1]
85
86 febs=[]
87 from LArMonitoring.GlobalVariables import lArDQGlobals
88 from ROOT import LArStrHelper
89 larStrHelp=LArStrHelper()
90 for b in be:
91 for p in posneg:
92 if len(ft) == 1 and ft[0] == -1:
93 ftlist=range(0,32) if b==0 else range(0,24)
94 else:
95 ftlist=ft
96 slist = range(1,15) if b==0 else range(1,16)
97 febs += [larStrHelp.febNameString(not bool(b),p,i_ft,i_slot) for i_ft in ftlist for i_slot in slist]
98
99 flags.LArMon.customFEBsToMonitor = febs
100 pass
101
102
103 if args.calib:
104 flags.LArMon.LArDigitKey = args.gain
105 flags.LArMon.calibRun = True
106 else:
107 flags.LArMon.LArDigitKey = 'FREE'
108
109 if len(args.posneg) > 0:
110 flags.LArCalib.Preselection.Side = args.posneg
111 if len(args.be) > 0:
112 flags.LArCalib.Preselection.BEC = args.be
113 if len(args.ft) > 0:
114 flags.LArCalib.Preselection.FT = args.ft
115
116
117 flags.Output.HISTFileName = args.outfile
118 flags.DQ.enableLumiAccess = False
119 flags.DQ.useTrigger = False
120
121 from AthenaConfiguration.TestDefaults import defaultGeometryTags
122 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
123
124 flags.Exec.OutputLevel=args.olevel
125
126 flags.lock()
127
128 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
129 cfg = MainServicesCfg(flags)
130 from LArCalibProcessing.LArCalibBaseConfig import LArCalibBaseCfg
131 cfg.merge(LArCalibBaseCfg(flags))
132
133 if args.calib:
134 from LArByteStream.LArRawCalibDataReadingConfig import LArRawCalibDataReadingCfg
135 cfg.merge(LArRawCalibDataReadingCfg(flags,gain=flags.LArMon.LArDigitKey,doDigit=True))
136 else:
137 from LArByteStream.LArRawDataReadingConfig import LArRawDataReadingCfg
138 cfg.merge(LArRawDataReadingCfg(flags,LArDigitKey=flags.LArMon.LArDigitKey))
139
140 # we need pedestals
141 from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDBCfg
142 cfg.merge(LArElecCalibDBCfg(flags,["Pedestal"]))
143
144 from LArMonitoring.LArNoiseCorrelationMonAlg import LArNoiseCorrelationMonConfig
145 cfg.merge(LArNoiseCorrelationMonConfig(flags))
146
147 if args.cnf:
148 from LArMonitoring.LArCoherentNoisefractionAlg import LArCoherentNoisefractionConfig
149 cfg.merge(LArCoherentNoisefractionConfig(flags,groupsToMonitor=args.grps, doTrigSel=args.trigsel))
150
151 if args.postp:
152 # needs to add postprocessing
153 from DataQualityUtils.DQPostProcessingAlg import DQPostProcessingAlg
154 ppa = DQPostProcessingAlg("DQPostProcessingAlg")
155 ppa.Interval = 1000000 # Big number (>evtMax) to do postprocessing during finalization
156 rn=flags.Input.RunNumbers[0]
157 ppa.FileKey = f'/{flags.DQ.FileKey}/run_{rn}/'
158 cfg.addEventAlgo(ppa, sequenceName='AthEndSeq')
159
160 if args.skipev > 0:
161 cfg.getService("EventSelector").SkipEvents=int(args.skipev)
162
163 cfg.getService("MessageSvc").OutputLevel=args.olevel
164 # and run
165 cfg.run(args.maxev)
166
Helper class to manipulate strings for LArOnlineID names.