Hey All,
I am trying to plot the ratio of two normalized histograms using the following piece of code:
#include "TFile.h"
#include "TTree.h"
void histogram_qinv()
{
//gStyle->SetOptStat(0);
TFile *f1 = TFile::Open("toymodel_fluctuation_mixed.root");
TH1D *h1A = (TH1D*)gDirectory->Get("qinv_mixed");
TH1D *h2A = (TH1D*)gDirectory->Get("Del_pT_mixed");
TFile *f2 = TFile::Open("toymodel_fluctuation.root");
TH1D *h1B = (TH1D*)gDirectory->Get("qinv_data");
TH1D *h2B = (TH1D*)gDirectory->Get("Del_pT_data");
TH1F *ratio_qinv = (TH1F*)h1B->Clone("ratio_qinv");
TH1F *ratio_Del_pT = (TH1F*)h2B->Clone("ratio_Del_pT");
ratio_qinv->Divide(h1A);
ratio_Del_pT->Divide(h2A);
TFile *f = new TFile("toymodel_qinv.root","RECREATE"); //create a root file
h1A->Write();
h1B->Write();
h2A->Write();
h2B->Write();
ratio_qinv->Write();
ratio_qinv->Draw("HIST");
ratio_Del_pT->Write();
f->Write(); //write histogram in root file
f->Close();
}
It creates a ratio plot but the
number of entries in each plot is not the same as well as there is something wrong when there are few points which zero for each plot and that gives an undefined point in ratio plot. Suggest me if you find something wrong or some smart way to draw ratio plot of two histograms.Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided