Skip to content
Snippets Groups Projects
Commit ce78c3cf authored by Axel Naumann's avatar Axel Naumann
Browse files

Add Anders and his TTreeReader.

parent fa49954f
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ The following people have contributed to this new version:
Cristina Cristescu, CERN/SFT,\
Olivier Couet, CERN/SFT,\
Kyle Cranmer, NYU, RooStats,\
Anders Eie, NTNU,\
Gerri Ganis, CERN/SFT,\
Andrei Gheata, CERN/Alice,\
Wim Lavrijsen, LBNL, PyRoot,\
......
## Tree Libraries
### TTreeReader
ROOT offers a new class `TTreeReader` that gives simple, safe and fast access to the content of a `TTree`.
Using it is trivial:
```
#include "TFile.h"
#include "TH1F.h"
#include "TTreeReader.h"
#include "TTreeReaderValue.h"
void hsimpleReader() {
TH1F *myHist = new TH1F("h1","ntuple",100,-4,4);
TFile *myFile = TFile::Open("hsimple.root");
// Create a TTreeReader for the tree, for instance by passing the
// TTree's name and the TDirectory / TFile it is in.
TTreeReader myReader("ntuple", myFile);
// The branch "px" contains floats; access them as myPx.
TTreeReaderValue<Float_t> myPx(myReader, "px");
// The branch "py" contains floats, too; access those as myPy.
TTreeReaderValue<Float_t> myPy(myReader, "py");
// Loop over all entries of the TTree or TChain.
while (myReader.Next()) {
// Just access the data as if myPx and myPy were iterators (note the '*'
// in front of them):
myHist->Fill(*myPx + *myPy);
}
myHist->Draw();
}
```
TTreeReader checks whether the type that you expect can be extracted from the tree's branch and will clearly complain if not.
It reads on demand: only data that are actually needed are read, there is no need for `SetBranchStatus()`, `SetBranchAddress()`, `LoadTree()` or anything alike.
It uses the memory management of TTree, removing possible double deletions or memory leaks and relieveing you from the need to manage the memory yourself.
It turns on the tree cache, accelerating the reading of data.
It has been extensively tested on all known types of TTree branches and is thus a generic, fits-all access method for data stored in TTrees.
### TTreePlayer
- The TEntryList for ||-Coord plot was not defined correctly.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment