CMS 3D CMS Logo

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

Classes

class  IOV
 
class  ParsingError
 

Functions

def cmp_tags
 
def dump_footer
 
def dump_header
 
def exit
 
def get_lastIOVs
 
def get_listoftags
 
def get_plots
 
def get_productionFiles
 
def get_productionIOVs
 
def nonzero
 
def pack
 
def parse
 
def unpack
 
def unpackLumiid
 
def write_iovs
 
def write_plots
 
def write_tags
 

Variables

string auth = "/afs/cern.ch/cms/DB/conddb"
 
string br = '<BR>'
 
string dest = "oracle://cms_orcoff_prod/CMS_COND_31X_BEAMSPOT"
 Get the latest tags dest = "frontier://cmsfrontier.cern.ch:8000/Frontier/CMS_COND_31X_BEAMSPOT". More...
 
string end = '\n'
 
string htmlwebsite = "https://yumiceva.web.cern.ch/yumiceva/beamspot/"
 
tuple lasttag = list_lastIOVs.keys()
 
list lines = []
 
tuple list_lastIOVs = get_lastIOVs( list_tags, dest, auth)
 
tuple list_tags = get_listoftags( dest, auth)
 
string optionstring = ""
 
tuple outfile = open(option.output,'w')
 
tuple pngfiles = get_plots(option.path,option.output, list_lastIOVs[lasttag], lasttag)
 
tuple processedruns = get_productionIOVs('/afs/cern.ch/cms/CAF/CMSCOMM/COMM_BSPOT/yumiceva/tmp_lumi_workflow/')
 
tuple USAGE = re.compile(r'(?s)\s*usage: (.*?)(\n[ \t]*\n|$)')
 

Function Documentation

def beamvalidation.cmp_tags (   a,
  b 
)

Definition at line 77 of file beamvalidation.py.

77 
78 def cmp_tags(a,b):
79 
80  yeara = int(a.split('_')[1])
81  yearb = int(b.split('_')[1])
82 
83  if yeara < yearb: return -1
84  if yeara > yearb: return 1
85 
86  suffix = "_offline"
87  if a.find("_express") != -1:
88  suffix = "_express"
89  if a.find("_prompt") != -1:
90  suffix = "_prompt"
91 
92  tmpa = a.replace("BeamSpotObjects_2009_v","")
93  tmpa = tmpa.replace(suffix,"")
94 
95  tmpb = b.replace("BeamSpotObjects_2009_v","")
96  tmpb = tmpb.replace(suffix,"")
97 
98  na = int(tmpa)
99  nb = int(tmpb)
100  if na < nb: return -1
101  if na == nb: return 0
102  if na > nb: return 1
103 
104 #___
def beamvalidation.dump_footer (   lines)

Definition at line 125 of file beamvalidation.py.

126 def dump_footer(lines):
127 
128  lines.append('</body>\n</html>\n')
129 
#______________
def beamvalidation.dump_header (   lines)

Definition at line 105 of file beamvalidation.py.

106 def dump_header(lines):
107 
108  lines.append('''
109 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>
110 <head><title>Beam Spot Calibration Status</title></head>
111 
112 <body>
113 
114 <H1>Status of the Beam Spot Calibration</H1>
115 <BR>
116 <BR>
117 This page is updated every 10 minutes:
118 <BR>
119 <strong><script src="datemod.js"
120 type="text/javascript"></script></strong>
121 
122 ''')
123 
124 #____
def beamvalidation.exit (   msg = "")

Definition at line 50 of file beamvalidation.py.

Referenced by get_productionIOVs().

50 
51 def exit(msg=""):
52  raise SystemExit(msg or optionstring.replace("%prog",sys.argv[0]))
def beamvalidation.get_lastIOVs (   listoftags,
  dest,
  auth 
)

Definition at line 228 of file beamvalidation.py.

References split.

