Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4InuclParticle.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: G4InuclParticle.cc 71719 2013-06-21 00:01:54Z mkelsey $
27 //
28 // 20100409 M. Kelsey -- Drop unused string argument from ctors.
29 // 20110721 M. Kelsey -- Add model ID as optional ctor argument (so subclasses
30 // don't have to call SetModel()).
31 // 20110922 M. Kelsey -- Add stream argument to printParticle() => print()
32 // 20130620 M. Kelsey -- Address Coverity #37504, check self in op=()
33 // 20130806 M. Kelsey -- Per A. Dotti, move empty G4DynPart to file scope to
34 // address thread-collision problem.
35 // 20140310 M. Kelsey -- Fix constness in G4PD* passing
36 
37 #include <cmath>
38 
39 #include "G4InuclParticle.hh"
40 #include "G4ios.hh"
41 #include "G4SystemOfUnits.hh"
42 
43 // Internal constructor only usable by subclasses
45  const G4LorentzVector& mom,
47  : modelId(model) {
48  setDefinition(pd);
49  setMomentum(mom);
50 }
51 
52 
53 // Assignment operator for use with std::sort()
55  if (this != &right) {
56  pDP = right.pDP;
57  modelId = right.modelId;
58  }
59 
60  return *this;
61 }
62 
63 
64 // Set particle definition allowing for null pointer to erase DynPart content
65 
66 namespace {
67  static const G4DynamicParticle empty; // To zero out everything
68 }
69 
71  if (pd) pDP.SetDefinition(pd);
72  else pDP = empty;
73 }
74 
75 
76 // WARNING! Bertini code doesn't do four-vectors; repair mass before use!
78  G4double mass = getMass();
79  if (std::fabs(mass-mom.m()) <= 1e-5)
80  pDP.Set4Momentum(mom*GeV/MeV); // From Bertini to G4 units
81  else
82  pDP.SetMomentum(mom.vect()*GeV/MeV); // Don't change current mass!
83 }
84 
85 
86 // Proper stream output (just calls print())
87 
88 std::ostream& operator<<(std::ostream& os, const G4InuclParticle& part) {
89  part.print(os);
90  return os;
91 }
92 
93 void G4InuclParticle::print(std::ostream& os) const {
95  os << " px " << mom.px() << " py " << mom.py() << " pz " << mom.pz()
96  << " pmod " << mom.rho() << " E " << mom.e()
97  << " creator model " << modelId;
98 }
99 
G4InuclParticle & operator=(const G4InuclParticle &right)
static constexpr double MeV
Definition: G4SIunits.hh:214
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
double py() const
G4DynamicParticle pDP
double px() const
void setDefinition(const G4ParticleDefinition *pd)
double G4double
Definition: G4Types.hh:76
TString part[npart]
Definition: Style.C:32
void Set4Momentum(const G4LorentzVector &momentum)
double rho() const
virtual void print(std::ostream &os) const
void setMomentum(const G4LorentzVector &mom)
double pz() const
G4LorentzVector getMomentum() const
void SetMomentum(const G4ThreeVector &momentum)
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
Hep3Vector vect() const
const XML_Char XML_Content * model
Definition: expat.h:151
static constexpr double GeV
Definition: G4SIunits.hh:217
G4double getMass() const