ATLAS Offline Software
Loading...
Searching...
No Matches
ReadCalibDb Namespace Reference

Functions

 get_data_schema (cursor, db, head_id)
 build_rt_relation (r, t, rt_id)
 ReadRtCalibDb (db, reader_passwd, head_id)
 build_t0_vec (values)
 ReadT0CalibDb (db, reader_passwd, head_id)

Variables

 argv

Function Documentation

◆ build_rt_relation()

ReadCalibDb.build_rt_relation ( r,
t,
rt_id )

Definition at line 18 of file ReadCalibDb.py.

18def build_rt_relation(r,t, rt_id):
19 gr=TGraph(len(r))
20 gr.SetName("gr_" + str(rt_id))
21 for i in range(0, len(r)):
22 gr.SetPoint(i, r[i], t[i])
23 sp=TSpline3("sp_" + str(rt_id), gr)
24 up = MuonFixedIdUnpack(rt_id)
25 id_str=up.stationNameString() + "_" + str(up.stationPhi()) + "_" + str(up.stationEta())
26 gr.Write("gr_" + id_str)
27 sp.Write("sp_" + id_str)
28 return gr, sp
29
30
31

◆ build_t0_vec()

ReadCalibDb.build_t0_vec ( values)

Definition at line 65 of file ReadCalibDb.py.

65def build_t0_vec(values):
66 ret=[]
67 keys=values.keys()
68 keys.sort()
69 for key in keys:
70 ret.append(values[key])
71 return ret
72

◆ get_data_schema()

ReadCalibDb.get_data_schema ( cursor,
db,
head_id )

Definition at line 13 of file ReadCalibDb.py.

13def get_data_schema(cursor, db, head_id):
14 meta_schema = {'MP': 'ATLAS_MUONCALIBR_MPI', 'UM' : 'ATLAS_MUONCALIBR_UM', 'RM' : 'ATLAS_MUONCALIBR_RM'}
15 cursor.execute("select data_schema from " + meta_schema[db] + ".MDT_HEAD where head_id=:hid", {'hid': head_id})
16 return cursor.fetchone()[0]
17

◆ ReadRtCalibDb()

ReadCalibDb.ReadRtCalibDb ( db,
reader_passwd,
head_id )

Definition at line 32 of file ReadCalibDb.py.

32def ReadRtCalibDb(db, reader_passwd, head_id):
33 ra = CalibDbInfo.dbr[CalibDbInfo.calibdb]
34 tns = CalibDbInfo.tns[CalibDbInfo.calibdb]
35 if not reader_passwd:
36 reader_passwd = CalibDbInfo.dbr_password[CalibDbInfo.calibdb]
37 connection=cx_Oracle.connect(ra, reader_passwd, tns)
38 cursor=connection.cursor()
39 data_schema=get_data_schema(cursor, db, head_id)
40
41 query="select rt.validflag, rt.region_id, mp.r, mp.t from " + data_schema + ".mdt_rt rt, " + data_schema + ".mdt_rt_map mp where mp.head_id=:hid and rt.head_id=:hid and rt.region_id= mp.region_id and mp.calibflag= rt.calibflag and mp.point_nr<rt.bins and rt.validflag>2 order by rt.region_id, mp.point_nr"
42 cursor.arraysize = 1000*100
43
44 cursor.execute(query, {'hid': head_id})
45 rt_gr={}
46 rt_sp={}
47 r=[]
48 t=[]
49 prev_id=None
50 for validflag_in, region_id, r_p, t_p in cursor.fetchall():
51 this_id=region_id
52 if this_id!=prev_id:
53 if len(r):
54 rt_gr[prev_id], rt_sp[prev_id] = build_rt_relation(r,t, prev_id)
55 r=[]
56 t=[]
57 prev_id = this_id
58 r.append(r_p)
59 t.append(t_p)
60 if len(r)>0:
61 rt_gr[prev_id], rt_sp[prev_id] = build_rt_relation(r,t, prev_id)
62 return rt_gr, rt_sp
63
64

◆ ReadT0CalibDb()

ReadCalibDb.ReadT0CalibDb ( db,
reader_passwd,
head_id )

Definition at line 73 of file ReadCalibDb.py.

73def ReadT0CalibDb(db, reader_passwd, head_id):
74 ra = CalibDbInfo.dbr[CalibDbInfo.calibdb]
75 tns = CalibDbInfo.tns[CalibDbInfo.calibdb]
76 connection=cx_Oracle.connect(ra, reader_passwd, tns)
77 cursor=connection.cursor()
78 data_schema=get_data_schema(cursor, db, head_id)
79
80 query="select CHAMBER, TUBE_ID, TO_NUMBER(P4), VALIDFLAG, TO_NUMBER(ADC_0) from " + data_schema + ".MDT_TUBE where head_id=:hid and validflag>2 order by chamber"
81 cursor.arraysize = 1000*400
82 cursor.execute(query, {'hid': head_id})
83 t0s={}
84 current_values={}
85 prev_chamber=None
86 filled_chambers=set([])
87 for chamber, tube, t0, validflag, adc in cursor.fetchall():
88 if prev_chamber != chamber:
89 if prev_chamber:
90 up=MuonFixedIdUnpack(prev_chamber)
91 t0s[(up.stationNameString(), up.stationPhi(), up.stationEta())] = build_t0_vec(current_values)
92 filled_chambers.add(prev_chamber)
93 prev_chamber = chamber
94 current_values={}
95 up=MuonFixedIdUnpack(tube)
96 tid=288 * (up.mdtMultilayer() - 1) + 72 * (up.mdtTubeLayer() - 1) + (up.mdtTube() - 1 )
97 current_values[tid] = (t0, validflag, adc)
98 up=MuonFixedIdUnpack(prev_chamber)
99 t0s[(up.stationNameString(), up.stationPhi(), up.stationEta())] = build_t0_vec(current_values)
100 return t0s
101
102
103
104
STL class.

Variable Documentation

◆ argv

ReadCalibDb.argv

Definition at line 8 of file ReadCalibDb.py.