3 from AthenaConfiguration.ComponentFactory
import CompFactory
4 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
5 from AthenaConfiguration.MainServicesConfig
import MainEvgenServicesCfg
7 from CaloTools.CaloNoiseCondAlgConfig
import CaloNoiseCondAlgCfg
8 from LArCalibUtils.LArHVScaleConfig
import LArHVScaleCfg
9 from IOVDbSvc.IOVDbSvcConfig
import addOverride
10 from AthenaCommon.Logging
import logging
16 flags.Calo.Noise.fixedLumiForNoise=1
17 flags.LAr.doHVCorr =
False
20 msg = logging.getLogger(
"CaloScaleNoiseCfg")
25 noisetag=
"LARNoiseOflCellNoise-RUN2-UPD1-00"
26 msg.info(
"Noise rescaling using tag %s", noisetag)
29 raise RuntimeError(
"At this point (early run 3), only a dt of 25ns is supported")
32 noisetag=
"LARNoiseOflCellNoisenoise-mc16-EposA3-ofc25mu0-25ns"
34 noisetag=
"LARNoiseOflCellNoisenoise-mc16-EposA3-ofc25mu60-25ns"
36 raise RuntimeError(
"At this point (early run 3), only mu values of 0 and 60 are supported")
39 msg.info(
"Absolute noise scaling using tag %s for mu=%i and dt=%i" , noisetag,mu,dt)
43 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
45 from TileGeoModel.TileGMConfig
import TileGMCfg
55 result.merge(
addOverride(flags,
"/LAR/NoiseOfl/CellNoise",noisetag))
57 result.merge(
addOverride(flags,
"/LAR/NoiseOfl/CellNoise",noisetag))
61 result.addEventAlgo(CompFactory.CaloRescaleNoise(absScaling=absolute))
64 rootfile=
"cellnoise_data.root"
65 if os.path.exists(rootfile):
67 result.addService(CompFactory.THistSvc(Output = [
"file1 DATAFILE='"+output+
"' OPT='RECREATE'"]))
68 result.setAppProperty(
"HistogramPersistency",
"ROOT")
73 if __name__==
"__main__":
75 parser= argparse.ArgumentParser(description=
"(Re-)scale noise based on HV DCS values")
76 parser.add_argument(
'datestamp',help=
"time specification like 2007-05-25:14:01:00")
77 parser.add_argument(
'-a',
'--absolute', action=
"store_true", help=
"Absolute rescaling based on noise derived from MC")
78 parser.add_argument(
'-t',
'--globaltag', type=str, help=
"Global conditions tag ")
79 parser.add_argument(
'-s',
'--sqlite', type=str,help=
"sqlite with CellNoise and HVCorr folders to be scaled ")
80 parser.add_argument(
'-o',
'--output',type=str,default=
"cellnoise_data.root",help=
"name stub for root and sqlite output files")
81 args = parser.parse_args()
84 from time
import strptime
85 from calendar
import timegm
87 ts=strptime(args.datestamp+
'/UTC',
'%Y-%m-%d:%H:%M:%S/%Z')
88 TimeStamp=
int(timegm(ts))
89 TimeStamp_ns=TimeStamp*1000000000
90 except ValueError
as e:
91 print(
"ERROR in time specification, use e.g. 2007-05-25:14:01:00")
96 from LArCalibProcessing.TimeStampToRunLumi
import TimeStampToRunLumi
101 print(
"WARNING: CaloScaleNoise: Failed to convert time",TimeStamp_ns,
"into a run/lumi number. Using 'infinite' run-number",rlb[0])
104 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
106 flags.Input.RunNumbers=[rlb[0]]
107 print(
"set the runnumber: ",flags.Input.RunNumbers)
108 flags.Input.TimeStamps=[TimeStamp]
110 flags.IOVDb.DatabaseInstance=
"CONDBR2"
111 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
112 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
115 flags.IOVDb.GlobalTag=args.globaltag
118 flags.IOVDb.SqliteInput=args.sqlite
119 flags.IOVDb.SqliteFolders=(
"/LAR/NoiseOfl/CellNoise",
"/LAR/ElecCalibFlat/HVScaleCorr",)
125 print(
"Start running...")