14 from __future__
import print_function
23 A very simple way to make plots with ROOT via an XML file.
25 usage: %prog -x <XML configuration file>
26 -b, --batch : run in batch mode without graphics.
27 -c, --create = CREATE: create XML configuration file from a ROOT file.
28 -e, --example = EXAMPLE: generate an example xml file.
29 -f, --flag = FLAG: create a baneer
30 -l, --list = LIST: list of objects in the ROOT file.
31 -p, --prt = PRT: print canvas in the format specified png, ps, eps, pdf, etc.
32 -t, --tag = TAG: tag name for XML configuration file.
33 -v, --verbose : verbose output.
34 -w, --wait : Pause script after plotting a new superposition of histograms.
35 -x, --xml = XML: xml configuration file.
37 Francisco Yumiceva (yumiceva@fnal.gov)
43 import os, string, re, sys, math
48 print(
"\nCannot load PYROOT, make sure you have setup ROOT in the path")
49 print(
"and pyroot library is also defined in the variable PYTHONPATH, try:\n")
50 if (os.getenv(
"PYTHONPATH")):
51 print(
" setenv PYTHONPATH ${PYTHONPATH}:$ROOTSYS/lib\n")
53 print(
" setenv PYTHONPATH $ROOTSYS/lib\n")
56 from ROOT
import TFile
57 from ROOT
import TCanvas
58 from ROOT
import TLegend
59 from ROOT
import SetOwnership
60 from ROOT
import THStack
61 from ROOT
import TLatex
64 from ROOT
import TGraphErrors
65 from ROOT
import TVectorD
68 from xml.sax
import saxutils, make_parser, handler
69 from xml.sax.handler
import feature_namespaces
77 USAGE = re.compile(
r'(?s)\s*usage: (.*?)(\n[ \t]*\n|$)')
80 "True if options were given"
81 for v
in self.__dict__.
values():
82 if v
is not None:
return True
85 optparse.Values.__nonzero__ = nonzero
92 raise SystemExit(msg
or optionstring.replace(
"%prog",sys.argv[0]))
94 def parse(docstring, arglist=None):
96 optionstring = docstring
97 match = USAGE.search(optionstring)
98 if not match:
raise ParsingError(
"Cannot find the option string")
99 optlines = match.group(1).splitlines()
101 p = optparse.OptionParser(optlines[0])
102 for line
in optlines[1:]:
103 opt, help=line.split(
':')[:2]
104 short,long=opt.split(
',')[:2]
107 long=long.split(
'=')[0]
110 p.add_option(short.strip(),long.strip(),
111 action = action, help = help.strip())
112 except (IndexError,ValueError):
113 raise ParsingError(
"Cannot parse the option string correctly")
114 return p.parse_args(arglist)
190 if name ==
'validation':
192 self.
atype = attrs.get(
'type',
None)
194 self.
data[self.
atype].type = attrs.get(
'type',
None)
195 self.
data[self.
atype].filename = attrs.get(
'file',
None)
196 self.
data[self.
atype].release = attrs.get(
'release',
None)
197 self.
data[self.
atype].weight = attrs.get(
'weight',
'')
199 self.
data[self.
atype].histos[attrs.get(
'name',
None)] = attrs.get(
'source',
None)
203 aname = attrs.get(
'name',
None)
205 self.
divide[aname].name = aname
206 self.
divide[aname].numerator = attrs.get(
'numerator',
None)
207 self.
divide[aname].denominator = attrs.get(
'denominator',
None)
208 self.
divide[aname].DivideOption = attrs.get(
'DivideOption',
None)
209 self.
divide[aname].Option = attrs.get(
'Option',
None)
210 if name ==
'addition':
211 aname = attrs.get(
'name',
None)
215 self.
addition[aname].title = attrs.get(
'title',
None)
216 self.
addition[aname].YTitle = attrs.get(
'YTitle',
None)
217 self.
addition[aname].XTitle = attrs.get(
'XTitle',
None)
218 self.
addition[aname].Option = attrs.get(
'Option',
None)
219 self.
addition[aname].Weight = attrs.get(
'Wight',
None)
220 self.
addition[aname].Normalize = attrs.get(
'Normalize',
None)
221 self.
addition[aname].SetGrid = attrs.get(
'SetGrid',
None)
222 if name ==
'additionItem':
226 if name ==
'superimpose':
227 aname = attrs.get(
'name',
None)
230 self.
superimpose[aname].title = attrs.get(
'title',
None)
231 self.
superimpose[aname].SetLogy = attrs.get(
'SetLogy',
None)
232 self.
superimpose[aname].SetGrid = attrs.get(
'SetGrid',
None)
233 self.
superimpose[aname].Normalize = attrs.get(
'Normalize',
None)
234 self.
superimpose[aname].Stack = attrs.get(
'Stack',
None)
235 self.
superimpose[aname].YTitle = attrs.get(
'YTitle',
None)
236 self.
superimpose[aname].XTitle = attrs.get(
'XTitle',
None)
237 self.
superimpose[aname].projection = attrs.get(
'Projection',
None)
238 self.
superimpose[aname].bin = attrs.get(
'bin',
None)
239 self.
superimpose[aname].profile = attrs.get(
'Profile',
None)
240 self.
superimpose[aname].Fill = attrs.get(
'Fill',
None)
241 self.
superimpose[aname].Option = attrs.get(
'Option',
None)
242 self.
superimpose[aname].Weight = attrs.get(
'Weight',
None)
243 self.
superimpose[aname].Maximum = attrs.get(
'Maximum',
None)
244 self.
superimpose[aname].Minimum = attrs.get(
'Minimum',
None)
245 self.
superimpose[aname].Labels = attrs.get(
'Labels',
None)
246 self.
superimpose[aname].Rebin = attrs.get(
'Rebin',
None)
249 aname = attrs.get(
'name',
None)
251 self.
graph[aname].name = aname
252 self.
graph[aname].title = attrs.get(
'title',
None)
253 self.
graph[aname].SetLogy = attrs.get(
'SetLogy',
None)
254 self.
graph[aname].SetGrid = attrs.get(
'SetGrid',
None)
255 self.
graph[aname].Normalize = attrs.get(
'Normalize',
None)
256 self.
graph[aname].Stack = attrs.get(
'Stack',
None)
257 self.
graph[aname].YTitle = attrs.get(
'YTitle',
None)
258 self.
graph[aname].XTitle = attrs.get(
'XTitle',
None)
259 self.
graph[aname].projection = attrs.get(
'Projection',
None)
260 self.
graph[aname].bin = attrs.get(
'bin',
None)
261 self.
graph[aname].profile = attrs.get(
'Profile',
None)
262 self.
graph[aname].Fill = attrs.get(
'Fill',
None)
263 self.
graph[aname].Option = attrs.get(
'Option',
None)
264 self.
graph[aname].Weight = attrs.get(
'Weight',
None)
265 self.
graph[aname].Maximum = attrs.get(
'Maximum',
None)
266 self.
graph[aname].Minimum = attrs.get(
'Minimum',
None)
267 self.
graph[aname].Labels = attrs.get(
'Labels',
None)
269 if name ==
'superimposeItem':
277 if name ==
'graphItem':
288 if __name__ ==
'__main__':
299 Banner =
"CMS Preliminary"
304 if not args
and not option:
exit()
307 ROOT.gROOT.SetBatch()
316 ins.SetFilename(option.list)
322 createXML.Verbose(
False)
323 createXML.createXML(
True)
325 createXML.SetTag(option.tag)
326 createXML.SetFilename(option.create)
327 createXML.GetListObjects()
330 if not option.xml:
exit()
333 printFormat = option.prt
341 xmlfile = open(option.xml)
344 print(
" ERROR: xml file \"" + option.xml +
"\" does not exist")
348 parser = make_parser()
351 parser.setFeature(feature_namespaces, 0)
357 parser.setContentHandler(dh)
360 parser.parse(option.xml)
368 outputroot = TFile(
"cuy.root",
"RECREATE")
379 if verbose :
print(
"= Processing set called: " + ikey)
380 afilename = thedata[ikey].filename
381 if firstFilename ==
'':
382 firstFilename = afilename
384 if thedata[ikey].release !=
None:
385 arelease = thedata[ikey].release
386 if verbose :
print(
"== filename: " + afilename)
387 if verbose :
print(
"== release: " + arelease)
388 if verbose :
print(
"== weight: " + thedata[ikey].weight)
389 thehistos = thedata[ikey].histos
390 afilelist[afilename] = TFile(afilename)
391 if verbose :
print(
"== get histograms: ")
392 histonamekeys = thehistos.keys()
393 for ihname
in histonamekeys:
394 if verbose :
print(
"=== Histogram name: \""+ ihname +
"\" source: \""+thehistos[ihname]+
"\"")
395 thedata[ikey].TH1s[ihname] = ROOT.gDirectory.Get(thehistos[ihname])
398 print(thedata[ikey].TH1s[ihname].GetName())
403 afilelist[firstFilename].
cd()
407 theaddition = dh.addition
408 if verbose :
print(
"= Create addition histograms:")
410 for ikey
in theaddition:
411 if verbose :
print(
"== plot name: \""+theaddition[ikey].name+
"\" title: \""+theaddition[ikey].title+
"\"")
412 listname = theaddition[ikey].histos
413 listweight = theaddition[ikey].weight
416 cv[theaddition[ikey].name] = TCanvas(theaddition[ikey].name,theaddition[ikey].name,700,700)
420 for ihname
in listname:
422 if listweight[ihnameIt]:
424 aweight =
float(listweight[ihnameIt])
427 tmpkeys = thedata[jkey].histos.keys()
428 for tmpname
in tmpkeys:
429 if tmpname == ihname:
430 ath = thedata[jkey].TH1s[tmpname]
432 print(
"ERROR: histogram name \""+tmpname+
"\" does not exist in file "+thedata[jkey].filename)
434 if verbose :
print(
"=== add histogram: "+ath.GetName() +
" from " + thedata[jkey].filename +
" mean = " +
"%.2f" % round(ath.GetMean(),2) +
" weight= " +
str(aweight))
437 newth = ath.Clone(theaddition[ikey].name)
439 if theaddition[ikey].Normalize ==
"true":
440 newth.Scale(1/newth.Integral())
446 if theaddition[ikey].Normalize ==
"true":
447 atmpth.Scale(1/atmpth.Integral())
448 atmpth.Scale(aweight)
450 ihnameIt = ihnameIt + 1
452 if theaddition[ikey].XTitle !=
None:
453 newth.SetXTitle(theaddition[ikey].XTitle)
454 if theaddition[ikey].YTitle !=
None:
455 newth.SetYTitle(theaddition[ikey].YTitle)
457 if theaddition[ikey].Option:
458 newth.Draw(theaddition[ikey].Option)
462 if theaddition[ikey].SetGrid ==
"true":
463 cv[theaddition[ikey].name].SetGrid()
465 cv[theaddition[ikey].name].Update()
468 newth.SetName(theaddition[ikey].name)
469 newTH1list.append(newth.GetName())
471 thedata[newth.GetName()].TH1s[newth.GetName()] = newth
472 thedata[newth.GetName()].histos[newth.GetName()] = newth.GetName()
479 if verbose :
print(
"= Create ratio histograms:")
481 thedivition = dh.divide
482 for ikey
in thedivition:
483 if verbose :
print(
"== plot name: \""+thedivition[ikey].name+
"\" title: \""+
"\"")
484 numerator = thedivition[ikey].numerator
485 denominator = thedivition[ikey].denominator
488 cv[thedivition[ikey].name] = TCanvas(thedivition[ikey].name,thedivition[ikey].name,700,700)
491 tmpkeys = thedata[jkey].histos.keys()
492 for tmpname
in tmpkeys:
493 if tmpname == numerator:
494 numeratorth = thedata[jkey].TH1s[tmpname]
495 if numeratorth
is None:
496 print(
"ERROR: histogram name \""+tmpname+
"\" does not exist in file "+thedata[jkey].filename)
500 if tmpname == denominator:
501 denominatorth = thedata[jkey].TH1s[tmpname]
502 if denominatorth
is None:
503 print(
"ERROR: histogram name \""+tmpname+
"\" does not exist in file "+thedata[jkey].filename)
510 denominatorth.Sumw2()
511 newth = numeratorth.Clone()
513 if thedivition[ikey].DivideOption
is None:
514 newth.Divide(numeratorth,denominatorth)
516 newth.Divide(numeratorth,denominatorth,1.,1.,thedivition[ikey].DivideOption)
522 if thedivition[ikey].Option:
523 newth.Draw(thedivition[ikey].Option)
527 cv[thedivition[ikey].name].Update()
532 raw_input(
'Press ENTER to continue\n ' )
535 newth.SetName(thedivition[ikey].name)
536 newTH1list.append(newth.GetName())
538 thedata[newth.GetName()].TH1s[newth.GetName()] = newth
539 thedata[newth.GetName()].histos[newth.GetName()] = newth.GetName()
546 thesuper = dh.superimpose
547 if verbose :
print(
"= Create superimpose histograms:")
548 for ikey
in thesuper:
549 if verbose :
print(
"== plot name: \""+thesuper[ikey].name+
"\" title: \""+thesuper[ikey].title+
"\"")
550 listname = thesuper[ikey].histos
551 listcolor = thesuper[ikey].color
552 listmarker = thesuper[ikey].marker
553 listlegend = thesuper[ikey].legend
556 for il
in listlegend:
557 if il==
None: dolegend =
False
558 if verbose :
print(
"dolegend = " +
str(dolegend))
560 doRebin=thesuper[ikey].Rebin
561 if doRebin
is not None :
563 if verbose :
print(
"Rebin is ", doRebin)
564 if thesuper[ikey].Normalize ==
"true":
566 if verbose :
print(
"normalize = " +
str(doNormalize))
569 if thesuper[ikey].projection ==
"x": projectAxis =
"x"
570 if thesuper[ikey].projection ==
"y": projectAxis =
"y"
571 if thesuper[ikey].bin !=
None: projectBin = thesuper[ikey].bin
573 if thesuper[ikey].profile ==
"x": profileAxis =
"x"
574 if thesuper[ikey].profile ==
"y": profileAxis =
"y"
576 if thesuper[ikey].Fill ==
"true": doFill =
True
577 if verbose :
print(
"fill option:"+ doFill)
579 cv[thesuper[ikey].name] = TCanvas(thesuper[ikey].name,thesuper[ikey].title,700,700)
581 aleg = TLegend(0.6,0.4,0.8,0.6)
582 SetOwnership( aleg, 0 )
584 aleg.SetTextSize(0.035)
585 aleg.SetFillColor(10)
586 aleg.SetBorderSize(0)
591 stacklist[thesuper[ikey].name] = THStack(
"astack"+thesuper[ikey].name,thesuper[ikey].title)
592 astack = stacklist[thesuper[ikey].name]
593 for ihname
in listname:
596 tmpkeys = thedata[jkey].histos.keys()
598 for tmpname
in tmpkeys:
600 if tmpname == ihname:
601 ath = thedata[jkey].TH1s[tmpname]
603 print(
"ERROR: histogram name \""+tmpname+
"\" does not exist in file "+thedata[jkey].filename)
605 if verbose :
print(
"=== superimpose histogram: "+ath.GetName() +
" mean = " +
"%.2f" % round(ath.GetMean(),2))
607 if projectAxis ==
"x":
609 newthpx = ath.ProjectionX(ath.GetName()+
"_px",0,-1,
"e")
611 newthpx = ath.ProjectionX(ath.GetName()+
"_px",
int(projectBin),
int(projectBin),
"e")
612 newth = newthpx.Clone()
613 if projectAxis ==
"y":
615 newthpy = ath.ProjectionY(ath.GetName()+
"_py",0,-1,
"e")
617 newthpx = ath.ProjectionY(ath.GetName()+
"_py",
int(projectBin),
int(projectBin),
"e")
618 newth = newthpy.Clone()
619 if profileAxis ==
"x":
620 newthpx = ath.ProfileX(ath.GetName()+
"_px",0,-1,
"e")
621 newth = newthpx.Clone()
622 if profileAxis ==
"y":
623 newthpy = ath.ProfileY(ath.GetName()+
"_py",0,-1,
"e")
624 newth = newthpy.Clone()
628 if thedata[jkey].weight !=
None and thesuper[ikey].Weight==
"true":
629 aweight =
float( thedata[jkey].weight )
630 if verbose:
print(
" with weight = " +
str(aweight))
635 if projectAxis ==
"no" and profileAxis ==
"no" :newth = ath.Clone()
637 if doRebin
is not None and doRebin>0 :
644 if not listcolor[ii]:
647 newth.SetLineColor(
int(listcolor[ii]))
648 newth.SetMarkerColor(
int(listcolor[ii]))
650 if doFill: newth.SetFillColor(
int(listcolor[ii]))
652 if listmarker[ii] !=
None:
653 newth.SetMarkerStyle(
int(listmarker[ii]))
656 newth.Scale(1./newth.Integral())
659 if thesuper[ikey].Labels !=
None:
660 thelabels = thesuper[ikey].Labels.split(
',')
664 for ilabel
in thelabels:
665 newth.GetXaxis().SetBinLabel(ib,ilabel)
688 if thesuper[ikey].XTitle !=
None:
690 astack.Add(newth,
"HIST")
691 elif thesuper[ikey].Option:
692 astack.Add(newth,thesuper[ikey].Option)
697 astack.SetTitle(thesuper[ikey].title)
700 newth.GetPainter().PaintStat(ROOT.gStyle.GetOptStat(),0);
702 tmpsumth = newth.Clone()
712 if dolegend
and doFill:
713 aleg.AddEntry(newth,listlegend[ii],
"F")
715 aleg.AddEntry(newth,listlegend[ii],
"P")
717 newth.SetName(tmpname)
723 if thesuper[ikey].Maximum !=
None:
724 astack.SetMaximum(
float(thesuper[ikey].Maximum) )
725 if thesuper[ikey].Minimum !=
None:
726 astack.SetMinimum(
float(thesuper[ikey].Minimum) )
727 if thesuper[ikey].Stack ==
"true":
729 if thesuper[ikey].Stack ==
"false" or thesuper[ikey].Stack ==
None:
731 astack.Draw(
"nostack")
732 if thesuper[ikey].XTitle !=
None:
733 astack.GetHistogram().SetXTitle(thesuper[ikey].XTitle)
734 if thesuper[ikey].YTitle !=
None:
735 astack.GetHistogram().SetYTitle(thesuper[ikey].YTitle)
737 astack.Draw(
"sameaxis")
755 if thesuper[ikey].SetLogy ==
"true":
756 cv[thesuper[ikey].name].SetLogy()
757 if thesuper[ikey].SetGrid ==
"true":
758 cv[thesuper[ikey].name].SetGrid()
773 tex = TLatex(0.35,0.95,Banner)
775 tex.SetTextSize(0.05)
778 cv[thesuper[ikey].name].Update()
783 raw_input(
'Press ENTER to continue\n ' )
791 if verbose :
print(
"= Create graph histograms:")
792 for ikey
in thegraph:
793 if verbose :
print(
"== plot name: \""+thegraph[ikey].name+
"\" title: \""+thegraph[ikey].title+
"\"")
794 listname = thegraph[ikey].histos
795 listcolor = thegraph[ikey].color
796 listmarker = thegraph[ikey].marker
797 listlegend = thegraph[ikey].legend
798 listflavour = thegraph[ikey].flavour
801 for il
in listlegend:
802 if il==
None: dolegend =
False
803 if verbose :
print(
"dolegend = " +
str(dolegend))
805 if thegraph[ikey].Normalize ==
"true":
807 if verbose :
print(
"normalize = " +
str(doNormalize))
810 if thegraph[ikey].projection ==
"x": projectAxis =
"x"
811 if thegraph[ikey].projection ==
"y": projectAxis =
"y"
812 if thegraph[ikey].bin !=
None: projectBin = thegraph[ikey].bin
814 if thegraph[ikey].profile ==
"x": profileAxis =
"x"
815 if thegraph[ikey].profile ==
"y": profileAxis =
"y"
817 if thegraph[ikey].Fill ==
"true": doFill =
True
818 if verbose :
print(
"fill option:"+ doFill)
820 cv[thegraph[ikey].name] = TCanvas(thegraph[ikey].name,thegraph[ikey].title,700,700)
822 aleg = TLegend(0.6,0.4,0.8,0.6)
823 SetOwnership( aleg, 0 )
825 aleg.SetTextSize(0.035)
826 aleg.SetFillColor(10)
827 aleg.SetBorderSize(0)
832 stacklist[thegraph[ikey].name] = THStack(
"astack"+thegraph[ikey].name,thegraph[ikey].title)
833 astack = stacklist[thegraph[ikey].name]
834 xVal_val = TVectorD()
835 yVal_val = TVectorD()
836 yBin_val = std.vector(int)()
837 xErr_val = TVectorD()
838 yErr_val = TVectorD()
839 zVal_val = TVectorD()
840 zErr_val = TVectorD()
843 xVal_ref = TVectorD()
844 yVal_ref = TVectorD()
845 yBin_ref = std.vector(int)()
846 xErr_ref = TVectorD()
847 yErr_ref = TVectorD()
848 zVal_ref = TVectorD()
849 zErr_ref = TVectorD()
855 for ihname
in listname:
858 tmpkeys = thedata[jkey].histos.keys()
860 for tmpname
in tmpkeys:
862 if tmpname == ihname:
864 ath = thedata[jkey].TH1s[tmpname]
866 print(
"ERROR: histogram name \""+tmpname+
"\" does not exist in file "+thedata[jkey].filename)
868 if verbose :
print(
"=== graph histogram: "+ath.GetName() +
" mean = " +
"%.2f" % round(ath.GetMean(),2))
870 if listflavour[ii] ==
"5":
873 BinWidth = (0.01+ath.GetMaximum())/nBinB
874 BMid = 0.005+BinWidth/2
876 for iBinB
in range(1,nBinB+1):
880 nAthBin = ath.GetNbinsX()-2
882 maxInHisto = ath.GetMaximum()
883 minInHisto = ath.GetMinimum()
887 if BMid <= maxInHisto : yClosestInit = maxInHisto + 1
888 else : yClosestInit = minInHisto - 1.0
889 iBinClosest = iBinClosestInit
890 yClosest = yClosestInit
891 for iAthBin
in range(1,nAthBin+1):
892 yBin = ath.GetBinContent(iAthBin)
894 if dif1 < 0 : dif1 = yBin-BMid
896 if dif2 < 0 : dif2 = BMid-yClosest
899 iBinClosest = iAthBin
903 if yClosest < min
or yClosest > max:
906 if iBinClosest > 0
and listmarker[ii] ==
"8":
908 nVal_ref = nVal_ref+1
909 xVal_ref.ResizeTo(nVal_ref)
911 xErr_ref.ResizeTo(nVal_ref)
912 xVal_ref[nVal_ref-1] = BMid
913 yBin_ref.push_back(iBinClosest)
914 xErr_ref[nVal_ref-1] = ath.GetBinError ( iBinClosest )
915 Err = xErr_ref[nVal_ref-1]
916 if Err < BinWidth : Err = BinWidth
917 elif iBinClosest > 0:
918 nVal_val = nVal_val+1
919 xVal_val.ResizeTo(nVal_val)
921 xErr_val.ResizeTo(nVal_val)
922 xVal_val[nVal_val-1] = BMid
923 yBin_val.push_back(iBinClosest)
924 xErr_val[nVal_val-1] = ath.GetBinError ( iBinClosest )
925 Err = xErr_val[nVal_val-1]
926 if Err < BinWidth : Err = BinWidth
927 elif listflavour[ii] ==
"4" and listmarker[ii] ==
"8":
928 yVal_ref.ResizeTo(nVal_ref)
929 yErr_ref.ResizeTo(nVal_ref)
930 for iVal
in range(0,nVal_ref):
931 yVal_ref[iVal] = ath.GetBinContent (yBin_ref[iVal])
932 if yVal_ref[iVal] > RangeMax : RangeMax = yVal_ref[iVal]
933 yErr_ref[iVal] = ath.GetBinError (yBin_ref[iVal])
934 elif listflavour[ii] ==
"4":
935 yVal_val.ResizeTo(nVal_val)
936 yErr_val.ResizeTo(nVal_val)
937 for iVal
in range(0,nVal_val):
938 yVal_val[iVal] = ath.GetBinContent (yBin_val[iVal])
939 yErr_val[iVal] = ath.GetBinError (yBin_val[iVal])
940 elif listmarker[ii] ==
"8":
941 zVal_ref.ResizeTo(nVal_ref)
942 zErr_ref.ResizeTo(nVal_ref)
943 for iVal
in range(0,nVal_ref):
944 zVal_ref[iVal] = ath.GetBinContent (yBin_ref[iVal])
945 zErr_ref[iVal] = ath.GetBinError (yBin_ref[iVal])
946 if zVal_ref[iVal] < RangeMin : RangeMin = zVal_ref[iVal]
948 zVal_val.ResizeTo(nVal_val)
949 zErr_val.ResizeTo(nVal_val)
950 for iVal
in range(0,nVal_val):
951 zVal_val[iVal] = ath.GetBinContent (yBin_val[iVal])
952 zErr_val[iVal] = ath.GetBinError (yBin_val[iVal])
961 graphs = [TGraphErrors(xVal_ref,yVal_ref,xErr_ref,yErr_ref),
962 TGraphErrors(xVal_ref,zVal_ref,xErr_ref,zErr_ref),
963 TGraphErrors(xVal_val,yVal_val,xErr_val,yErr_val),
964 TGraphErrors(xVal_val,zVal_val,xErr_val,zErr_val)]
969 for ii
in range(0,4):
1011 if ii == 0
or ii == 2:
1013 if ii == 0
or ii == 1:
1016 graphs[ii].SetLineColor(col)
1017 graphs[ii].SetMarkerStyle(mark)
1018 graphs[ii].SetMarkerColor(col)
1019 graphs[ii].SetTitle(thegraph[ikey].title)
1104 if thegraph[ikey].XTitle !=
None:
1105 graphs[0].GetHistogram().SetXTitle(thegraph[ikey].XTitle)
1106 if thegraph[ikey].YTitle !=
None:
1107 graphs[0].GetHistogram().SetYTitle(thegraph[ikey].YTitle)
1110 if RangeMax > 0.5 : RangeMax = 1.5
1111 if RangeMax < 0.5 : RangeMax = RangeMax + 0.05
1113 RangeMin = RangeMin - 0.5*RangeMin
1116 if RangeMin < 0.00001 : RangeMin = 0.00005
1117 graphs[0].GetYaxis().SetRangeUser(RangeMin,RangeMax)
1134 graphs[0].Draw(
"AP")
1135 graphs[1].Draw(
"sameP")
1136 graphs[2].Draw(
"sameP")
1137 graphs[3].Draw(
"sameP")
1140 if thegraph[ikey].SetLogy ==
"true":
1141 cv[thegraph[ikey].name].SetLogy()
1142 if thegraph[ikey].SetGrid ==
"true":
1143 cv[thegraph[ikey].name].SetGrid()
1158 tex = TLatex(0.35,0.95,Banner)
1160 tex.SetTextSize(0.05)
1163 cv[thegraph[ikey].name].Update()
1164 save = thegraph[ikey].name
1165 cv[thegraph[ikey].name].Print(save +
".gif")
1169 raw_input(
'Press ENTER to continue\n ' )
1177 for ikey
in theaddition:
1178 cv[theaddition[ikey].name].Print(theaddition[ikey].name +
"." + printFormat)
1179 for ikey
in thesuper:
1180 cv[thesuper[ikey].name].Print(thesuper[ikey].name +
"." + printFormat)
1181 for ikey
in thegraph:
1182 cv[thegraph[ikey].name].Print(thegraph[ikey].name +
"notgood." + printFormat)
1190 while not rep
in [
'q',
'Q',
'.q',
'qq' 'p']:
1191 rep = raw_input(
'\nenter: ["q",".q" to quit] ["p" or "print" to print all canvas]: ' )
1193 if rep==
'quit': rep =
'q'
1194 if rep==
'p' or rep==
'print':
1195 for ikey
in theaddition:
1196 cv[theaddition[ikey].name].Print(theaddition[ikey].name +
"." + printFormat)
1197 for ikey
in thesuper:
1198 cv[thesuper[ikey].name].Print(thesuper[ikey].name +
"." + printFormat)
1199 for ikey
in thegraph:
1200 cv[thegraph[ikey].name].Print(thegraph[ikey].name +
"." + printFormat)