CMS 3D CMS Logo

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

Functions

def getListOfRunsAndLumiFromFile
 
def getListOfRunsAndLumiFromRR
 
def main
 

Function Documentation

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

Definition at line 17 of file checkRuns.py.

Referenced by main().

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

Definition at line 29 of file checkRuns.py.

References print(), and str.

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

Definition at line 100 of file checkRuns.py.

References bitset_utilities.append(), beamvalidation.exit(), getListOfRunsAndLumiFromFile(), if(), eostools.ls(), print(), sistrip::SpyUtilities.range(), submitPVValidationJobs.split(), and str.

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