2 from __future__
import print_function
3 import sys,os,subprocess,re
5 from CommonMethods
import *
11 import simplejson
as json
13 print(
"Please set a crab environment in order to get the proper JSON lib")
17 def getUploadedIOVs(tagName,destDB="oracle://cms_orcoff_prod/CMS_COND_31X_BEAMSPOT
"):
18 listIOVCommand = "cmscond_list_iov -c " + destDB +
" -P /afs/cern.ch/cms/DB/conddb -t " + tagName
19 dbError = subprocess.getstatusoutput( listIOVCommand )
21 if dbError[1].
find(
"metadata entry \"" + tagName +
"\" does not exist") != -1:
24 exit(
"ERROR: Can\'t connect to db because:\n" + dbError[1])
27 aCommand = listIOVCommand +
" | grep DB= | awk \'{print $1}\'"
29 output = subprocess.getstatusoutput( aCommand )
33 exit(
"ERROR: The tag " + tagName +
" exists but I can't get the value of the last IOV")
36 for run
in output[1].
split(
'\n'):
37 runs.append(long(run))
43 file = open(fileName);
44 jsonFile = file.read();
46 jsonList=json.loads(jsonFile);
49 for element
in jsonList:
50 selected_dcs[long(element)]=jsonList[element]
55 RunReg =
"http://pccmsdqm04.cern.ch/runregistry"
58 Group =
"Collisions10"
61 FULLADDRESS=RunReg +
"/xmlrpc"
64 server = xmlrpclib.ServerProxy(FULLADDRESS)
66 sel_runtable=
"{groupName} ='" + Group +
"' and {runNumber} > " +
str(firstRun)
70 while tries<maxAttempts:
72 run_data = server.DataExporter.export(
'RUN',
'GLOBAL',
'csv_runs', sel_runtable)
76 print(
"Trying to get run data. This fails only 2-3 times so don't panic yet...", tries,
"/", maxAttempts)
78 print(
"Exception type: ", sys.exc_info()[0])
79 if tries==maxAttempts:
80 error =
"Ok, now panic...run registry unaccessible...I'll get the runs from a json file!"
86 for line
in run_data.split(
"\n"):
87 run=line.split(
',')[0]
89 listOfRuns.append(run)
93 firstRun = listOfRuns[len(listOfRuns)-1];
94 lastRun = listOfRuns[0];
95 sel_dcstable=
"{groupName} ='" + Group +
"' and {runNumber} >= " +
str(firstRun) +
" and {runNumber} <= " +
str(lastRun) +
" and {parDcsBpix} = 1 and {parDcsFpix} = 1 and {parDcsTibtid} = 1 and {parDcsTecM} = 1 and {parDcsTecP} = 1 and {parDcsTob} = 1 and {parDcsEbminus} = 1 and {parDcsEbplus} = 1 and {parDcsEeMinus} = 1 and {parDcsEePlus} = 1 and {parDcsEsMinus} = 1 and {parDcsEsPlus} = 1 and {parDcsHbheA} = 1 and {parDcsHbheB} = 1 and {parDcsHbheC} = 1 and {parDcsH0} = 1 and {parDcsHf} = 1"
96 while tries<maxAttempts:
98 dcs_data = server.DataExporter.export(
'RUNLUMISECTION',
'GLOBAL',
'json' , sel_dcstable)
102 print(
"I was able to get the list of runs and now I am trying to access the detector status", tries,
"/", maxAttempts)
104 print(
"Exception type: ", sys.exc_info()[0])
106 if tries==maxAttempts:
107 error =
"Ok, now panic...run registry unaccessible...I'll get the runs from a json file!"
132 jsonList=json.loads(dcs_data)
135 for element
in listOfRuns:
137 if element
in jsonList:
138 selected_dcs[long(element)]=jsonList[element]
141 selected_dcs[long(element)]= [[]]
146 usage =
"USAGE: ./checkPayloads.py (optional tagNumber) (optional \"lumi\") (optional \"z\" (optional destDB)"
152 if len(sys.argv) >= 2:
153 if not sys.argv[1].isdigit():
156 tagNumber = sys.argv[1]
157 if len(sys.argv) >= 3:
158 if not sys.argv[2] ==
"lumi":
161 dbBase =
"_LumiBased"
162 if len(sys.argv) >= 4:
163 if not sys.argv[3] ==
"z":
168 if(len(sys.argv) > 4):
192 knownMissingRunList = [132573,132958,133081,133242,133472,133473,136290,138560,138562,139455,140133,140182,142461,142465,142503,142653,143977,148859]
193 tagName =
"BeamSpotObjects_2009" + dbBase + sigmaZ +
"_v" + tagNumber +
"_offline"
194 print(
"Checking payloads for tag " + tagName)
195 listOfRunsAndLumi = {};
197 if(
not listOfRunsAndLumi):
198 listOfRunsAndLumi =
getListOfRunsAndLumiFromFile(-1,
"/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions10/7TeV/StreamExpress/Cert_132440-149442_7TeV_StreamExpress_Collisions10_JSON_v3.txt");
208 listOfIOVs = tmpListOfIOVs
210 for iov
in tmpListOfIOVs:
211 if((iov >> 32)
not in listOfIOVs):
212 listOfIOVs.append(iov >>32)
213 RRRuns = sorted(listOfRunsAndLumi.keys())
216 if run
not in listOfIOVs:
218 if listOfRunsAndLumi[run] == [[]]:
219 extraMsg =
" but it is empty in the RR"
220 if not printExtra:
continue
221 if run
in knownMissingRunList :
222 extraMsg =
" but this run is know to be bad "
223 if not printExtra:
continue
224 print(
"Run: " +
str(run) +
" is missing for DB tag " + tagName + extraMsg)
227 if __name__ ==
"__main__":
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
if(conf_.getParameter< bool >("UseStripCablingDB"))
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def getListOfRunsAndLumiFromRR
def getListOfRunsAndLumiFromFile