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)
29 args = parser.parse_args()
30 if help
in args
and args.help
is not None and args.help:
36 objTable={
"RAMP":
"Ramp",
39 "PEDESTAL":
"Pedestal",
43 "MPHYSOVERMCAL":
"MphysOverMcal",
44 "MPHYSMCAL":
"MphysOverMcal",
45 "MPMC":
"MphysOverMcal",
48 "HVSCALECORR":
"HVScaleCorr",
49 "HVSCALE":
"HVScaleCorr",
51 "AUTOCORR":
"AutoCorr",
53 "CALIWAVE":
"CaliWave",
54 "PHYSWAVE":
"PhysWave",
60 for obj
in args.objects.split(
","):
62 if objU
not in objTable:
63 print(
"ERROR: Unknown conditions type",obj)
66 objects.add(objTable[objU])
67 if "OFCCALI" not in obj.upper()
and 'WAVE' not in obj.upper()
and not args.offline:
68 objectsOnl.add(objTable[objU])
71 for fld
in args.folders.split(
","):
74 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
76 from LArCalibProcessing.LArCalibConfigFlags
import addLArCalibFlags
79 flags.Input.RunNumbers=[args.run]
80 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
81 flags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
85 flags.Input.isMC=args.isMC
86 flags.LArCalib.isSC=args.isSC
88 flags.LAr.doAlign=
False
90 flags.LAr.OFCShapeFolder=args.ofcfolder
92 from AthenaConfiguration.Enums
import LHCPeriod
93 if flags.Input.RunNumbers[0] < 222222:
95 flags.GeoModel.Run=LHCPeriod.Run1
96 flags.IOVDb.DatabaseInstance=
"OFLP200" if flags.Input.isMC
else "COMP200"
98 flags.GeoModel.Run=LHCPeriod.Run2
99 flags.IOVDb.DatabaseInstance=
"OFLP200" if flags.Input.isMC
else "CONDBR2"
102 flags.IOVDb.GlobalTag=args.dbtag
103 elif flags.Input.isMC:
104 flags.IOVDb.GlobalTag=
"OFLCOND-MC16-SDR-20"
105 elif flags.IOVDb.DatabaseInstance ==
"COMP200":
106 flags.IOVDb.GlobalTag=
"COMCOND-BLKPA-RUN1-09"
108 flags.IOVDb.GlobalTag=
"CONDBR2-ES1PA-2024-01"
113 flags.IOVDb.SqliteInput=args.sqlite
114 flags.IOVDb.SqliteFolders=tuple(flds)
115 if len(objects)!=len(objectsOnl):
116 flags.IOVDb.DBConnection=
"COOLOFL_LAR/CONDBR2"
120 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
124 from McEventSelector.McEventSelectorConfig
import McEventSelectorCfg
128 InitialTimeStamp = 0,
129 TimeStampInterval = 1))
134 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
137 if flags.LArCalib.isSC:
139 from LArCabling.LArCablingConfig
import LArOnOffIdMappingSCCfg, LArCalibIdMappingSCCfg, LArLATOMEMappingCfg
144 from LArConfiguration.LArElecCalibDBConfig
import LArElecCalibDBSCCfg
148 from LArCabling.LArCablingConfig
import LArOnOffIdMappingCfg, LArCalibIdMappingCfg
152 from LArConfiguration.LArElecCalibDBConfig
import LArElecCalibDBCfg
155 from LArBadChannelTool.LArBadChannelConfig
import LArBadChannelCfg
158 bcKey =
"LArBadChannelSC" if flags.LArCalib.isSC
else "LArBadChannel"
160 if "Pedestal" in objects:
161 ckey =
"LArPedestalSC" if flags.LArCalib.isSC
else "LArPedestal"
162 cfg.addEventAlgo(CompFactory.LArPedestals2Ntuple(ContainerKey = ckey,
163 AddFEBTempInfo =
False,
165 isSC = flags.LArCalib.isSC,
169 if "AutoCorr" in objects:
170 ckey=
"LArAutoCorrSC" if flags.LArCalib.isSC
else "LArAutoCorr"
171 cfg.addEventAlgo(CompFactory.LArAutoCorr2Ntuple(ContainerKey =
"LArAutoCorrSym" if flags.Input.isMC
else ckey,
172 AddFEBTempInfo =
False,
174 isSC = flags.LArCalib.isSC,
177 if "Ramp" in objects:
178 ckey =
"LArRampSC" if flags.LArCalib.isSC
else "LArRamp"
180 from IOVDbSvc.IOVDbSvcConfig
import addFolders
181 if flags.LArCalib.isSC:
182 cfg.merge(
addFolders(flags,
'/LAR/ElecCalibOflSC/Ramps/RampLinea',modifiers=
'<key>LArRampSC</key>',className=
'LArRampComplete'))
184 cfg.merge(
addFolders(flags,
'/LAR/ElecCalibOfl/Ramps/RampLinea',className=
'LArRampComplete'))
185 cfg.addEventAlgo(CompFactory.LArRamps2Ntuple(RampKey=
"LArRampSym" if flags.Input.isMC
else ckey,
186 AddFEBTempInfo =
False,
188 isSC = flags.LArCalib.isSC,
194 from IOVDbSvc.IOVDbSvcConfig
import addFolders
198 cfg.merge(
addFolders(flags,fld,tag=
"".
join(foldername.split(
'/')) + args.ftag))
201 ckey=
'LArOFC' if '1phase' in fld
else 'LArLArOFCPhys4samples'
204 ckey =
"LArOFCSC" if flags.LArCalib.isSC
else "LArOFC"
205 cfg.addEventAlgo(CompFactory.LArOFC2Ntuple(AddFEBTempInfo =
False,
207 isSC = flags.LArCalib.isSC,
211 if "OFCCali" in objects:
213 from IOVDbSvc.IOVDbSvcConfig
import addFolders
217 cfg.merge(
addFolders(flags,fld,tag=
"".
join(foldername.split(
'/')) + args.ftag))
220 ckey=
'LArOFC' if '1phase' in fld
else 'LArOFC'
223 ckey =
"LArOFCSCCali" if flags.LArCalib.isSC
else "LArOFCCali"
224 fldr =
"/LAR/ElecCalibFlatSC/OFCCali" if flags.LArCalib.isSC
else "/LAR/ElecCalibFlat/OFCCali"
225 dbString =
"<db>sqlite://;schema="+args.sqlite+
";dbname=CONDBR2" if args.sqlite
else "<db>COOLONL_LAR/CONDBR2</db>"
226 from IOVDbSvc.IOVDbSvcConfig
import addFolders
227 cfg.merge(
addFolders(flags,fldr,detDb=dbString,className=
"CondAttrListCollection"))
228 LArOFCSCCondAlg = CompFactory.getComp(
"LArFlatConditionsAlg<LArOFCSC>")(
"LArOFCSCCaliCondAlg")
229 LArOFCSCCondAlg.ReadKey=fldr
230 LArOFCSCCondAlg. WriteKey=ckey
231 cfg.addCondAlgo(LArOFCSCCondAlg)
233 cfg.addEventAlgo(CompFactory.LArOFC2Ntuple(
"LArOFC2NtupleCali",
234 AddFEBTempInfo =
False,
236 NtupleName=
"OFCCali" if args.ntname==
'' else args.ntname,
237 isSC = flags.LArCalib.isSC,
242 if "Shape" in objects:
243 ckey =
"LArShapeSC" if flags.LArCalib.isSC
else "LArShape"
246 cfg.addEventAlgo(CompFactory.LArShape2Ntuple(ContainerKey=ckey,
247 AddFEBTempInfo =
False,
249 isSC = flags.LArCalib.isSC,
253 if "MphysOverMcal" in objects:
254 cfg.addEventAlgo(CompFactory.LArMphysOverMcal2Ntuple(ContainerKey =
"LArMphysOverMcalSC" if flags.LArCalib.isSC
else "LArMphysOverMcal",
255 AddFEBTempInfo =
False,
257 isSC = flags.LArCalib.isSC,
262 if "DAC2uA" in objects
or "uA2MeV" in objects:
263 uackey =
"LAruA2MeVSC" if flags.LArCalib.isSC
else "LAruA2MeV"
264 dackey =
"LArDAC2uASC" if flags.LArCalib.isSC
else "LArDAC2uA"
265 ua2MeVKey=
"LAruA2MeVSym" if flags.Input.isMC
else uackey
266 dac2uAKey=
"LArDAC2uASym" if flags.Input.isMC
else dackey
268 cfg.addEventAlgo(CompFactory.LAruA2MeV2Ntuple(uA2MeVKey=ua2MeVKey
if "uA2MeV" in objects
else "",
269 DAC2uAKey=dac2uAKey
if "DAC2uA" in objects
else "",
270 isSC = flags.LArCalib.isSC,
275 if "HVScaleCorr" in objects:
276 cfg.addEventAlgo(CompFactory.LArHVScaleCorr2Ntuple(ContainerKey=
"LArHVScaleCorrSC" if flags.LArCalib.isSC
else "LArHVScaleCorr",
277 AddFEBTempInfo =
False,
278 isSC = flags.LArCalib.isSC,
282 if "fSampl" in objects:
283 cfg.addEventAlgo(CompFactory.LArfSampl2Ntuple(ContainerKey=
"LArfSamplSC" if flags.LArCalib.isSC
else "LArfSamplSym",
284 isSC=flags.LArCalib.isSC
287 if "CaliWave" in objects:
289 print(
'No CaliWave in MC')
291 fld =
"/LAR/ElecCalibOflSC/CaliWaves/CaliWave" if flags.LArCalib.isSC
else "/LAR/ElecCalibOfl/CaliWaves/CaliWave"
292 from IOVDbSvc.IOVDbSvcConfig
import addFolders
293 cfg.merge(
addFolders(flags,fld,modifiers=
'<key>LArCaliWave</key><typeName>LArCaliWaveContainer</typeName>'))
294 cfg.addEventAlgo(CompFactory.LArCaliWaves2Ntuple(KeyList = [
"LArCaliWave"],
295 NtupleName =
"CALIWAVE",
296 AddFEBTempInfo =
False,
297 SaveDerivedInfo =
True,
301 isSC = flags.LArCalib.isSC,
305 if "PhysWave" in objects:
307 print(
'No PhysWave in MC yet')
309 fld =
"/LAR/ElecCalibOflSC/PhysWaves/RTM" if flags.LArCalib.isSC
else "/LAR/ElecCalibOfl/PhysWaves/RTM"
310 from IOVDbSvc.IOVDbSvcConfig
import addFolders
312 cfg.addEventAlgo(CompFactory.LArPhysWaves2Ntuple(KeyList = [
"LArPhysWave"],
313 NtupleName =
"PHYSWAVE",
314 AddFEBTempInfo =
False,
315 SaveDerivedInfo =
True,
318 isSC = flags.LArCalib.isSC,
323 if os.path.exists(rootfile):
325 cfg.addService(CompFactory.NTupleSvc(Output = [
"FILE1 DATAFILE='"+rootfile+
"' OPT='NEW'" ]))
326 cfg.setAppProperty(
"HistogramPersistency",
"ROOT")
328 if args.dbtag
and 'CALIB' in args.dbtag:
329 cfg.getService(
"IOVDbSvc").DBInstance=
""
332 cfg.getService(
"PoolSvc").ReadCatalog+=[
"xmlcatalog_file:%s"%args.poolcat,]