I added a std::vector<Float_t> to my tree.
When I try to read it back I get:
root [7] bxtree->GetEntry(10)
Error in <TBuffer::CheckByteCount>: object of class times read too few bytes:
2 instead of 10
(Int_t)78136
where “times” is name of my vector.
Now, since I have many parallel vectors of my user defined classes and I manage to read them very well (after loading a compiled library), I decided to add to my LinkDef.hh file the following line:
analogous to the one I use for vectors of my own classes.
rootcint moderately complains with:
and the problem in reading back persists.
In the user’s guide I couldn’ t find anything on stl containers, where should I look for help?
I take the chance to wish you all a Merry Christmas
bye
Davide
I attach a script version which illustrates the problem.
Actually, the problem, as usual, is only with nested vectors, where also vectors of user defined classes cannot be put (see my post “collections of collections”).
Here I don’t get the error message reported above as in the compiled case, but still the size of the innermost vector<Float_t> is 0.
Other similar vector<Float_t> placed outside the vector of user defined objects are fine. sample_writer_new.C (587 Bytes) sample_bx_classes_nohits.C (1.94 KB)
root [0] #include <vector>
root [1] .x sample_reader.C
Size of L: 3
Size of C: 3
Note that I had to make sure to load the vector library.
Which version of ROOT are you using? Were the cintdlls built (this is essential for the interpreter to work)? Which platform are you running on?
If you are already using a recent version of ROOT and the cintdlls have been built, please re-submit a full tar file to reproduce the problem including you resulting (faulty) root file.
I’m running on linux mandrake 9.1 with a 2.4.21 kernel
gcc is 3.2.2
Root was installed as binary as I did many times.
I don’t know what cintdlls, are but “dll” sounds like windows to me and anyhow I didn’t compile root by myself. If I’m wrong and I’m missing a step, please send me a link with doc.
You see here root version and output.
[code]ddangelo@isengard:~$ root
Warning in TEnvRec::ChangeValue: duplicate entry <Library.TArrowEditor=libGed.so libHist.so libGpad.so libGraf.so libGui.so libTree.so libTreePlayer.so> for level 0; ignored
*
W E L C O M E to R O O T *
*
Version 4.02/00 16 December 2004 *
*
You are welcome to visit our Web site *
http://root.cern.ch *
*
FreeType Engine v2.1.3 used to render TrueType fonts.
Compiled for linux with thread support.
CINT/ROOT C/C++ Interpreter version 5.15.159, Nov 14 2004
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] #include
root [1] .x sample_reader.C
Size of L: 3
Size of C: 0
root [2]
[/code]
I just noticed the initial warning now, but it doesn’t look related to the problem to me.
sorry for such a delayed answer but was on other things for a while.
I implemented your modifications, thank you.
The situation now is the following:
The BxLabenCluster vector can have size =0 or !=0 depending on event typology.
Now, when 1 or more cluster exist also the vector<Float_t> within them is handled correctly. When no clusters are present, the bxtree->GetEntry() produces the ususal error message:
where “times” is the name of the std::vector<Float_t>.
Of course a huge amount of such errors (1 per event) is produced by TTree::Draw() or by a TBrowser click, though in both cases plots are correct.
sorry for late answering.
I prepared simple files reproducing the issue.
You should run from CINT first the writer and then the reader.
The clusters vector is filled only in half of the cases and in those also the vector of float “times” within cluster object has the right size.
In the other cases TTree::GetEntry() produces the error message I mentioned before.