Y axis range problem in THStack


In my macro for stacking histograms, I can change the range of x-axis as I want to, but cannot do the same for Y axis. The upper limit of the histogram is around 6, but the peak of the distribution is slightly over 10. I tried every option for Yaxis range mentioned in this forum but nothing changes.

The simplified macro, input and output root files are attached. Could you help me on this issue?

Source-files.zip (59.8 KB)
stack_50PU_MET2.root (16.9 KB)
50PU_stack.C (2.66 KB)

root [0] .x 50PU_stack.C
Error: Symbol sgnl5top is not defined in current scope  50PU_stack.C:29:
Error: Failed to evaluate sgnl5top->Get("hMET2")
Error: Illegal Assignment to an undeclared symbol MET2_50PU_TDR5 50PU_stack.C:29:
*** Interpreter error recovered ***
root [1] 


“MET2_50PU_TDR5= (TH1F*) sgnl5top->Get(“hMET2”);”

line supposed be deleted. New macro is attached.

50PU_stack.C (2.6 KB)

root [0] .x 50PU_stack.C
SysError in <TFile::TFile>: file stacked_plots/stack_MET2_50PU.root can not be opened (No such file or directory)
Warning in <TFile::Write>: file stacked_plots/stack_MET2_50PU.root not opened in write mode
root [1] 

I think you should create a folder with name “stacked_plots”. There is no input file in my “stacked_plots” folder.


50PU_stack.C (2.39 KB)

Thanks Wile. I was away 5 minutes and you replied meanwhile. :slight_smile:

Thank you very much.

The lines below gave me what I what.

[code] hs16->GetXaxis()->SetRangeUser(500, 2000);
if (hs16->GetMinimum() > MET2_50PU_TDR4->GetMinimum())

if (hs16->GetMaximum() < MET2_50PU_TDR4->GetMaximum())
hs16->SetMaximum(MET2_50PU_TDR4->GetMaximum()); [/code]

However, you changed the order of previous lines. Why did you need to change them? Could you enlighten me a little?