CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
checkRuns Namespace Reference

Functions

def getListOfRunsAndLumiFromFile
 
def getListOfRunsAndLumiFromRR
 
def main
 

Function Documentation

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

Definition at line 15 of file checkRuns.py.

Referenced by main().

15 
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
def getListOfRunsAndLumiFromFile
Definition: checkRuns.py:15
def checkRuns.getListOfRunsAndLumiFromRR (   firstRun = -1,
  error = "" 
)

Definition at line 27 of file checkRuns.py.

27 
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
def getListOfRunsAndLumiFromRR
Definition: checkRuns.py:27
def checkRuns.main ( )

Definition at line 98 of file checkRuns.py.

References bitset_utilities.append(), cmsRelvalreport.exit, getListOfRunsAndLumiFromFile(), reco.if(), eostools.ls(), and split.

98 
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 
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def ls
Definition: eostools.py:348
def main
Definition: checkRuns.py:98
if(dp >Float(M_PI)) dp-
def getListOfRunsAndLumiFromFile
Definition: checkRuns.py:15
double split
Definition: MVATrainer.cc:139