ATLAS Offline Software
LArCellConditions.py
Go to the documentation of this file.
1 #!/bin/env python
2 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 
4 
14 
15 
16 import os,sys,getopt
17 from AthenaConfiguration.TestDefaults import defaultGeometryTags
18 fhistory = os.path.expanduser("~/.LArCellConditionsHist")
19 
20 
21 def usage():
22  print(sys.argv[0]+": Convert and expand LAr Identifiers, print some database content")
23  print("Options:")
24  print("-c Print also (some) electronic calibration constants")
25  print("-s Use SingleVersion folders (default)")
26  print("-m Use MultiVersion folders (the opposite of -s)")
27  print("-g Include geometrical position (true eta/phi)")
28  print("-r <run> Specify a run number")
29  print("-t <tag> Specify global tag")
30  print("--detdescr <DetDescrVersion>")
31  print("--sqlite <sqlitefile>")
32  print("-h Print this help text and exit")
33 
34 try:
35  opts,args=getopt.getopt(sys.argv[1:],"csmgdhr:t:",["help","detdescr=","sqlite="])
36 except Exception as e:
37  usage()
38  print(e)
39  sys.exit(-1)
40 
41 
42 printCond=False
43 run=None
44 tag=None
45 sv=True
46 geo=False
47 detdescrtag=defaultGeometryTags.RUN2
48 detdescrset=False
49 sqlite=""
50 
51 for o,a in opts:
52  if (o=="-c"): printCond=True
53  if (o=="-t"): tag=a
54  if (o=="-r" and a.isdigit()): run=int(a)
55  if (o=="-s"): sv=True
56  if (o=="-m"): sv=False
57  if (o=="-g"): geo=True
58  if (o=="-h" or o=="--help"):
59  usage()
60  sys.exit(0)
61  if (o=="--detdescr"):
62  detdescrtag=a
63  detdescrset=True
64  if (o=="--sqlite"): sqlite=a
65 
66 import readline
67 
68 try:
69  if run is None:
70  defRun=0x7fffffff
71  prompt= "Enter run number [%i]:" % defRun
72  runIn=input(prompt).strip()
73  if runIn=="":
74  run=defRun
75  else:
76  if runIn.isdigit():
77  run=int(runIn)
78  else:
79  usage()
80  print("Expect numerical parameter for run, got",runIn)
81  sys.exit(0)
82  pass
83  pass
84  pass
85 
86  if tag is None:
87  if (run>222222):
88  defTag="CONDBR2-BLKPA-2014-00"
89  else:
90  defTag="COMCOND-BLKPA-RUN1-06"
91  pass
92  prompt= "Enter conditions tag [%s]:" % defTag
93  tagIn=input(prompt).strip()
94  if tagIn=="":
95  tag=defTag
96  else:
97  tag=tagIn
98 
99 
100  if geo and not detdescrset:
101  prompt="Enter DetectorDescripton tag [%s]:" % detdescrtag
102  detdescrtagIn=input(prompt).strip()
103  if detdescrtagIn != "":
104  detdescrtag=detdescrtagIn
105 
106 except:
107  print("Failed to get run number and/or conditions tag")
108  sys.exit(0)
109 
110 
111 #Don't let PyRoot open X-connections
112 sys.argv = sys.argv[:1] + ['-b']
113 
114 from AthenaConfiguration.AllConfigFlags import initConfigFlags
116 flags.Input.Files = []
117 flags.Input.TimeStamps = [1000]
118 flags.Input.isMC=False
119 flags.Input.RunNumbers=[run]
120 flags.IOVDb.DatabaseInstance="CONDBR2" if run>222222 else "COMP200"
121 flags.IOVDb.GlobalTag=tag
122 flags.GeoModel.AtlasVersion = detdescrtag
123 flags.LAr.doAlign=False
124 from AthenaCommon.Constants import FATAL
125 flags.Exec.OutputLevel=FATAL
126 flags.lock()
127 
128 from RootUtils import PyROOTFixes # noqa F401
129 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
130 cfg=MainServicesCfg(flags)
131 
132 from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
133 cfg.merge (McEventSelectorCfg (flags))
134 
135 if geo:
136  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
137  cfg.merge(LArGMCfg(flags))
138 else:
139  from DetDescrCnvSvc.DetDescrCnvSvcConfig import DetDescrCnvSvcCfg
140  cfg.merge(DetDescrCnvSvcCfg(flags))
141 
142 from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
143 cfg.merge(LArOnOffIdMappingCfg(flags))
144 
145 from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDBCfg
146 requiredConditions=["Pedestal","Ramp","DAC2uA","uA2MeV","MphysOverMcal","HVScaleCorr"]
147 cfg.merge(LArElecCalibDBCfg(flags,requiredConditions))
148 
149 from LArBadChannelTool.LArBadChannelConfig import LArBadChannelCfg
150 cfg.merge(LArBadChannelCfg(flags))
151 
152 from LArConditionsCommon.LArCellConditionsAlg import LArCellConditionsAlg
153 theLArCellConditionsAlg=LArCellConditionsAlg("LArCellConditions",
154  printConditions=printCond,
155  printLocation=geo)
156 cfg.addEventAlgo(theLArCellConditionsAlg)
157 
158 if os.path.exists( fhistory ):
159  readline.read_history_file( fhistory )
160 readline.set_history_length( 128 )
161 cfg.run(2) #First event is dummy to close DB connections, second has the user-loop
162 
163 readline.write_history_file(fhistory)
python.LArElecCalibDBConfig.LArElecCalibDBCfg
def LArElecCalibDBCfg(flags, condObjs)
Definition: LArElecCalibDBConfig.py:47
python.LArBadChannelConfig.LArBadChannelCfg
def LArBadChannelCfg(configFlags, tag=None, isSC=False)
Definition: LArBadChannelConfig.py:8
python.DetDescrCnvSvcConfig.DetDescrCnvSvcCfg
def DetDescrCnvSvcCfg(flags, **kwargs)
Definition: DetDescrCnvSvcConfig.py:6
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:245
Constants
some useful constants -------------------------------------------------—
LArCablingConfig.LArOnOffIdMappingCfg
def LArOnOffIdMappingCfg(configFlags)
Definition: LArCablingConfig.py:62
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
readCCLHist.int
int
Definition: readCCLHist.py:84
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
LArCellConditions.usage
def usage()
Definition: LArCellConditions.py:21