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 next 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
Re: Reading the TTree cbmsim with R3B member functions [message #18518 is a reply to message #18516] Fri, 18 September 2015 12:07 Go to previous messageGo to next message
Dmytro Kresan is currently offline  Dmytro Kresan
Messages: 166
Registered: June 2004
first-grade participant
From: *gsi.de
Dear Christiaan,

next week I will use the code you have posted here to test and debug the issue with TLeaf. Will let you know about the result.

Best regards,
Dima
Re: Reading the TTree cbmsim with R3B member functions [message #18522 is a reply to message #18516] Mon, 21 September 2015 10:46 Go to previous message
Dmytro Kresan is currently offline  Dmytro Kresan
Messages: 166
Registered: June 2004
first-grade participant
From: *gsi.de
Dear Christiaan,

I have tested your sample code with NeuLAND simulated data using both ROOT 5 and 6. I can not reproduce your problem. For both ways of accessing the data: either via TLeaf or TClonesArray the histograms match perfectly - plot is attached. Please revise your code: make an intermediate histogram filling, intermediate output of array sizes you use (event-by-event).

Best regards,
Dima
  • Attachment: c1.jpg
    (Size: 13.95KB, Downloaded 364 times)
Previous Topic: R3BRoot with ROOT6
Next Topic: new R3B setup components
Goto Forum:
  


Current Time: Tue Dec 10 00:26:28 CET 2024

Total time taken to generate the page: 0.00731 seconds