6 if __name__==
'__main__':
12 parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
14 parser.add_argument(
'-r',
'--run', dest=
'run', default=
'00408918', help=
'Run number string as in input filename', type=str)
15 parser.add_argument(
'-g',
'--gain', dest=
'gain', default=
"MEDIUM", help=
'Gain string', type=str)
16 parser.add_argument(
'-p',
'--partition', dest=
'partition', default=
"Em", help=
'Data taking partition string', type=str)
17 parser.add_argument(
'-f',
'--fileprefix', dest=
'fprefix', default=
"data24_calib", help=
'File prefix string', type=str)
18 parser.add_argument(
'-i',
'--indirprefix', dest=
'dprefix', default=
"/eos/atlas/atlastier0/rucio/", help=
'Input directory prefix string', type=str)
19 parser.add_argument(
'-d',
'--indir', dest=
'indir', default=
"", help=
'Full input dir string', type=str)
20 parser.add_argument(
'-t',
'--trigger', dest=
'trig', default=
'calibration_', help=
'Trigger string in filename', type=str)
21 parser.add_argument(
'-o',
'--outrwaveprefix', dest=
'outrwaveprefix', default=
"LArCaliWave", help=
'Prefix of CaliWave output root filename', type=str)
22 parser.add_argument(
'-l',
'--outpprefix', dest=
'outpprefix', default=
"LArCaliWave_OFC_Cali", help=
'Prefix of output pool filename', type=str)
23 parser.add_argument(
'-j',
'--outrofcprefix', dest=
'outrofcprefix', default=
"LArOFCCali", help=
'Prefix of output Cali OFC root filename', type=str)
24 parser.add_argument(
'-e',
'--outrdir', dest=
'outrdir', default=
"/eos/atlas/atlascerngroupdisk/det-larg/Temp/Weekly/ntuples", help=
'Output root file directory', type=str)
25 parser.add_argument(
'-k',
'--outpdir', dest=
'outpdir', default=
"/eos/atlas/atlascerngroupdisk/det-larg/Temp/Weekly/poolFiles", help=
'Output pool file directory', type=str)
26 parser.add_argument(
'-u',
'--insqlite', dest=
'insql', default=
"mysql.db", help=
'Input sqlite file with pedestals, in pool output dir.', type=str)
27 parser.add_argument(
'-n',
'--outsqlite', dest=
'outsql', default=
"mysql_delay.db", help=
'Output sqlite file, in pool output dir.', type=str)
28 parser.add_argument(
'-m',
'--subdet', dest=
'subdet', default=
"EMB", help=
'Subdetector, EMB, EMEC, HEC, FCAL or HECFCAL', type=str)
29 parser.add_argument(
'-s',
'--side', dest=
'side', default=
"C", help=
'Detector side empty (means both), C or A', type=str)
30 parser.add_argument(
'-c',
'--isSC', dest=
'supercells', default=
False, action=
"store_true", help=
'is SC data ?')
31 parser.add_argument(
'-a',
'--isRawdata', dest=
'rawdata', default=
False, action=
"store_true", help=
'is raw data ?')
32 parser.add_argument(
'-x',
'--ignoreBarrel', dest=
'ignoreB', default=
False, action=
"store_true", help=
'ignore Barrel channels ?')
33 parser.add_argument(
'-v',
'--ignoreEndcap', dest=
'ignoreE', default=
False, action=
"store_true", help=
'ignore Endcap channels ?')
34 parser.add_argument(
'-b',
'--badchansqlite', dest=
'badsql', default=
"SnapshotBadChannel.db", help=
'Output sqlite file, in pool output dir.', type=str)
35 parser.add_argument(
'--FW6', dest=
'fw6', default=
False, help=
'Is it for fw v. 6', action=
'store_true')
36 parser.add_argument(
'--EMF', dest=
'emf', default=
False, help=
'Is it for EMF', action=
'store_true')
38 args = parser.parse_args()
39 if help
in args
and args.help
is not None and args.help:
43 for _, value
in args._get_kwargs():
48 args.run = args.run.zfill(8)
54 gain=args.gain.lower().capitalize()
55 if not args.supercells:
56 partstr = args.partition
58 partstr = args.partition+
"-DT"
62 InputDir = args.dprefix+args.fprefix+
"/calibration_LArElec-Delay-32s-"+gain+
"-"+partstr+
"/"+args.run+
"/"+args.fprefix+
"."+args.run+
".calibration_LArElec-Delay-32s-"+gain+
"-"+partstr+
".daq.RAW/"
65 from LArCalibProcessing.LArCalib_Delay_OFCCaliConfig
import LArDelay_OFCCaliCfg
68 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
71 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
72 from LArCalibProcessing.LArCalibConfigFlags
import addLArCalibFlags
78 flags.LArCalib.Input.Dir = InputDir
79 flags.LArCalib.Input.Type = args.trig
80 flags.LArCalib.Input.RunNumbers = [
int(args.run),]
81 flags.LArCalib.Input.Database = args.outpdir +
"/" +args.insql
82 flags.LArCalib.Input.isRawData = args.rawdata
83 gainNumMap={
"HIGH":0,
"MEDIUM":1,
"LOW":2}
84 flags.LArCalib.Gain=gainNumMap[args.gain.upper()]
88 flags.Input.Files=flags.LArCalib.Input.Files
90 print (
"Input files to be processed:")
91 for f
in flags.Input.Files:
94 if len(flags.Input.Files) == 0 :
95 print(
"Unable to find any input files. Please check the input directory:",InputDir)
100 if not flags.LArCalib.isSC:
101 if args.subdet ==
'EMB' or args.subdet ==
'EMEC':
102 flags.LArCalib.Input.SubDet=
"EM"
104 flags.LArCalib.Input.SubDet=args.subdet
107 flags.LArCalib.Preselection.Side = [0,1]
108 elif args.side ==
"C":
109 flags.LArCalib.Preselection.Side = [0]
110 elif args.side ==
"A":
111 flags.LArCalib.Preselection.Side = [1]
113 print(
"unknown side ",args.side)
116 if args.subdet !=
"EM":
117 if args.subdet ==
'EMB':
118 flags.LArCalib.Preselection.BEC = [0]
120 flags.LArCalib.Preselection.BEC = [1]
122 if args.subdet ==
'FCAL':
123 flags.LArCalib.Preselection.FT = [6]
124 elif args.subdet ==
'HEC':
125 flags.LArCalib.Preselection.FT = [3,10,16,22]
126 elif args.subdet ==
'HECFCAL':
127 flags.LArCalib.Preselection.FT = [3,6,10,16,22]
131 flags.LArCalib.BadChannelDB = args.outpdir +
"/" + args.badsql
134 OutputCaliWaveRootFileName = args.outrwaveprefix +
"_" + args.run
135 OutputPoolFileName = args.outpprefix +
"_" + args.run
136 OutputOFCCaliRootFileName = args.outrofcprefix +
"_" + args.run
138 if args.subdet !=
"" and not flags.LArCalib.isSC:
139 OutputCaliWaveRootFileName +=
"_"+args.subdet
140 OutputPoolFileName +=
"_"+args.subdet
141 OutputOFCCaliRootFileName +=
"_"+args.subdet
143 if flags.LArCalib.Input.SubDet==
"EM":
144 OutputCaliWaveRootFileName += args.side
145 OutputPoolFileName += args.side
146 OutputOFCCaliRootFileName += args.side
148 OutputCaliWaveRootFileName +=
".root"
149 OutputPoolFileName +=
".pool.root"
150 OutputOFCCaliRootFileName +=
".root"
152 flags.LArCalib.Output.ROOTFile = args.outrdir +
"/" + OutputCaliWaveRootFileName
153 flags.LArCalib.Output.POOLFile = args.outpdir +
"/" + OutputPoolFileName
154 flags.LArCalib.Output.ROOTFile2 = args.outrdir +
"/" + OutputOFCCaliRootFileName
155 if args.outsql.startswith(
"/"):
156 flags.IOVDb.DBConnection=
"sqlite://;schema=" + args.outsql +
";dbname=CONDBR2"
158 flags.IOVDb.DBConnection=
"sqlite://;schema="+args.outpdir +
"/" + args.outsql +
";dbname=CONDBR2"
161 flags.IOVDb.GlobalTag =
"LARCALIB-RUN2-00"
165 flags.LArCalib.doValidation=
False
172 pdir=
'/afs/cern.ch/user/l/lardaq/public/detlar/athena/P1CalibrationProcessing/run/Patterns/EMF/EMF_Oct2024/Delay/emf/'
173 pfile = pdir+args.partition+
'/parameters.dat'
175 pdir=
'/afs/cern.ch/user/l/lardaq/public/detlar/athena/P1CalibrationProcessing/run/Patterns/P1/'
177 pdir +=
'LatomeRuns/'
178 if 'Emec' in args.partition:
179 pfile = pdir +
'emec-std/SC_HighDelay/parameters.dat'
181 pfile = pdir +
'barrel/Delay_' + args.partition[:-4] +
'/parameters.dat'
183 flags.LArCalib.Input.paramsFile = pfile
188 flags.LArCalib.Input.paramsFile = pfile
193 flags.Exec.OutputLevel = INFO
195 from AthenaConfiguration.Enums
import LHCPeriod
196 flags.GeoModel.Run = LHCPeriod.Run3
198 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
199 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
203 flags.IOVDb.SqliteInput=
"/afs/cern.ch/user/p/pavol/public/EMF_otherCond.db"
204 flags.IOVDb.SqliteFolders = (
"/LAR/BadChannelsOfl/BadChannelsSC",
"/LAR/BadChannels/BadChannelsSC",
"/LAR/Identifier/OnOffIdMap",)
205 flags.LArCalib.doValidation=
False
208 flags.dump(evaluate=
True)
224 from IOVDbSvc.IOVDbSvcConfig
import addOverride
225 cfg.merge(
addOverride(flags,
"/LAR/Identifier/LatomeMapping",
"LARIdentifierLatomeMapping-fw6"))
228 from IOVDbSvc.IOVDbSvcConfig
import addOverride
229 cfg.merge(
addOverride(flags,
"/LAR/Identifier/LatomeMapping",
"LARIdentifierLatomeMapping-EMF"))
230 fldrs=cfg.getService(
"IOVDbSvc").Folders
231 for i
in range(0, len(fldrs)):
232 if 'Align' in fldrs[i]: fldrs[i] +=
'<forceRunNumber>9999999</forceRunNumber>'
237 cfg.getEventAlgo(
"LArRawSCDataReadingAlg").LATOMEDecoder.IgnoreBarrelChannels=args.ignoreB
239 cfg.getEventAlgo(
"LArRawSCCalibDataReadingAlg").LATOMEDecoder.IgnoreBarrelChannels=args.ignoreB
242 cfg.getEventAlgo(
"LArRawSCDataReadingAlg").LATOMEDecoder.IgnoreEndcapChannels=args.ignoreE
244 cfg.getEventAlgo(
"LArRawSCCalibDataReadingAlg").LATOMEDecoder.IgnoreEndcapChannels=args.ignoreE
246 cfg.getService(
"IOVDbSvc").DBInstance=
""
248 cfg.getService(
"MessageSvc").defaultLimit=20000
255 cmdline = ([
'/afs/cern.ch/user/l/larcalib/LArDBTools/python/BuildTagHierarchy.py',args.outpdir +
"/" + args.outsql , flags.IOVDb.GlobalTag])
258 subprocess.run(cmdline, check=
True)
259 except Exception
as e:
260 print(
'Could not create tag hierarchy in output sqlite file !!!!')