[ROOT] TClonesArrays in TTrees

From: Dave Ireland (d.ireland@physics.gla.ac.uk)
Date: Fri Nov 24 2000 - 13:49:20 MET


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