ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCalib
MuonCalibDbOperations
share
CalibCoolCompareRT.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
3
4
import
sys
5
import
getopt
6
7
cool_database_strings=[
'COOLOFL_MDT/COMP200'
,
'COOLOFL_MDT/COMP200'
]
8
cool_folders=[
'/MDT/RT'
,
'/MDT/RT'
]
9
cool_tags=[
'COMCOND-BLKPST-004-07'
,
'COMCOND-BLKPST-004-07'
]
10
run_numbers=[
None
,
None
]
11
12
def
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
16
theArgs=sys.argv[1:]
17
18
for
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
48
if
len(theArgs)!=1:
49
sys.stderr.write(
"Error in commandline!\n"
)
50
printhelp
(sys.argv[0])
51
52
outfile_nm=theArgs[0]
53
54
print
(cool_database_strings)
55
print
(cool_folders)
56
print
(cool_tags)
57
print
(run_numbers)
58
print
(outfile_nm)
59
60
sys.argv=[sys.argv[0],
'-b'
]
61
62
from
ROOT
import
*
63
from
array
import
*
64
65
from
MuonCalibDbOperations.ReadCool
import
*
66
from
MuonCalibIdentifier.MuonFixedIdUnpack
import
*
67
68
cool_rts=[]
69
70
outfile=TFile(outfile_nm,
"RECREATE"
)
71
72
for
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
80
all_stations=
set
(cool_rts[0].keys()).union(
set
(cool_rts[1].keys()))
81
82
outfile.cd()
83
tree=TTree(
"tree"
,
"t0 differences"
)
84
85
station_nm=
array
(
'c'
,
"BIL\0"
)
86
station_phi=
array
(
'i'
, [0])
87
station_eta=
array
(
'i'
, [0])
88
tree.Branch(
"station_nm"
, station_nm,
"station_nm/C"
)
89
tree.Branch(
"station_phi"
, station_phi,
"station_phi/I"
)
90
tree.Branch(
"station_eta"
, station_eta,
"station_eta/I"
)
91
92
n_tubes=[]
93
t=[]
94
v=[]
95
r=
array
(
'f'
, 13*[0.0])
96
for
i
in
range(13):
97
r[i]=float(i+1)
98
tree.Branch(
"r"
, r,
"r[13]/F"
)
99
#validflag=[]
100
#adc=[]
101
for
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
107
for
ident
in
all_stations:
108
up=
MuonFixedIdUnpack
(ident)
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()
127
outfile.Write()
128
129
130
131
132
array
STL class.
set
STL class.
CalibCoolCompareRT.printhelp
printhelp(argv0)
Definition
CalibCoolCompareRT.py:12
ReadCool
MuonFixedIdUnpack
MuonFixedIdUnpack
Definition
MuonFixedIdUnpack.py:1
Generated on
for ATLAS Offline Software by
1.17.0