3 from __future__
import print_function
10 cool_database_string = CalibDbDefaults.cool_database_string
11 cool_folder = CalibDbDefaults.cool_folders[calibtype]
12 cool_tag = CalibDbDefaults.cool_tags[calibtype]
13 dbname = CalibDbDefaults.cool_dbname
18 sys.stderr.write(
"Usage: " + argv0 +
" [-h] [-s <cool database string>] [-f <cool folder>] [-t <cool tag>] <run number> <calib db>/<head id> <reader password> <root file>\n")
21 optlist, args = getopt.gnu_getopt(sys.argv,
'hs:f:t:')
25 for opt, oa
in optlist:
28 cool_database_string =
'sqlite://;schema=' + oa +
';dbname=' + dbname
31 cool_database_string = oa
40 run_number=
int(args[1])
44 reader_password=args[3]
47 sys.argv=[ sys.argv[0],
'-b' ]
54 cool_tag =
GetFolderTag(cool_database_string, cool_folder)
57 print (
"Cool database: " + cool_database_string +
" " + cool_folder +
" " + cool_tag +
" " +
str(run_number))
58 cool_t0s=
ReadT0Cool(cool_database_string, cool_folder, cool_tag, run_number)
60 print (
"Calibration database: " + db +
"/" +
str(head_id))
62 print (len(calib_t0s),
"chambers in calibration databse")
64 outfile=TFile(root_filename,
"RECREATE")
65 tree=TTree(
"tree",
"t0 differences")
70 tree.Branch(
"station_nm", station_nm,
"station_nm/C")
71 tree.Branch(
"station_phi", station_phi,
"station_phi/I")
72 tree.Branch(
"station_eta", station_eta,
"station_eta/I")
80 validflag_cool=
array(
'i', 432*[0])
81 validflag_calib=
array(
'i', 432*[0])
83 tree.Branch(
"n_tubes", n_tubes,
"n_tubes/I")
84 tree.Branch(
"n_tubes_calib", n_tubes_calib,
"n_tubes_calib/I")
85 tree.Branch(
"n_tubes_cool", n_tubes_cool,
"n_tubes_cool/I")
86 tree.Branch(
"dt0", dt0,
"dt0[n_tubes]/F")
88 tree.Branch(
"t0_cool", t0_cool,
"t0_cool[n_tubes]/F")
89 tree.Branch(
"t0_calib", t0_calib,
"t0_calib[n_tubes]/F")
92 tree.Branch(
"d_validflag", d_validflag,
"d_validflag[n_tubes]/I")
93 tree.Branch(
"validflag_cool", validflag_cool,
"validflag_cool[n_tubes]/I")
94 tree.Branch(
"validflag_calib", validflag_calib,
"validflag_calib[n_tubes]/I")
95 tree.Branch(
"d_adc", d_adc,
"d_adc[n_tubes]/F")
97 for chamber_id
in cool_t0s:
98 if chamber_id
not in calib_t0s:
102 station_nm[i]=chamber_id[0][i]
104 station_phi[0]=chamber_id[1]
105 station_eta[0]=chamber_id[2]
106 cot0s=cool_t0s[chamber_id]
107 cat0s=calib_t0s[chamber_id]
108 n_tubes[0]=
min(len(cot0s), len(cat0s))
109 n_tubes_calib[0]=len(cat0s)
110 n_tubes_cool[0]=len(cot0s)
111 for i
in range(0, n_tubes[0]):
112 dt0[i]=cot0s[i][0] - cat0s[i][0]
113 d_validflag[i]=cot0s[i][1] - cat0s[i][1]
114 validflag_cool[i]=cot0s[i][1]
115 validflag_calib[i]=cat0s[i][1]
116 d_adc[i]=cot0s[i][2] - cat0s[i][2]
117 t0_cool[i]=cot0s[i][0]
118 t0_calib[i]=cat0s[i][0]