TClones, Objects, and Pointers

From: Jeff Templon (templon@studbolt.physast.uga.edu)
Date: Mon Feb 14 2000 - 21:21:19 MET


Hi,

Thanks for the answers to my last questions.  To answer some of the
questions I got about that mail, I want to generate some events
(distributed flat across experimental acceptances); first i generate
scattered electrons.  If the four-momentum transfer to the target
protons (it's e-p scattering) is large enough to have accomodated
J/psi production, I do so, letting the J/psi particles be produced
uniformly in the recoil rest frame; then I boot the residual proton
back to the lab and check to see if it's detected in a spectrometer.

particles I know I always have:

beam
scattered electron
target proton
recoiling hadronic system

particles I may have:

J/psi
recoiling proton
  o rest frame
  o lab frame

So I wanted to understand, if I threw all these particles into a
TClonesArray, if I would still know whic particle each was?  it sounds 
like "no".  picking a random object out of the array, I wouldn't know
whether it was the proton, or electron, or psi particle without first
performing some test on it.

Another question: I notice that almost all critters that get put into
the trees are declared as pointers, e.g.

  TLorentzVector *scat = new TLorentzVector(1,1,1,1);
  TLorentzVector *X = new TLorentzVector();
  TLorentzVector *prot = new TLorentzVector();

I did this to mimic what I had seen in the documentation.  The
question is, why do this?  Why not declare scat, X, and prot without
the star:

  TLorentzVector scat
  TLorentzVector X;
  TLorentzVector prot;

The latter certainly requires less typing.  Thus I infer there must be 
some important reason for the first form, or else most ROOT coders
wish to accelerate achievement of RSI ;-)

I have Lippman's C++ Primer tome, if anyone can point me to the
relevant page numbers containing the proper wisdom on this subject I
would be grateful.

					JT



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:18 MET