Ignore:
Timestamp:
Jun 18, 2010, 11:42:07 AM (14 years ago)
Author:
garnier
Message:

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/hadronic/models/cascade/cascade/include/G4CascadeMomentum.hh

    r1228 r1315  
    2424// ********************************************************************
    2525//
    26 // $Id: G4CascadeMomentum.hh,v 1.1 2008/09/22 10:06:32 gcosmo Exp $
    27 // GEANT4 tag $Name: geant4-09-03 $
    28 //
     26// $Id: G4CascadeMomentum.hh,v 1.5 2010/03/16 22:10:26 mkelsey Exp $
     27// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
    2928//
    3029// Class G4CascadeMomentum
     
    3534// std::vector<double> in the cascade mode code, which causes
    3635// problems for performance due to excess memory allocations.
    37 
     36//
     37// NOTE:  The Bertini code does not pass legitimate four-vectors when
     38//        creating new particles; the new getLV() function takes an
     39//        optional mass argument (in Bertini units [GeV]) so that a
     40//        valid G4LorentzVector can be returned.
     41//
    3842// Author: Peter Elmer, Princeton University                  7-Aug-2008
     43// Update: Michael Kelsey, SLAC (support G4LorentzVector)     8-Jan-2010
    3944// --------------------------------------------------------------------
    4045#ifndef G4CASCADE_MOMENTUM_HH
     
    4449
    4550#include "G4Types.hh"
     51#include "G4LorentzVector.hh"
     52#include "G4ThreeVector.hh"
    4653
    4754class G4CascadeMomentum
    4855{
    4956  public:
    50 
    5157    G4CascadeMomentum() {for (int i=0; i<4; ++i) data_[i]=0.0;}
    5258
    53     G4double& operator[](int i)
    54     {
     59    // WARNING!  This metric is (t,x,y,z), DIFFERENT FROM HepLV!
     60    G4CascadeMomentum(const G4LorentzVector& lv) {
     61      setLV(lv);
     62    }
     63
     64    G4double& operator[](int i) {
    5565      assert(i>=0 && i<4);
    5666      return data_[i];
    5767    }
    58     const G4double& operator[](int i) const
    59     {
     68    const G4double& operator[](int i) const {
    6069      assert(i>=0 && i<4);
    6170      return data_[i];
    6271    }
    6372
     73    operator const G4LorentzVector&() const {
     74      return getLV();                   // Casting can't do mass repairs
     75    }
     76
     77    const G4LorentzVector& getLV(G4double mass=-1.) const {
     78      if (mass>=0.) lv.setVectM(get3V(),mass);          // Force input mass!
     79      else lv.set(data_[1],data_[2],data_[3],data_[0]);
     80     
     81      return lv;
     82    }
     83
     84    G4ThreeVector get3V() const {
     85      return getLV().vect();
     86    }
     87
     88    void setLV(const G4LorentzVector& lv) {
     89      data_[0] = lv.t();                // NOTE DIFFERENT METRIC CONVENTION!
     90      data_[1] = lv.x();
     91      data_[2] = lv.y();
     92      data_[3] = lv.z();
     93    }
     94
     95    G4CascadeMomentum& operator=(const G4LorentzVector& lv) {
     96      setLV(lv);
     97      return *this;
     98    }
     99
    64100  private:
     101    G4double data_[4];
     102    mutable G4LorentzVector lv;         // Buffer for conversion operations
     103};
    65104
    66     G4double data_[4];
    67 };
    68105#endif
    69106
Note: See TracChangeset for help on using the changeset viewer.