ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCalib
MuonCalibDbOperations
share
CalibCoolCompareT0.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
3
4
import
sys
5
import
getopt
6
import
CalibdDbDefaults
7
8
cool_database_strings=[CalibDbDefaults.cool_database_string, CalibDbDefaults.cool_database_string]
9
cool_folders=[CalibDbDefaults.cool_folders[calibtype], CalibDbDefaults.cool_folders[calibtype]]
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
66
from
MuonCalibDbOperations.ReadCool
import
*
67
68
cool_t0s=[]
69
70
for
i
in
range(2):
71
if
not
cool_tags[i]:
72
cool_tags[i] = GetFolderTag(cool_database_strings[i], cool_folders[i])
73
print
(
"Cool database: "
+ cool_database_strings[i] +
" "
+ cool_folders[i] +
" "
+ cool_tags[i] +
" "
+ str(run_numbers[i]))
74
cool_t0s.append(ReadT0Cool(cool_database_strings[i], cool_folders[i], cool_tags[i], run_numbers[i]))
75
76
77
all_stations=
set
(cool_t0s[0].keys()).union(
set
(cool_t0s[1].keys()))
78
79
80
outfile=TFile(outfile_nm,
"RECREATE"
)
81
tree=TTree(
"tree"
,
"t0 differences"
)
82
83
station_nm=
array
(
'c'
,
"BIL\0"
)
84
station_phi=
array
(
'i'
, [0])
85
station_eta=
array
(
'i'
, [0])
86
tree.Branch(
"station_nm"
, station_nm,
"station_nm/C"
)
87
tree.Branch(
"station_phi"
, station_phi,
"station_phi/I"
)
88
tree.Branch(
"station_eta"
, station_eta,
"station_eta/I"
)
89
90
n_tubes=[]
91
t0=[]
92
t0_mean=[]
93
t0_min=[]
94
t0_max=[]
95
#validflag=[]
96
#adc=[]
97
for
i
in
range(2):
98
n_tubes.append(
array
(
'i'
, [0]))
99
tree.Branch(
"n_tubes_"
+ str(i), n_tubes[-1],
"n_tubes_"
+ str(i) +
"/I"
)
100
t0.append(
array
(
'f'
, 432*[0.0]))
101
tree.Branch(
"t0_"
+ str(i), t0[-1],
"t0_"
+ str(i) +
"[n_tubes_"
+ str(i) +
"]/F"
)
102
t0_mean.append(
array
(
'f'
, [0.0]))
103
tree.Branch(
"t0_mean_"
+ str(i), t0_mean[-1],
"t0_mean_"
+ str(i) +
"/F"
)
104
t0_min.append(
array
(
'f'
, [0.0]))
105
tree.Branch(
"t0_min_"
+ str(i), t0_min[-1],
"t0_min_"
+ str(i) +
"/F"
)
106
t0_max.append(
array
(
'f'
, [0.0]))
107
tree.Branch(
"t0_max_"
+ str(i), t0_max[-1],
"t0_max_"
+ str(i) +
"/F"
)
108
109
110
for
ident
in
all_stations:
111
for
i
in
range(0,3):
112
station_nm[i]=ident[0][i]
113
station_phi[0]=ident[1]
114
station_eta[0]=ident[2]
115
for
i
in
range(2):
116
if
not
ident
in
cool_t0s[i]:
117
n_tubes[i][0]=0
118
t0_mean[i][0]=9e9
119
t0_min[i][0]=9e9
120
t0_max[i][0]=9e9
121
continue
122
t0_mean[i][0]=0.0
123
t0_min[i][0]=9e9
124
t0_max[i][0]=-9e9
125
theT0s=cool_t0s[i][ident]
126
n_tubes[i][0]=len(theT0s)
127
for
j
in
range(n_tubes[i][0]):
128
t0_mean[i][0]+=theT0s[j][0]
129
if
t0_min[i][0]>theT0s[j][0]:
130
t0_min[i][0]=theT0s[j][0]
131
if
t0_max[i][0]<theT0s[j][0]:
132
t0_max[i][0]=theT0s[j][0]
133
t0[i][j]=theT0s[j][0]
134
t0_mean[i][0]/=float(n_tubes[i][0])
135
tree.Fill()
136
outfile.Write()
137
138
139
140
141
array
STL class.
set
STL class.
CalibCoolCompareT0.printhelp
printhelp(argv0)
Definition
CalibCoolCompareT0.py:13
ReadCool
Generated on
for ATLAS Offline Software by
1.17.0