229 def get_lastIOVs( listoftags, dest, auth ):
230 
231  dbtags = ['offline','express','prompt']
232 
233  results = {}
234  for itag in dbtags:
235 
236  lasttag = listoftags[itag][0]
237  #fix for the moment to read old tags
238  if itag != "offline":
239  lasttag = listoftags[itag][1]
240 
241  queryIOVs_cmd = "cmscond_list_iov -c "+dest+" -P "+auth+" -t "+ lasttag
242  print queryIOVs_cmd
243 
244  outcmd = commands.getstatusoutput( queryIOVs_cmd )
245 
246  tmparr = outcmd[1].split('\n')
247 
248  TimeType = tmparr[1].split()[1]
249  listIOVs = []
250 
251  # look at number of payloads
252  lastline = tmparr[len(tmparr)-1].split()
253  npayloads = int( lastline[len(lastline)-1] )
254 
255  maxIOVs = 3
256  if npayloads < 3:
257  maxIOVs = npayloads
258  # pick the last three IOVs
259  for i in range(0,maxIOVs):
260  tmpline = tmparr[len(tmparr) -2 -i]
261  aIOV = IOV()
262  aIOV.IOVfirst = tmpline.split()[0]
263  aIOV.IOVlast = tmpline.split()[1]
264  aIOV.type = TimeType
265  listIOVs.append( aIOV )
266 
267  results[lasttag] = listIOVs
268 
269  return results
270 
271 #
# lumi tools CondCore/Utilities/python/timeUnitHelper.py
double split
Definition: MVATrainer.cc:139
def beamvalidation.get_listoftags (   dest,
  auth 
)

Definition at line 184 of file beamvalidation.py.

References split.

185 def get_listoftags(dest, auth,):
186 
187  queryTags_cmd = "cmscond_list_iov -c "+dest+" -P "+auth+" -a | grep BeamSpotObjects"
188  print queryTags_cmd
189  outcmd = commands.getstatusoutput( queryTags_cmd )
190  print outcmd[1]
191 
192  listtags = outcmd[1].split()
193 
194  listtags_offline = []
195  for itag in listtags:
196  if itag[len(itag)-7:len(itag)] == "offline":
197  listtags_offline.append(itag)
198  listtags_express = []
199  for itag in listtags:
200  if itag[len(itag)-7:len(itag)] == "express":
201  listtags_express.append(itag)
202  listtags_prompt = []
203  for itag in listtags:
204  if itag[len(itag)-6:len(itag)] == "prompt":
205  listtags_prompt.append(itag)
206 
207  listtags_offline.sort( cmp = cmp_tags )
208  listtags_offline.reverse()
209  listtags_express.sort( cmp = cmp_tags )
210  listtags_express.reverse()
211  listtags_prompt.sort( cmp = cmp_tags )
212  listtags_prompt.reverse()
213 
214  result = {}
215  result['offline'] = listtags_offline
216  result['express'] = listtags_express
217  result['prompt'] = listtags_prompt
218 
219  return result
220 
#______________________
double split
Definition: MVATrainer.cc:139
def beamvalidation.get_plots (   path,
  output,
  iovs,
  tag 
)

Definition at line 293 of file beamvalidation.py.

References split, and unpack().

294 def get_plots(path,output, iovs, tag):
295 
296  initial=iovs[len(iovs)-1].IOVfirst
297  final =iovs[0].IOVfirst
298  if iovs[0].type == "lumiid":
299  initial = str(unpack(initial)[0])+":"+str(unpack(initial)[1])
300  final = str(unpack(final)[0])+":"+str(unpack(final)[1])
301 
302  initial = str(int(initial) -100 )
303  cmd = path+"/plotBeamSpotDB.py -b -P -t "+tag+" -i "+initial +" -f "+final
304  print cmd
305  outcmd = commands.getstatusoutput( cmd )
306  print outcmd[1]
307 
308  cmd = "ls *.png"
309  outcmd = commands.getstatusoutput( cmd )
310 
311  pngfiles = outcmd[1].split('\n')
312  print pngfiles
313 
314  cmd = "cp *.png "+os.path.dirname(output)
315  outcmd = commands.getstatusoutput( cmd )
316  cmd = "rm *.png"
317  outcmd = commands.getstatusoutput( cmd )
318 
319  pngfiles.sort()
320  return pngfiles
321 
#_______________________________
double split
Definition: MVATrainer.cc:139
def beamvalidation.get_productionFiles (   directory)

Definition at line 344 of file beamvalidation.py.

References split.

Referenced by get_productionIOVs().

345 def get_productionFiles( directory ):
346 
347  list = commands.getstatusoutput('ls -t '+directory)
348  list = list[1].split()
349  newlist = []
350  for i in list:
351  if i.find('BeamFit_')!=-1:
352  newlist.append(i)
353 
354  return newlist
#_______________________________
double split
Definition: MVATrainer.cc:139
def beamvalidation.get_productionIOVs (   directory)

Definition at line 355 of file beamvalidation.py.

References exit(), get_productionFiles(), and parse().

