Dear Roooters,
I have a quick question whether or not this piece of code is “correct” (or will do what I intend it to):
for(Int_t i=1; i < DecayTree->GetEntries(); i++)
{
RealDataHist->Fill((data2.get(i))->getRealValue("nSPDHits"),sData->GetSWeight(i,"nsig"));
}
data2 is RooDataSet created from the DecayTree TTree, sData is from RooStats::SPlot and RealDataHist is a normal TH1F* histogram. Because the histogram is specifically binned, I cant just create one the normal way from RooDataSet.
Will the iteration through the dataset work like this? Are they numbered from 0?
Sometimes the code returns the error message :
Error in : Trying to dereference null pointer or trying to call routine taking non-null arguments.
( for (data2.get(i)) )
and sometimes it just crashes. Any ideas?
EDIT:: I just checked and for a tree with 10.5k events the
(data2.get(i))->getRealValue("nSPDHits")
returns sensible values until around 8.5k event and then displays the error mentioned above.
Cheers,
Maks