Hi Rooters
I am trying to show two histograms on one canvas on top of each other for comparison reasons. Here is the code:
#include "Riostream.h"
#include "TString.h"
#include "TMath.h"
void COMPARISON_SCRIPT()
{
TFile *READ_File1 = new TFile("/Users/aibutt/BLACKHOLE_ANALYSIS/DATA2011/non-commutative/D1_STEPPED_ANALYSIS_2011.root", "READ");
READ_File1 -> cd();
TH1F *RD1 = (TH1F*)gDirectory -> Get("SumPT_CR_800_1200_EF_j240_a4tc_EFFS");
TH1F *RD2 = (TH1F*)gDirectory -> Get("SumPT_SR_1200PLUS_EF_j240_a4tc_EFFS");
gStyle -> SetOptStat(0000000);
TCanvas *canvas_1 = new TCanvas("canvas_1", "canvas_1", 0,0,700,500);
canvas_1 -> cd();
RD1 -> SetTitle("COMPARISON SumPt CR and SR");
RD1 -> GetXaxis()->SetTitle("SumPt (GeV)");
RD1 -> SetLineColor(4);
RD1 -> SetLineWidth(2);
RD1 -> Draw("");
RD2 -> SetLineColor(2);
RD2 -> SetLineWidth(1);
RD2 -> Draw("same");
TLegend* legend = new TLegend(0.62,0.8,0.894,0.9);
legend->AddEntry( RD1, "SumPT_CR_800_1200_EF_j240_a4tc_EFFS", "l");
legend->AddEntry( RD2, "SumPT_SR_1200PLUS_EF_j240_a4tc_EFFS", "l");
legend->SetFillColor(0);
legend->SetBorderSize(1);
legend->Draw("");
canvas_1 -> Update();
canvas_1 ->SaveAs("/Users/aibutt/BLACKHOLE_ANALYSIS/DATA2011/non-commutative/SumPT_1_j240.gif");
}
But I am getting following error which I am not able to resolve:
root [0] .x COMPARISON_SCRIPT.C
Error: illegal pointer to class object RD2 0x0 147 COMPARISON_SCRIPT.C:24:
*** Interpreter error recovered ***
root [1]
And it plots only the first histogram that I am declaring in my code as RD1.
Cheers
Aatif