356 def get_productionIOVs( directory ):
357 
358  files = get_productionFiles( directory )
359  listofruns = []
360  for f in files:
361  ii = f.find('Run')
362  arun = f[ii:len(f)-4]
363  listofruns.append(arun)
364  return listofruns
365 
#______________________________
def beamvalidation.nonzero (   self)

Definition at line 38 of file beamvalidation.py.

Referenced by CSCDigiValidator.zeroSupStripDigis().

38 
39 def nonzero(self): # will become the nonzero method of optparse.Values
40  "True if options were given"
41  for v in self.__dict__.itervalues():
42  if v is not None: return True
43  return False
44 
45 optparse.Values.__nonzero__ = nonzero # dynamically fix optparse.Values
def beamvalidation.pack (   high,
  low 
)
pack high,low 32bit unsigned int to one unsigned 64bit long long
   Note:the print value of result number may appear signed, if the sign bit is used.

Definition at line 272 of file beamvalidation.py.

273 def pack(high,low):
274  """pack high,low 32bit unsigned int to one unsigned 64bit long long
275  Note:the print value of result number may appear signed, if the sign bit is used.
276  """
277  h=high<<32
278  return (h|low)
def beamvalidation.parse (   docstring,
  arglist = None 
)

Definition at line 53 of file beamvalidation.py.

Referenced by get_productionIOVs().

53 
54 def parse(docstring, arglist=None):
55  global optionstring
56  optionstring = docstring
57  match = USAGE.search(optionstring)
58  if not match: raise ParsingError("Cannot find the option string")
59  optlines = match.group(1).splitlines()
60  try:
61  p = optparse.OptionParser(optlines[0])
62  for line in optlines[1:]:
63  opt, help=line.split(':')[:2]
64  short,long=opt.split(',')[:2]
65  if '=' in opt:
66  action='store'
67  long=long.split('=')[0]
68  else:
69  action='store_true'
70  p.add_option(short.strip(),long.strip(),
71  action = action, help = help.strip())
72  except (IndexError,ValueError):
73  raise ParsingError("Cannot parse the option string correctly")
74  return p.parse_args(arglist)
75 
76 #_______________________________
def beamvalidation.unpack (   i)
unpack 64bit unsigned long long into 2 32bit unsigned int, return tuple (high,low)

Definition at line 279 of file beamvalidation.py.

References mathSSE.return().

Referenced by get_plots(), and unpackLumiid().

280 def unpack(i):
281  """unpack 64bit unsigned long long into 2 32bit unsigned int, return tuple (high,low)
282  """
283  high=i>>32
284  low=i&0xFFFFFFFF
285  return(high,low)
return((rh^lh)&mask)
def beamvalidation.unpackLumiid (   i)
unpack 64bit lumiid to dictionary {'run','lumisection'}

Definition at line 286 of file beamvalidation.py.

References unpack().

287 def unpackLumiid(i):
288  """unpack 64bit lumiid to dictionary {'run','lumisection'}
289  """
290  j=unpack(i)
291  return {'run':j[0],'lumisection':j[1]}
292 
#____________________________
def beamvalidation.write_iovs (   iovs,
  lines 
)

Definition at line 153 of file beamvalidation.py.

154 def write_iovs(iovs, lines):
155 
156  end = '\n'
157  br = '<BR>'+end
158  # hearder
159  lines.append('<tr>'+end)
160  for i in iovs.keys():
161  lines.append('<th>'+i)
162  lines.append('</th>'+end)
163  lines.append('</tr>'+end)
164  # lumi type
165  lines.append('<tr>'+end)
166  for i in iovs.keys():
167  aIOVlist = iovs[i]
168  aIOV = IOV()
169  if len(aIOVlist) > 0:
170  aIOV = aIOVlist[0]
171  lines.append('<td> '+aIOV.type+' </td>'+end)
172  lines.append('</tr>'+end)
173  # print iovs
174  for niovs in range(0,len(iovs[iovs.keys()[0]])):
175  lines.append('<tr>'+end)
176  for i in iovs.keys():
177  aIOVlist = iovs[i]
178  aIOV = IOV()
179  if len(aIOVlist) > niovs:
180  aIOV = aIOVlist[niovs]
181  lines.append('<td> '+aIOV.IOVfirst +' - '+aIOV.IOVlast+' </td>'+end)
182  lines.append('</tr>'+end)
183 
#______________
def beamvalidation.write_plots (   lines,
  plots,
  web 
)

