AnalysisTree.cpp
Go to the documentation of this file.
1 #define AnalysisTree_cxx
2 #include "AnalysisTree.h"
3 #include <TH2.h>
4 #include <TStyle.h>
5 #include <TCanvas.h>
6 
8 {
9 // In a ROOT session, you can do:
10 // root> .L AnalysisTree.C
11 // root> AnalysisTree t
12 // root> t.GetEntry(12); // Fill t data members with entry number 12
13 // root> t.Show(); // Show values of entry 12
14 // root> t.Show(16); // Read and show values of entry 16
15 // root> t.Loop(); // Loop on all entries
16 //
17 
18 // This is the loop skeleton where:
19 // jentry is the global entry number in the chain
20 // ientry is the entry number in the current Tree
21 // Note that the argument to GetEntry must be:
22 // jentry for TChain::GetEntry
23 // ientry for TTree::GetEntry and TBranch::GetEntry
24 //
25 // To read only selected branches, Insert statements like:
26 // METHOD1:
27 // fChain->SetBranchStatus("*",0); // disable all branches
28 // fChain->SetBranchStatus("branchname",1); // activate branchname
29 // METHOD2: replace line
30 // fChain->GetEntry(jentry); //read all branches
31 //by b_branchname->GetEntry(ientry); //read only this branch
32  if (fChain == 0) return;
33 
34  Long64_t nentries = fChain->GetEntriesFast();
35 
36  Long64_t nbytes = 0, nb = 0;
37  for (Long64_t jentry=0; jentry<nentries;jentry++) {
38  Long64_t ientry = LoadTree(jentry);
39  if (ientry < 0) break;
40  nb = fChain->GetEntry(jentry); nbytes += nb;
41  // if (Cut(ientry) < 0) continue;
42  }
43 }
TTree * fChain
Definition: AnalysisTree.h:21
static constexpr double nb
Definition: Units.h:81
virtual void Loop()
Definition: AnalysisTree.cpp:7
virtual Long64_t LoadTree(Long64_t entry)