Functions | |
def | getListOfRunsAndLumiFromFile |
def | getListOfRunsAndLumiFromRR |
def | main |
def checkRuns::getListOfRunsAndLumiFromFile | ( | firstRun = -1 , |
|
fileName = "" |
|||
) |
Definition at line 15 of file checkRuns.py.
def checkRuns::getListOfRunsAndLumiFromRR | ( | firstRun = -1 , |
|
error = "" |
|||
) |
Definition at line 27 of file checkRuns.py.
00028 : 00029 RunReg ="https://pccmsdqm04.cern.ch/runregistry" 00030 #RunReg = "https://localhost:40010/runregistry" 00031 #Dataset=%Online% 00032 Group = "Collisions10" 00033 00034 # get handler to RR XML-RPC server 00035 FULLADDRESS=RunReg + "/xmlrpc" 00036 #print "RunRegistry from: ",FULLADDRESS 00037 #firstRun = 153000 00038 server = xmlrpclib.ServerProxy(FULLADDRESS) 00039 #sel_runtable="{groupName} ='" + Group + "' and {runNumber} > " + str(firstRun) + " and {datasetName} LIKE '" + Dataset + "'" 00040 sel_runtable="{groupName} ='" + Group + "' and {runNumber} > " + str(firstRun) 00041 00042 tries = 0; 00043 maxAttempts = 3 00044 while tries<maxAttempts: 00045 try: 00046 run_data = server.DataExporter.export('RUN', 'GLOBAL', 'csv_runs', sel_runtable) 00047 break 00048 except: 00049 tries += 1 00050 print "Trying to get run data. This fails only 2-3 times so don't panic yet...", tries, "/", maxAttempts 00051 time.sleep(1) 00052 print "Exception type: ", sys.exc_info()[0] 00053 if tries==maxAttempts: 00054 error = "Ok, now panic...run registry unaccessible...I'll get the runs from a json file!" 00055 print error; 00056 return {}; 00057 00058 listOfRuns=[] 00059 runErrors = {} 00060 for line in run_data.split("\n"): 00061 run=line.split(',')[0] 00062 if run.isdigit(): 00063 listOfRuns.append(run) 00064 00065 tries = 0 00066 maxAttempts = 3 00067 firstRun = listOfRuns[len(listOfRuns)-1]; 00068 lastRun = listOfRuns[0]; 00069 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" 00070 while tries<maxAttempts: 00071 try: 00072 dcs_data = server.DataExporter.export('RUNLUMISECTION', 'GLOBAL', 'json' , sel_dcstable) 00073 break 00074 except: 00075 tries += 1 00076 print "I was able to get the list of runs and now I am trying to access the detector status", tries, "/", maxAttempts 00077 time.sleep(1) 00078 print "Exception type: ", sys.exc_info()[0] 00079 00080 if tries==maxAttempts: 00081 error = "Ok, now panic...run registry unaccessible...I'll get the runs from a json file!" 00082 print error; 00083 return {}; 00084 00085 selected_dcs={} 00086 jsonList=json.loads(dcs_data) 00087 00088 #for element in jsonList: 00089 for element in listOfRuns: 00090 #if element in listOfRuns: 00091 if element in jsonList: 00092 selected_dcs[long(element)]=jsonList[element] 00093 else: 00094 #print "WARNING: Run " + element + " is a collision10 run with 0 lumis in Run Registry!" 00095 selected_dcs[long(element)]= [[]] 00096 return selected_dcs
def checkRuns::main | ( | ) |
Definition at line 98 of file checkRuns.py.
00099 : 00100 filesDir = "LatestRuns/Results/"; 00101 fileList = ls(filesDir) 00102 listOfRunsAndLumi = {}; 00103 #listOfRunsAndLumi = getListOfRunsAndLumiFromRR(-1); 00104 if(not listOfRunsAndLumi): 00105 listOfRunsAndLumi = getListOfRunsAndLumiFromFile(-1,"/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions10/7TeV/StreamExpress/Cert_132440-149442_7TeV_StreamExpress_Collisions10_JSON_v3.txt"); 00106 00107 runKeys = listOfRunsAndLumi.keys(); 00108 runKeys.sort(); 00109 runFiles = []; 00110 for fileName in fileList: 00111 regExp = re.search('(\D+)(\d+)_(\d+)_(\d+).txt',fileName); 00112 if(not regExp): 00113 error = "Can't find reg exp"; 00114 exit(error); 00115 runFiles.append(long(regExp.group(3))); 00116 00117 #for run in runKeys: 00118 # if(run not in runFiles): 00119 # print "Can't find run", run, "in the files!" 00120 00121 runsAndLumisInRR = {}; 00122 for run in runKeys: 00123 RRList = []; 00124 for lumiRange in listOfRunsAndLumi[run]: 00125 if lumiRange != []: 00126 for l in range(lumiRange[0],lumiRange[1]+1): 00127 RRList.append(long(l)); 00128 #print run, "->", RRList; 00129 runsAndLumisInRR[run] = RRList; 00130 00131 runsAndLumisProcessed = {} 00132 for fileName in fileList: 00133 file = open(filesDir+fileName) 00134 for line in file: 00135 if line.find("Runnumber") != -1: 00136 run = long(line.replace('\n','').split(' ')[1]) 00137 elif line.find("LumiRange") != -1: 00138 lumiLine = line.replace('\n','').split(' ') 00139 begLumi = long(lumiLine[1]) 00140 endLumi = long(lumiLine[3]) 00141 if begLumi != endLumi: 00142 error = "The lumi range is greater than 1 for run " + str(run) + " " + line + " in file: " + runListDir + fileName 00143 exit(error) 00144 else: 00145 if not run in runsAndLumisProcessed: 00146 runsAndLumisProcessed[run] = [] 00147 if begLumi in runsAndLumisProcessed[run]: 00148 print "Lumi " + str(begLumi) + " in event " + str(run) + " already exist. This MUST not happen but right now I will ignore this lumi!" 00149 else: 00150 runsAndLumisProcessed[run].append(begLumi) 00151 file.close() 00152 #print run, "->", runsAndLumisProcessed[run]; 00153 00154 for run in runKeys: 00155 missingLumis = []; 00156 for lumi in runsAndLumisInRR[run]: 00157 #print str(counter) + "->" + str(lumi) 00158 #counter += 1 00159 if(run not in runFiles): 00160 print "Can't find run", run, "in the files!" 00161 break ; 00162 elif( not lumi in runsAndLumisProcessed[run]): 00163 missingLumis.append(lumi) 00164 if(len(missingLumis) != 0): 00165 print "In run", run, "these lumis are missing ->", missingLumis 00166