Hey,
I am trying to open two root files, extract certain histograms from them, and then superimpose them. However, I seem to be only opening one of the files.
void Ratio_And_Overlaying_Plots() { //OPENING BRACE
//NUMBER OF ROOT FILES
const int numHistograms = 4;
//DECLARE POINTERS
TFile* s[numHistograms];
TCanvas *b[numHistograms];
std::vector<std::string> Histogram_Names_Mu0Mu0Y0 = {"mc20099", //variable 20 is lambda
"mc26099", //variable 26 is CosThetaCS
"mc27099", //Variable 27 is PhiCS
"mc28099" //Variable 28 is (q_T)^2
};
std::vector<std::string> Histogram_Names_Mu4Mu4Y5 = {"mc20099",
"mc26099",
"mc27099",
"mc28099"
};
std::vector<std::string> Root_File_Names = {"mc_Plots_Cos_CS_Theta_Mu0Mu0Y0.root",
"mc_Plots_Cos_CS_Theta_Mu4Mu4Y5.root"
};
for (Int_t i = 0; i <numHistograms; i++){
s[i] = TFile::Open(Root_File_Names[0].c_str(),Root_File_Names[1].c_str()); // Open root files
TH1D *h1;
s[i]->GetObject(Histogram_Names_Mu0Mu0Y0[i].c_str(), h1); //Get the ith histogram from the file
TH1D *h2;
s[i]->GetObject(Histogram_Names_Mu4Mu4Y5[i].c_str(), h2);
b[i] = new TCanvas(TString::Format("b%i", i), TString::Format("Plot Canvas %i", i), 700, 500); //Declaring TCanvas on which to superimpose the two histograms.
TH1D *h12 = new TH1D(*h1); //setting h12 to h1
h12->SetName(Form("h_%i",i));
h12->Draw();
h12->SetLineColor(kRed);
h2->Draw("same");
h2->SetLineColor(kBlue);
b[i]->Update();
} //closing i loop
} //CLOSING BRACE
Please provide the following information:
ROOT Version rootVer=6.10/04
Platform, compiler gcc gcc620_x86_64_slc6