CMS 3D CMS Logo

cuy.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #____________________________________________________________
3 #
4 # cuy
5 #
6 # A very simple way to make plots with ROOT via an XML file
7 #
8 # Francisco Yumiceva
9 # yumiceva@fnal.gov
10 #
11 # Fermilab, 2008
12 #
13 # imported from UserCode/Yumiceva/cuy
14 from __future__ import print_function
15 import six
16 #
17 # modified by Adrien Caudron to create TGraphErrors for b-tag performance plots
18 # UCLouvain, 2012
19 #_____________________________________________________________
20 
21 """
22  cuy
23 
24  A very simple way to make plots with ROOT via an XML file.
25 
26  usage: %prog -x <XML configuration file>
27  -b, --batch : run in batch mode without graphics.
28  -c, --create = CREATE: create XML configuration file from a ROOT file.
29  -e, --example = EXAMPLE: generate an example xml file.
30  -f, --flag = FLAG: create a baneer
31  -l, --list = LIST: list of objects in the ROOT file.
32  -p, --prt = PRT: print canvas in the format specified png, ps, eps, pdf, etc.
33  -t, --tag = TAG: tag name for XML configuration file.
34  -v, --verbose : verbose output.
35  -w, --wait : Pause script after plotting a new superposition of histograms.
36  -x, --xml = XML: xml configuration file.
37 
38  Francisco Yumiceva (yumiceva@fnal.gov)
39  Fermilab 2008
40 
41 """
42 
43 
44 import os, string, re, sys, math
45 
46 try:
47  import ROOT
48 except:
49  print("\nCannot load PYROOT, make sure you have setup ROOT in the path")
50  print("and pyroot library is also defined in the variable PYTHONPATH, try:\n")
51  if (os.getenv("PYTHONPATH")):
52  print(" setenv PYTHONPATH ${PYTHONPATH}:$ROOTSYS/lib\n")
53  else:
54  print(" setenv PYTHONPATH $ROOTSYS/lib\n")
55  sys.exit()
56 
57 from ROOT import TFile
58 from ROOT import TCanvas
59 from ROOT import TLegend
60 from ROOT import SetOwnership
61 from ROOT import THStack
62 from ROOT import TLatex
63 from ROOT import TH1
64 from ROOT import TH1F
65 from ROOT import TGraphErrors
66 from ROOT import TVectorD
67 from ROOT import std
68 
69 from xml.sax import saxutils, make_parser, handler
70 from xml.sax.handler import feature_namespaces
71 
72 import Inspector
73 import Style
74 
75 #_______________OPTIONS________________
76 import optparse
77 
78 USAGE = re.compile(r'(?s)\s*usage: (.*?)(\n[ \t]*\n|$)')
79 
80 def nonzero(self): # will become the nonzero method of optparse.Values
81  "True if options were given"
82  for v in six.itervalues(self.__dict__):
83  if v is not None: return True
84  return False
85 
86 optparse.Values.__nonzero__ = nonzero # dynamically fix optparse.Values
87 
88 class ParsingError(Exception): pass
89 
90 optionstring=""
91 
92 def exit(msg=""):
93  raise SystemExit(msg or optionstring.replace("%prog",sys.argv[0]))
94 
95 def parse(docstring, arglist=None):
96  global optionstring
97  optionstring = docstring
98  match = USAGE.search(optionstring)
99  if not match: raise ParsingError("Cannot find the option string")
100  optlines = match.group(1).splitlines()
101  try:
102  p = optparse.OptionParser(optlines[0])
103  for line in optlines[1:]:
104  opt, help=line.split(':')[:2]
105  short,long=opt.split(',')[:2]
106  if '=' in opt:
107  action='store'
108  long=long.split('=')[0]
109  else:
110  action='store_true'
111  p.add_option(short.strip(),long.strip(),
112  action = action, help = help.strip())
113  except (IndexError,ValueError):
114  raise ParsingError("Cannot parse the option string correctly")
115  return p.parse_args(arglist)
116 
117 #______________________________________________________________________
118 
120  def __init__(self):
121  self.type = ""
122  self.filename = ""
123  self.release = ""
124  self.histos = {}
125  self.TH1s = {}
126  self.weight = None
127 
129  def __init__(self):
130  self.name = ""
131  self.numerator = None
132  self.denominator = None
133 
135  def __init__(self):
136  self.name = ""
137  self.title = ""
138  self.color = ""
139 
141  def __init__(self):
142  self.name = ""
143  self.title = ""
144  self.SetLogy = ""
145  self.SetGrid = ""
146  self.histos = []
147  self.weight = []
148 
150  def __init__(self):
151  self.name = ""
152  self.title = ""
153  self.SetLogy = ""
154  self.SetGrid = ""
155  self.histos = []
156  self.color = []
157  self.marker = []
158  self.legend = []
159  self.weight = []
160  #self.flavour = []
161 #**********************************
163  def __init__(self):
164  self.name = ""
165  self.title = ""
166  self.SetLogy = ""
167  self.SetGrid = ""
168  self.histos = []
169  self.color = []
170  self.marker = []
171  self.legend = []
172  self.weight = []
173  self.flavour = []
174 #**********************************
175 
176 class FindIssue(handler.ContentHandler):
177  def __init__(self):
178  self.data = {}
179  self.divide = {}
180  self.addition = {}
181  self.superimpose = {}
182  self.graph = {}
183  self.tmpaddname = ""
184  self.plot = {}
185  self.size = 0
186  self.atype = ""
187  self.tmpsupername = ""
188  self.tmpgraphname = ""
189 
190  def startElement(self, name, attrs):
191  if name == 'validation':
192  self.size = self.size + 1
193  self.atype = attrs.get('type',None)
194  self.data[self.atype] = ValElement()
195  self.data[self.atype].type = attrs.get('type',None)
196  self.data[self.atype].filename = attrs.get('file',None)
197  self.data[self.atype].release = attrs.get('release',None)
198  self.data[self.atype].weight = attrs.get('weight','')
199  if name == 'TH1':
200  self.data[self.atype].histos[attrs.get('name',None)] = attrs.get('source',None)
201  #print attrs.get('name',None)
202  #print attrs.get('source',None)
203  if name == 'divide':
204  aname = attrs.get('name',None)
205  self.divide[aname] = divideElement()
206  self.divide[aname].name = aname
207  self.divide[aname].numerator = attrs.get('numerator',None)
208  self.divide[aname].denominator = attrs.get('denominator',None)
209  self.divide[aname].DivideOption = attrs.get('DivideOption',None)
210  self.divide[aname].Option = attrs.get('Option',None)
211  if name == 'addition':
212  aname = attrs.get('name',None)
213  self.addition[aname] = additionElement()
214  self.tmpaddname = aname
215  self.addition[aname].name = aname
216  self.addition[aname].title = attrs.get('title',None)
217  self.addition[aname].YTitle = attrs.get('YTitle',None)
218  self.addition[aname].XTitle = attrs.get('XTitle',None)
219  self.addition[aname].Option = attrs.get('Option',None)
220  self.addition[aname].Weight = attrs.get('Wight',None)
221  self.addition[aname].Normalize = attrs.get('Normalize',None)
222  self.addition[aname].SetGrid = attrs.get('SetGrid',None)
223  if name == 'additionItem':
224  #print "in element: " + self.tmpsupername
225  self.addition[self.tmpaddname].histos.append(attrs.get('name',None))
226  self.addition[self.tmpaddname].weight.append(attrs.get('weight',None))
227  if name == 'superimpose':
228  aname = attrs.get('name',None)
229  self.superimpose[aname] = superimposeElement()
230  self.superimpose[aname].name = aname
231  self.superimpose[aname].title = attrs.get('title',None)
232  self.superimpose[aname].SetLogy = attrs.get('SetLogy',None)
233  self.superimpose[aname].SetGrid = attrs.get('SetGrid',None)
234  self.superimpose[aname].Normalize = attrs.get('Normalize',None)
235  self.superimpose[aname].Stack = attrs.get('Stack',None)
236  self.superimpose[aname].YTitle = attrs.get('YTitle',None)
237  self.superimpose[aname].XTitle = attrs.get('XTitle',None)
238  self.superimpose[aname].projection = attrs.get('Projection',None)
239  self.superimpose[aname].bin = attrs.get('bin',None)
240  self.superimpose[aname].profile = attrs.get('Profile',None)
241  self.superimpose[aname].Fill = attrs.get('Fill',None)
242  self.superimpose[aname].Option = attrs.get('Option',None)
243  self.superimpose[aname].Weight = attrs.get('Weight',None)
244  self.superimpose[aname].Maximum = attrs.get('Maximum',None)
245  self.superimpose[aname].Minimum = attrs.get('Minimum',None)
246  self.superimpose[aname].Labels = attrs.get('Labels',None)
247  self.superimpose[aname].Rebin = attrs.get('Rebin',None)
248  self.tmpsupername = aname
249  if name == 'graph':
250  aname = attrs.get('name',None)
251  self.graph[aname] = graphElement()
252  self.graph[aname].name = aname
253  self.graph[aname].title = attrs.get('title',None)
254  self.graph[aname].SetLogy = attrs.get('SetLogy',None)
255  self.graph[aname].SetGrid = attrs.get('SetGrid',None)
256  self.graph[aname].Normalize = attrs.get('Normalize',None)
257  self.graph[aname].Stack = attrs.get('Stack',None)
258  self.graph[aname].YTitle = attrs.get('YTitle',None)
259  self.graph[aname].XTitle = attrs.get('XTitle',None)
260  self.graph[aname].projection = attrs.get('Projection',None)
261  self.graph[aname].bin = attrs.get('bin',None)
262  self.graph[aname].profile = attrs.get('Profile',None)
263  self.graph[aname].Fill = attrs.get('Fill',None)
264  self.graph[aname].Option = attrs.get('Option',None)
265  self.graph[aname].Weight = attrs.get('Weight',None)
266  self.graph[aname].Maximum = attrs.get('Maximum',None)
267  self.graph[aname].Minimum = attrs.get('Minimum',None)
268  self.graph[aname].Labels = attrs.get('Labels',None)
269  self.tmpgraphname = aname
270  if name == 'superimposeItem':
271  #print "in element: " + self.tmpsupername
272  self.superimpose[self.tmpsupername].histos.append(attrs.get('name',None))
273  self.superimpose[self.tmpsupername].color.append(attrs.get('color',None))
274  self.superimpose[self.tmpsupername].marker.append(attrs.get('MarkerStyle',None))
275  self.superimpose[self.tmpsupername].legend.append(attrs.get('legend',None))
276  #self.superimpose[self.tmpsupername].flavour.append(attrs.get('flavour',None))
277  #self.superimpose[self.tmpsupername].weight.append(attrs.get('weight',None))
278  if name == 'graphItem':
279  #print "in element: " + self.tmpsupername
280  self.graph[self.tmpgraphname].histos.append(attrs.get('name',None))
281  self.graph[self.tmpgraphname].color.append(attrs.get('color',None))
282  self.graph[self.tmpgraphname].marker.append(attrs.get('MarkerStyle',None))
283  self.graph[self.tmpgraphname].legend.append(attrs.get('legend',None))
284  self.graph[self.tmpgraphname].flavour.append(attrs.get('flavour',None))
285  #self.se[self.tmpsupername].weight.append(attrs.get('weight',None))
286 
287 
288 
289 if __name__ == '__main__':
290 
291 
292 
293  # style
294  thestyle = Style.Style()
295  thestyle.SetStyle()
296 
297  printCanvas = False
298  printFormat = "png"
299  printBanner = False
300  Banner = "CMS Preliminary"
301  verbose = False
302 
303  # check options
304  option,args = parse(__doc__)
305  if not args and not option: exit()
306 
307  if option.batch:
308  ROOT.gROOT.SetBatch()
309 
310  if option.verbose:
311  verbose = True
312 
313  if option.list:
315  ins.Verbose(True)
316  ins.createXML(False)
317  ins.SetFilename(option.list)
318  ins.GetListObjects()
319  sys.exit()
320 
321  if option.create:
322  createXML = Inspector.Inspector()
323  createXML.Verbose(False)
324  createXML.createXML(True)
325  if option.tag:
326  createXML.SetTag(option.tag)
327  createXML.SetFilename(option.create)
328  createXML.GetListObjects()
329  sys.exit()
330 
331  if not option.xml: exit()
332  if option.prt:
333  printCanvas = True
334  printFormat = option.prt
335 
336  if option.flag:
337  printBanner = True
338  Banner = option.flag
339 
340  # check xml file
341  try:
342  xmlfile = open(option.xml)
343  xmlfile.close()
344  except:
345  print(" ERROR: xml file \"" + option.xml + "\" does not exist")
346  sys.exit()
347 
348  # Create a parser
349  parser = make_parser()
350 
351  # Tell the parser we are not interested in XML namespaces
352  parser.setFeature(feature_namespaces, 0)
353 
354  # Create the handler
355  dh = FindIssue()
356 
357  # Tell the parser to use our handler
358  parser.setContentHandler(dh)
359 
360  # Parse the input
361  parser.parse(option.xml)
362 
363  # list of canvas
364  cv = {}
365  afilelist = {}
366  stacklist = {}
367 
368  # root output file
369  outputroot = TFile("cuy.root","RECREATE")
370 
371  # new histograms
372  newTH1list = []
373 
374  # extract histograms
375  thedata = dh.data
376 
377  firstFilename = ''
378 
379  for ikey in thedata:
380  if verbose : print("= Processing set called: " + ikey)
381  afilename = thedata[ikey].filename
382  if firstFilename == '':
383  firstFilename = afilename
384  arelease = ""
385  if thedata[ikey].release != None:
386  arelease = thedata[ikey].release
387  if verbose : print("== filename: " + afilename)
388  if verbose : print("== release: " + arelease)
389  if verbose : print("== weight: " + thedata[ikey].weight)
390  thehistos = thedata[ikey].histos
391  afilelist[afilename] = TFile(afilename)
392  if verbose : print("== get histograms: ")
393  histonamekeys = thehistos.keys()
394  for ihname in histonamekeys:
395  if verbose : print("=== Histogram name: \""+ ihname + "\" source: \""+thehistos[ihname]+"\"")
396  thedata[ikey].TH1s[ihname] = ROOT.gDirectory.Get(thehistos[ihname])
397  #SetOwnership(thedata[ikey].TH1s[ihname], 0)
398  # check if file exists
399  print(thedata[ikey].TH1s[ihname].GetName())
400 
401 
402  # plot superimpose histograms
403  #afilelist['../outputLayer2_ttbarmuonic_all.root'].cd()
404  afilelist[firstFilename].cd()
405  #print thedata['ttbar'].TH1s['gen_eta'].GetEntries()
406 
407 
408  theaddition = dh.addition
409  if verbose : print("= Create addition histograms:")
410 
411  for ikey in theaddition:
412  if verbose : print("== plot name: \""+theaddition[ikey].name+"\" title: \""+theaddition[ikey].title+"\"")
413  listname = theaddition[ikey].histos
414  listweight = theaddition[ikey].weight
415 
416  #create canvas
417  cv[theaddition[ikey].name] = TCanvas(theaddition[ikey].name,theaddition[ikey].name,700,700)
418 
419  isFirst = True
420  ihnameIt = 0
421  for ihname in listname:
422  aweight = 1
423  if listweight[ihnameIt]:
424  #if thedata[jkey].weight != None and theaddition[ikey].Weight == "true":
425  aweight = float(listweight[ihnameIt])
426  #aweight = float(thedata[jkey].weight)
427  for jkey in thedata:
428  tmpkeys = thedata[jkey].histos.keys()
429  for tmpname in tmpkeys:
430  if tmpname == ihname:
431  ath = thedata[jkey].TH1s[tmpname]
432  if ath is None:
433  print("ERROR: histogram name \""+tmpname+"\" does not exist in file "+thedata[jkey].filename)
434  exit(0)
435  if verbose : print("=== add histogram: "+ath.GetName() + " from " + thedata[jkey].filename + " mean = " + "%.2f" % round(ath.GetMean(),2) + " weight= " + str(aweight))
436  #ath.Print("all")
437  if isFirst:
438  newth = ath.Clone(theaddition[ikey].name)
439  newth.Sumw2()
440  if theaddition[ikey].Normalize == "true":
441  newth.Scale(1/newth.Integral())
442  newth.Scale(aweight)
443  isFirst = False
444  else:
445  atmpth = ath.Clone()
446  atmpth.Sumw2()
447  if theaddition[ikey].Normalize == "true":
448  atmpth.Scale(1/atmpth.Integral())
449  atmpth.Scale(aweight)
450  newth.Add( atmpth )
451  ihnameIt = ihnameIt + 1
452 
453  if theaddition[ikey].XTitle != None:
454  newth.SetXTitle(theaddition[ikey].XTitle)
455  if theaddition[ikey].YTitle != None:
456  newth.SetYTitle(theaddition[ikey].YTitle)
457 
458  if theaddition[ikey].Option:
459  newth.Draw(theaddition[ikey].Option)
460  else:
461  newth.Draw()
462 
463  if theaddition[ikey].SetGrid == "true":
464  cv[theaddition[ikey].name].SetGrid()
465 
466  cv[theaddition[ikey].name].Update()
467 
468  # add new histogram to the list
469  newth.SetName(theaddition[ikey].name)
470  newTH1list.append(newth.GetName())
471  thedata[newth.GetName()] = ValElement()
472  thedata[newth.GetName()].TH1s[newth.GetName()] = newth
473  thedata[newth.GetName()].histos[newth.GetName()] = newth.GetName()
474 
475  # write new histograms to file
476  outputroot.cd()
477  newth.Write()
478 
479 
480  if verbose : print("= Create ratio histograms:")
481 
482  thedivition = dh.divide
483  for ikey in thedivition:
484  if verbose : print("== plot name: \""+thedivition[ikey].name+"\" title: \""+"\"")
485  numerator = thedivition[ikey].numerator
486  denominator = thedivition[ikey].denominator
487 
488  #create canvas
489  cv[thedivition[ikey].name] = TCanvas(thedivition[ikey].name,thedivition[ikey].name,700,700)
490 
491  for jkey in thedata:
492  tmpkeys = thedata[jkey].histos.keys()
493  for tmpname in tmpkeys:
494  if tmpname == numerator:
495  numeratorth = thedata[jkey].TH1s[tmpname]
496  if numeratorth is None:
497  print("ERROR: histogram name \""+tmpname+"\" does not exist in file "+thedata[jkey].filename)
498  exit(0)
499  #print "=== numerator histogram: "+numeratorth.GetName() + " from " + thedata[jkey].filename + " mean = " + "%.2f" % round(numeratorth.GetMean(),2) + " weight= " + str(aweight)
500 
501  if tmpname == denominator:
502  denominatorth = thedata[jkey].TH1s[tmpname]
503  if denominatorth is None:
504  print("ERROR: histogram name \""+tmpname+"\" does not exist in file "+thedata[jkey].filename)
505  exit(0)
506  #print "=== denominator histogram: "+denominatorth.GetName() + " from " + thedata[jkey].filename + " mean = " + "%.2f" % round(denominatorth.GetMean(),2) + " weight= " + str(aweight)
507 
508 
509 
510  numeratorth.Sumw2()
511  denominatorth.Sumw2()
512  newth = numeratorth.Clone()
513  newth.Clear()
514  if thedivition[ikey].DivideOption is None:
515  newth.Divide(numeratorth,denominatorth)
516  else:
517  newth.Divide(numeratorth,denominatorth,1.,1.,thedivition[ikey].DivideOption)
518 # if theaddition[ikey].XTitle != None:
519 # newth.SetXTitle(theaddition[ikey].XTitle)
520 # if theaddition[ikey].YTitle != None:
521 # newth.SetYTitle(theaddition[ikey].YTitle)
522 
523  if thedivition[ikey].Option:
524  newth.Draw(thedivition[ikey].Option)
525  else:
526  newth.Draw()
527 
528  cv[thedivition[ikey].name].Update()
529 
530 
531  # pause
532  if option.wait:
533  raw_input( 'Press ENTER to continue\n ' )
534 
535  # add new histogram to the list
536  newth.SetName(thedivition[ikey].name)
537  newTH1list.append(newth.GetName())
538  thedata[newth.GetName()] = ValElement()
539  thedata[newth.GetName()].TH1s[newth.GetName()] = newth
540  thedata[newth.GetName()].histos[newth.GetName()] = newth.GetName()
541 
542  # write new histograms to file
543  outputroot.cd()
544  newth.Write()
545 
546 
547  thesuper = dh.superimpose
548  if verbose : print("= Create superimpose histograms:")
549  for ikey in thesuper:
550  if verbose : print("== plot name: \""+thesuper[ikey].name+"\" title: \""+thesuper[ikey].title+"\"")
551  listname = thesuper[ikey].histos
552  listcolor = thesuper[ikey].color
553  listmarker = thesuper[ikey].marker
554  listlegend = thesuper[ikey].legend
555  #listweight = thesuper[ikey].weight
556  dolegend = False
557  for il in listlegend:
558  if il==None: dolegend = False
559  if verbose : print("dolegend = " +str(dolegend))
560  doNormalize = False
561  doRebin=thesuper[ikey].Rebin
562  if doRebin is not None :
563  doRebin=int(doRebin)
564  if verbose : print("Rebin is ", doRebin)
565  if thesuper[ikey].Normalize == "true":
566  doNormalize = True
567  if verbose : print("normalize = " +str(doNormalize))
568  projectAxis = "no"
569  projectBin = -1 #all
570  if thesuper[ikey].projection == "x": projectAxis = "x"
571  if thesuper[ikey].projection == "y": projectAxis = "y"
572  if thesuper[ikey].bin != None: projectBin = thesuper[ikey].bin
573  profileAxis = "no"
574  if thesuper[ikey].profile == "x": profileAxis = "x"
575  if thesuper[ikey].profile == "y": profileAxis = "y"
576  doFill = False
577  if thesuper[ikey].Fill == "true": doFill = True
578  if verbose : print("fill option:"+ doFill)
579  #create canvas
580  cv[thesuper[ikey].name] = TCanvas(thesuper[ikey].name,thesuper[ikey].title,700,700)
581  #legend
582  aleg = TLegend(0.6,0.4,0.8,0.6)
583  SetOwnership( aleg, 0 )
584  aleg.SetMargin(0.12)
585  aleg.SetTextSize(0.035)
586  aleg.SetFillColor(10)
587  aleg.SetBorderSize(0)
588 
589  isFirst = 1
590  ii = 0
591 
592  stacklist[thesuper[ikey].name] = THStack("astack"+thesuper[ikey].name,thesuper[ikey].title)
593  astack = stacklist[thesuper[ikey].name]
594  for ihname in listname:
595 
596  for jkey in thedata:
597  tmpkeys = thedata[jkey].histos.keys()
598 
599  for tmpname in tmpkeys:
600 
601  if tmpname == ihname:
602  ath = thedata[jkey].TH1s[tmpname]
603  if ath is None:
604  print("ERROR: histogram name \""+tmpname+"\" does not exist in file "+thedata[jkey].filename)
605  exit(0)
606  if verbose : print("=== superimpose histogram: "+ath.GetName() + " mean = " + "%.2f" % round(ath.GetMean(),2))
607  # project 2D histogram if requested
608  if projectAxis == "x":
609  if projectBin == -1:
610  newthpx = ath.ProjectionX(ath.GetName()+"_px",0,-1,"e")
611  else:
612  newthpx = ath.ProjectionX(ath.GetName()+"_px",int(projectBin),int(projectBin),"e")
613  newth = newthpx.Clone()
614  if projectAxis == "y":
615  if projectBin == -1:
616  newthpy = ath.ProjectionY(ath.GetName()+"_py",0,-1,"e")
617  else:
618  newthpx = ath.ProjectionY(ath.GetName()+"_py",int(projectBin),int(projectBin),"e")
619  newth = newthpy.Clone()
620  if profileAxis == "x":
621  newthpx = ath.ProfileX(ath.GetName()+"_px",0,-1,"e")
622  newth = newthpx.Clone()
623  if profileAxis == "y":
624  newthpy = ath.ProfileY(ath.GetName()+"_py",0,-1,"e")
625  newth = newthpy.Clone()
626 
627  # get weight
628  aweight = 1
629  if thedata[jkey].weight != None and thesuper[ikey].Weight=="true":
630  aweight = float( thedata[jkey].weight )
631  if verbose: print(" with weight = " + str(aweight))
632  #if listweight[ii]:
633  # aweight = float( listweight[ii] )
634 
635  # clone original histogram
636  if projectAxis == "no" and profileAxis == "no" :newth = ath.Clone()
637 
638  if doRebin is not None and doRebin>0 :
639  newth.Rebin(doRebin)
640 
641  newth.Sumw2()
642  newth.Scale(aweight)
643 
644  # check if we have color
645  if not listcolor[ii]:
646  listcolor[ii] = 1
647 
648  newth.SetLineColor(int(listcolor[ii]))
649  newth.SetMarkerColor(int(listcolor[ii]))
650 
651  if doFill: newth.SetFillColor(int(listcolor[ii]))
652 
653  if listmarker[ii] != None:
654  newth.SetMarkerStyle(int(listmarker[ii]))
655  # normalize
656  if doNormalize:
657  newth.Scale(1./newth.Integral())
658  #print " "+listlegend[ii]
659 
660  if thesuper[ikey].Labels != None:
661  thelabels = thesuper[ikey].Labels.split(',')
662  ib = 1
663  #print thelabels
664 
665  for ilabel in thelabels:
666  newth.GetXaxis().SetBinLabel(ib,ilabel)
667  #if ib==1:
668  #newth.GetXaxis().SetBinLabel(ib,"")
669  #newth.GetHistogram().GetXaxis().SetBinLabel(ib,ilabel)
670  ib += 1
671  #if aweight==0.0081:
672  # newth.SetBinContent(1, newth.GetBinContent(1) / 0.28756)
673  # if aweight==0.0883:
674  #newth.SetBinContent(1, newth.GetBinContent(1) / 0.01953)
675  #if aweight==0.0731:
676  #newth.SetBinContent(1, newth.GetBinContent(1) / 0.0367)
677  #if aweight==0.4003:
678  #newth.SetBinContent(1, newth.GetBinContent(1) / 0.5683)
679  #if aweight==0.003:
680  #newth.SetBinContent(1, newth.GetBinContent(1) / 0.21173)
681  #if aweight==0.0027:
682  #newth.SetBinContent(1, newth.GetBinContent(1) / 0.26394)
683  #if aweight==0.0034:
684  #newth.SetBinContent(1, newth.GetBinContent(1) / 0.26394)
685 
686 
687  # stack histograms
688  if doFill:
689  if thesuper[ikey].XTitle != None:
690  newth.SetXTitle("")
691  astack.Add(newth,"HIST")
692  elif thesuper[ikey].Option:
693  astack.Add(newth,thesuper[ikey].Option)
694  else:
695  #newth.Fit("landau")
696  astack.Add(newth)
697 
698  astack.SetTitle(thesuper[ikey].title)
699 
700  if isFirst==1:
701  newth.GetPainter().PaintStat(ROOT.gStyle.GetOptStat(),0);
702  isFirst=0
703  tmpsumth = newth.Clone()
704  else:
705  tmpsumth.Add(newth)
706  # newth.SetTitle(thesuper[ikey].title)
707  # if thesuper[ikey].YTitle != None:
708  # newth.SetYTitle(thesuper[ikey].YTitle)
709  # newth.Draw()
710  # isFirst=0
711  #else:
712  # newth.Draw("same")
713  if dolegend and doFill:
714  aleg.AddEntry(newth,listlegend[ii],"F")
715  elif dolegend:
716  aleg.AddEntry(newth,listlegend[ii],"P")
717 
718  newth.SetName(tmpname)
719  outputroot.cd()
720  newth.Write()
721  ii = ii + 1
722 
723 
724  if thesuper[ikey].Maximum != None:
725  astack.SetMaximum( float(thesuper[ikey].Maximum) )
726  if thesuper[ikey].Minimum != None:
727  astack.SetMinimum( float(thesuper[ikey].Minimum) )
728  if thesuper[ikey].Stack == "true":
729  astack.Draw()
730  if thesuper[ikey].Stack == "false" or thesuper[ikey].Stack == None:
731  astack.Draw()
732  astack.Draw("nostack")
733  if thesuper[ikey].XTitle != None:
734  astack.GetHistogram().SetXTitle(thesuper[ikey].XTitle)
735  if thesuper[ikey].YTitle != None:
736  astack.GetHistogram().SetYTitle(thesuper[ikey].YTitle)
737  if doFill:
738  astack.Draw("sameaxis")
739 
740 
741  #thelabels = []
742  #if thesuper[ikey].Labels != None:
743  # thelabels = thesuper[ikey].Labels.split(',')
744  # ib = 1
745  # print thelabels
746 
747  # for ilabel in thelabels:
748  # astack.GetXaxis().SetBinLabel(ib,ilabel)
749  #astack.GetHistogram().GetXaxis().SetBinLabel(ib,ilabel)
750  #ib += 1
751  # astack.Draw()
752  # astack.Draw("sameaxis")
753 
754  if dolegend:
755  aleg.Draw()
756  if thesuper[ikey].SetLogy == "true":
757  cv[thesuper[ikey].name].SetLogy()
758  if thesuper[ikey].SetGrid == "true":
759  cv[thesuper[ikey].name].SetGrid()
760 
761  # test smearing
762  #rn = ROOT.TRandom(12345)
763  #for iibin in range(0,tmpsumth.GetNbinsX()):
764  # tmpsumth.SetBinContent(iibin, rn.Poisson(tmpsumth.GetBinContent(iibin)) )
765  # if tmpsumth.GetBinContent(iibin) == 0:
766  # tmpsumth.SetBinError(iibin, 0 )
767  # else:
768  # tmpsumth.SetBinError(iibin, 1/math.sqrt(tmpsumth.GetBinContent(iibin)) )
769 
770  #tmpsumth.Draw("same E1")
771 
772 
773  if printBanner:
774  tex = TLatex(0.35,0.95,Banner)
775  tex.SetNDC()
776  tex.SetTextSize(0.05)
777  tex.Draw()
778 
779  cv[thesuper[ikey].name].Update()
780  #cv[thesuper[ikey].name].Print("test.png")
781 
782  # pause
783  if option.wait:
784  raw_input( 'Press ENTER to continue\n ' )
785 
786 
787 
788 #**********************************************************************
789 
790 
791  thegraph = dh.graph
792  if verbose : print("= Create graph histograms:")
793  for ikey in thegraph:
794  if verbose : print("== plot name: \""+thegraph[ikey].name+"\" title: \""+thegraph[ikey].title+"\"")
795  listname = thegraph[ikey].histos
796  listcolor = thegraph[ikey].color
797  listmarker = thegraph[ikey].marker
798  listlegend = thegraph[ikey].legend
799  listflavour = thegraph[ikey].flavour
800  #listweight = thegraph[ikey].weight
801  dolegend = False
802  for il in listlegend:
803  if il==None: dolegend = False
804  if verbose : print("dolegend = " +str(dolegend))
805  doNormalize = False
806  if thegraph[ikey].Normalize == "true":
807  doNormalize = True
808  if verbose : print("normalize = " +str(doNormalize))
809  projectAxis = "no"
810  projectBin = -1 #all
811  if thegraph[ikey].projection == "x": projectAxis = "x"
812  if thegraph[ikey].projection == "y": projectAxis = "y"
813  if thegraph[ikey].bin != None: projectBin = thegraph[ikey].bin
814  profileAxis = "no"
815  if thegraph[ikey].profile == "x": profileAxis = "x"
816  if thegraph[ikey].profile == "y": profileAxis = "y"
817  doFill = False
818  if thegraph[ikey].Fill == "true": doFill = True
819  if verbose : print("fill option:"+ doFill)
820  #create canvas
821  cv[thegraph[ikey].name] = TCanvas(thegraph[ikey].name,thegraph[ikey].title,700,700)
822  #legend
823  aleg = TLegend(0.6,0.4,0.8,0.6)
824  SetOwnership( aleg, 0 )
825  aleg.SetMargin(0.12)
826  aleg.SetTextSize(0.035)
827  aleg.SetFillColor(10)
828  aleg.SetBorderSize(0)
829 
830  isFirst = 1
831  ii = 0
832 
833  stacklist[thegraph[ikey].name] = THStack("astack"+thegraph[ikey].name,thegraph[ikey].title)
834  astack = stacklist[thegraph[ikey].name]
835  xVal_val = TVectorD()
836  yVal_val = TVectorD()
837  yBin_val = std.vector(int)()
838  xErr_val = TVectorD()
839  yErr_val = TVectorD()
840  zVal_val = TVectorD()
841  zErr_val = TVectorD()
842  nVal_val = 0
843 
844  xVal_ref = TVectorD()
845  yVal_ref = TVectorD()
846  yBin_ref = std.vector(int)()
847  xErr_ref = TVectorD()
848  yErr_ref = TVectorD()
849  zVal_ref = TVectorD()
850  zErr_ref = TVectorD()
851  nVal_ref = 0
852 
853  RangeMax = 0.005
854  RangeMin = 0.9
855 
856  for ihname in listname:
857 
858  for jkey in thedata:
859  tmpkeys = thedata[jkey].histos.keys()
860 
861  for tmpname in tmpkeys:
862 
863  if tmpname == ihname:
864 
865  ath = thedata[jkey].TH1s[tmpname]
866  if ath is None:
867  print("ERROR: histogram name \""+tmpname+"\" does not exist in file "+thedata[jkey].filename)
868  exit(0)
869  if verbose : print("=== graph histogram: "+ath.GetName() + " mean = " + "%.2f" % round(ath.GetMean(),2))
870  #print listflavour[ii]
871  if listflavour[ii] == "5":
872  #print "iiiiiiiiiii"
873  nBinB = 200 #ath.GetNbinsX()
874  BinWidth = (0.01+ath.GetMaximum())/nBinB
875  BMid = 0.005+BinWidth/2
876  Err = BinWidth
877  for iBinB in range(1,nBinB+1):
878  #BinWidth = (0.01+ath.GetMaximum())/200 #ath.GetBinWidth(iBinB)
879  BMid = BMid+Err #BinWidth #ath.GetBinCenter(iBinB)
880  #newh = TH1(ath)
881  nAthBin = ath.GetNbinsX()-2
882  #newh = TH1(ath)
883  maxInHisto = ath.GetMaximum()
884  minInHisto = ath.GetMinimum()
885  #print minInHisto
886  yClosestInit = 0
887  iBinClosestInit = 0
888  if BMid <= maxInHisto : yClosestInit = maxInHisto + 1
889  else : yClosestInit = minInHisto - 1.0
890  iBinClosest = iBinClosestInit
891  yClosest = yClosestInit
892  for iAthBin in range(1,nAthBin+1):
893  yBin = ath.GetBinContent(iAthBin)
894  dif1 = BMid-yBin
895  if dif1 < 0 : dif1 = yBin-BMid
896  dif2 = yClosest-BMid
897  if dif2 < 0 : dif2 = BMid-yClosest
898  if dif1 < dif2:
899  yClosest = yBin
900  iBinClosest = iAthBin
901  min = BMid-Err/2
902  max = BMid+Err/2
903  #print iBinClosest
904  if yClosest < min or yClosest > max:
905  iBinClosest = 0
906  #print "iji"
907  if iBinClosest > 0 and listmarker[ii] == "8":
908  #print "hhhhhhhhhhhhhhhh"
909  nVal_ref = nVal_ref+1
910  xVal_ref.ResizeTo(nVal_ref)
911  #yBin_ref.ResizeTo(nVal_ref)
912  xErr_ref.ResizeTo(nVal_ref)
913  xVal_ref[nVal_ref-1] = BMid
914  yBin_ref.push_back(iBinClosest)
915  xErr_ref[nVal_ref-1] = ath.GetBinError ( iBinClosest )
916  Err = xErr_ref[nVal_ref-1]
917  if Err < BinWidth : Err = BinWidth
918  elif iBinClosest > 0:
919  nVal_val = nVal_val+1
920  xVal_val.ResizeTo(nVal_val)
921  #yBin_val.ResizeTo(nVal_val)
922  xErr_val.ResizeTo(nVal_val)
923  xVal_val[nVal_val-1] = BMid
924  yBin_val.push_back(iBinClosest)
925  xErr_val[nVal_val-1] = ath.GetBinError ( iBinClosest )
926  Err = xErr_val[nVal_val-1]
927  if Err < BinWidth : Err = BinWidth
928  elif listflavour[ii] == "4" and listmarker[ii] == "8":
929  yVal_ref.ResizeTo(nVal_ref)
930  yErr_ref.ResizeTo(nVal_ref)
931  for iVal in range(0,nVal_ref):
932  yVal_ref[iVal] = ath.GetBinContent (yBin_ref[iVal])
933  if yVal_ref[iVal] > RangeMax : RangeMax = yVal_ref[iVal]
934  yErr_ref[iVal] = ath.GetBinError (yBin_ref[iVal])
935  elif listflavour[ii] == "4":
936  yVal_val.ResizeTo(nVal_val)
937  yErr_val.ResizeTo(nVal_val)
938  for iVal in range(0,nVal_val):
939  yVal_val[iVal] = ath.GetBinContent (yBin_val[iVal])
940  yErr_val[iVal] = ath.GetBinError (yBin_val[iVal])
941  elif listmarker[ii] == "8":
942  zVal_ref.ResizeTo(nVal_ref)
943  zErr_ref.ResizeTo(nVal_ref)
944  for iVal in range(0,nVal_ref):
945  zVal_ref[iVal] = ath.GetBinContent (yBin_ref[iVal])
946  zErr_ref[iVal] = ath.GetBinError (yBin_ref[iVal])
947  if zVal_ref[iVal] < RangeMin : RangeMin = zVal_ref[iVal]
948  else:
949  zVal_val.ResizeTo(nVal_val)
950  zErr_val.ResizeTo(nVal_val)
951  for iVal in range(0,nVal_val):
952  zVal_val[iVal] = ath.GetBinContent (yBin_val[iVal])
953  zErr_val[iVal] = ath.GetBinError (yBin_val[iVal])
954  ii = ii + 1
955 
956  #print xVal_ref.GetNoElements()
957  #print yVal_ref.GetNrows()
958  #print xErr_ref.GetNrows()
959  #print yErr_ref.GetNrows()
960 
961  #graphs = std.vector(TGraphErrors)()
962  graphs = [TGraphErrors(xVal_ref,yVal_ref,xErr_ref,yErr_ref),
963  TGraphErrors(xVal_ref,zVal_ref,xErr_ref,zErr_ref),
964  TGraphErrors(xVal_val,yVal_val,xErr_val,yErr_val),
965  TGraphErrors(xVal_val,zVal_val,xErr_val,zErr_val)]
966  ii = 0
967 
968 
969 
970  for ii in range(0,4):
971 
972  # project 2D histogram if requested
973  #if projectAxis == "x":
974  # if projectBin == -1:
975  # newthpx = ath.ProjectionX(ath.GetName()+"_px",0,-1,"e")
976  # else:
977  # newthpx = ath.ProjectionX(ath.GetName()+"_px",int(projectBin),int(projectBin),"e")
978  # newth = newthpx.Clone()
979  #if projectAxis == "y":
980  # if projectBin == -1:
981  # newthpy = ath.ProjectionY(ath.GetName()+"_py",0,-1,"e")
982  # else:
983  # newthpx = ath.ProjectionY(ath.GetName()+"_py",int(projectBin),int(projectBin),"e")
984  # newth = newthpy.Clone()
985  #if profileAxis == "x":
986  # newthpx = ath.ProfileX(ath.GetName()+"_px",0,-1,"e")
987  # newth = newthpx.Clone()
988  #if profileAxis == "y":
989  # newthpy = ath.ProfileY(ath.GetName()+"_py",0,-1,"e")
990  # newth = newthpy.Clone()
991 
992  # get weight
993  aweight = 1
994  #if thedata[jkey].weight != None and thegraph[ikey].Weight=="true":
995  # aweight = float( thedata[jkey].weight )
996  #if verbose: print " with weight = " + str(aweight)
997  #if listweight[ii]:
998  # aweight = float( listweight[ii] )
999 
1000  # clone original histogram
1001  #if projectAxis == "no" and profileAxis == "no" :newth = ath.Clone()
1002 
1003  #newth.Sumw2()
1004  #newth.Scale(aweight)
1005 
1006  # check if we have color
1007  #if not listcolor[ii]:
1008  # listcolor[ii] = 1
1009 
1010  col = 2
1011  mark = 22
1012  if ii == 0 or ii == 2:
1013  col = 1
1014  if ii == 0 or ii == 1:
1015  mark = 8
1016 
1017  graphs[ii].SetLineColor(col)
1018  graphs[ii].SetMarkerStyle(mark)
1019  graphs[ii].SetMarkerColor(col)
1020  graphs[ii].SetTitle(thegraph[ikey].title)
1021  #if doFill: newth.SetFillColor(int(listcolor[ii]))
1022 
1023  #if listmarker[ii] != None:
1024  # newth.SetMarkerStyle(int(listmarker[ii]))
1025  # normalize
1026  #if doNormalize:
1027  # newth.Scale(1./newth.Integral())
1028  #print " "+listlegend[ii]
1029 
1030  #if thegraph[ikey].Labels != None:
1031  # thelabels = thesuper[ikey].Labels.split(',')
1032  # ib = 1
1033  #print thelabels
1034 
1035  # for ilabel in thelabels:
1036  # newth.GetXaxis().SetBinLabel(ib,ilabel)
1037  #if ib==1:
1038  #newth.GetXaxis().SetBinLabel(ib,"")
1039  #newth.GetHistogram().GetXaxis().SetBinLabel(ib,ilabel)
1040  # ib += 1
1041  #if aweight==0.0081:
1042  # newth.SetBinContent(1, newth.GetBinContent(1) / 0.28756)
1043  # if aweight==0.0883:
1044  #newth.SetBinContent(1, newth.GetBinContent(1) / 0.01953)
1045  #if aweight==0.0731:
1046  #newth.SetBinContent(1, newth.GetBinContent(1) / 0.0367)
1047  #if aweight==0.4003:
1048  #newth.SetBinContent(1, newth.GetBinContent(1) / 0.5683)
1049  #if aweight==0.003:
1050  #newth.SetBinContent(1, newth.GetBinContent(1) / 0.21173)
1051  #if aweight==0.0027:
1052  #newth.SetBinContent(1, newth.GetBinContent(1) / 0.26394)
1053  #if aweight==0.0034:
1054  #newth.SetBinContent(1, newth.GetBinContent(1) / 0.26394)
1055 
1056 
1057  # stack histograms
1058  #if doFill:
1059  # if thegraph[ikey].XTitle != None:
1060  # newth.SetXTitle("")
1061  # astack.Add(newth,"HIST")
1062  #elif thegraph[ikey].Option:
1063  # astack.Add(newth,thegraph[ikey].Option)
1064  #else:
1065  #newth.Fit("landau")
1066  # astack.Add(newth)
1067 
1068  #astack.SetTitle(thegraph[ikey].title)
1069 
1070  if isFirst==1:
1071  #graphs[ii].GetPainter().PaintStat(ROOT.gStyle.GetOptStat(),0);
1072  isFirst=0
1073  #tmpsumth = graphs[ii].Clone()
1074  #else:
1075  # tmpsumth.Add(graphs[ii])
1076  # newth.SetTitle(thesuper[ikey].title)
1077  # if thesuper[ikey].YTitle != None:
1078  # newth.SetYTitle(thesuper[ikey].YTitle)
1079  # newth.Draw()
1080  # isFirst=0
1081  #else:
1082  # newth.Draw("same")
1083  #if dolegend and doFill:
1084  # aleg.AddEntry(newth,listlegend[ii],"F")
1085  #elif dolegend:
1086  # aleg.AddEntry(newth,listlegend[ii],"P")
1087 
1088  #graphs[ii].SetName(tmpname)
1089  #if ii == 0 : graphs[ii].Draw()
1090  #else : graphs[ii].Draw("same")
1091  outputroot.cd()
1092  graphs[ii].Write()
1093  ii = ii + 1
1094 
1095 
1096  #if thegraph[ikey].Maximum != None:
1097  # graphs[0].SetMaximum( float(thegraph[ikey].Maximum) )
1098  #if thegraph[ikey].Minimum != None:
1099  # graphs[0].SetMinimum( float(thegraph[ikey].Minimum) )
1100  #if thegraph[ikey].Stack == "true":
1101  # astack.Draw()
1102  #if thegraph[ikey].Stack == "false" or thegraph[ikey].Stack == None:
1103  # astack.Draw()
1104  # astack.Draw("nostack")
1105  if thegraph[ikey].XTitle != None:
1106  graphs[0].GetHistogram().SetXTitle(thegraph[ikey].XTitle)
1107  if thegraph[ikey].YTitle != None:
1108  graphs[0].GetHistogram().SetYTitle(thegraph[ikey].YTitle)
1109  #if doFill:
1110  # astack.Draw("sameaxis")
1111  if RangeMax > 0.5 : RangeMax = 1.5
1112  if RangeMax < 0.5 : RangeMax = RangeMax + 0.05
1113  #RangeMax = 1.1
1114  RangeMin = RangeMin - 0.5*RangeMin
1115  #print RangeMax
1116  #print RangeMin
1117  if RangeMin < 0.00001 : RangeMin = 0.00005
1118  graphs[0].GetYaxis().SetRangeUser(RangeMin,RangeMax)
1119 
1120  #thelabels = []
1121  #if thesuper[ikey].Labels != None:
1122  # thelabels = thesuper[ikey].Labels.split(',')
1123  # ib = 1
1124  # print thelabels
1125 
1126  # for ilabel in thelabels:
1127  # astack.GetXaxis().SetBinLabel(ib,ilabel)
1128  #astack.GetHistogram().GetXaxis().SetBinLabel(ib,ilabel)
1129  #ib += 1
1130  # astack.Draw()
1131  # astack.Draw("sameaxis")
1132 
1133  #h = TH1F()
1134  #h.Draw()
1135  graphs[0].Draw("AP")
1136  graphs[1].Draw("sameP")
1137  graphs[2].Draw("sameP")
1138  graphs[3].Draw("sameP")
1139  if dolegend:
1140  aleg.Draw()
1141  if thegraph[ikey].SetLogy == "true":
1142  cv[thegraph[ikey].name].SetLogy()
1143  if thegraph[ikey].SetGrid == "true":
1144  cv[thegraph[ikey].name].SetGrid()
1145 
1146  # test smearing
1147  #rn = ROOT.TRandom(12345)
1148  #for iibin in range(0,tmpsumth.GetNbinsX()):
1149  # tmpsumth.SetBinContent(iibin, rn.Poisson(tmpsumth.GetBinContent(iibin)) )
1150  # if tmpsumth.GetBinContent(iibin) == 0:
1151  # tmpsumth.SetBinError(iibin, 0 )
1152  # else:
1153  # tmpsumth.SetBinError(iibin, 1/math.sqrt(tmpsumth.GetBinContent(iibin)) )
1154 
1155  #tmpsumth.Draw("same E1")
1156 
1157 
1158  if printBanner:
1159  tex = TLatex(0.35,0.95,Banner)
1160  tex.SetNDC()
1161  tex.SetTextSize(0.05)
1162  tex.Draw()
1163 
1164  cv[thegraph[ikey].name].Update()
1165  save = thegraph[ikey].name
1166  cv[thegraph[ikey].name].Print(save + ".gif")#Print("test.png")
1167 
1168  # pause
1169  if option.wait:
1170  raw_input( 'Press ENTER to continue\n ' )
1171 
1172 
1173 #*********************************************************************
1174 
1175 
1176  if printCanvas:
1177 
1178  for ikey in theaddition:
1179  cv[theaddition[ikey].name].Print(theaddition[ikey].name + "." + printFormat)
1180  for ikey in thesuper:
1181  cv[thesuper[ikey].name].Print(thesuper[ikey].name + "." + printFormat)
1182  for ikey in thegraph:
1183  cv[thegraph[ikey].name].Print(thegraph[ikey].name + "notgood." + printFormat)
1184 
1185 
1186  #outputroot.Write()
1187  #outputroot.Close()
1188 
1189 # if not option.wait:
1190  rep = ''
1191  while not rep in [ 'q', 'Q', '.q', 'qq' 'p']:
1192  rep = raw_input( '\nenter: ["q",".q" to quit] ["p" or "print" to print all canvas]: ' )
1193  if 0<len(rep):
1194  if rep=='quit': rep = 'q'
1195  if rep=='p' or rep=='print':
1196  for ikey in theaddition:
1197  cv[theaddition[ikey].name].Print(theaddition[ikey].name + "." + printFormat)
1198  for ikey in thesuper:
1199  cv[thesuper[ikey].name].Print(thesuper[ikey].name + "." + printFormat)
1200  for ikey in thegraph:
1201  cv[thegraph[ikey].name].Print(thegraph[ikey].name + "." + printFormat)
1202 
1203 
def __init__(self)
Definition: cuy.py:135
def __init__(self)
Definition: cuy.py:150
def __init__(self)
Definition: cuy.py:141
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def __init__(self)
Definition: cuy.py:129
def __init__(self)
Definition: cuy.py:177
tmpgraphname
Definition: cuy.py:188
def __init__(self)
Definition: cuy.py:163
def parse(docstring, arglist=None)
Definition: cuy.py:95
def __init__(self)
Definition: cuy.py:120
tmpsupername
Definition: cuy.py:187
def startElement(self, name, attrs)
Definition: cuy.py:190
def nonzero(self)
Definition: cuy.py:80
#define str(s)
def exit(msg="")
Definition: cuy.py:92