Thanks a lot Klaus,
Looping over Nbins+2 in the histogram created using "->Project();" helps me getting the same number of events than using ->GetEntries();
However I still need to understand why I don't get the same number of entries looping over the tree or doing a Project.
I checked out the values that were being filled in the tree like that:
if (kk % 10000 == 0 && kk != 0)
cout<<"*** FILLING *** "<< kk << " : "<< cosThetaP << "\t"<< Pz << " / " <<(sqrt(pow(Px, 2)+pow(Py,2)+pow(Pz,2)))<< endl;
(cosThetaP, Pz, Px and Py are defined from the branch addressed variables, and cosThetaP is the variable I want at the end fill in the Histogram)
and I saw that costThetaP, as well as Pz and sqrt(...) were showing sometimes "-nan" value.
So I added a variable that counted how many times I was getting nan:
//cout << "cosThe is nan"<<endl;
However, the number of entries still don't match.
In addition I have also got the number of entries from the histogram filled looping over the Tree, summing up over Nbins, summing up over Nbins+2 and using GetEntries(), and the results are very strange.
For different files I get:
File Reco->GetEntries() Sum=Sum+Reco->GetBinContent(i) Sum=Sum+Reco->GetBinContent(i) Nr. -nan events
from bin=1 to bin=Nbins from bin=0 to bin=Nbins+1 value of fail
1 493075 564152 487270 21476
2 379395 510432 465690 14101
3 646731 373536 0 11467
4 505865 380024 0 22111
Before filling the histogram looping over the tree I've initialized them using
for (int b=0; b<Nbins+2; b++)
Can the over/underflow bins have negative values??? even after initializing them to 0 values???