Changeset 1315 for trunk/source/processes/hadronic/models/cascade/cascade/include/G4CascadeMomentum.hh
- Timestamp:
- Jun 18, 2010, 11:42:07 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/hadronic/models/cascade/cascade/include/G4CascadeMomentum.hh
r1228 r1315 24 24 // ******************************************************************** 25 25 // 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 $ 29 28 // 30 29 // Class G4CascadeMomentum … … 35 34 // std::vector<double> in the cascade mode code, which causes 36 35 // 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 // 38 42 // Author: Peter Elmer, Princeton University 7-Aug-2008 43 // Update: Michael Kelsey, SLAC (support G4LorentzVector) 8-Jan-2010 39 44 // -------------------------------------------------------------------- 40 45 #ifndef G4CASCADE_MOMENTUM_HH … … 44 49 45 50 #include "G4Types.hh" 51 #include "G4LorentzVector.hh" 52 #include "G4ThreeVector.hh" 46 53 47 54 class G4CascadeMomentum 48 55 { 49 56 public: 50 51 57 G4CascadeMomentum() {for (int i=0; i<4; ++i) data_[i]=0.0;} 52 58 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) { 55 65 assert(i>=0 && i<4); 56 66 return data_[i]; 57 67 } 58 const G4double& operator[](int i) const 59 { 68 const G4double& operator[](int i) const { 60 69 assert(i>=0 && i<4); 61 70 return data_[i]; 62 71 } 63 72 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 64 100 private: 101 G4double data_[4]; 102 mutable G4LorentzVector lv; // Buffer for conversion operations 103 }; 65 104 66 G4double data_[4];67 };68 105 #endif 69 106
Note: See TracChangeset
for help on using the changeset viewer.