Definition at line 322 of file beamvalidation.py.

323 def write_plots(lines, plots,web):
324 
325  end = '\n'
326  br = '<BR>'+end
327 
328  lines.append(br)
329  lines.append('''
330 <table border="1">
331 
332 ''')
333  for i in range(0,len(plots)):
334  plot = plots[i]
335  plot = os.path.basename(plot)
336  if i%2 == 0:
337  lines.append("<tr>"+end)
338  lines.append("<td> <a href=\""+web+"/"+plot+"\"> <img src="+plot+" alt="+plot+" width='700' height='250' /> </a> </td>"+end)
339  if i%2 == 1:
340  lines.append("</tr>"+end)
341 
342  lines.append('</table>'+end)
343 
#________________________________
def beamvalidation.write_tags (   tags,
  lines 
)

Definition at line 130 of file beamvalidation.py.

131 def write_tags(tags, lines):
132 
133  end = '\n'
134  br = '<BR>'+end
135 
136  lines.append('<tr>'+end)
137  for i in tags.keys():
138 
139  lines.append('<th>'+i)
140  lines.append('</th>'+end)
141  lines.append('</tr>'+end)
142 
143  for ntags in range(0,len(tags['offline'])):
144  lines.append('<tr>'+end)
145  for i in tags.keys():
146  alist = tags[i]
147  if ntags < len(tags[i]):
148  lines.append('<td> '+alist[ntags]+' </td>'+end)
149  else:
150  lines.append('<td> </td>')
151  lines.append('</tr>'+end)
152 
#______________

Variable Documentation

string beamvalidation.auth = "/afs/cern.ch/cms/DB/conddb"

Definition at line 381 of file beamvalidation.py.

string beamvalidation.br = '<BR>'

Definition at line 395 of file beamvalidation.py.

Referenced by edm::RootTree.dropBranch(), LHEProducer.filter(), magfieldparam::TkBfield.getBrfz(), magfieldparam::TkBfield.getBxyz(), CustomParticleFactory.getDecayTable(), edm::RootDelayedReader.getProduct_(), edm::FileInPath.initialize_(), OAE85lParametrizedMagneticField.inTeslaUnchecked(), RBorderFinder.RBorderFinder(), edm::PoolOutputModule::OutputItem::Sorter.Sorter(), fwlite::internal::BranchMapReaderStrategyV8.updateFile(), fwlite::internal::BranchMapReaderStrategyV11.updateFile(), fwlite::internal::BranchMapReaderStrategyV17.updateFile(), and fwlite::internal::BranchMapReaderStrategyV1.updateMap().

string beamvalidation.dest = "oracle://cms_orcoff_prod/CMS_COND_31X_BEAMSPOT"

Get the latest tags dest = "frontier://cmsfrontier.cern.ch:8000/Frontier/CMS_COND_31X_BEAMSPOT".

Definition at line 380 of file beamvalidation.py.

string beamvalidation.end = '\n'

Definition at line 394 of file beamvalidation.py.

string beamvalidation.htmlwebsite = "https://yumiceva.web.cern.ch/yumiceva/beamspot/"

Definition at line 375 of file beamvalidation.py.

tuple beamvalidation.lasttag = list_lastIOVs.keys()

Definition at line 422 of file beamvalidation.py.

list beamvalidation.lines = []

Definition at line 393 of file beamvalidation.py.

tuple beamvalidation.list_lastIOVs = get_lastIOVs( list_tags, dest, auth)

Definition at line 387 of file beamvalidation.py.

tuple beamvalidation.list_tags = get_listoftags( dest, auth)

Definition at line 384 of file beamvalidation.py.

string beamvalidation.optionstring = ""

Definition at line 48 of file beamvalidation.py.

tuple beamvalidation.outfile = open(option.output,'w')

Definition at line 431 of file beamvalidation.py.

tuple beamvalidation.pngfiles = get_plots(option.path,option.output, list_lastIOVs[lasttag], lasttag)

Definition at line 426 of file beamvalidation.py.

tuple beamvalidation.processedruns = get_productionIOVs('/afs/cern.ch/cms/CAF/CMSCOMM/COMM_BSPOT/yumiceva/tmp_lumi_workflow/')

Definition at line 390 of file beamvalidation.py.

tuple beamvalidation.USAGE = re.compile(r'(?s)\s*usage: (.*?)(\n[ \t]*\n|$)')

Definition at line 36 of file beamvalidation.py.