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