#include #include #include #include #include #include #include void FConvo() { // Open the ROOT files containing the ntuples TFile *file1 = new TFile("All.root"); TFile *file2 = new TFile("Am.root"); // Declare histograms Int_t binN = 500; auto NearDet_edep1 = new TH2D("NearDet_edep1", ";Event Number;Energy (MeV)", binN, 0, 100, binN, 0, 600.0); auto NearDet_edep2 = new TH2D("NearDet_edep2", ";Event Number;Energy (MeV)", binN, 0, 100, binN, 0, 600.0); // Access the ntuples from each file TTree *tree1 = dynamic_cast(file1->Get("Hits")); TTree *tree2 = dynamic_cast(file2->Get("Hits")); // Declare variables to hold the data Int_t fEvent; // Set branch addresses to variables if tree1 is not null if (tree1 != nullptr) { tree1->SetBranchAddress("fEvent", &fEvent); } // Set branch addresses to variables if tree2 is not null if (tree2 != nullptr) { tree2->SetBranchAddress("fEvent", &fEvent); } TCanvas *c1 = new TCanvas("c1", "", 1800, 1400); c1->cd(); NearDet_edep1->SetLineColor(kRed); // Set color to red NearDet_edep1->SetLineWidth(4); // Set line width to 2 NearDet_edep1->Draw(); NearDet_edep1->SetStats(0); NearDet_edep2->SetLineColor(kBlue); // Set color to blue NearDet_edep2->SetLineWidth(4); // Set line width to 2 NearDet_edep2->Draw("SAME"); NearDet_edep2->SetStats(0); TLegend *leg = new TLegend(0.55, 0.7, 0.85, 0.85); leg->AddEntry(NearDet_edep1, "All", "L"); leg->AddEntry(NearDet_edep2, "Am", "L"); leg->Draw(); }