Message: Re: G4LorentzVector set(G4LorentzVector) bug Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Warning Re: G4LorentzVector set(G4LorentzVector) bug 

Forum: User Requirements
Re: Question G4LorentzVector set(G4LorentzVector) bug (Simon Albright)
Date: 07 Sep, 2014
From: Andrea Dotti <Andrea Dotti>

Hello,

G4LorentzVector (typedef to CLHEP::HepLorentzVector) does not have a ::set( G4LorentzVector& ) method.

Note that instead it has a set( const Hep3Vector& ) method, but, in such a case it only sets the spatial components! Note the Hep3Vector class name. Since the G4LorentzVector has conversion operators to the spatial components Hep3Vector, I think that the behavior you observe is the technically correct one (even if unexpected):

In this code:

{
   G4LorentzVector vect1, vect2;
   // manipulate vect1 and vect2
   vect1->setVect( vect2 );
}

the last line is equivalent to:

{
   Hep3Vector tempSpatialOnly = vect2.vect();
   vect1->setVect(  tempSpatialOnly ); //t component is lost! 
  assert(vect1.e() == 0 ); //!Correct
}

What you want to do is:

{
  vect1 = vect2;    //(e.g. use assignment operator)
}

or:

{
  vect1->setX( vect2.x() );
  vect2->setY( vect2.y() );
  ...
}

or:

{
   vect1->set( vect2 , vect2.e() ); //This is probably confusing since it has the conversion hiddent
}

Documentation is here: http://www-geant4.kek.jp/Reference/10.00.p02/classCLHEP_1_1HepLorentzVector.html

Andrea

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Ok: Re: G4LorentzVector set(G4LorentzVector) bug   (Simon Albright - 07 Sep, 2014)
 Add Message Add Message
to: "Re: G4LorentzVector set(G4LorentzVector) bug"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]