ATLAS Offline Software
CalibCoolCompareRT.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 from __future__ import print_function
4 
5 import sys
6 import getopt
7 
8 cool_database_strings=['COOLOFL_MDT/COMP200', 'COOLOFL_MDT/COMP200']
9 cool_folders=['/MDT/RT', '/MDT/RT']
10 cool_tags=['COMCOND-BLKPST-004-07', 'COMCOND-BLKPST-004-07']
11 run_numbers=[None, None]
12 
13 def printhelp(argv0):
14  sys.stderr.write("Usage: " + argv0 + " [-h] [-s <cool database string>] [-f <cool folder>] [-t <cool tag>] <run number 1> [-s <cool database string>] [-f <cool folder>] [-t <cool tag>] <run number 2> <root file>\n")
15  sys.exit(1)
16 
17 theArgs=sys.argv[1:]
18 
19 for i in range(2):
20  optlist, args = getopt.getopt(theArgs, 'hs:f:t:')
21 
22  for opt, oa in optlist:
23  if opt=='-s':
24  if oa[-2:]=='db':
25  cool_database_strings[i] = 'sqlite://;schema=' + oa + ';dbname=COMP200'
26  cool_tags[i]=''
27  else:
28  cool_database_strings[i] = oa
29  continue
30  if opt=='-f':
31  cool_folders[i]=oa
32  continue
33  if opt=='-t':
34  cool_tags[i]=oa
35  continue
36  if opt=='-h':
37  printhelp(sys.argv[0])
38  continue
39  if len(args)<2:
40  sys.stderr.write("Error in commandline!\n")
41  printhelp(sys.argv[0])
42  try:
43  run_numbers[i]=int(args[0])
44  except ValueError:
45  sys.stderr.write("Error in commandline!\n")
46  printhelp(sys.argv[0])
47  theArgs=args[1:]
48 
49 if len(theArgs)!=1:
50  sys.stderr.write("Error in commandline!\n")
51  printhelp(sys.argv[0])
52 
53 outfile_nm=theArgs[0]
54 
55 print (cool_database_strings)
56 print (cool_folders)
57 print (cool_tags)
58 print (run_numbers)
59 print (outfile_nm)
60 
61 sys.argv=[sys.argv[0], '-b']
62 
63 from ROOT import *
64 from array import *
65 
68 
69 cool_rts=[]
70 
71 outfile=TFile(outfile_nm, "RECREATE")
72 
73 for i in range(2):
74  outfile.mkdir("graphs_"+str(i)).cd()
75  if not cool_tags[i]:
76  cool_tags[i] = GetFolderTag(cool_database_strings[i], cool_folders[i])
77  print ("Cool database: " + cool_database_strings[i] + " " + cool_folders[i] + " " + cool_tags[i] + " " + str(run_numbers[i]))
78  cool_rts.append(ReadRtCool(cool_database_strings[i], cool_folders[i], cool_tags[i], run_numbers[i])[1])
79 
80 
81 all_stations=set(cool_rts[0].keys()).union(set(cool_rts[1].keys()))
82 
83 outfile.cd()
84 tree=TTree("tree", "t0 differences")
85 
86 station_nm=array('c', "BIL\0")
87 station_phi=array('i', [0])
88 station_eta=array('i', [0])
89 tree.Branch("station_nm", station_nm, "station_nm/C")
90 tree.Branch("station_phi", station_phi, "station_phi/I")
91 tree.Branch("station_eta", station_eta, "station_eta/I")
92 
93 n_tubes=[]
94 t=[]
95 v=[]
96 r=array('f', 13*[0.0])
97 for i in range(13):
98  r[i]=float(i+1)
99 tree.Branch("r", r, "r[13]/F")
100 #validflag=[]
101 #adc=[]
102 for i in range(2):
103  t.append(array('f', 13*[0.0]))
104  v.append(array('f', 13*[0.0]))
105  tree.Branch("t_" + str(i), t[-1], "t_" + str(i) + "[13]/F")
106  tree.Branch("v_" + str(i), v[-1], "v_" + str(i) + "[13]/F")
107 
108 for ident in all_stations:
110  nm=up.stationNameString()
111  for i in range(0,3):
112  station_nm[i]=nm[i]
113  station_phi[0]=up.stationPhi()
114  station_eta[0]=up.stationEta()
115  for i in range(2):
116  if not ident in cool_rts[i]:
117  for j in range(13):
118  t[i][j]=-9e9
119  v[i][j]=-9e9
120  continue
121  theRt=cool_rts[i][ident]
122  for j in range(13):
123  t[i][j]=theRt.Eval(float(j+1))
124  v[i][j]=1/theRt.Derivative(float(j+1))
125 
126 
127  tree.Fill()
128 outfile.Write()
129 
130 
131 
132 
133 
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MuonFixedIdUnpack
Definition: MuonFixedIdUnpack.py:1
CalibCoolCompareRT.printhelp
def printhelp(argv0)
Definition: CalibCoolCompareRT.py:13
MuonFixedIdUnpack
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
array
ReadCool.GetFolderTag
def GetFolderTag(db_string, folder)
Definition: MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py:159
ReadCool
calibdata.cd
cd
Definition: calibdata.py:51
str
Definition: BTagTrackIpAccessor.cxx:11
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
ReadCool.ReadRtCool
def ReadRtCool(db_string, folder, tag, run_number)
Definition: MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py:70
readCCLHist.float
float
Definition: readCCLHist.py:83