6 if __name__==
'__main__':
11 from AthenaCommon
import Logging
12 log = Logging.logging.getLogger(
'LArPedestalAutoCorr' )
18 parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
20 parser.add_argument(
'-r',
'--run', dest=
'run', default=
'00408913', help=
'Run number string as in input filename', type=str)
21 parser.add_argument(
'-g',
'--gain', dest=
'gain', default=
"MEDIUM", help=
'Gain string', type=str)
22 parser.add_argument(
'-p',
'--partition', dest=
'partition', default=
"All", help=
'Partition string', type=str)
23 parser.add_argument(
'-f',
'--fileprefix', dest=
'fprefix', default=
"data24_calib", help=
'File prefix string', type=str)
24 parser.add_argument(
'-i',
'--indirprefix', dest=
'dprefix', default=
"/eos/atlas/atlastier0/rucio/", help=
'Input directory prefix string', type=str)
25 parser.add_argument(
'-d',
'--indir', dest=
'indir', default=
"", help=
'Full input dir string', type=str)
26 parser.add_argument(
'-t',
'--trigger', dest=
'trig', default=
'calibration_', help=
'Trigger string in filename', type=str)
27 parser.add_argument(
'-o',
'--outrprefix', dest=
'outrprefix', default=
"LArPedAutoCorr", help=
'Prefix of output root filename', type=str)
28 parser.add_argument(
'-l',
'--outpprefix', dest=
'outpprefix', default=
"LArPedAutoCorr", help=
'Prefix of output pool filename', type=str)
29 parser.add_argument(
'-e',
'--outrdir', dest=
'outrdir', default=
"/eos/atlas/atlascerngroupdisk/det-larg/Temp/Weekly/ntuples", help=
'Output root file directory', type=str)
30 parser.add_argument(
'-k',
'--outpdir', dest=
'outpdir', default=
"/eos/atlas/atlascerngroupdisk/det-larg/Temp/Weekly/poolFiles", help=
'Output pool file directory', type=str)
31 parser.add_argument(
'-n',
'--outsqlite', dest=
'outsql', default=
"mysql.db", help=
'Output sqlite file, in pool output dir.', type=str)
32 parser.add_argument(
'-m',
'--subdet', dest=
'subdet', default=
"EMB", help=
'Subdetector, EMB, EMEC, HEC or FCAL', type=str)
33 parser.add_argument(
'-s',
'--side', dest=
'side', default=
"C", help=
'Detector side empty (means both), C or A', type=str)
34 parser.add_argument(
'-c',
'--isSC', dest=
'supercells', default=
False, action=
"store_true", help=
'is SC data ?')
35 parser.add_argument(
'-a',
'--isRawdata', dest=
'rawdata', default=
False, action=
"store_true", help=
'is raw data ?')
36 parser.add_argument(
'-b',
'--badchansqlite', dest=
'badsql', default=
"SnapshotBadChannel.db", help=
'Input sqlite file with bad chans.', type=str)
37 parser.add_argument(
'--FW6', dest=
'fw6', default=
False, help=
'Is it for fw v. 6', action=
'store_true')
38 parser.add_argument(
'--EMF', dest=
'emf', default=
False, help=
'Is it for EMF', action=
'store_true')
40 args = parser.parse_args()
41 if help
in args
and args.help
is not None and args.help:
45 for _, value
in args._get_kwargs():
50 args.run = args.run.zfill(8)
56 gain=args.gain.lower().capitalize()
59 if not args.supercells:
60 partstr = args.partition
62 partstr = args.partition+
"-DT"
66 InputDir = args.dprefix+args.fprefix+
"/calibration_LArElec-Pedestal-32s-"+gain+
"-"+partstr+
"/"+args.run+
"/"+args.fprefix+
"."+args.run+
".calibration_LArElec-Pedestal-32s-"+gain+
"-"+partstr+
".daq.RAW/"
69 from LArCalibProcessing.LArCalib_PedestalAutoCorrConfig
import LArPedestalAutoCorrCfg
72 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
75 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
76 from LArCalibProcessing.LArCalibConfigFlags
import addLArCalibFlags
83 flags.LArCalib.Input.Dir = InputDir
84 flags.LArCalib.Input.Type = args.trig
85 flags.LArCalib.Input.RunNumbers = [
int(args.run),]
86 flags.LArCalib.Input.isRawData = args.rawdata
88 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
89 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
92 flags.Input.Files=flags.LArCalib.Input.Files
94 log.info(
"Input files to be processed:")
95 for f
in flags.Input.Files:
98 if len(flags.Input.Files) == 0 :
99 print(
"Unable to find any input files. Please check the input directory:",InputDir)
105 if not flags.LArCalib.isSC:
106 if args.subdet ==
'EMB' or args.subdet ==
'EMEC':
107 flags.LArCalib.Input.SubDet=
"EM"
109 flags.LArCalib.Input.SubDet=args.subdet
113 flags.LArCalib.Preselection.Side = [0]
114 elif args.side ==
"A":
115 flags.LArCalib.Preselection.Side = [1]
117 log.warning(
"Bad side argument: ",args.side,
" using both!!")
119 if args.subdet ==
'EMB':
120 flags.LArCalib.Preselection.BEC = [0]
122 flags.LArCalib.Preselection.BEC = [1]
124 if args.subdet ==
'FCAL':
125 flags.LArCalib.Preselection.FT = [6]
126 elif args.subdet ==
'HEC':
127 flags.LArCalib.Preselection.FT = [3,10,16,22]
130 OutputPedAutoCorrRootFileName = args.outrprefix +
"_" + args.run
131 OutputPedAutoCorrPoolFileName = args.outpprefix +
"_" + args.run
133 if args.subdet !=
"" and not flags.LArCalib.isSC:
134 OutputPedAutoCorrRootFileName = OutputPedAutoCorrRootFileName +
"_"+args.subdet
135 OutputPedAutoCorrPoolFileName = OutputPedAutoCorrPoolFileName +
"_"+args.subdet
136 if flags.LArCalib.Input.SubDet==
"EM":
137 OutputPedAutoCorrRootFileName = OutputPedAutoCorrRootFileName + args.side
138 OutputPedAutoCorrPoolFileName = OutputPedAutoCorrPoolFileName + args.side
139 OutputPedAutoCorrRootFileName = OutputPedAutoCorrRootFileName +
".root"
140 OutputPedAutoCorrPoolFileName = OutputPedAutoCorrPoolFileName +
".pool.root"
142 flags.LArCalib.Output.ROOTFile = args.outrdir +
"/" + OutputPedAutoCorrRootFileName
143 flags.LArCalib.Output.POOLFile = args.outpdir +
"/" + OutputPedAutoCorrPoolFileName
144 if args.outsql.startswith(
"/"):
145 flags.IOVDb.DBConnection=
"sqlite://;schema=" + args.outsql +
";dbname=CONDBR2"
147 flags.IOVDb.DBConnection=
"sqlite://;schema="+args.outpdir +
"/" + args.outsql +
";dbname=CONDBR2"
150 flags.IOVDb.GlobalTag =
"LARCALIB-RUN2-00"
154 if args.badsql.startswith(
"/"):
155 flags.LArCalib.BadChannelDB = args.badsql
157 flags.LArCalib.BadChannelDB = args.outpdir +
"/" + args.badsql
163 flags.Exec.OutputLevel = INFO
165 from AthenaConfiguration.Enums
import LHCPeriod
166 flags.GeoModel.Run = LHCPeriod.Run3
170 flags.IOVDb.SqliteInput=
"/afs/cern.ch/user/p/pavol/public/EMF_otherCond.db"
171 flags.IOVDb.SqliteFolders = (
"/LAR/BadChannelsOfl/BadChannelsSC",
"/LAR/BadChannels/BadChannelsSC",
"/LAR/Identifier/OnOffIdMap",
"/LAR/BadChannelsOfl/MissingFEBs",
"/LAR/BadChannelsOfl/KnownMNBFEBs",
"/LAR/BadChannelsOfl/KnownBADFEBs")
172 flags.LArCalib.doValidation=
False
175 flags.dump(evaluate=
True)
178 cmdlinerm = ([
'/bin/rm',
'-f', flags.LArCalib.BadChannelDB])
179 if not flags.LArCalib.isSC:
180 cmdline = ([
'AtlCoolCopy',
'COOLOFL_LAR/CONDBR2',
'sqlite://;schema='+flags.LArCalib.BadChannelDB+
';dbname=CONDBR2',
'-f',
'/LAR/BadChannelsOfl/BadChannels',
'-f',
'/LAR/BadChannelsOfl/MissingFEBs',
'-t', flags.IOVDb.GlobalTag,
'-c',
'-a',
'-hitag'])
182 cmdline = ([
'AtlCoolCopy',
'COOLOFL_LAR/CONDBR2',
'sqlite://;schema='+flags.LArCalib.BadChannelDB+
';dbname=CONDBR2',
'-f',
'/LAR/BadChannelsOfl/BadChannelsSC',
'-t',
'LARBadChannelsOflBadChannelsSC'+flags.LArCalib.BadChannelTagSC,
'-c',
'-a',
'-hitag',
'-ch',
'0'])
185 cp = subprocess.run(cmdlinerm, check=
True, capture_output=
True )
186 except Exception
as e:
188 log.info(
'not existing BadChan sqlite file, fine')
193 cp = subprocess.run(cmdline, check=
True, capture_output=
True )
194 except Exception
as e:
197 log.error(
'Could not create BadChan sqlite file !!!!')
207 from IOVDbSvc.IOVDbSvcConfig
import addOverride
208 cfg.merge(
addOverride(flags,
"/LAR/Identifier/LatomeMapping",
"LARIdentifierLatomeMapping-fw6"))
210 cfg.getService(
"IOVDbSvc").DBInstance=
""
213 fldrs=cfg.getService(
"IOVDbSvc").Folders
214 for i
in range(0, len(fldrs)):
215 if 'Align' in fldrs[i]: fldrs[i] +=
'<forceRunNumber>9999999</forceRunNumber>'
216 if 'LatomeMapping' in fldrs[i]: fldrs[i] +=
'<tag>LARIdentifierLatomeMapping-EMF</tag>'
222 if args.outsql.startswith(
"/"):
223 cmdline = ([
'/afs/cern.ch/user/l/larcalib/LArDBTools/python/BuildTagHierarchy.py', args.outsql , flags.IOVDb.GlobalTag])
225 cmdline = ([
'/afs/cern.ch/user/l/larcalib/LArDBTools/python/BuildTagHierarchy.py',args.outpdir +
"/" + args.outsql , flags.IOVDb.GlobalTag])
228 subprocess.run(cmdline, check=
True)
229 except Exception
as e:
230 log.error(
'Could not create tag hierarchy in output sqlite file !!!!')