CMS 3D CMS Logo

Functions
checkRuns Namespace Reference

Functions

def getListOfRunsAndLumiFromFile (firstRun=-1, fileName="")
 
def getListOfRunsAndLumiFromRR (firstRun=-1, error="")
 
def main ()
 

Function Documentation

def checkRuns.getListOfRunsAndLumiFromFile (   firstRun = -1,
  fileName = "" 
)

Definition at line 16 of file checkRuns.py.

Referenced by main().

16 def getListOfRunsAndLumiFromFile(firstRun=-1,fileName=""):
17  file = open(fileName);
18  jsonFile = file.read();
19  file.close()
20  jsonList=json.loads(jsonFile);
21 
22  selected_dcs = {};
23  for element in jsonList:
24  selected_dcs[long(element)]=jsonList[element]
25  return selected_dcs
26 
def getListOfRunsAndLumiFromFile(firstRun=-1, fileName="")
Definition: checkRuns.py:16
def checkRuns.getListOfRunsAndLumiFromRR (   firstRun = -1,
  error = "" 
)

Definition at line 28 of file checkRuns.py.

References edm.print(), and str.

28 def getListOfRunsAndLumiFromRR(firstRun=-1,error=""):
29  RunReg ="http://pccmsdqm04.cern.ch/runregistry"
30  #RunReg = "http://localhost:40010/runregistry"
31  #Dataset=%Online%
32  Group = "Collisions10"
33 
34  # get handler to RR XML-RPC server
35  FULLADDRESS=RunReg + "/xmlrpc"
36  #print "RunRegistry from: ",FULLADDRESS
37  #firstRun = 153000
38  server = xmlrpclib.ServerProxy(FULLADDRESS)
39  #sel_runtable="{groupName} ='" + Group + "' and {runNumber} > " + str(firstRun) + " and {datasetName} LIKE '" + Dataset + "'"
40  sel_runtable="{groupName} ='" + Group + "' and {runNumber} > " + str(firstRun)
41 
42  tries = 0;
43  maxAttempts = 3
44  while tries<maxAttempts:
45  try:
46  run_data = server.DataExporter.export('RUN', 'GLOBAL', 'csv_runs', sel_runtable)
47  break
48  except:
49  tries += 1
50  print("Trying to get run data. This fails only 2-3 times so don't panic yet...", tries, "/", maxAttempts)
51  time.sleep(1)
52  print("Exception type: ", sys.exc_info()[0])
53  if tries==maxAttempts:
54  error = "Ok, now panic...run registry unaccessible...I'll get the runs from a json file!"
55  print(error);
56  return {};
57 
58  listOfRuns=[]
59  runErrors = {}
60  for line in run_data.split("\n"):
61  run=line.split(',')[0]
62  if run.isdigit():
63  listOfRuns.append(run)
64 
65  tries = 0
66  maxAttempts = 3
67  firstRun = listOfRuns[len(listOfRuns)-1];
68  lastRun = listOfRuns[0];
69  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"
70  while tries<maxAttempts:
71  try:
72  dcs_data = server.DataExporter.export('RUNLUMISECTION', 'GLOBAL', 'json' , sel_dcstable)
73  break
74  except:
75  tries += 1
76  print("I was able to get the list of runs and now I am trying to access the detector status", tries, "/", maxAttempts)
77  time.sleep(1)
78  print("Exception type: ", sys.exc_info()[0])
79 
80  if tries==maxAttempts:
81  error = "Ok, now panic...run registry unaccessible...I'll get the runs from a json file!"
82  print(error);
83  return {};
84 
85  selected_dcs={}
86  jsonList=json.loads(dcs_data)
87 
88  #for element in jsonList:
89  for element in listOfRuns:
90  #if element in listOfRuns:
91  if element in jsonList:
92  selected_dcs[long(element)]=jsonList[element]
93  else:
94  #print "WARNING: Run " + element + " is a collision10 run with 0 lumis in Run Registry!"
95  selected_dcs[long(element)]= [[]]
96  return selected_dcs
97 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def getListOfRunsAndLumiFromRR(firstRun=-1, error="")
Definition: checkRuns.py:28
#define str(s)
def checkRuns.main ( )

Definition at line 99 of file checkRuns.py.

References mps_setup.append, cmsRelvalreport.exit, getListOfRunsAndLumiFromFile(), eostools.ls(), edm.print(), split, and str.

99 def main():
100  filesDir = "LatestRuns/Results/";
101  fileList = ls(filesDir)
102  listOfRunsAndLumi = {};
103  #listOfRunsAndLumi = getListOfRunsAndLumiFromRR(-1);
104  if(not listOfRunsAndLumi):
105  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 
107  runKeys = listOfRunsAndLumi.keys();
108  runKeys.sort();
109  runFiles = [];
110  for fileName in fileList:
111  regExp = re.search('(\D+)(\d+)_(\d+)_(\d+).txt',fileName);
112  if(not regExp):
113  error = "Can't find reg exp";
114  exit(error);
115  runFiles.append(long(regExp.group(3)));
116 
117  #for run in runKeys:
118  # if(run not in runFiles):
119  # print "Can't find run", run, "in the files!"
120 
121  runsAndLumisInRR = {};
122  for run in runKeys:
123  RRList = [];
124  for lumiRange in listOfRunsAndLumi[run]:
125  if lumiRange != []:
126  for l in range(lumiRange[0],lumiRange[1]+1):
127  RRList.append(long(l));
128  #print run, "->", RRList;
129  runsAndLumisInRR[run] = RRList;
130 
131  runsAndLumisProcessed = {}
132  for fileName in fileList:
133  file = open(filesDir+fileName)
134  for line in file:
135  if line.find("Runnumber") != -1:
136  run = long(line.replace('\n','').split(' ')[1])
137  elif line.find("LumiRange") != -1:
138  lumiLine = line.replace('\n','').split(' ')
139  begLumi = long(lumiLine[1])
140  endLumi = long(lumiLine[3])
141  if begLumi != endLumi:
142  error = "The lumi range is greater than 1 for run " + str(run) + " " + line + " in file: " + runListDir + fileName
143  exit(error)
144  else:
145  if not run in runsAndLumisProcessed:
146  runsAndLumisProcessed[run] = []
147  if begLumi in runsAndLumisProcessed[run]:
148  print("Lumi " + str(begLumi) + " in event " + str(run) + " already exist. This MUST not happen but right now I will ignore this lumi!")
149  else:
150  runsAndLumisProcessed[run].append(begLumi)
151  file.close()
152  #print run, "->", runsAndLumisProcessed[run];
153 
154  for run in runKeys:
155  missingLumis = [];
156  for lumi in runsAndLumisInRR[run]:
157  #print str(counter) + "->" + str(lumi)
158  #counter += 1
159  if(run not in runFiles):
160  print("Can't find run", run, "in the files!")
161  break ;
162  elif( not lumi in runsAndLumisProcessed[run]):
163  missingLumis.append(lumi)
164  if(len(missingLumis) != 0):
165  print("In run", run, "these lumis are missing ->", missingLumis)
166 
167 
def getListOfRunsAndLumiFromFile(firstRun=-1, fileName="")
Definition: checkRuns.py:16
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def ls(path, rec=False)
Definition: eostools.py:349
def main()
Definition: checkRuns.py:99
#define str(s)
double split
Definition: MVATrainer.cc:139