Hi,
I want this kind of graph:
But I get this:
I want a solid line between the bins of the same histogram. I tried to use the “L” option for drawing.
Here is the code:
void fuse_hists(){
TString filename1 = "run_03/run_03.root"; // CP-even
TString hist1 = "h_Phi_q1_q2_t_tbarSM;1";
TString filename2 = "run_04/run_04.root"; // CP-odd
TString hist2 = "h_Phi_q1_q2_t_tbarSM;1";
TString title = "\\phi_C (rad)";
TString outFilePNG = "PhiC.png";
TCanvas* c1 = new TCanvas("Name", "Title", 1280, 1024);
THStack *hstack = new THStack("Name", "");
TFile* file1 = new TFile(filename1, "READ");
TH1F* th1f1 = (TH1F*)file1->Get(hist1);
th1f1->SetDirectory(nullptr);
file1->Close();
TFile* file2 = new TFile(filename2, "READ");
TH1F* th1f2 = (TH1F*)file2->Get(hist2);
th1f2->SetDirectory(nullptr);
file2->Close();
th1f1->Sumw2();
th1f2->Sumw2();
th1f1->SetLineColor(kBlack);
th1f2->SetLineColor(kBlue);
//normalize
th1f1->Scale(1./th1f1->Integral());
th1f2->Scale(1./th1f2->Integral());
hstack-> Add(th1f1);
hstack-> Add(th1f2);
hstack->Draw("nostackb l");
hstack->GetXaxis()->SetTitle(title);
hstack->GetYaxis()->SetTitle("Normalized distribution");
TLegend* legend = new TLegend(0.7, 0.75, 0.9, 0.9);
legend->AddEntry(th1f1, "CP-even", "l");//"fas"
legend->AddEntry(th1f2, "CP-odd", "l");
legend->Draw();
gPad->Modified();
gPad->Update();
c1->Print(outFilePNG);
}
ROOT Version: 6.24/06
Platform: Debian
Compiler: Not Provided