2 import sys,os,commands,re
4 from CommonMethods
import *
10 import simplejson
as json
12 print "Please set a crab environment in order to get the proper JSON lib" 16 def getUploadedIOVs(tagName,destDB="oracle://cms_orcoff_prod/CMS_COND_31X_BEAMSPOT
"): 17 listIOVCommand = "cmscond_list_iov -c " + destDB +
" -P /afs/cern.ch/cms/DB/conddb -t " + tagName
18 dbError = commands.getstatusoutput( listIOVCommand )
20 if dbError[1].
find(
"metadata entry \"" + tagName +
"\" does not exist") != -1:
23 exit(
"ERROR: Can\'t connect to db because:\n" + dbError[1])
26 aCommand = listIOVCommand +
" | grep DB= | awk \'{print $1}\'" 28 output = commands.getstatusoutput( aCommand )
32 exit(
"ERROR: The tag " + tagName +
" exists but I can't get the value of the last IOV")
35 for run
in output[1].
split(
'\n'):
36 runs.append(long(run))
42 file = open(fileName);
43 jsonFile = file.read();
45 jsonList=json.loads(jsonFile);
48 for element
in jsonList:
49 selected_dcs[long(element)]=jsonList[element]
54 RunReg =
"http://pccmsdqm04.cern.ch/runregistry" 57 Group =
"Collisions10" 60 FULLADDRESS=RunReg +
"/xmlrpc" 63 server = xmlrpclib.ServerProxy(FULLADDRESS)
65 sel_runtable=
"{groupName} ='" + Group +
"' and {runNumber} > " +
str(firstRun)
69 while tries<maxAttempts:
71 run_data = server.DataExporter.export(
'RUN',
'GLOBAL',
'csv_runs', sel_runtable)
75 print "Trying to get run data. This fails only 2-3 times so don't panic yet...", tries,
"/", maxAttempts
77 print "Exception type: ", sys.exc_info()[0]
78 if tries==maxAttempts:
79 error =
"Ok, now panic...run registry unaccessible...I'll get the runs from a json file!" 85 for line
in run_data.split(
"\n"):
86 run=line.split(
',')[0]
88 listOfRuns.append(run)
92 firstRun = listOfRuns[len(listOfRuns)-1];
93 lastRun = listOfRuns[0];
94 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" 95 while tries<maxAttempts:
97 dcs_data = server.DataExporter.export(
'RUNLUMISECTION',
'GLOBAL',
'json' , sel_dcstable)
101 print "I was able to get the list of runs and now I am trying to access the detector status", tries,
"/", maxAttempts
103 print "Exception type: ", sys.exc_info()[0]
105 if tries==maxAttempts:
106 error =
"Ok, now panic...run registry unaccessible...I'll get the runs from a json file!" 131 jsonList=json.loads(dcs_data)
134 for element
in listOfRuns:
136 if element
in jsonList:
137 selected_dcs[long(element)]=jsonList[element]
140 selected_dcs[long(element)]= [[]]
145 usage =
"USAGE: ./checkPayloads.py (optional tagNumber) (optional \"lumi\") (optional \"z\" (optional destDB)" 151 if len(sys.argv) >= 2:
152 if not sys.argv[1].isdigit():
155 tagNumber = sys.argv[1]
156 if len(sys.argv) >= 3:
157 if not sys.argv[2] ==
"lumi":
160 dbBase =
"_LumiBased" 161 if len(sys.argv) >= 4:
162 if not sys.argv[3] ==
"z":
167 if(len(sys.argv) > 4):
191 knownMissingRunList = [132573,132958,133081,133242,133472,133473,136290,138560,138562,139455,140133,140182,142461,142465,142503,142653,143977,148859]
192 tagName =
"BeamSpotObjects_2009" + dbBase + sigmaZ +
"_v" + tagNumber +
"_offline" 193 print "Checking payloads for tag " + tagName
194 listOfRunsAndLumi = {};
196 if(
not listOfRunsAndLumi):
197 listOfRunsAndLumi =
getListOfRunsAndLumiFromFile(-1,
"/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions10/7TeV/StreamExpress/Cert_132440-149442_7TeV_StreamExpress_Collisions10_JSON_v3.txt");
207 listOfIOVs = tmpListOfIOVs
209 for iov
in tmpListOfIOVs:
210 if((iov >> 32)
not in listOfIOVs):
211 listOfIOVs.append(iov >>32)
212 RRRuns = sorted(listOfRunsAndLumi.keys())
215 if run
not in listOfIOVs:
217 if listOfRunsAndLumi[run] == [[]]:
218 extraMsg =
" but it is empty in the RR" 219 if not printExtra:
continue 220 if run
in knownMissingRunList :
221 extraMsg =
" but this run is know to be bad " 222 if not printExtra:
continue 223 print "Run: " +
str(run) +
" is missing for DB tag " + tagName + extraMsg
226 if __name__ ==
"__main__":
def getListOfRunsAndLumiFromRR(firstRun=-1, error="")
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def getUploadedIOVs(tagName, destDB="oracle://cms_orcoff_prod/CMS_COND_31X_BEAMSPOT")
def getListOfRunsAndLumiFromFile(firstRun=-1, fileName="")