Hi Dave, As far as I can understand (I'm not an expert) when your clones array is created, You should not create the TLorentzVector with the 'new' operator like you did: > TLorentzVector *p = new TLorentzVector(1,2,3,4); because the memory is already allocated. You should create it directly in the array like that for (int i = 0; i<n ; i++) { new(*a[i]) TLorentzVector(1,2,3,4); } You can access your TLorentzVectors through the pointers a[i] insted of 'p' Well, it is explained in the page: http://root.cern.ch/root/html225/TClonesArray.html or in the Root User's Guide. Denis ------------------------------------------------------------------------ Istituto Nazionale di Fisica Nucleare | Office: A 39 Via Pietro Giuria, 1 | Phone: (+39)011-6707377/7359 I-10125 TORINO (Italy) | Fax: (+39)011-6699579 ------------------------------------------------------------------------ at Cern: office 160-R-030, phone (+41)22-7672917/72918 ------------------------------------------------------------------------ On Fri, 24 Nov 2000, Dave Ireland wrote: > Hi, > > This is basically a plea for advice from a novice, so I apologise in > advance if there is a simple answer. I have scoured the ROOT website and > others, so this is really a last resort! > > After successfully creating a tree of TLorentzVectors, I want to extend > this to create a simple tree of TClonesArrays of TLorentzVectors, so I > try to do this using the following code:- > > // create file and tree... > TFile *f = new TFile("zzz", "RECREATE"); > TTree *tree = new TTree("T", "Testing TClonesArrays"); > > // create pointer to TClonesArray > TClonesArray *a = new TClonesArray("TLorentzVector"); > > // define branch in tree by passing the address of the pointer to the > // TClonesArray... > tree->Branch("test branch", &a); > > // create TLorentzVectors by some means (eventually to be part of a > loop), e.g. > TLorentzVector *p = new TLorentzVector(1,2,3,4); > > //***** > //***** WHAT CODE SHOULD GO HERE TO INSERT THE TLorentzVector OBJECT > //***** INTO THE TClonesArray????? > //***** > //***** > > // fill tree... > tree->Fill(); > > // write tree to file... > f->Write(); > > I have tried a few things, none of which were successful. I would be > grateful for any suggestions. > > Cheers, > > Dave
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:37 MET