Hi,
I am making histograms and drawing multiple on a single canvas, some histograms however, have entries that far exceed the y axis on my plot, resulting in an ugly bin going out through the border.
Here is the code I am using to make the plots:
#include <iostream>
#include <sstream>
#include "TStyle.h"
#include "TTree.h"
#include "TH1F.h"
#include "TCanvas.h"
#include "TFile.h"
#include <fstream>
using namespace std;
void compare_hists(void) {
for(int mh=105;mh<=200;mh=mh+5)
{
stringstream oss;
oss<<mh;
string mhh = oss.str();
string file_in = "/prj_root/6001/higgs_write/savannas/zh_llbb_new/vjets_05_04_01/results/TMVA/examples_zh/TMVA_muon_mh=";
string file_out ="bdt_plots/";
file_in.append(mhh);
file_in.append("_");
file_in.append(mhh);
file_in.append(".root");
file_out.append(mhh);
file_out.append(".eps");
const char *file_i=(char*)file_in.c_str();
const char *file_o=(char*)file_out.c_str();
TFile *tf = new TFile(file_i);
TH1D* hist_2 = (TH1D*)tf->Get("Method_BDT/BDTG/MVA_BDTG_S");
TH1D* hist_4 = (TH1D*)tf->Get("Method_BDT/BDTG/MVA_BDTG_Train_S");
TH1D* hist_1 = (TH1D*)tf->Get("Method_BDT/BDTG/MVA_BDTG_B");
TH1D* hist_3 = (TH1D*)tf->Get("Method_BDT/BDTG/MVA_BDTG_Train_B");
//hist_2->SetAxisRange(0.0,0.25,"y");
TCanvas* can = new TCanvas("BDTG output","BDTG output");
hist_1->GetXaxis()->SetTitle("Background, Signal, Training, Testing");
hist_1->SetLineWidth(2);
hist_2->SetLineWidth(2);
hist_3->SetLineWidth(2);
hist_4->SetLineWidth(2);
hist_1->SetLineColor(1);
hist_2->SetLineColor(2);
hist_3->SetLineColor(6);//67
hist_4->SetLineColor(4);
hist_1->Scale(1.0/hist_1->Integral());
hist_2->Scale(1.0/hist_2->Integral());
hist_3->Scale(1.0/hist_3->Integral());
hist_4->Scale(1.0/hist_4->Integral());
hist_1->Draw("hist");
hist_4->Draw("samehist");
hist_2->Draw("samehist");
hist_3->Draw("samehist");
// TLegend *leg2 = new TLegend(0.15,0.8,0.4,0.9,NULL,"brNDC");
TLegend *leg2 = new TLegend(0.4,0.6,0.6,0.8,NULL,"brNDC");
if(hist_1->Integral()>0) leg2->AddEntry(hist_1,"testing_background");
if(hist_3->Integral()>0) leg2->AddEntry(hist_3,"training_background");
if(hist_2->Integral()>0) leg2->AddEntry(hist_2,"testing_signal");
if(hist_4->Integral()>0) leg2->AddEntry(hist_4,"training_signal");
leg2->Draw("same hist");
can->SaveAs(file_o);
}
}
Thank you in advance,
Charlie Mueller