ROOT Version: 6.14
Platform: Ubuntu16.04
_Compiler:_gcc530
I am running a python script, which works all fine in terms of major parts (TTree, TH1F hist filling, scaling and other stuffs)
However, positions of TPad and TLatex are incorrect.
Instead of talking, I believe it’s better to post my script and the resultant plot to determine the source of error.
from __future__ import division
#import ROOT
from ROOT import *
#from histutil import *
c1 = TCanvas( 'c1', 'Histogram Drawing Options', 800,800 )
c1.SetGrid()
gStyle.SetHistLineWidth(1)
gStyle.SetLineWidth(3)
gPad.SetTickx()
gPad.SetTicky()
gStyle.SetLineWidth(3)
gStyle.SetPalette(kBird)
c1.Clear()
pad1 = TPad("pad1", "The pad with the function",0,0.25,1,1)
pad1.SetFrameLineWidth(3)
pad1.Draw()
c1.cd()
##gStyle.SetOptTitle(0)
##gStyle.SetOptStat(0)
_file0 = TFile.Open('/uscms/home/s/nobackup/LLDJ_slc6_530_CMSSW_8_0_26_patch1/src/LLDJstandalones/ntuples/config/lldjntuple_mc_AOD50w.root','read')
sample ='ZH_HToSSTobbbb_ZToLL_MH-125_MS-15_ctauS-10'
h16 = TH1F("Decaydist",'%s Decaydist' % sample,200, 0, 20)
h16w = TH1F("Decaydistw",'%s Decaydistw' % sample,200, 0, 20)
mytree16 = _file0.Get("lldjNtuple/EventTree")
1,1 Top
for entry in mytree16:
Decaydist=mytree16.Decaydist
weight = mytree16.Simweight
number = Decaydist.size()
for i in range(number):
#h16s.Fill(weight[i],1)
h16.Fill(Decaydist[i],1)
h16w.Fill(Decaydist[i],weight[i])
texf = TLatex()
texf.SetTextColor(1)
texf.SetTextAlign(22)
texf.SetTextSize(0.03)
#texf.SetTextAngle(90)
texf.DrawLatex(.165,.9,"CMS")
h16.Draw('HIST')
#h16.GetXaxis().SetRangeUser(0,10)
#h16.GetYaxis().SetRangeUser(10,20000)
h16.SetLineColor(2)
h16w.Draw('HIST SAME')
h16w.SetLineColor(5)
#title = TPaveLabel(.11,.95,.35,.99,"new title","brNDC")
#title.Draw()
legend = TLegend(0.5,0.75,0.7,0.9)
legend.AddEntry(h16,"Decaydist for ctau =1","f")
legend.AddEntry(h16w,"Decaydist for ctau =2","f")
legend.Draw()
l = TLatex()
l.SetTextAlign(33);
l.SetTextSize(0.02)
l.DrawTextNDC(0.13,0.9,"CMS")
l.DrawTextNDC(0.17,0.9,"#it{Preliminary}")
c1.Modified()
c1.Update()
I am planning to make the pad of my hist to be smaller than canvas, and position “CMS, Preliminary” aligned at left top of the Histogram pad.
But, what I obtain is…
Could you point out the source of error, and if there exists any advice in terms of positioning pad,LATEX,Pavetext box easily, could you teach me (such as automatically aligning TLatex with TPad)?
So far, my positioning strategy has been just trial and re-edit, which was so confusing.
Thank you.