Re: [ROOT] TClonesArray of TLorentzVectors

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Aug 08 2001 - 17:37:32 MEST


Hi Andre,

The new operator expects an object, not a pointer. You can do, eg:

{
  gSystem->Load("libPhysics.so");
  TTree *t = new TTree("testtree","testtree"); 
  TClonesArray *ca = new TClonesArray("TLorentzVector",10);
  TClonesArray &clones = *ca;
  int i;
  for (i=0; i<10; ++i) 
    new (clones[i]) TLorentzVector(1,2,3,4);

  ca->ls();
  t->Branch("leptons",&ca,32000,99);  
}


Rene Brun

Andre Holzner wrote:
> 
> Hello,
> 
> after doing gSystem->Load("libPhysics.so") I do
> 
> {
>   t = new TTree("testtree","testtree");
>   ca = new TClonesArray("TLorentzVector",10);
>   int i;
>   for (i=0; i<10; ++i)
>     new (ca[i]) TLorentzVector;
> 
>    t->Branch("leptons",&ca);
> }
> 
> in CINT. I get a *** Break *** segmentation violation.
> 
> With TObject however, this seems to work. What am I doing wrong ?
> 
> I'm using root  3.01/06 3 August 2001 on Linux/i386.
> 
> best regards & thanks for the help,
> 
> André
> 
> --
> ------------------+----------------------------------
> Andre Holzner     | +41 22 76 76750
> Bureau 32 2-C13   | Building 32
> CERN              | Office 2-C13
> CH-1211 Geneve 23 | http://wwweth.cern.ch/~holzner/



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:56 MET