Missing statbox

hello
I overlap the histograms after doing the job and getting the stack histogram the stat box is missing is there any way for stat box . kindly check my macro.


while the resultant hist is

also i want to mention that the colors show histograms(from different source).

It is difficult to see what is wrong with only this screen dump. Can you provide some code we can run ?

Hi ,
Yes i tell u what i m doing in the code
I am stacking the histograms which i am getting from root files ( WW.root ,TT.root,DY.root)
By giving the command
THStack* hs= new THStack("name ",“Title”);

Then i add all histograms in hs
hs->Add(h1);
hs->Add(h2);
.
.
.
.
.

h1, h2 … are names of histograms which i m stacking .
then i give command
hs->Draw();

I send u macro from that u may get idea .

Thank you couet

savewmass.cc (1.4 KB)

Your macro seems correct. As I do note have your root files I tried to simulate what you are doing using an histogram I have and it is fine for me. I see the stats. Which root version are you using ? on which platform ? can I have the root files ?

Hi

I send you. Root Version is 5.34/07 and Root platform is linuxx8664gcc also the root files .

Kindly find the attachement

Thank you

where are the attachements ?

Hi

Find The attachement.

Ok … but where ? I see nothing …

Hi

Get these ones.

DY.root (23.2 KB)

TT.root (18.7 KB)

TTWT.root (25.5 KB)

TTZT.root (20.8 KB)

WW.root (14.4 KB)

wzt.root (35.8 KB)

ZZT.root (34.3 KB)

Yes the stat are not created when you plot the stack. You need to draw h1 before
like:

 void savewmass() {
  gStyle->SetOptStat(1001);
  TCanvas* c1 = new TCanvas("wmass","w-mass",50,50,800,600);

   TFile *f1 = new TFile("WW.root");
  TFile *f2 = new TFile("TT.root");
  TFile *f3 = new TFile("DY.root");


   TH1F *h1 = (TH1F*)f1->Get("W_Tran_mass");
   h1->SetFillColor(6);

   TH1F *h2 = (TH1F*)f2->Get("W_Tran_mass");
   h2->SetFillColor(4);

   TH1F *h3 = (TH1F*)f3->Get("W_Tran_mass");
   h3->SetFillColor(3);

   THStack* hs= new THStack("hs","W-Mass stacked histograms");
h1->Draw();


gPad->Update();
//   c1->cd(1);
   hs->Add(h1);
  hs->Add(h2);
  hs->Add(h3);

   hs->Draw();
   gPad->Update();
  hs->GetXaxis()->SetTitle("GeV");
  hs->GetYaxis()->SetTitle("# of entries");

  TLegend *leg = new TLegend(0.6,0.8,0.9,0.9);

  leg->AddEntry(h1,"WW","f");
  leg->AddEntry(h2,"TT","f");
  leg->AddEntry(h3,"DY","f");
  leg->Draw();
}

Hello

I try it but find only one stat box as i stack three histograms so i want three stat box .
i repeat it three times as
h1->Draw();
h2->Draw();
h3->Draw();
then i get the stat box for last histogram .

 void savewmass() {
  gStyle->SetOptStat(1001);
  TCanvas* c1 = new TCanvas("wmass","w-mass",50,50,800,600);

   TFile *f1 = new TFile("WW.root");
  TFile *f2 = new TFile("TT.root");
  TFile *f3 = new TFile("DY.root");


   TH1F *h1 = (TH1F*)f1->Get("W_Tran_mass");
   h1->SetFillColor(6);

   TH1F *h2 = (TH1F*)f2->Get("W_Tran_mass");
   h2->SetFillColor(4);

   TH1F *h3 = (TH1F*)f3->Get("W_Tran_mass");
   h3->SetFillColor(3);

   THStack* hs= new THStack("hs","W-Mass stacked histograms");
h1->Draw();
gPad->Update();
   TPaveStats *ps1 = (TPaveStats*)h1->GetListOfFunctions()->FindObject("stats");
h2->Draw();
gPad->Update();
   TPaveStats *ps2 = (TPaveStats*)h2->GetListOfFunctions()->FindObject("stats");


//   c1->cd(1);
   hs->Add(h1);
  hs->Add(h2);
  hs->Add(h3);

   hs->Draw();
   ps1->Draw();
   ps2->Draw();
   gPad->Update();
  hs->GetXaxis()->SetTitle("GeV");
  hs->GetYaxis()->SetTitle("# of entries");

  TLegend *leg = new TLegend(0.6,0.8,0.9,0.9);

  leg->AddEntry(h1,"WW","f");
  leg->AddEntry(h2,"TT","f");
  leg->AddEntry(h3,"DY","f");
  leg->Draw();
}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.