hi
I am trying to auto-set a THStack axis range with something like
[code]
//hs refers to the THStack plot
TH1 *hlast = ((TH1 *)(hs->GetStack()->Last())); // the “SUM”
hlast->GetXaxis()->SetRange(hnn->FindFirstBinAbove(0),hnn->FindLastBinAbove(0));
hlast->SetFillColor(0);
hlast->SetLineColor(0);
hlast->Draw();
hs->GetXaxis()->SetTitle("");
hs->Draw(“same”);
[/code]
so practically, I am trying to plot the “SUM” of the THStack with “white” color, so to properly set the axis range, and then plot the THStack as well, but this fails giving the attached plot where the THStack is not properly shown… Any advice ?
Also, how could I force the top plot to have aligned margins with the bottom (ratio plot) one ?
So, drawing directly the THStack, results in a plot where the axis range are the “full” and not set according to hsum->FindFirstBinAbove(0),hsum->FindLastBinAbove(0) - What I do now, sets correctly the axis range but without plotting correctly the THStack on top - For simplicity, I dont put the code for the ratio, but this is trivial and anyway works as expected - is the top plot that I cannot get it to be displayed properly.
root [0]
Processing Overlap.C...
Data .root
Error in <TFile::TFile>: file Data.root does not exist
Error in <TList::AddLast>: argument is a null pointer
Rare .root
Error in <TFile::TFile>: file Rare.root does not exist
Error in <TList::AddLast>: argument is a null pointer
SingleTop .root
Error in <TFile::TFile>: file SingleTop.root does not exist
Error in <TList::AddLast>: argument is a null pointer
WJets .root
Error in <TFile::TFile>: file WJets.root does not exist
Error in <TList::AddLast>: argument is a null pointer
TT .root
Error in <TFile::TFile>: file TT.root does not exist
Error in <TList::AddLast>: argument is a null pointer
========================================================
Target path: mergedDataplots.root:/
Error: illegal pointer to class object first_source 0x0 6 Overlap.C:82:
*** Interpreter error recovered ***
root [1]
Ok … here is the simplified version I made from your example. Seems to me it is fine. Can you tell me me what you think is wrong there ? Overlap.C (7.65 KB)
Indeed, this did the trick - But now a new problem appears - Look at the attached plot - The ticks in the axis have been stripped, looks like the THStack are drawn on top of the Canvas or something like this - Maybe this is a ROOT bug or something?