//some standard C++ includes #include #include #include #include #include #include #include #include #include #include //some ROOT includes #include "TInterpreter.h" #include "TROOT.h" #include "TH1F.h" #include "TH2D.h" #include "TFile.h" #include "TMath.h" #include "TTree.h" #include "TBranch.h" #include "TVector3.h" //"art" includes (canvas, and gallery) #include "canvas/Utilities/InputTag.h" #include "gallery/Event.h" #include "gallery/ValidHandle.h" #include "canvas/Persistency/Common/FindMany.h" #include "canvas/Persistency/Common/FindOne.h" #include "gallery/Handle.h" //"larsoft" object includes #include "lardataobj/RecoBase/OpFlash.h" #include "lardataobj/RecoBase/OpHit.h" #include "lardataobj/RawData/RawDigit.h" #include "lardataobj/RecoBase/Hit.h" #include "lardataobj/RecoBase/Track.h" #include "lardataobj/RecoBase/SpacePoint.h" #include "lardataobj/AnalysisBase/T0.h" #include "lardataobj/MCBase/MCTrack.h" #include "lardataobj/MCBase/MCStep.h" //(timing information for the beam) #include "lardataobj/RawData/TriggerData.h" #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" //"larreco" reconstruction for MCS. #include "larreco/RecoAlg/TrajectoryMCSFitter.h" using namespace art; using namespace std; using namespace std::chrono; void readTTree() { gStyle->SetOptStat(0); // read the Tree generated by tree2w and fill one histogram // we are only interested by the destep branch // note that we use "new" to create the TFile and TTree objects because we // want to keep these objects alive when we leave this function TFile *f1 = new TFile("/pnfs/uboone/scratch/users/abhat/gallery_output.root"); TFile *f2 = new TFile("/pnfs/uboone/scratch/users/abhat/nospacecharge_gallery_output.root"); TTree *t1 = (TTree*)f1->Get("SCEtree"); TTree *t2 = (TTree*)f2->Get("SCEtree"); static Float_t track_startX1; static Float_t track_startY1; static Float_t track_startX2; static Float_t track_startY2; TBranch *b_track_startX1 = t1->GetBranch("track_startX"); TBranch *b_track_startY1 = t1->GetBranch("track_startY"); TBranch *b_track_startX2 = t2->GetBranch("track_startX"); TBranch *b_track_startY2 = t2->GetBranch("track_startY"); b_track_startX1->SetAddress(&track_startX1); b_track_startY1->SetAddress(&track_startY1); b_track_startX2->SetAddress(&track_startX2); b_track_startY2->SetAddress(&track_startY2); //create one histogram TH2D* h_track_start1 = new TH2D("h_track_start1","Starting Point of Tracks;X-Coordinate (cm);Y-Coordinate (cm)",100,-10,270,100,-130,130); h_track_start1->SetMarkerStyle(20); h_track_start1->SetMarkerColor(2); TH2D* h_track_start2 = new TH2D("h_track_start2","Starting Point of Tracks;X-Coordinate (cm);Y-Coordinate (cm)",100,-10,270,100,-130,130); h_track_start2->SetMarkerStyle(20); h_track_start2->SetMarkerColor(4); //read only the destep branch for all entries Int_t nentries = (Int_t)t1->GetEntries(); for (Int_t i=0;iGetEntry(i); b_track_startY1->GetEntry(i); // fill the histogram with the destep entry h_track_start1->Fill(track_startX1,track_startY1); } Int_t mentries = (Int_t)t2->GetEntries(); for (Int_t i=0;iGetEntry(i); b_track_startY2->GetEntry(i); // fill the histogram with the destep entry h_track_start2->Fill(track_startX2,track_startY2); } // we do not close the file; we want to keep the generated histograms; // we fill a 3-d scatter plot with the particle step coordinates TCanvas* canvas = new TCanvas("canvas","Hit Info!",1500,500); h_track_start1->Draw("P"); h_track_start2->Draw("P SAME"); TLine *l1 = new TLine(-10,-116.5,270,-116.5); TLine *l2 = new TLine(-10,116.5,270,116.5); l1->Draw(); l2->Draw("SAME"); auto legend = new TLegend(0.1,0.7,0.48,0.9); legend->AddEntry(h_track_start1,"CV","p"); legend->AddEntry(h_track_start2,"nospacecharge","p"); legend->Draw(); }