Crash when GetEntry with TBufferFile

Hello

I am trying to read a TTree and when

eventTree->GetEntry(jentry)

inside the loop, then I get this

Error in TBufferFile::CheckByteCount: object of class TRootJet read too many bytes: 55 instead of 36
Warning in TBufferFile::CheckByteCount: TRootJet::Streamer() not in sync with data on file TopTreeCMS.root, fix Streamer()
Error in TBufferFile::CheckByteCount: object of class TRootJet read too many bytes: 53 instead of 36
Warning in TBufferFile::CheckByteCount: TRootJet::Streamer() not in sync with data on file TopTreeCMS.root, fix Streamer()
Error in TBufferFile::CheckByteCount: object of class TRootJet read too many bytes: 53 instead of 36
Warning in TBufferFile::CheckByteCount: TRootJet::Streamer() not in sync with data on file TopTreeCMS.root, fix Streamer()
Error in TBufferFile::CheckByteCount: object of class TRootJet read too many bytes: 55 instead of 36
Warning in TBufferFile::CheckByteCount: TRootJet::Streamer() not in sync with data on file TopTreeCMS.root, fix Streamer()
Error in TBufferFile::CheckByteCount: object of class TRootJet read too many bytes: 55 instead of 36
Warning in TBufferFile::CheckByteCount: TRootJet::Streamer() not in sync with data on file TopTreeCMS.root, fix Streamer()
Error in TBufferFile::CheckByteCount: object of class TRootMuon read too many bytes: 71 instead of 36
Warning in TBufferFile::CheckByteCount: TRootMuon::Streamer() not in sync with data on file TopTreeCMS.root, fix Streamer()

Any ideas?

Thanks for your time

Alexis

Hi,

can you post the full output and the ROOT file you are trying to read? Please attach them or upload them to afs or a web server.

Cheers, Axel.

Hello again!
After some deeper investigation (line-by-line debugging) the problems seems to be in the following lines in my code, which open a root and assigns addresses to TClonesArray objects(i am saving you from .root files and all coding, just the important lines;-)))

br = (TBranch*)->fChain->GetBranch(“MCparticles”);
tc = new TClonesArray(“TRootMCParticle”,0);
br->SetAddress(&tc)

and more specific, if you comment the 3rd line, it does not crash, which means, cannot assign address property to a TClonesArray…

So, any more tips would be really helpful

Thanks in advance

Alexis

Post the shortest possible script and data file reproducing the problem.

Rene

Hi!

I am attaching the .cpp and h files… I was searching in other answers, and found a similar problem root.cern.ch/phpBB2/viewtopic.ph … setaddress …So, if I SetStatus("*",0) and then try to read the number of entries, it always return 0 (normal, but it does not crash). Now, if I try to SetStatus (1) to this branch just before I read its entries, it crashes…

You can find the root file (just 2 events, because is to big) in the /tmp/alkaloge in the lxplus225 machine

Thanks again!

PS- I am using some namespace TopTree which actually just defines the TRoot objects collection
toptree.cpp (3.52 KB)
toptree.h (55.9 KB)

Hi,

The result of MakeClass (which you used) contains a (necessary for this skeleton) call to SetMakeClass(1). The purpose of SetMakeClass is to tell the TTree than its content will not be access via object but rather via the individual numerical data members. When set SetMakeClass is turned on, attempting to use object (as you do via the br->SetAddress(&tc) ) will result in incorrect result at best (and often crashes).

Cheers,
Philippe.

Also never access the Branch of a chain directly, (because the Branch are object within the TTree within the TChain and thus any information you set there will be ‘forgotten’ when the chain opens the next file). Instead use:TBranch *br; fChain->SetBranchAddress(branchname,&datapointer,&br);

Ok, thank you very much for your time!