GSI Forum
GSI Helmholtzzentrum für Schwerionenforschung

Home » R3BRoot » General Discussions » Reading the TTree cbmsim with R3B member functions (Use of Bare Root member functions and R3Broot member functions do not give the same data)
icon5.gif  Reading the TTree cbmsim with R3B member functions [message #18516] Fri, 18 September 2015 10:28 Go to previous message
C. A. Douma is currently offline  C. A. Douma
Messages: 88
Registered: September 2015
Location: Groningen
continuous participant
From: *kvi-cart.rug.nl
Dear all,

I am a new R3Broot user. until now I have been reading the cbmsim tree in the following way:

TFile* f = new TFile("r3bsim.root","read");
TTree* t;
f->GetObject("cbmsim",t);
TLeaf* LandPoint_fLightYield = cbmsim->FindLeaf("LandPoint.fLightYield");
Long64_t nEvents = t->GetEntries();
Long64_t nBytes;
TH1D* h = new TH1D("h","h",100,0.0,1.0);
Int_t EventSize;
Double_t light;
for (Long64_t Entry = 0; Entry<nEvents; ++Entry)
{
nBytes = t->GetEntry(Entry);
EventSize = LandPoint_fLightYield->GetNdata();

for (Int_t k = 0; k<EventSize; ++k)
{
light = LandPoint_fLightYield->GetValue(k);
h->Fill("light"0;
}
}
h->Draw();

I would like to change this code into using the special R3B member functions:

TFile* f = new TFile("r3bsim.root","read");
TTree* t;
f->GetObject("cbmsim",t);
TClonesArray* LandPoints;
LandPoints = new TClonesArray("R3BLandPoint");
R3BLandPoint* Single_LandPoint;
Long64_t nEvents = t->GetEntries();
Long64_t nBytes;
TH1D* h_new = new TH1D("h_new","h_new",100,0.0,1.0);
Int_t EventSize;
Double_t light;
for (Long64_t Entry = 0; Entry<nEvents; ++Entry)
{
nBytes = t->GetEntry(Entry);
EventSize = LandPoints->GetEntries();

for (Int_t k = 0; k<EventSize; ++k)
{
Single_LandPoint = (R3BLandPoint*) LandPoints->At(k);
light = Single_LandPoint->GetLightYield();
h_new->Fill("light"0;
}
}
h_new->Draw();

But the two pieces of code do not give the same histogram. (I did play with the boundaries and bin-size of the histogram, this did not solve the problem).
The histogram h_new contains far less entries. Is there anyone who can help me?

Christiaan Douma.
PhD student at KVI-CART
University of Groningen, Netherlands
Supervisor: prof. dr. N. Kalantar
 
Read Message icon5.gif
Read Message
Read Message
Previous Topic: R3BRoot with ROOT6
Next Topic: new R3B setup components
Goto Forum:
  


Current Time: Sat Apr 20 00:54:39 CEST 2024

Total time taken to generate the page: 0.00656 seconds