4 from AthenaConfiguration.ComponentFactory
import CompFactory
7 if __name__==
'__main__':
13 parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
14 parser.add_argument(
'-r',
'--run', dest=
'run', default=0x7fffffff, help=
'Run number', type=int)
15 parser.add_argument(
'--sqlite', dest=
'sqlite', default=
None, help=
'sqlite file to read from (default: oracle)', type=str)
16 parser.add_argument(
'-t',
'--tag',dest=
'dbtag',default=
None,help=
"Global conditions tag", type=str)
17 parser.add_argument(
'-f',
'--ftag',dest=
'ftag',default=
None,help=
"folder tag suffig", type=str)
18 parser.add_argument(
'-o',
'--out', dest=
'out', default=
"LArConditions.root", help=
'Output root file', type=str)
19 parser.add_argument(
'--ofcfolder',dest=
'ofcfolder',default=
"", help=
"OFC flavor",type=str)
20 parser.add_argument(
'-s',
'--isSC', dest=
'isSC', action=
'store_true', default=
False, help=
'is SC?')
21 parser.add_argument(
'-m',
'--isMC', dest=
'isMC', action=
'store_true', default=
False, help=
'is MC?')
23 parser.add_argument(
"--objects",dest=
"objects",default=
"PEDESTAL,RAMP",help=
"List of conditions types to be dumped",type=str)
24 parser.add_argument(
"--folders",dest=
"folders",default=
"/LAR/ElecCalibFlat/Pedestal,/LAR/ElecCalibFlat/Ramp",help=
"List of folders to be taken from sqlite",type=str)
25 parser.add_argument(
'--offline',dest=
"offline", action=
'store_true', default=
False, help=
'is offline folder?')
26 parser.add_argument(
'--poolcat',dest=
"poolcat", default=
"", type=str, help=
'is offline folder?')
27 parser.add_argument(
'-n',
'--ntuple', dest=
'ntname', default=
'', help=
'output ntuple name (if different from default)', type=str)
28 parser.add_argument(
'--oLevel', dest=
'olevel', default=3, help=
'OutputLevel of the job', type=int)
30 args = parser.parse_args()
31 if help
in args
and args.help
is not None and args.help:
38 objTable={
"RAMP":
"Ramp",
41 "PEDESTAL":
"Pedestal",
45 "MPHYSOVERMCAL":
"MphysOverMcal",
46 "MPHYSMCAL":
"MphysOverMcal",
47 "MPMC":
"MphysOverMcal",
50 "HVSCALECORR":
"HVScaleCorr",
51 "HVSCALE":
"HVScaleCorr",
53 "AUTOCORR":
"AutoCorr",
55 "CALIWAVE":
"CaliWave",
56 "PHYSWAVE":
"PhysWave",
61 "PHYSAC":
"PhysAutoCorr",
66 for obj
in args.objects.split(
","):
68 if objU
not in objTable:
69 print(
"ERROR: Unknown conditions type",obj)
72 objects.add(objTable[objU])
73 if "OFCCALI" not in obj.upper()
and 'WAVE' not in obj.upper()
and 'DSPTHR' not in obj.upper()
and 'MINBIAS' not in obj.upper()
and not args.offline:
74 objectsOnl.add(objTable[objU])
77 for fld
in args.folders.split(
","):
80 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
82 from LArCalibProcessing.LArCalibConfigFlags
import addLArCalibFlags
85 flags.Input.RunNumbers=[args.run]
86 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
87 flags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
91 flags.Input.isMC=args.isMC
92 flags.LArCalib.isSC=args.isSC
94 flags.LAr.doAlign=
False
96 flags.LAr.OFCShapeFolder=args.ofcfolder
98 from AthenaConfiguration.Enums
import LHCPeriod
99 if flags.Input.RunNumbers[0] < 222222:
101 flags.GeoModel.Run=LHCPeriod.Run1
102 flags.IOVDb.DatabaseInstance=
"OFLP200" if flags.Input.isMC
else "COMP200"
104 flags.GeoModel.Run=LHCPeriod.Run2
105 flags.IOVDb.DatabaseInstance=
"OFLP200" if flags.Input.isMC
else "CONDBR2"
108 flags.IOVDb.GlobalTag=args.dbtag
109 elif flags.Input.isMC:
110 flags.IOVDb.GlobalTag=
"OFLCOND-MC16-SDR-20"
111 elif flags.IOVDb.DatabaseInstance ==
"COMP200":
112 flags.IOVDb.GlobalTag=
"COMCOND-BLKPA-RUN1-09"
114 flags.IOVDb.GlobalTag=
"CONDBR2-ES1PA-2024-01"
116 flags.Exec.OutputLevel=args.olevel
117 flags.Debug.DumpCondStore=
True
118 flags.Debug.DumpDetStore=
True
121 flags.IOVDb.SqliteInput=args.sqlite
122 flags.IOVDb.SqliteFolders=tuple(flds)
123 if len(objects)!=len(objectsOnl):
124 flags.IOVDb.DBConnection=
"COOLOFL_LAR/CONDBR2"
126 if "fSampl" in objects:
127 flags.Overlay.DataOverlay=
True
131 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
135 from McEventSelector.McEventSelectorConfig
import McEventSelectorCfg
139 InitialTimeStamp = 0,
140 TimeStampInterval = 1))
143 if "fSampl" in objects:
144 from IOVDbSvc.IOVDbSvcConfig
import addOverride
145 cfg.merge(
addOverride(flags,
"/LAR/ElecCalibMC/fSampl",
"LARElecCalibMCfSampl-G496-19213-FTFP_BERT_BIRK"))
148 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
151 if flags.LArCalib.isSC:
153 from LArCabling.LArCablingConfig
import LArOnOffIdMappingSCCfg, LArCalibIdMappingSCCfg, LArLATOMEMappingCfg
158 from LArConfiguration.LArElecCalibDBConfig
import LArElecCalibDBSCCfg
162 from LArCabling.LArCablingConfig
import LArOnOffIdMappingCfg, LArCalibIdMappingCfg
166 from LArConfiguration.LArElecCalibDBConfig
import LArElecCalibDBCfg
169 from LArBadChannelTool.LArBadChannelConfig
import LArBadChannelCfg
172 bcKey =
"LArBadChannelSC" if flags.LArCalib.isSC
else "LArBadChannel"
174 if "Pedestal" in objects:
175 ckey =
"LArPedestalSC" if flags.LArCalib.isSC
else "LArPedestal"
176 cfg.addEventAlgo(CompFactory.LArPedestals2Ntuple(ContainerKey = ckey,
177 AddFEBTempInfo =
False,
179 isSC = flags.LArCalib.isSC,
183 if "AutoCorr" in objects:
184 from IOVDbSvc.IOVDbSvcConfig
import addFolders
185 if flags.LArCalib.isSC:
186 cfg.merge(
addFolders(flags,
'/LAR/ElecCalibOflSC/AutoCorrs/AutoCorr',modifiers=
'<key>LArAutoCorrSC</key>',className=
'LArAutoCorrComplete'))
189 cfg.merge(
addFolders(flags,
'/LAR/ElecCalibOfl/AutoCorrs/AutoCorr',tag=
"".
join(
'/LAR/ElecCalibOfl/AutoCorrs/AutoCorr'.
split(
'/')) + args.ftag))
191 cfg.merge(
addFolders(flags,
'/LAR/ElecCalibOfl/AutoCorrs/AutoCorr',className=
'LArAutoCorrComplete'))
192 ckey=
"LArAutoCorrSC" if flags.LArCalib.isSC
else "LArAutoCorr"
193 cfg.addEventAlgo(CompFactory.LArAutoCorr2Ntuple(ContainerKey =
"LArAutoCorrSym" if flags.Input.isMC
else ckey,
194 AddFEBTempInfo =
False,
196 isSC = flags.LArCalib.isSC,
197 ApplyCorrection =
True,
203 if "PhysAutoCorr" in objects:
204 from IOVDbSvc.IOVDbSvcConfig
import addFolders
205 if flags.LArCalib.isSC:
206 cfg.merge(
addFolders(flags,
'/LAR/ElecCalibOflSC/AutoCorrs/PhysicsAutoCorr',modifiers=
'<key>LArAutoCorrSC</key>',className=
'LArAutoCorrComplete'))
209 cfg.merge(
addFolders(flags,
'/LAR/ElecCalibOfl/AutoCorrs/PhysicsAutoCorr',tag=
"".
join(
'/LAR/ElecCalibOfl/AutoCorrs/PhysicsAutoCorr'.
split(
'/')) + args.ftag))
211 cfg.merge(
addFolders(flags,
'/LAR/ElecCalibOfl/AutoCorrs/PhysicsAutoCorr',className=
'LArAutoCorrComplete'))
212 ckey=
"LArPhysAutoCorrSC" if flags.LArCalib.isSC
else "LArPhysAutoCorr"
213 cfg.addEventAlgo(CompFactory.LArAutoCorr2Ntuple(ContainerKey = ckey,
214 AddFEBTempInfo =
False,
216 isSC = flags.LArCalib.isSC,
217 ApplyCorrection =
not flags.Input.isMC,
218 AddCorrUndo =
not flags.Input.isMC,
223 if "Ramp" in objects:
224 ckey =
"LArRampSC" if flags.LArCalib.isSC
else "LArRamp"
226 from IOVDbSvc.IOVDbSvcConfig
import addFolders
227 if flags.LArCalib.isSC:
228 cfg.merge(
addFolders(flags,
'/LAR/ElecCalibOflSC/Ramps/RampLinea',modifiers=
'<key>LArRampSC</key>',className=
'LArRampComplete'))
230 cfg.merge(
addFolders(flags,
'/LAR/ElecCalibOfl/Ramps/RampLinea',className=
'LArRampComplete'))
231 cfg.addEventAlgo(CompFactory.LArRamps2Ntuple(RampKey=
"LArRampSym" if flags.Input.isMC
else ckey,
232 AddFEBTempInfo =
False,
234 isSC = flags.LArCalib.isSC,
242 from IOVDbSvc.IOVDbSvcConfig
import addFolders
246 cfg.merge(
addFolders(flags,fld,tag=
"".
join(fld.split(
'/')) + args.ftag))
250 ntname=
'OFC' if '1phase' in fld
else 'OFC_1ns'
253 ckey =
"LArOFCSC" if flags.LArCalib.isSC
else "LArOFC"
255 cfg.addEventAlgo(CompFactory.LArOFC2Ntuple(AddFEBTempInfo =
False,
258 isSC = flags.LArCalib.isSC,
262 if "OFCCali" in objects:
264 from IOVDbSvc.IOVDbSvcConfig
import addFolders
268 cfg.merge(
addFolders(flags,fld,tag=
"".
join(foldername.split(
'/')) + args.ftag))
271 ckey=
'LArOFC' if '1phase' in fld
else 'LArOFC'
274 ckey =
"LArOFCSCCali" if flags.LArCalib.isSC
else "LArOFCCali"
275 fldr =
"/LAR/ElecCalibFlatSC/OFCCali" if flags.LArCalib.isSC
else "/LAR/ElecCalibFlat/OFCCali"
276 dbString =
"<db>sqlite://;schema="+args.sqlite+
";dbname=CONDBR2" if args.sqlite
else "<db>COOLONL_LAR/CONDBR2</db>"
277 from IOVDbSvc.IOVDbSvcConfig
import addFolders
278 cfg.merge(
addFolders(flags,fldr,detDb=dbString,className=
"CondAttrListCollection"))
279 LArOFCSCCondAlg = CompFactory.getComp(
"LArFlatConditionsAlg<LArOFCSC>")(
"LArOFCSCCaliCondAlg")
280 LArOFCSCCondAlg.ReadKey=fldr
281 LArOFCSCCondAlg. WriteKey=ckey
282 cfg.addCondAlgo(LArOFCSCCondAlg)
284 cfg.addEventAlgo(CompFactory.LArOFC2Ntuple(
"LArOFC2NtupleCali",
285 AddFEBTempInfo =
False,
287 NtupleName=
"OFCCali" if args.ntname==
'' else args.ntname,
288 isSC = flags.LArCalib.isSC,
293 if "Shape" in objects:
295 from IOVDbSvc.IOVDbSvcConfig
import addFolders
299 cfg.merge(
addFolders(flags,fld,tag=
"".
join(fld.split(
'/')) + args.ftag))
303 ntname=
'SHAPE' if '1phase' in fld
else 'SHAPE_1ns'
306 ckey =
"LArShapeSC" if flags.LArCalib.isSC
else "LArShape"
310 cfg.addEventAlgo(CompFactory.LArShape2Ntuple(ContainerKey=ckey,
311 AddFEBTempInfo =
False,
313 isSC = flags.LArCalib.isSC,
317 if "MphysOverMcal" in objects:
319 from IOVDbSvc.IOVDbSvcConfig
import addFolders
320 if flags.LArCalib.isSC:
321 print(
'offline, adding /LAR/ElecCalibOflSC/MphysOverMcal/RTM folder')
322 cfg.merge(
addFolders(flags,
'/LAR/ElecCalibOflSC/MphysOverMcal/RTM',modifiers=
'<key>LArMphysOverMcalSC</key>',className=
'LArMphysOverMcalComplete'))
324 cfg.merge(
addFolders(flags,
'/LAR/ElecCalibOfl/MphysOverMcal/RTM',className=
'LArMphysOverMcalComplete'))
326 cfg.addEventAlgo(CompFactory.LArMphysOverMcal2Ntuple(ContainerKey =
"LArMphysOverMcalSC" if flags.LArCalib.isSC
else "LArMphysOverMcal",
327 AddFEBTempInfo =
False,
329 isSC = flags.LArCalib.isSC,
334 if "DAC2uA" in objects
or "uA2MeV" in objects:
335 uackey =
"LAruA2MeVSC" if flags.LArCalib.isSC
else "LAruA2MeV"
336 dackey =
"LArDAC2uASC" if flags.LArCalib.isSC
else "LArDAC2uA"
337 ua2MeVKey=
"LAruA2MeVSym" if flags.Input.isMC
else uackey
338 dac2uAKey=
"LArDAC2uASym" if flags.Input.isMC
else dackey
340 cfg.addEventAlgo(CompFactory.LAruA2MeV2Ntuple(uA2MeVKey=ua2MeVKey
if "uA2MeV" in objects
else "",
341 DAC2uAKey=dac2uAKey
if "DAC2uA" in objects
else "",
342 isSC = flags.LArCalib.isSC,
347 if "HVScaleCorr" in objects:
349 iovDbSvc=cfg.getService(
"IOVDbSvc")
350 for i
in range(0,len(iovDbSvc.Folders)):
351 if (iovDbSvc.Folders[i].
find(
"HVScaleCorr")>=0):
352 iovDbSvc.Folders[i]+=
"<key>/LAR/ElecCalibFlatSC/HVScaleCorr</key>"
354 cfg.addEventAlgo(CompFactory.LArHVScaleCorr2Ntuple(ContainerKey=
"LArHVScaleCorrSC" if flags.LArCalib.isSC
else "LArHVScaleCorr",
355 AddFEBTempInfo =
False,
356 isSC = flags.LArCalib.isSC,
360 if "fSampl" in objects:
361 cfg.addEventAlgo(CompFactory.LArfSampl2Ntuple(ContainerKey=
"LArfSamplSC" if flags.LArCalib.isSC
else "LArfSamplSym",
362 isSC=flags.LArCalib.isSC
365 if "CaliWave" in objects:
367 print(
'No CaliWave in MC')
369 fld =
"/LAR/ElecCalibOflSC/CaliWaves/CaliWave" if flags.LArCalib.isSC
else "/LAR/ElecCalibOfl/CaliWaves/CaliWave"
370 from IOVDbSvc.IOVDbSvcConfig
import addFolders
371 cfg.merge(
addFolders(flags,fld,modifiers=
'<key>LArCaliWave</key><typeName>LArCaliWaveContainer</typeName>'))
372 cfg.addEventAlgo(CompFactory.LArCaliWaves2Ntuple(KeyList = [
"LArCaliWave"],
373 NtupleName =
"CALIWAVE",
374 AddFEBTempInfo =
False,
375 SaveDerivedInfo =
True,
379 isSC = flags.LArCalib.isSC,
383 if "PhysWave" in objects:
385 print(
'No PhysWave in MC yet')
387 fld =
"/LAR/ElecCalibOflSC/PhysWaves/RTM" if flags.LArCalib.isSC
else "/LAR/ElecCalibOfl/PhysWaves/RTM"
388 from IOVDbSvc.IOVDbSvcConfig
import addFolders
390 cfg.addEventAlgo(CompFactory.LArPhysWaves2Ntuple(KeyList = [
"LArPhysWave"],
391 NtupleName =
"PHYSWAVE",
392 AddFEBTempInfo =
False,
393 SaveDerivedInfo =
True,
396 isSC = flags.LArCalib.isSC,
400 if "DSPThr" in objects:
401 from IOVDbSvc.IOVDbSvcConfig
import addFolders
402 cfg.merge(
addFolders(flags,
"/LAR/Configuration/DSPThresholdFlat/Thresholds",detDb=
"LAR_ONL"))
403 cfg.addEventAlgo(CompFactory.LArDSPThresholds2Ntuple(DumpFlat=
True,FlatFolder=
"/LAR/Configuration/DSPThresholdFlat/Thresholds"))
405 if "MinBias" in objects:
407 from IOVDbSvc.IOVDbSvcConfig
import addFolders
409 myfld=
"/LAR/ElecCalibOfl/LArPileupAverage"
412 myfld=
"/LAR/LArPileup/LArPileupAverage"
415 cfg.merge(
addFolders(flags,myfld,detDb=mydb,className=
"LArMinBiasAverageMC",tag=
"".
join(myfld.split(
'/')) + args.ftag))
417 cfg.merge(
addFolders(flags,myfld,detDb=mydb,className=
"LArMinBiasAverageMC"))
418 LArMinBiasAverageSymAlg = CompFactory.getComp(
"LArSymConditionsAlg<LArMinBiasAverageMC, LArMinBiasAverageSym>")
419 LArMCSymCondAlg=CompFactory.LArMCSymCondAlg
422 cfg.addEventAlgo(CompFactory.LArMinBias2Ntuple(ContainerKey=
"",ContainerKeyAv=
"LArSymPileupAverage"))
425 if os.path.exists(rootfile):
427 cfg.addService(CompFactory.NTupleSvc(Output = [
"FILE1 DATAFILE='"+rootfile+
"' OPT='NEW'" ]))
428 cfg.setAppProperty(
"HistogramPersistency",
"ROOT")
430 if args.dbtag
and 'CALIB' in args.dbtag:
431 cfg.getService(
"IOVDbSvc").DBInstance=
""
434 cfg.getService(
"PoolSvc").ReadCatalog+=[
"xmlcatalog_file:%s"%args.poolcat,]