8 RUNMIN = os.getenv(
"HCALDQM_RUNMIN")
9 conn = os.getenv(
"HCALDQM_DBCONNECT")
10 level1= [
'HCAL_LEVEL_1']
11 names = [
'HCAL_HBHE',
'HCAL_HF',
'HCAL_HO',
'HCAL_LEVEL_1',
'HCAL_HBHE904',
'HCAL_HF904']
13 ngrbxidmap=
"/nfshome0/akhukhun/hcaldqm/config/id2sn_rmcu.json"
14 ngccmidmap=
"/nfshome0/akhukhun/hcaldqm/config/id2sn_ngccm.json"
15 ngqieidmap=
"/nfshome0/akhukhun/hcaldqm/config/id2sn_qie.json"
19 db = cx_Oracle.connect(conn)
22 sql=
"select runnumber, string_value, name from runsession_parameter where runnumber > {} and runnumber < {} and (".
format(runmin, runmax)
23 sql = sql +
" or ".
join([
"name=:key"+
str(i)
for i
in range(n*len(level1))])
24 sql = sql +
") order by runnumber"
25 for i
in range(len(level1)):
26 p[
"key"+
str(n*i)]=
'CMS.'+level1[i]+
":HCAL_TIME_OF_FM_START"
27 p[
"key"+
str(n*i+1)]=
'CMS.'+level1[i]+
":FM_FULLPATH"
28 p[
"key"+
str(n*i+2)]=
'CMS.'+level1[i]+
":LOCAL_RUNKEY_SELECTED"
29 p[
"key"+
str(n*i+3)]=
'CMS.'+level1[i]+
":LOCAL_RUN_KEY"
30 p[
"key"+
str(n*i+4)]=
'CMS.'+level1[i]+
":EVENTS_TAKEN"
31 cursor = cursor.execute(sql, p)
39 if r
not in out: out[r] = dict(time=
"", nevents=-1, fm=
"", key=
"")
40 if(k.endswith(
"HCAL_TIME_OF_FM_START")): out[r][
"time"]=n
41 elif(k.endswith(
"FM_FULLPATH")):
44 if(len(fm)>maxfm): maxfm=len(fm)
45 elif(k.endswith(
"EVENTS_TAKEN")):
46 out[r][
"nevents"] = int(n)
47 if(len(n)>maxn): maxn = len(n)
49 form=
"%s | %-24s | %{}d | %-{}s | %s".
format(maxn, maxfm)
50 for r,i
in sorted(out.items()):
print (form % (r, i[
"time"], i[
"nevents"], i[
"fm"], i[
"key"]))
55 db = cx_Oracle.connect(conn)
57 sql=
"select name from runsession_parameter where runnumber=:run"
59 cursor = cursor.execute(sql, p)
65 for i
in sorted(res):
print(i)
68 db = cx_Oracle.connect(conn)
71 OR=
" or ".
join([
"name=:key"+
str(i)
for i
in range(len(names))])
72 sql=
"".
join([
"select value from runsession_string where runsession_parameter_id=any(select id from runsession_parameter where (runnumber=:run and (", OR,
" )))"])
73 for i
in range(len(names)): p[
"key"+
str(i)]=
'CMS.'+names[i]+
":"+key
74 cursor = cursor.execute(sql, p)
75 result = (cursor.fetchone()[0]).
read()
81 date =
read(run,
"HCAL_TIME_OF_FM_START")
82 v = date.split()[0].
split(
"-")
85 month = (
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec")
86 print(
"%s%02d" % (month[m-1], d))
89 db = cx_Oracle.connect(conn)
92 OR=
" or ".
join([
"name like :key"+
str(i)
for i
in range(len(names))])
93 sql=
"".
join([
"select name, string_value from runsession_parameter where runnumber=:run and (", OR,
" )"])
94 for i
in range(len(names)): p[
"key"+
str(i)]=
'CMS.'+names[i]+
":"+
"ngRBXManager_Firmware_UniqueIDs_H%"
95 cursor = cursor.execute(sql, p)
97 row = cursor.fetchone()
102 array = result.split(
";")
104 row = cursor.fetchone()
105 for key
in sorted(out):
106 print (
"-----------------------\n{0} ".
format(key))
107 for l
in out[key]:
print (l)
113 db = cx_Oracle.connect(conn)
116 OR=
" OR ".
join([
"name like :key"+
str(i)
for i
in range(len(names))])
117 sql=
"".
join([
"select name, string_value from runsession_parameter where runnumber=:run and (", OR,
" )"])
118 for i
in range(len(names)): p[
"key"+
str(i)]=
'CMS.'+names[i]+
":"+
"ngRBXManager_Firmware_UniqueIDs_H%"
119 cursor = cursor.execute(sql, p)
121 row = cursor.fetchone()
126 if 'M' in rbx: n = 3;
127 if 'P' in rbx: n = 3;
128 key =
"{:s}{:02d}".
format(rbx[:n], int(rbx[n:]))
131 array = result.split(
";")
137 if isqie
and w[0]==
"QCard":
140 rl[
'rm'] = int(w[3][-1])
141 rl[
'qie'] = int(w[1])
142 if isqie
and w[0]==
"CU":
147 if not isqie
and (w[0].startswith(
"ngCCMa")
or w[0].startswith(
"ngCCMb"))
and w[2]==
"UID:":
148 rl[
'id0'] = (w[11][1:],
"-1")[
"ERROR" in line]
149 rl[
'id'] = (w[12][:-1],
"-1")[
"ERROR" in line]
152 if(rl): value.append(rl)
153 if key.startswith(
"HB")
or key.startswith(
"HE"):
154 out[key] = {
"value":value,
"rbx":rbx}
155 row = cursor.fetchone()
160 json_data=open(ngqieidmap).
read()
161 data.update(json.loads(json_data))
163 for key
in sorted(out):
164 for q
in out[key][
"value"]:
166 if out[key][
"rbx"].startswith(
'HE'):
168 id0=
'0x'+
'%08x' % nid0
170 k=
'_'.
join((id0, q[
'id']))
172 if k
in data: v=data[k]
173 print (
"%-5s %d %d %-11s %-10s %6d" % (out[key][
"rbx"], q[
'rm'], q[
'qie'], id0, q[
'id'], v))
179 db = cx_Oracle.connect(conn)
182 OR=
" OR ".
join([
"name like :key"+
str(i)
for i
in range(len(names))])
183 sql=
"".
join([
"select name, string_value from runsession_parameter where runnumber=:run and (", OR,
" )"])
184 for i
in range(len(names)): p[
"key"+
str(i)]=
'CMS.'+names[i]+
":"+
"ngRBXManager_Firmware_UniqueIDs_HB%"
185 cursor = cursor.execute(sql, p)
187 row = cursor.fetchone()
194 if 'M' in rbx: n = 3;
195 if 'P' in rbx: n = 3;
196 key =
"{:s}{:02d}".
format(rbx[:n], int(rbx[n:]))
199 array = result.split(
";")
207 value +=
"{0}{1}".
format(w[7][:-2], (
"",
" ")[i==3])
211 if w[0]==
"CU": value +=
" {0}".
format(w[4][:-2])
212 if w[0].startswith(
"ngCCM")
and w[2]==
"UID:":
213 valueCCM +=
" {0}0{1} ".
format(w[11][1:], w[12][2:-1])
215 out[key] = {
"value":value+valueCCM,
"rbx":rbx}
216 row = cursor.fetchone()
219 for f
in (ngrbxidmap, ngccmidmap):
220 json_data=open(f).
read()
221 data.update(json.loads(json_data))
222 if(hasRMinfo
and hasCCMinfo):
print (
"RBX | RM1 RM2 RM3 RM4 CU CCMa CCMb\n------|-----------------------------------")
223 elif hasRMinfo:
print (
"RBX | RM1 RM2 RM3 RM4 CU\n------|-------------------------")
224 else:
print(
"Cannot find published information on RM IDs.");
return
225 for key
in sorted(out):
227 for k
in out[key][
"value"].
split():
228 if data.has_key(k): res = res +
"{:4d} ".
format(data[k])
229 elif "NAC" in k: res = res +
" 0 "
230 else: res = res +
" -1 "
231 print (
"%-5s | %s" % (out[key][
"rbx"].
strip(), res))
238 if __name__==
"__main__":
239 parser = argparse.ArgumentParser(description=
"With no arguments, return list of runs with a small summary after runmin={}".
format(RUNMIN))
240 parser.add_argument(
"--run", help=
"run number", type=int);
241 parser.add_argument(
"--runmin", help=
"earliest run number", type=int, default=RUNMIN);
242 parser.add_argument(
"--runmax", help=
"earliest run number", type=int, default=99999999999999999);
243 parser.add_argument(
"--key", help=
"get value for a given key; special values are: sn, qie, ccm, date");
244 a=parser.parse_args();
247 elif(a.key==
"ccm"):
dumpIDs(a.run,
False)
249 elif(a.key==
"sn"):
dumpSNs(a.run)
250 elif(a.key==
"date"):
dumpDate(a.run)
const uint16_t range(const Frame &aFrame)
if(conf_.getParameter< bool >("UseStripCablingDB"))
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
static std::string join(char **cmd)