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
16 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")
19 optlist, args = getopt.gnu_getopt(sys.argv,
'hs:f:t:')
23 for opt, oa
in optlist:
26 cool_database_string =
'sqlite://;schema=' + oa +
';dbname=' + dbname
29 cool_database_string = oa
38 run_number=
int(args[1])
42 reader_password=args[3]
45 sys.argv=[ sys.argv[0],
'-b' ]
53 outfile=TFile(root_filename,
"RECREATE")
56 cool_tag =
GetFolderTag(cool_database_string, cool_folder)
58 outfile.mkdir(
"cool").
cd()
59 print (
"Cool database: " + cool_database_string +
" " + cool_folder +
" " + cool_tag +
" " +
str(run_number))
60 cool_gr, cool_sp, dummy=
ReadRtCool(cool_database_string, cool_folder, cool_tag, run_number)
62 outfile.mkdir(
"calibdb").
cd()
63 print (
"Calibration database: " + db +
"/" +
str(head_id))
67 tree=TTree(
"tree",
"rt differences")
72 tree.Branch(
"region_id", region_id,
"region_id/I")
73 tree.Branch(
"station_nm", station_nm,
"station_nm/C")
74 tree.Branch(
"station_phi", station_phi,
"station_phi/I")
75 tree.Branch(
"station_eta", station_eta,
"station_eta/I")
83 tree.Branch(
"n_points", n_points,
"n_points/I")
84 tree.Branch(
"n_points_calib", n_points_calib,
"n_points_calib/I")
85 tree.Branch(
"n_points_cool", n_points_cool,
"n_points_cool/I")
86 tree.Branch(
"dt13", dt13,
"dt13/F")
87 tree.Branch(
"dr13", dr13,
"dr13/F")
89 for chamber_id
in cool_gr:
90 if chamber_id
not in calib_gr:
92 region_id[0]=chamber_id
94 st_str=up.stationNameString()
96 station_nm[i]=st_str[i]
97 station_phi[0]=up.stationPhi()
98 station_eta[0]=up.stationEta()
99 co_gr=cool_gr[chamber_id]
100 co_sp=cool_sp[chamber_id]
101 ca_gr=calib_gr[chamber_id]
102 ca_sp=calib_sp[chamber_id]
103 n_points[0] =
min(co_gr.GetN(), ca_gr.GetN(), 100)
104 n_points_calib[0] = ca_gr.GetN()
105 n_points_cool[0] = co_gr.GetN()
106 for i
in range(i, n_points[0]):
107 dr[i]=ca_gr.GetX()[i]
108 dt[i]=ca_gr.GetY()[i]
109 dt13[0] = ca_sp.Eval(13.0) - co_sp.Eval(13.0)
110 dr13[0] = dt13[0] / ca_sp.Derivative(13.0)