//////////////////////////////////////////////////////////////////// /// \file inroot.cc /// /// \brief Extracts some standard data from a root file. /// /// \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 The standard data is used to check the inroot producer /// works. /// //////////////////////////////////////////////////////////////////// #include #include #include #include void inroot(std::string event_file, std::string outfile) { RAT::DU::DSReader* dsReader = new RAT::DU::DSReader(event_file); TFile *outtfile = new TFile(outfile.c_str(),"RECREATE"); TH1D* hMC = new TH1D( "hMC", "Number of mc hits per mc-event", 200, 0.0, 2000.0 ); hMC->SetXTitle( "Number of mc hits per mc-event." ); hMC->SetYTitle( "Count per 10 hit bin." ); TH1D* hUnCal = new TH1D( "hUnCal", "Number of UnCal hits per (triggered) ev-event", 200, 0.0, 2000.0 ); hUnCal->SetXTitle( "Number of mc hits per ev-event." ); hUnCal->SetYTitle( "Count per 10 hit bin." ); TH1D* hCal = new TH1D( "hCal", "Number of Cal hits per (triggered) ev-event", 200, 0.0, 2000.0 ); hCal->SetXTitle( "Number of mc hits per ev-event." ); hCal->SetYTitle( "Count per 10 hit bin." ); for( size_t iEntry = 0; iEntry < dsReader->GetEntryCount(); iEntry++ ) { const RAT::DS::Entry& rDS = dsReader->GetEntry( iEntry ); const RAT::DS::MC& rMC = rDS.GetMC(); hMC->Fill( rMC.GetMCPMTCount() ); for( size_t iEV = 0; iEV < rDS.GetEVCount(); iEV++ ) { const RAT::DS::EV& rEV = rDS.GetEV( iEV ); hUnCal->Fill( rEV.GetUncalPMTs().GetCount() ); hCal->Fill( rEV.GetCalPMTs().GetCount() ); } } outtfile->cd(); hMC->Write(); hUnCal->Write(); hCal->Write(); outtfile->Close(); delete outtfile; delete dsReader; }