//////////////////////////////////////////////////////////////////// /// \file ntuple.c /// /// \brief Extracts standard information from ntuple files. /// /// \author P G Jones /// /// REVISION HISTORY:\n /// 2014-05-29 : P G Jones - Added header information.\n // 2018-02-10 : R Lane - change to function arguments necessary for ROOT 6 compatibility /// /// \details /// //////////////////////////////////////////////////////////////////// #include #include #include void ntuple(std::string event_file, std::string outfile) { TFile *event_tfile = new TFile(event_file.c_str()); TTree *event_ttree = (TTree*)event_tfile->Get("output"); TFile *outtfile = new TFile(outfile.c_str(), "RECREATE"); TH1F* hKE = new TH1F("hKE", "Particle Kinetic Energy", 8, 0.0, 8.0); hKE->SetYTitle("Events per 1MeV bin"); hKE->SetXTitle("Particle Kinetic Energy [MeV]"); TH1F* hNhits = new TH1F("hNhits", "Nhits", 2, 0.0, 100.0); hNhits->SetYTitle("Events per 50 nhit bin"); hNhits->SetXTitle("Nhits"); TH1F* hEnergy = new TH1F("hEnergy", "Reconstructed Energy", 8, 0.0, 8.0); hEnergy->SetYTitle("Events per 1MeV bin"); hEnergy->SetXTitle("Reconstructed Energy [MeV]"); event_ttree->Draw("mcke1>>hKE", "", "goff"); event_ttree->Draw("nhits>>hNhits", "", "goff"); event_ttree->Draw("energy>>hEnergy", "waterFit==1", "goff"); outtfile->cd(); hKE->Write(); hNhits->Write(); hEnergy->Write(); outtfile->Close(); event_tfile->Close(); delete event_tfile; delete outtfile; }