CMS 3D CMS Logo

Functions
checkRuns Namespace Reference

Functions

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

Function Documentation

◆ getListOfRunsAndLumiFromFile()

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

Definition at line 17 of file checkRuns.py.

Referenced by main().

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

◆ getListOfRunsAndLumiFromRR()

def checkRuns.getListOfRunsAndLumiFromRR (   firstRun = -1,
  error = "" 
)

Definition at line 29 of file checkRuns.py.

References print(), and str.

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

◆ main()

def checkRuns.main ( )

Definition at line 100 of file checkRuns.py.

References mps_setup.append, beamvalidation.exit(), getListOfRunsAndLumiFromFile(), if(), eostools.ls(), print(), FastTimerService_cff.range, submitPVValidationJobs.split(), and str.

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