Hi Mario,
ROOT (Cint, to be exact) has a hard time interpreting a vector of an arbitrary class. You'll have to provide a dictionary for this combination. For how to do that, see e.g. the PS on "loader.C" in Philippe's answer at http://root.cern.ch/phpBB2/viewtopic.php?t=2294, i.e.
#include <vector> #ifdef __MAKECINT__ #pragma link C++ class vector<TLorentzVector>+; #endif
root [] .L loader.C+
Btw, I can reproduce your problem with the named lib, and I'll fix it today or tomorrow. I believe CompileMacro just doesn't care about the libname parameter you provide; it just builds the default one either way.
Cheers, Axel.
Mario Kadastik wrote:
> Ok, when I first thought that it might be me misusing clear, then
> pop_back() should work nicely when I have more than 1 elements. Well it
> doesn't:
>
> [oberon] /home/mario/pythia > root -l -b
>
> root [0] TLorentzVector p1 = TLorentzVector(1,2,3,4)
>
> root [1] TLorentzVector p2 = TLorentzVector(3,4,7,10)
>
> root [2] vector<TLorentzVector> tst;
>
> root [3] tst.push_back(p1)
>
> root [4] tst.push_back(p2)
>
> root [5] tst.size()
>
> (const unsigned int)2
>
> root [6] tst.pop_back()
>
>
> *** Break *** segmentation violation
>
>
> what's even worse is that with a tick older version of root (5.08/00)
> which I have on my iBook, the failure message is a bit better:
>
> root [0] TLorentzVector p1 = TLorentzVector(1,2,3,4)
>
> root [1] TLorentzVector p2 = TLorentzVector(2,3,4,9)
>
> root [2] vector<TLorentzVector> tst;
>
> root [3] tst.push_back(p1)
>
> root [4] tst.push_back(p2)
>
> root [5] tst.size()
>
> (const unsigned int)2
>
> root [6] tst.pop_back()
>
> root.exe(3013) malloc: *** Deallocation of a pointer not malloced:
> 0x3340728; This could be a double free(), or free() called with the
> middle of an allocated block; Try setting environment variable
> MallocHelp to see tools to help debug
>
>
> the one with just the segfault is ROOT version 5.11/06 on Linux x86.
>
>
> Mario
>
>
> On Jul 3, 2006, at 10:29 AM, Mario Kadastik wrote:
>
>
>> Hello, >> >> >> I couldn't quite figure out why my code is randomly crashing with >> segfaults until I started to test around segments of it and came to a >> bizarre conclusion, that vectors are behaving oddly: >> >> [oberon] /home/mario/pythia > root -l -b >> >> root [0] TLorentzVector p1 = TLorentzVector(1,2,3,4) >> >> root [1] p1.M() >> >> (const Double_t)1.41421356237309515e+00 >> >> root [2] vector<TLorentzVector> tst; >> >> root [3] tst.push_back(p1) >> >> root [4] tst.size() >> >> (const unsigned int)1 >> >> root [5] tst.clear() >> >> root [6] tst.size() >> >> (const unsigned int)0 >> >> root [7] tst.push_back(p1) >> >> root [8] tst.size() >> >> >> *** Break *** segmentation violation >> >> >> Or for example: >> >> [oberon] /home/mario/pythia > root -l -b >> >> root [0] TLorentzVector p1 = TLorentzVector(1,2,3,4) >> >> root [1] TLorentzVector p2 = TLorentzVector(3,4,7,10) >> >> root [2] vector<TLorentzVector> tst; >> >> root [3] tst.size() >> >> (const unsigned int)0 >> >> root [4] tst.push_back(p1) >> >> root [5] tst.push_back(p2) >> >> root [6] tst.clear() >> >> >> *** Break *** segmentation violation >> >> >> what am I doing wrong? This seems to be some basic misunderstanding on >> my part on vectors. Am I not supposed to clear them? And if I'm not, >> then why is the function there? Am I misusing it? What I'd like to do >> is to have two vectors of TLorentzVector type. One for positive >> particles, other for negative and then I could fill them at every >> event, iterate over them to generate plots and then at the end of the >> event clear them for the next event. How am I supposed to do that >> without using the clear function? >> >> >> -------------------------------- >> >> Mario Kadastik >> >> CMS experiment >> >> mario.kadastik_at_cern.ch <mailto:mario.kadastik_at_cern.ch> >> >> >> "Physics is like sex, sure it may give some practical results, but >> that's not why we do it" >> >> --- Richard P. Feynman >> >> >>
This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:59 MET