4 from AthenaConfiguration.ComponentFactory
import CompFactory
5 from AthenaConfiguration.MainServicesConfig
import MainEvgenServicesCfg
8 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
12 from LArCalibUtils.LArHVScaleConfig
import LArHVScaleCfg
15 result.getCondAlgo(
"LArHVCondAlg").UndoOnlineHVCorr=
False
16 result.getCondAlgo(
"LArHVCondAlg").keyOutputCorr=
"NewLArHVScaleCorr"
21 result.addEventAlgo(CompFactory.LArHVCorrMaker(LArHVScaleCorr=
"NewLArHVScaleCorr"))
24 from LArCalibTools.LArCalib_HVScale2NtupleConfig
import LArHVScaleCorr2NtupleCfg
26 result.getEventAlgo(
"LArHVScaleCorr2Ntuple").ContainerKey=
"NewLArHVScaleCorr"
29 from RegistrationServices.OutputConditionsAlgConfig
import OutputConditionsAlgCfg
31 outputFile=
"dummy.root",
32 ObjectList=[
"CondAttrListCollection#/LAR/ElecCalibFlat/HVScaleCorr",],
40 result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders =
True,
42 OverrideNames = [
"HVScaleCorr"],
43 OverrideTypes = [
"Blob16M"],
46 result.getService(
"IOVDbSvc").DBInstance=
""
50 if __name__==
"__main__":
52 from time
import time,strptime
53 from calendar
import timegm
55 parser= argparse.ArgumentParser(description=
"Recalclulate HV corrections based on DCS values")
56 parser.add_argument(
'datestamp',help=
"time specification like 2007-05-25:14:01:00")
57 parser.add_argument(
'Run',type=int, nargs=
'?', default=0,help=
"IOV start (run-number)")
58 parser.add_argument(
'LB',type=int, nargs=
'?', default=0,help=
"IOV start (run-number)")
59 parser.add_argument(
'-g',
'--globaltag', type=str, help=
"Geometry Tag ")
60 parser.add_argument(
'-o',
'--output',type=str,default=
"hvcorr",help=
"name stub for root and sqlite output files")
62 args = parser.parse_args()
64 ts=strptime(args.datestamp+
'/UTC',
'%Y-%m-%d:%H:%M:%S/%Z')
65 TimeStamp=
int(timegm(ts))
66 TimeStamp_ns=TimeStamp*1000000000
67 except ValueError
as e:
68 print(
"ERROR in time specification, use e.g. 2007-05-25:14:01:00")
72 from LArCalibProcessing.TimeStampToRunLumi
import TimeStampToRunLumi
77 print(
"WARNING: Failed to convert time",TimeStamp_ns,
"into a run/lumi number. Using 'infinite' run-number",rlb[0])
80 print(
"---> Working on run",rlb[0],
"LB",rlb[1],
"Timestamp:",TimeStamp)
81 timediff=
int(time()-TimeStamp)
83 print(
"ERROR: Timestamp in the future???")
85 (days,remainder)=divmod(timediff,24*60*60)
86 (hours,seconds)=divmod(remainder,60*60)
87 print (
"---> Timestamp is %i days %i hours and %i minutes ago" % (days,hours,
int(seconds/60)))
90 print(
"Output IOV will be from run %i lumiblock %i to INF" % (args.Run,args.LB))
92 outputName=args.output
94 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
95 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
99 ConfigFlags.IOVDb.GlobalTag=args.globaltag
101 ConfigFlags.Input.RunNumbers=[rlb[0]]
102 ConfigFlags.Input.LumiBlockNumbers=[rlb[1]]
103 ConfigFlags.Input.TimeStamps=[TimeStamp]
104 ConfigFlags.Input.Files=[]
105 ConfigFlags.IOVDb.DatabaseInstance=
"CONDBR2"
106 ConfigFlags.IOVDb.DBConnection=
"sqlite://;schema="+outputName+
".sqlite;dbname=CONDBR2"
107 ConfigFlags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
112 cfg.getService(
"EventSelector").FirstLB=ConfigFlags.Input.LumiBlockNumbers[0]
113 cfg.merge(
HVCorrConfig(ConfigFlags,outputName,args.Run,args.LB))
116 print(
"Start running...")
118 sys.exit(cfg.run(1).isFailure())