ATLAS Offline Software
Loading...
Searching...
No Matches
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
16import os,sys,getopt
17from AthenaConfiguration.TestDefaults import defaultGeometryTags
18fhistory = os.path.expanduser("~/.LArCellConditionsHist")
19
20
21def 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
34try:
35 opts,args=getopt.getopt(sys.argv[1:],"csmgdhr:t:",["help","detdescr=","sqlite="])
36except Exception as e:
37 usage()
38 print(e)
39 sys.exit(-1)
40
41
42printCond=False
43run=None
44tag=None
45sv=True
46geo=False
47detdescrtag=defaultGeometryTags.RUN2
48detdescrset=False
49sqlite=""
50
51for 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
66import readline
67
68try:
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
106except:
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
112sys.argv = sys.argv[:1] + ['-b']
113
114from AthenaConfiguration.AllConfigFlags import initConfigFlags
115flags=initConfigFlags()
116flags.Input.Files = []
117flags.Input.TimeStamps = [1000]
118flags.Input.isMC=False
119flags.Input.RunNumbers=[run]
120flags.IOVDb.DatabaseInstance="CONDBR2" if run>222222 else "COMP200"
121flags.IOVDb.GlobalTag=tag
122flags.GeoModel.AtlasVersion = detdescrtag
123flags.LAr.doAlign=False
124from AthenaCommon.Constants import FATAL
125flags.Exec.OutputLevel=FATAL
126flags.lock()
127
128from RootUtils import PyROOTFixes # noqa F401
129from AthenaConfiguration.MainServicesConfig import MainServicesCfg
130cfg=MainServicesCfg(flags)
131
132from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
133cfg.merge (McEventSelectorCfg (flags))
134
135if geo:
136 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
137 cfg.merge(LArGMCfg(flags))
138else:
139 from DetDescrCnvSvc.DetDescrCnvSvcConfig import DetDescrCnvSvcCfg
140 cfg.merge(DetDescrCnvSvcCfg(flags))
141
142from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
143cfg.merge(LArOnOffIdMappingCfg(flags))
144
145from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDBCfg
146requiredConditions=["Pedestal","Ramp","DAC2uA","uA2MeV","MphysOverMcal","HVScaleCorr"]
147cfg.merge(LArElecCalibDBCfg(flags,requiredConditions))
148
149from LArBadChannelTool.LArBadChannelConfig import LArBadChannelCfg
150cfg.merge(LArBadChannelCfg(flags))
151
152from LArConditionsCommon.LArCellConditionsAlg import LArCellConditionsAlg
153theLArCellConditionsAlg=LArCellConditionsAlg("LArCellConditions",
154 printConditions=printCond,
155 printLocation=geo)
156cfg.addEventAlgo(theLArCellConditionsAlg)
157
158if os.path.exists( fhistory ):
159 readline.read_history_file( fhistory )
160readline.set_history_length( 128 )
161cfg.run(2) #First event is dummy to close DB connections, second has the user-loop
162
163readline.write_history_file(fhistory)
void print(char *figname, TCanvas *c1)