2 import sys,os,commands,re
4 from CommonMethods
import *
9 import simplejson
as json
11 print "Please set a crab environment in order to get the proper JSON lib"
16 file = open(fileName);
17 jsonFile = file.read();
19 jsonList=json.loads(jsonFile);
22 for element
in jsonList:
23 selected_dcs[long(element)]=jsonList[element]
28 RunReg =
"http://pccmsdqm04.cern.ch/runregistry"
31 Group =
"Collisions10"
34 FULLADDRESS=RunReg +
"/xmlrpc"
37 server = xmlrpclib.ServerProxy(FULLADDRESS)
39 sel_runtable=
"{groupName} ='" + Group +
"' and {runNumber} > " + str(firstRun)
43 while tries<maxAttempts:
45 run_data = server.DataExporter.export(
'RUN',
'GLOBAL',
'csv_runs', sel_runtable)
49 print "Trying to get run data. This fails only 2-3 times so don't panic yet...", tries,
"/", maxAttempts
51 print "Exception type: ", sys.exc_info()[0]
52 if tries==maxAttempts:
53 error =
"Ok, now panic...run registry unaccessible...I'll get the runs from a json file!"
59 for line
in run_data.split(
"\n"):
60 run=line.split(
',')[0]
62 listOfRuns.append(run)
66 firstRun = listOfRuns[len(listOfRuns)-1];
67 lastRun = listOfRuns[0];
68 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"
69 while tries<maxAttempts:
71 dcs_data = server.DataExporter.export(
'RUNLUMISECTION',
'GLOBAL',
'json' , sel_dcstable)
75 print "I was able to get the list of runs and now I am trying to access the detector status", tries,
"/", maxAttempts
77 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!"
85 jsonList=json.loads(dcs_data)
88 for element
in listOfRuns:
90 if element
in jsonList:
91 selected_dcs[long(element)]=jsonList[element]
94 selected_dcs[long(element)]= [[]]
99 filesDir =
"LatestRuns/Results/";
100 fileList =
ls(filesDir)
101 listOfRunsAndLumi = {};
103 if(
not listOfRunsAndLumi):
104 listOfRunsAndLumi =
getListOfRunsAndLumiFromFile(-1,
"/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions10/7TeV/StreamExpress/Cert_132440-149442_7TeV_StreamExpress_Collisions10_JSON_v3.txt");
106 runKeys = listOfRunsAndLumi.keys();
109 for fileName
in fileList:
110 regExp = re.search(
'(\D+)(\d+)_(\d+)_(\d+).txt',fileName);
112 error =
"Can't find reg exp";
114 runFiles.append(long(regExp.group(3)));
120 runsAndLumisInRR = {};
123 for lumiRange
in listOfRunsAndLumi[run]:
125 for l
in range(lumiRange[0],lumiRange[1]+1):
126 RRList.append(long(l));
128 runsAndLumisInRR[run] = RRList;
130 runsAndLumisProcessed = {}
131 for fileName
in fileList:
132 file = open(filesDir+fileName)
134 if line.find(
"Runnumber") != -1:
135 run = long(line.replace(
'\n',
'').
split(
' ')[1])
136 elif line.find(
"LumiRange") != -1:
137 lumiLine = line.replace(
'\n',
'').
split(
' ')
138 begLumi = long(lumiLine[1])
139 endLumi = long(lumiLine[3])
140 if begLumi != endLumi:
141 error =
"The lumi range is greater than 1 for run " + str(run) +
" " + line +
" in file: " + runListDir + fileName
144 if not run
in runsAndLumisProcessed:
145 runsAndLumisProcessed[run] = []
146 if begLumi
in runsAndLumisProcessed[run]:
147 print "Lumi " + str(begLumi) +
" in event " + str(run) +
" already exist. This MUST not happen but right now I will ignore this lumi!"
149 runsAndLumisProcessed[run].
append(begLumi)
155 for lumi
in runsAndLumisInRR[run]:
158 if(run
not in runFiles):
159 print "Can't find run", run,
"in the files!"
161 elif(
not lumi
in runsAndLumisProcessed[run]):
162 missingLumis.append(lumi)
163 if(len(missingLumis) != 0):
164 print "In run", run,
"these lumis are missing ->", missingLumis
167 if __name__ ==
"__main__":
def getListOfRunsAndLumiFromRR
def getListOfRunsAndLumiFromFile
if(conf.exists("allCellsPositionCalc"))