CMS 3D CMS Logo

Classes | Functions | Variables
beamvalidation Namespace Reference

Classes

class  IOV
 
class  ParsingError
 

Functions

def cmp_tags (a, b)
 
def dump_footer (lines)
 
def dump_header (lines)
 
def exit (msg="")
 
def get_lastIOVs (listoftags, dest, auth)
 
def get_listoftags (dest, auth)
 
def get_plots (path, output, iovs, tag)
 
def get_productionFiles (directory)
 
def get_productionIOVs (directory)
 
def nonzero (self)
 
def pack (high, low)
 
def parse (docstring, arglist=None)
 
def unpack (i)
 
def unpackLumiid (i)
 
def write_iovs (iovs, lines)
 
def write_plots (lines, plots, web)
 
def write_tags (tags, lines)
 

Variables

 args
 
 auth
 
 br
 
 dest
 Get the latest tags dest = "frontier://cmsfrontier.cern.ch:8000/Frontier/CMS_COND_31X_BEAMSPOT". More...
 
 end
 
 htmlwebsite
 
 lasttag
 
 lines
 
 list_lastIOVs
 
 list_tags
 
 option
 
 optionstring
 
 outfile
 
 pngfiles
 
 processedruns
 
 USAGE
 

Function Documentation

def beamvalidation.cmp_tags (   a,
  b 
)

Definition at line 78 of file beamvalidation.py.

References createfilelist.int.

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 #___
105 
def cmp_tags(a, b)
def beamvalidation.dump_footer (   lines)

Definition at line 126 of file beamvalidation.py.

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

Definition at line 106 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 #____
125 
def dump_header(lines)
def beamvalidation.exit (   msg = "")

Definition at line 51 of file beamvalidation.py.

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

Definition at line 229 of file beamvalidation.py.

References createfilelist.int, and 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 #
272 # lumi tools CondCore/Utilities/python/timeUnitHelper.py
def get_lastIOVs(listoftags, dest, auth)
double split
Definition: MVATrainer.cc:139
def beamvalidation.get_listoftags (   dest,
  auth 
)

Definition at line 185 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 
221 #______________________
def get_listoftags(dest, auth)
double split
Definition: MVATrainer.cc:139
def beamvalidation.get_plots (   path,
  output,
  iovs,
  tag 
)

Definition at line 294 of file beamvalidation.py.

References createfilelist.int, split, str, 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 
322 #_______________________________
def get_plots(path, output, iovs, tag)
#define str(s)
double split
Definition: MVATrainer.cc:139
def beamvalidation.get_productionFiles (   directory)

Definition at line 345 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
355 #_______________________________
def get_productionFiles(directory)
double split
Definition: MVATrainer.cc:139
def beamvalidation.get_productionIOVs (   directory)

Definition at line 356 of file beamvalidation.py.

References get_productionFiles().

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 
366 #______________________________
def get_productionIOVs(directory)
def get_productionFiles(directory)
def beamvalidation.nonzero (   self)

Definition at line 39 of file beamvalidation.py.

Referenced by CSCDigiValidator.zeroSupStripDigis().

39 def nonzero(self): # will become the nonzero method of optparse.Values
40  "True if options were given"
41  for v in six.itervalues(self.__dict__):
42  if v is not None: return True
43  return False
44 
45 optparse.Values.__nonzero__ = nonzero # dynamically fix optparse.Values
46 
def nonzero(self)
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 273 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)
279 
def pack(high, low)
def beamvalidation.parse (   docstring,
  arglist = None 
)

Definition at line 54 of file beamvalidation.py.

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 #_______________________________
77 
def parse(docstring, arglist=None)
def beamvalidation.unpack (   i)
unpack 64bit unsigned long long into 2 32bit unsigned int, return tuple (high,low)

Definition at line 280 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)
286 
return((rh^lh)&mask)
def beamvalidation.unpackLumiid (   i)
unpack 64bit lumiid to dictionary {'run','lumisection'}

Definition at line 287 of file beamvalidation.py.

References unpack().

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

Definition at line 154 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 
184 #______________
def write_iovs(iovs, lines)
def beamvalidation.write_plots (   lines,
  plots,
  web 
)

Definition at line 323 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 
344 #________________________________
def write_plots(lines, plots, web)
def beamvalidation.write_tags (   tags,
  lines 
)

Definition at line 131 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 
153 #______________
def write_tags(tags, lines)

Variable Documentation

beamvalidation.args

Definition at line 372 of file beamvalidation.py.

beamvalidation.auth

Definition at line 382 of file beamvalidation.py.

beamvalidation.br
beamvalidation.dest

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

Definition at line 381 of file beamvalidation.py.

beamvalidation.end

Definition at line 395 of file beamvalidation.py.

beamvalidation.htmlwebsite

Definition at line 376 of file beamvalidation.py.

beamvalidation.lasttag

Definition at line 423 of file beamvalidation.py.

beamvalidation.lines

Definition at line 394 of file beamvalidation.py.

beamvalidation.list_lastIOVs

Definition at line 388 of file beamvalidation.py.

beamvalidation.list_tags

Definition at line 385 of file beamvalidation.py.

beamvalidation.option

Definition at line 372 of file beamvalidation.py.

beamvalidation.optionstring

Definition at line 49 of file beamvalidation.py.

beamvalidation.outfile

Definition at line 432 of file beamvalidation.py.

beamvalidation.pngfiles

Definition at line 427 of file beamvalidation.py.

beamvalidation.processedruns

Definition at line 391 of file beamvalidation.py.

beamvalidation.USAGE

Definition at line 37 of file beamvalidation.py.