THStack is graphing me as if I were NOSTACK and I don't want that

Hi, I am trying to make THStack to the root files of some simulations that I made, but when I do it is like NOSTACK, also I only want to make stack to 3 of my simulations and a fourth one to be graphed in the same canvas, but without being in the stack, I would appreciate your help.

example

void histPT()
{
TFile f1 = TFile::Open(“histosPTGammaW.root”);
TH1F h1 = (TH1F)f1->Get(“pt”);
cout << h1->Integral() << endl;
Double_t factor1 = 149898.0
((h1->Integral()*1.0)/100000.0); //with nnpdf3.0 l as=0.130
cout << "factor " << factor1 << endl;
h1->Scale(factor1/(h1->Integral()*1.0));
h1->SetFillColor(kRed);

.
.
. (here I do the same with the other 2 files as above)

TFile f4 = TFile::Open(“histosPTGammaXD31.root”);
TH1F h4 = (TH1F)f4->Get(“pt”);
cout << h4->Integral() << endl;
Double_t factor4 = 757.746
((h4->Integral()*1.0)/100000.0);
cout << "factor " << factor4 << endl;
h4->Scale(factor4/(h4->Integral()*1.0));
h4->SetLineWidth(3);
h4->SetLineStyle(2);
h4->SetLineColor(39);
h4->GetXaxis()->SetTitle(“PT Gamma[GeV]”);
h4->GetYaxis()->SetTitle(“Eventos”);
h4->Draw(“h”);

THStack *hstack = new THStack(“hstack”,“PT Gamma [GeV] vs Events”);

hstack->Add(h3);
hstack->Add(h1);
hstack->Add(h2);
hstack->Draw(“h SAME”);
}

_ROOT Version: 6.24/06
_Platform: Ubuntu 20.04 LTS
Compiler: Not Provided

I do not have your data files. So I cannot try your example.
Is the range of h4 compatible with the stack range?
Maybe the stack is not visible because of that.
the best would be to post a reproducer we can run.

I suppose that when you simply do hstack->Draw(); the stack is correct?

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