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(
'-o',
'--output',type=str,default=
"hvcorr",help=
"name stub for root and sqlite output files")
80 args = parser.parse_args()
83 from time
import strptime
84 from calendar
import timegm
86 ts=strptime(args.datestamp+
'/UTC',
'%Y-%m-%d:%H:%M:%S/%Z')
87 TimeStamp=
int(timegm(ts))
88 TimeStamp_ns=TimeStamp*1000000000
89 except ValueError
as e:
90 print(
"ERROR in time specification, use e.g. 2007-05-25:14:01:00")
95 from LArCalibProcessing.TimeStampToRunLumi
import TimeStampToRunLumi
99 print(
"WARNING: Failed to convert time",TimeStamp_ns,
"into a run/lumi number. Using 'infinite' run-number",rlb[0])
102 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
104 flags.Input.RunNumbers=[rlb[0]]
105 flags.Input.TimeStamps=[TimeStamp]
107 flags.IOVDb.DatabaseInstance=
"CONDBR2"
108 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
109 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
112 flags.IOVDb.GlobalTag=args.globaltag
118 print(
"Start running...")