#define ReadNtupleExample_cxx #include "ReadNtupleExample.h" #include "Riostream.h" #include "TTimer.h" #include "TROOT.h" #include "TStyle.h" #include "TFile.h" #include "TH1F.h" #include "TH2F.h" #include "TNtuple.h" #include "TCanvas.h" #include "TPad.h" #include "TF1.h" #include "TProfile.h" #include "TLegend.h" #include "TH3F.h" void ReadNtupleExample::Loop() { // In a ROOT session, you can do: // Root > .L ReadNtupleExample.C // Root > ReadNtupleExample t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); TCanvas * c1 = new TCanvas("c1","The Ntuple canvas",750,800); c1->Divide(2,3); TH1F *hadc1 = new TH1F("hadc1","hadc1",100,0,70000); TH1F *hadc2 = new TH1F("hadc2","hadc2",100,0,70000); TH2F *h1vs2 = new TH2F("h1vs2","h1vs2",100,0.,70000.,100,0.,70000.); TH3F *h1vs2vstdc1 = new TH3F("h1vs2vstdc1","h1vs2vstdc1",100,0.,70000.,100,0.,70000.,100,0,1200); TH1F *hadc2Cond = new TH1F("hadc2Cond","hadc2Cond",100,0,70000); TProfile * hprof = new TProfile("hprof","Profile adcA vs adcB",100,0,70000,0,70000); Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentryGetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; hadc1->Fill(a); hadc2->Fill(b); h1vs2->Fill(a,b); hprof->Fill(a,b); h1vs2vstdc1->Fill(a,b,tdca); if(a<30000) hadc2Cond->Fill(b); } c1->cd(1); hadc1->DrawCopy(); c1->cd(2); hadc2->DrawCopy(); c1->cd(3); h1vs2->DrawCopy(); c1->cd(4); hprof->DrawCopy(); c1->cd(5); h1vs2vstdc1->DrawCopy(); c1->cd(6); hadc2Cond->DrawCopy(); }