ATLAS Offline Software
LArCalib_HVScale2NtupleConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.ComponentFactory import CompFactory
4 from AthenaConfiguration.MainServicesConfig import MainEvgenServicesCfg
5 
6 def LArHVScaleCorr2NtupleCfg(flags, rootfile="hvcorr_read.root"):
7 
8  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
9  result=LArGMCfg(flags)
10 
11  from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
12  result.merge(LArOnOffIdMappingCfg(flags))
13 
14  from LArBadChannelTool.LArBadChannelConfig import LArBadChannelCfg
15  result.merge(LArBadChannelCfg(flags))
16 
17  from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDBCfg
18  result.merge(LArElecCalibDBCfg(flags,["HVScaleCorr"]))
19 
20 
21  theLArHVScaleCorr2Ntuple = CompFactory.LArHVScaleCorr2Ntuple("LArHVScaleCorr2Ntuple")
22  theLArHVScaleCorr2Ntuple.AddFEBTempInfo = False
23  theLArHVScaleCorr2Ntuple.OffId=True
24  result.addEventAlgo(theLArHVScaleCorr2Ntuple)
25 
26  import os
27  if os.path.exists(rootfile):
28  os.remove(rootfile)
29  result.addService(CompFactory.NTupleSvc(Output = [ "FILE1 DATAFILE='"+rootfile+"' OPT='NEW'" ]))
30  result.setAppProperty("HistogramPersistency","ROOT")
31 
32  return result
33 
34 if __name__=="__main__":
35  import sys
36  from time import strptime
37  from calendar import timegm
38 
39  if len(sys.argv)<2:
40  print("Usage:")
41  print("%s <time> <outputfile> <globaltag>" % sys.argv[0])
42  sys.exit(-1)
43 
44 
45  try:
46  ts=strptime(sys.argv[1]+'/UTC','%Y-%m-%d:%H:%M:%S/%Z')
47  TimeStamp=int(timegm(ts))
48  TimeStamp_ns=TimeStamp*1000000000
49  except ValueError as e:
50  print("ERROR in time specification, use e.g. 2007-05-25:14:01:00")
51  print(e)
52  sys.exit(-1)
53 
54  from LArCalibProcessing.TimeStampToRunLumi import TimeStampToRunLumi
55 
56  rlb=TimeStampToRunLumi(TimeStamp_ns)
57  if rlb is None:
58  rlb=[0xFFFFFFF-1,0]
59  print("WARNING: Failed to convert time",TimeStamp_ns,"into a run/lumi number. Using 'infinite' run-number",rlb[0])
60 
61 
62  from AthenaConfiguration.AllConfigFlags import initConfigFlags
63  flags = initConfigFlags()
64  from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
65  addLArCalibFlags(flags)
66 
67  flags.Input.RunNumbers=[rlb[0]]
68  flags.Input.TimeStamps=[TimeStamp]
69  flags.Input.Files=[]
70  flags.IOVDb.DatabaseInstance="CONDBR2"
71  from AthenaConfiguration.TestDefaults import defaultGeometryTags
72  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
73 
74  rootfile="hvcorr_read.root"
75  if len(sys.argv)>2:
76  rootFile=sys.argv[2]
77 
78  if len(sys.argv)>3:
79  flags.IOVDb.GlobalTag=sys.argv[3]
80 
81  flags.lock()
83  cfg.merge(LArHVScaleCorr2NtupleCfg(flags))
84 
85 
86  print("Start running...")
87  cfg.run(1)
python.LArElecCalibDBConfig.LArElecCalibDBCfg
def LArElecCalibDBCfg(flags, condObjs)
Definition: LArElecCalibDBConfig.py:47
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.LArBadChannelConfig.LArBadChannelCfg
def LArBadChannelCfg(configFlags, tag=None, isSC=False)
Definition: LArBadChannelConfig.py:8
python.MainServicesConfig.MainEvgenServicesCfg
def MainEvgenServicesCfg(flags, LoopMgr="AthenaEventLoopMgr", withSequences=True)
Definition: MainServicesConfig.py:349
LArCablingConfig.LArOnOffIdMappingCfg
def LArOnOffIdMappingCfg(configFlags)
Definition: LArCablingConfig.py:62
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
LArCalib_HVScale2NtupleConfig.LArHVScaleCorr2NtupleCfg
def LArHVScaleCorr2NtupleCfg(flags, rootfile="hvcorr_read.root")
Definition: LArCalib_HVScale2NtupleConfig.py:6
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
python.LArCalibConfigFlags.addLArCalibFlags
def addLArCalibFlags(flags, isSC=False)
Definition: LArCalibConfigFlags.py:3
python.TimeStampToRunLumi.TimeStampToRunLumi
def TimeStampToRunLumi(tmstmp, guard=1, dbInstance="CONDBR2")
Definition: TimeStampToRunLumi.py:3