14 from __future__
import print_function
24 A very simple way to make plots with ROOT via an XML file.
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.
38 Francisco Yumiceva (yumiceva@fnal.gov)
44 import os, string, re, sys, math
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")
54 print(
" setenv PYTHONPATH $ROOTSYS/lib\n")
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
65 from ROOT
import TGraphErrors
66 from ROOT
import TVectorD
69 from xml.sax
import saxutils, make_parser, handler
70 from xml.sax.handler
import feature_namespaces
78 USAGE = re.compile(
r'(?s)\s*usage: (.*?)(\n[ \t]*\n|$)')
81 "True if options were given"
82 for v
in six.itervalues(self.__dict__):
83 if v
is not None:
return True
86 optparse.Values.__nonzero__ = nonzero
93 raise SystemExit(msg
or optionstring.replace(
"%prog",sys.argv[0]))
95 def parse(docstring, arglist=None):
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()
102 p = optparse.OptionParser(optlines[0])
103 for line
in optlines[1:]:
104 opt, help=line.split(
':')[:2]
105 short,long=opt.split(
',')[:2]
108 long=long.split(
'=')[0]
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)
191 if name ==
'validation':
193 self.
atype = attrs.get(
'type',
None)
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',
'')
200 self.
data[self.
atype].histos[attrs.get(
'name',
None)] = attrs.get(
'source',
None)
204 aname = attrs.get(
'name',
None)
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)
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':
227 if name ==
'superimpose':
228 aname = attrs.get(
'name',
None)
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)
250 aname = attrs.get(
'name',
None)
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)
270 if name ==
'superimposeItem':
278 if name ==
'graphItem':
289 if __name__ ==
'__main__':
300 Banner =
"CMS Preliminary"
305 if not args
and not option:
exit()
308 ROOT.gROOT.SetBatch()
317 ins.SetFilename(option.list)
323 createXML.Verbose(
False)
324 createXML.createXML(
True)
326 createXML.SetTag(option.tag)
327 createXML.SetFilename(option.create)
328 createXML.GetListObjects()
331 if not option.xml:
exit()
334 printFormat = option.prt
342 xmlfile = open(option.xml)
345 print(
" ERROR: xml file \"" + option.xml +
"\" does not exist")
349 parser = make_parser()
352 parser.setFeature(feature_namespaces, 0)
358 parser.setContentHandler(dh)
361 parser.parse(option.xml)
369 outputroot = TFile(
"cuy.root",
"RECREATE")
380 if verbose :
print(
"= Processing set called: " + ikey)
381 afilename = thedata[ikey].filename
382 if firstFilename ==
'':
383 firstFilename = afilename
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])
399 print(thedata[ikey].TH1s[ihname].GetName())
404 afilelist[firstFilename].
cd()
408 theaddition = dh.addition
409 if verbose :
print(
"= Create addition histograms:")
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
417 cv[theaddition[ikey].name] = TCanvas(theaddition[ikey].name,theaddition[ikey].name,700,700)
421 for ihname
in listname:
423 if listweight[ihnameIt]:
425 aweight =
float(listweight[ihnameIt])
428 tmpkeys = thedata[jkey].histos.keys()
429 for tmpname
in tmpkeys:
430 if tmpname == ihname:
431 ath = thedata[jkey].TH1s[tmpname]
433 print(
"ERROR: histogram name \""+tmpname+
"\" does not exist in file "+thedata[jkey].filename)
435 if verbose :
print(
"=== add histogram: "+ath.GetName() +
" from " + thedata[jkey].filename +
" mean = " +
"%.2f" % round(ath.GetMean(),2) +
" weight= " +
str(aweight))
438 newth = ath.Clone(theaddition[ikey].name)
440 if theaddition[ikey].Normalize ==
"true":
441 newth.Scale(1/newth.Integral())
447 if theaddition[ikey].Normalize ==
"true":
448 atmpth.Scale(1/atmpth.Integral())
449 atmpth.Scale(aweight)
451 ihnameIt = ihnameIt + 1
453 if theaddition[ikey].XTitle !=
None:
454 newth.SetXTitle(theaddition[ikey].XTitle)
455 if theaddition[ikey].YTitle !=
None:
456 newth.SetYTitle(theaddition[ikey].YTitle)
458 if theaddition[ikey].Option:
459 newth.Draw(theaddition[ikey].Option)
463 if theaddition[ikey].SetGrid ==
"true":
464 cv[theaddition[ikey].name].SetGrid()
466 cv[theaddition[ikey].name].Update()
469 newth.SetName(theaddition[ikey].name)
470 newTH1list.append(newth.GetName())
472 thedata[newth.GetName()].TH1s[newth.GetName()] = newth
473 thedata[newth.GetName()].histos[newth.GetName()] = newth.GetName()
480 if verbose :
print(
"= Create ratio histograms:")
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
489 cv[thedivition[ikey].name] = TCanvas(thedivition[ikey].name,thedivition[ikey].name,700,700)
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)
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)
511 denominatorth.Sumw2()
512 newth = numeratorth.Clone()
514 if thedivition[ikey].DivideOption
is None:
515 newth.Divide(numeratorth,denominatorth)
517 newth.Divide(numeratorth,denominatorth,1.,1.,thedivition[ikey].DivideOption)
523 if thedivition[ikey].Option:
524 newth.Draw(thedivition[ikey].Option)
528 cv[thedivition[ikey].name].Update()
533 raw_input(
'Press ENTER to continue\n ' )
536 newth.SetName(thedivition[ikey].name)
537 newTH1list.append(newth.GetName())
539 thedata[newth.GetName()].TH1s[newth.GetName()] = newth
540 thedata[newth.GetName()].histos[newth.GetName()] = newth.GetName()
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
557 for il
in listlegend:
558 if il==
None: dolegend =
False
559 if verbose :
print(
"dolegend = " +
str(dolegend))
561 doRebin=thesuper[ikey].Rebin
562 if doRebin
is not None :
564 if verbose :
print(
"Rebin is ", doRebin)
565 if thesuper[ikey].Normalize ==
"true":
567 if verbose :
print(
"normalize = " +
str(doNormalize))
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
574 if thesuper[ikey].profile ==
"x": profileAxis =
"x"
575 if thesuper[ikey].profile ==
"y": profileAxis =
"y"
577 if thesuper[ikey].Fill ==
"true": doFill =
True
578 if verbose :
print(
"fill option:"+ doFill)
580 cv[thesuper[ikey].name] = TCanvas(thesuper[ikey].name,thesuper[ikey].title,700,700)
582 aleg = TLegend(0.6,0.4,0.8,0.6)
583 SetOwnership( aleg, 0 )
585 aleg.SetTextSize(0.035)
586 aleg.SetFillColor(10)
587 aleg.SetBorderSize(0)
592 stacklist[thesuper[ikey].name] = THStack(
"astack"+thesuper[ikey].name,thesuper[ikey].title)
593 astack = stacklist[thesuper[ikey].name]
594 for ihname
in listname:
597 tmpkeys = thedata[jkey].histos.keys()
599 for tmpname
in tmpkeys:
601 if tmpname == ihname:
602 ath = thedata[jkey].TH1s[tmpname]
604 print(
"ERROR: histogram name \""+tmpname+
"\" does not exist in file "+thedata[jkey].filename)
606 if verbose :
print(
"=== superimpose histogram: "+ath.GetName() +
" mean = " +
"%.2f" % round(ath.GetMean(),2))
608 if projectAxis ==
"x":
610 newthpx = ath.ProjectionX(ath.GetName()+
"_px",0,-1,
"e")
612 newthpx = ath.ProjectionX(ath.GetName()+
"_px",
int(projectBin),
int(projectBin),
"e")
613 newth = newthpx.Clone()
614 if projectAxis ==
"y":
616 newthpy = ath.ProjectionY(ath.GetName()+
"_py",0,-1,
"e")
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()
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))
636 if projectAxis ==
"no" and profileAxis ==
"no" :newth = ath.Clone()
638 if doRebin
is not None and doRebin>0 :
645 if not listcolor[ii]:
648 newth.SetLineColor(
int(listcolor[ii]))
649 newth.SetMarkerColor(
int(listcolor[ii]))
651 if doFill: newth.SetFillColor(
int(listcolor[ii]))
653 if listmarker[ii] !=
None:
654 newth.SetMarkerStyle(
int(listmarker[ii]))
657 newth.Scale(1./newth.Integral())
660 if thesuper[ikey].Labels !=
None:
661 thelabels = thesuper[ikey].Labels.split(
',')
665 for ilabel
in thelabels:
666 newth.GetXaxis().SetBinLabel(ib,ilabel)
689 if thesuper[ikey].XTitle !=
None:
691 astack.Add(newth,
"HIST")
692 elif thesuper[ikey].Option:
693 astack.Add(newth,thesuper[ikey].Option)
698 astack.SetTitle(thesuper[ikey].title)
701 newth.GetPainter().PaintStat(ROOT.gStyle.GetOptStat(),0);
703 tmpsumth = newth.Clone()
713 if dolegend
and doFill:
714 aleg.AddEntry(newth,listlegend[ii],
"F")
716 aleg.AddEntry(newth,listlegend[ii],
"P")
718 newth.SetName(tmpname)
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":
730 if thesuper[ikey].Stack ==
"false" or thesuper[ikey].Stack ==
None:
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)
738 astack.Draw(
"sameaxis")
756 if thesuper[ikey].SetLogy ==
"true":
757 cv[thesuper[ikey].name].SetLogy()
758 if thesuper[ikey].SetGrid ==
"true":
759 cv[thesuper[ikey].name].SetGrid()
774 tex = TLatex(0.35,0.95,Banner)
776 tex.SetTextSize(0.05)
779 cv[thesuper[ikey].name].Update()
784 raw_input(
'Press ENTER to continue\n ' )
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
802 for il
in listlegend:
803 if il==
None: dolegend =
False
804 if verbose :
print(
"dolegend = " +
str(dolegend))
806 if thegraph[ikey].Normalize ==
"true":
808 if verbose :
print(
"normalize = " +
str(doNormalize))
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
815 if thegraph[ikey].profile ==
"x": profileAxis =
"x"
816 if thegraph[ikey].profile ==
"y": profileAxis =
"y"
818 if thegraph[ikey].Fill ==
"true": doFill =
True
819 if verbose :
print(
"fill option:"+ doFill)
821 cv[thegraph[ikey].name] = TCanvas(thegraph[ikey].name,thegraph[ikey].title,700,700)
823 aleg = TLegend(0.6,0.4,0.8,0.6)
824 SetOwnership( aleg, 0 )
826 aleg.SetTextSize(0.035)
827 aleg.SetFillColor(10)
828 aleg.SetBorderSize(0)
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()
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()
856 for ihname
in listname:
859 tmpkeys = thedata[jkey].histos.keys()
861 for tmpname
in tmpkeys:
863 if tmpname == ihname:
865 ath = thedata[jkey].TH1s[tmpname]
867 print(
"ERROR: histogram name \""+tmpname+
"\" does not exist in file "+thedata[jkey].filename)
869 if verbose :
print(
"=== graph histogram: "+ath.GetName() +
" mean = " +
"%.2f" % round(ath.GetMean(),2))
871 if listflavour[ii] ==
"5":
874 BinWidth = (0.01+ath.GetMaximum())/nBinB
875 BMid = 0.005+BinWidth/2
877 for iBinB
in range(1,nBinB+1):
881 nAthBin = ath.GetNbinsX()-2
883 maxInHisto = ath.GetMaximum()
884 minInHisto = ath.GetMinimum()
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)
895 if dif1 < 0 : dif1 = yBin-BMid
897 if dif2 < 0 : dif2 = BMid-yClosest
900 iBinClosest = iAthBin
904 if yClosest < min
or yClosest > max:
907 if iBinClosest > 0
and listmarker[ii] ==
"8":
909 nVal_ref = nVal_ref+1
910 xVal_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)
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]
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])
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)]
970 for ii
in range(0,4):
1012 if ii == 0
or ii == 2:
1014 if ii == 0
or ii == 1:
1017 graphs[ii].SetLineColor(col)
1018 graphs[ii].SetMarkerStyle(mark)
1019 graphs[ii].SetMarkerColor(col)
1020 graphs[ii].SetTitle(thegraph[ikey].title)
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)
1111 if RangeMax > 0.5 : RangeMax = 1.5
1112 if RangeMax < 0.5 : RangeMax = RangeMax + 0.05
1114 RangeMin = RangeMin - 0.5*RangeMin
1117 if RangeMin < 0.00001 : RangeMin = 0.00005
1118 graphs[0].GetYaxis().SetRangeUser(RangeMin,RangeMax)
1135 graphs[0].Draw(
"AP")
1136 graphs[1].Draw(
"sameP")
1137 graphs[2].Draw(
"sameP")
1138 graphs[3].Draw(
"sameP")
1141 if thegraph[ikey].SetLogy ==
"true":
1142 cv[thegraph[ikey].name].SetLogy()
1143 if thegraph[ikey].SetGrid ==
"true":
1144 cv[thegraph[ikey].name].SetGrid()
1159 tex = TLatex(0.35,0.95,Banner)
1161 tex.SetTextSize(0.05)
1164 cv[thegraph[ikey].name].Update()
1165 save = thegraph[ikey].name
1166 cv[thegraph[ikey].name].Print(save +
".gif")
1170 raw_input(
'Press ENTER to continue\n ' )
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)
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]: ' )
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)