ATLAS Offline Software
Loading...
Searching...
No Matches
LArCalib_HVCorrConfig.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
4
5from AthenaConfiguration.ComponentFactory import CompFactory
6from AthenaConfiguration.MainServicesConfig import MainEvgenServicesCfg
7
8def HVCorrConfig(flags, outputName="hvcorr", runOut=0, lbOut=0, isHI=False, hipatch=1.4, **hvscaleprops):
9
10 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
11 result=LArGMCfg(flags)
12
13 from LArCalibUtils.LArHVScaleConfig import LArHVScaleCfg
14 result.merge(LArHVScaleCfg(flags, keyOutputFullCorr="NewLArHVScaleCorr", **hvscaleprops))
15
16 from LArCabling.LArCablingConfig import LArOnOffIdMappingSCCfg
17 result.merge(LArOnOffIdMappingSCCfg(flags))
18 result.addEventAlgo(CompFactory.LArHVCorrToSCHVCorr(ContainerKey="NewLArHVScaleCorr",OutputKey="NewSCLArHVScaleCorr",
19 OutputFolder="/LAR/ElecCalibFlatSC/HVScaleCorrNew",
20 IsHeavyIons=isHI, PatchInHeavyIons=hipatch,
21 PhysicsWeights="TrigT1CaloCalibUtils/HVcorrPhysicsWeights.txt"))
22
23 #The LArHVCorrMaker creates a flat blob in a CondAttrListCollection
24 #Input: The HV Scale Correction computed by the LArHVCondAlg based on the DCS HV values
25 result.addEventAlgo(CompFactory.LArHVCorrMaker(LArHVScaleCorr="NewLArHVScaleCorr",folderName="/LAR/ElecCalibFlat/HVScaleCorrNew"))
26
29
30 #Ntuple writing ...
31 from LArCalibTools.LArCalib_HVScale2NtupleConfig import LArHVScaleCorr2NtupleCfg
32 result.merge(LArHVScaleCorr2NtupleCfg(flags, rootfile=outputName+'_ntuple.root',
33 hvcorr="NewLArHVScaleCorr", hvcorrSC="NewSCLArHVScaleCorr"))
34
35 #sqlite writing ...
36 from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
37 result.merge(OutputConditionsAlgCfg(flags,
38 outputFile="dummy.root",
39 ObjectList=["CondAttrListCollection#/LAR/ElecCalibFlat/HVScaleCorrNew#/LAR/ElecCalibFlat/HVScaleCorr",
40 "CondAttrListCollection#/LAR/ElecCalibFlatSC/HVScaleCorrNew#/LAR/ElecCalibFlatSC/HVScaleCorr",],
41 Run1=runOut,
42 LB1=lbOut
43 ))
44
45
46
47 #RegistrationSvc
48 result.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = True,
49 SVFolder=True,
50 OverrideNames = ["HVScaleCorr"],
51 OverrideTypes = ["Blob16M"],
52 ))
53 return result
54
55
57 # also used in CaloNoiseConfig.py
58 parser.add_argument('--isHI', dest='hi', default=False, help='is for HI ?', action='store_true')
59 parser.add_argument('--patchHI', dest='patchhi', type=float, default=1.4, help="Patching value for HI")
60
61
62if __name__=="__main__":
63 import argparse
64 from time import time
65 from LArCalibUtils.LArHVScaleConfig import addHvScaleParserArgs, buildHvScaleProps
66 parser= argparse.ArgumentParser(description="Recalculate HV corrections based on DCS values")
67 parser.add_argument('datestamp',help="time specification like 2007-05-25:14:01:00")
68 parser.add_argument('Run',type=int, nargs='?', default=0,help="IOV start (run-number)")
69 parser.add_argument('LB',type=int, nargs='?', default=0,help="IOV start (run-number)")
70 parser.add_argument('-g', '--globaltag', type=str, help="Global conditions Tag ")
71 parser.add_argument('-o', '--output',type=str,default="hvcorr",help="name stub for root and sqlite output files")
72 parser.add_argument('-l','--olevel',type=int, default=3,help="OutputLevel")
73 parser.add_argument('-s', '--sqlite',type=str,default="",help="name of sqlite file to be used instead of COOL")
74 addHvScaleParserArgs(parser)
76 args = parser.parse_args()
77 from AthenaConfiguration.AllConfigFlags import initConfigFlags
78 from LArCalibProcessing.TimeStampToRunLumi import fillInputFlags
79 ConfigFlags = initConfigFlags()
80 fillInputFlags(ConfigFlags, args.datestamp + "/UTC", infiniteRun=0xFFFFFFF-1)
81 print(f"---> Working on run {ConfigFlags.Input.RunNumbers[0]} LB {ConfigFlags.Input.LumiBlockNumbers[0]} "
82 f"Timestamp: {ConfigFlags.Input.TimeStamps[0]}")
83 timediff=int(time()-ConfigFlags.Input.TimeStamps[0])
84 if timediff<0:
85 print("ERROR: Timestamp in the future???")
86 else:
87 (days,remainder)=divmod(timediff,24*60*60)
88 (hours,seconds)=divmod(remainder,60*60)
89 print ("---> Timestamp is %i days %i hours and %i minutes ago" % (days,hours,int(seconds/60)))
90 pass
91 print("Output IOV will be from run %i lumiblock %i to INF" % (args.Run,args.LB))
92 outputName=args.output
93 from AthenaConfiguration.TestDefaults import defaultGeometryTags
94 if args.globaltag:
95 ConfigFlags.IOVDb.GlobalTag=args.globaltag
96 ConfigFlags.Input.Files=[]
97 ConfigFlags.IOVDb.DatabaseInstance="CONDBR2"
98 ConfigFlags.IOVDb.DBConnection="sqlite://;schema="+outputName+".db;dbname=CONDBR2"
99 if len(args.sqlite)>0:
100 ConfigFlags.IOVDb.SqliteInput=args.sqlite
101 ConfigFlags.IOVDb.SqliteFolders=("/LAR/ElecCalibFlat/HVScaleCorr",)
102 ConfigFlags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
103 ConfigFlags.Exec.OutputLevel=args.olevel
104 ConfigFlags.lock()
105 hvsp=buildHvScaleProps(args)
106 hvsp["keyOutputResidualCorr"]="" # tentativelydon't produce these (only full corr.) to save resources
107 cfg=MainEvgenServicesCfg(ConfigFlags)
108 #First LB not set by McEventSelectorCfg, set it here:
109 cfg.getService("EventSelector").FirstLB=ConfigFlags.Input.LumiBlockNumbers[0]
110 cfg.merge(HVCorrConfig(ConfigFlags, outputName, runOut=args.Run, lbOut=args.LB,
111 isHI=args.hi, hipatch=args.patchhi, **hvsp))
112 print("Start running...")
113 import sys
114 sys.exit(cfg.run(1).isFailure())
void print(char *figname, TCanvas *c1)
HVCorrConfig(flags, outputName="hvcorr", runOut=0, lbOut=0, isHI=False, hipatch=1.4, **hvscaleprops)