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 77 of file beamvalidation.py.

References createfilelist.int.

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

Definition at line 125 of file beamvalidation.py.

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

Definition at line 105 of file beamvalidation.py.

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

Definition at line 50 of file beamvalidation.py.

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

Definition at line 228 of file beamvalidation.py.

References createfilelist.int, and split.

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

References split.

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

Definition at line 293 of file beamvalidation.py.

References createfilelist.int, split, harvestTrackValidationPlots.str, and unpack().

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

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

Definition at line 355 of file beamvalidation.py.

References get_productionFiles().

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

Definition at line 38 of file beamvalidation.py.

Referenced by CSCDigiValidator.zeroSupStripDigis().

38 def nonzero(self): # will become the nonzero method of optparse.Values
39  "True if options were given"
40  for v in self.__dict__.itervalues():
41  if v is not None: return True
42  return False
43 
44 optparse.Values.__nonzero__ = nonzero # dynamically fix optparse.Values
45 
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 272 of file beamvalidation.py.

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

Definition at line 53 of file beamvalidation.py.

53 def parse(docstring, arglist=None):
54  global optionstring
55  optionstring = docstring
56  match = USAGE.search(optionstring)
57  if not match: raise ParsingError("Cannot find the option string")
58  optlines = match.group(1).splitlines()
59  try:
60  p = optparse.OptionParser(optlines[0])
61  for line in optlines[1:]:
62  opt, help=line.split(':')[:2]
63  short,long=opt.split(',')[:2]
64  if '=' in opt:
65  action='store'
66  long=long.split('=')[0]
67  else:
68  action='store_true'
69  p.add_option(short.strip(),long.strip(),
70  action = action, help = help.strip())
71  except (IndexError,ValueError):
72  raise ParsingError("Cannot parse the option string correctly")
73  return p.parse_args(arglist)
74 
75 #_______________________________
76 
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 279 of file beamvalidation.py.

References reco.return().

Referenced by get_plots(), and unpackLumiid().

279 def unpack(i):
280  """unpack 64bit unsigned long long into 2 32bit unsigned int, return tuple (high,low)
281  """
282  high=i>>32
283  low=i&0xFFFFFFFF
284  return(high,low)
285 
return(e1-e2)*(e1-e2)+dp *dp
def beamvalidation.unpackLumiid (   i)
unpack 64bit lumiid to dictionary {'run','lumisection'}

Definition at line 286 of file beamvalidation.py.

References unpack().

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

Definition at line 153 of file beamvalidation.py.

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

Definition at line 322 of file beamvalidation.py.

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

Definition at line 130 of file beamvalidation.py.

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

Variable Documentation

beamvalidation.args

Definition at line 371 of file beamvalidation.py.

beamvalidation.auth

Definition at line 381 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 380 of file beamvalidation.py.

beamvalidation.end

Definition at line 394 of file beamvalidation.py.

beamvalidation.htmlwebsite

Definition at line 375 of file beamvalidation.py.

beamvalidation.lasttag

Definition at line 422 of file beamvalidation.py.

beamvalidation.lines

Definition at line 393 of file beamvalidation.py.

beamvalidation.list_lastIOVs

Definition at line 387 of file beamvalidation.py.

beamvalidation.list_tags

Definition at line 384 of file beamvalidation.py.

beamvalidation.option

Definition at line 371 of file beamvalidation.py.

beamvalidation.optionstring

Definition at line 48 of file beamvalidation.py.

beamvalidation.outfile

Definition at line 431 of file beamvalidation.py.

beamvalidation.pngfiles

Definition at line 426 of file beamvalidation.py.

beamvalidation.processedruns

Definition at line 390 of file beamvalidation.py.

beamvalidation.USAGE

Definition at line 36 of file beamvalidation.py.