Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4PrimaryParticle.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 //
27 // $Id: G4PrimaryParticle.cc 110257 2018-05-17 14:20:12Z gcosmo $
28 //
29 
30 #include "G4PrimaryParticle.hh"
31 #include "G4SystemOfUnits.hh"
32 #include "G4ParticleDefinition.hh"
33 #include "G4ParticleTable.hh"
34 #include "G4ios.hh"
36 
38 {
40  return _instance;
41 }
42 
44 :PDGcode(0),G4code(0),
45  direction(0.,0.,1.),kinE(0.),
46  nextParticle(0),daughterParticle(0),trackID(-1),
47  mass(-1.),charge(0.),polX(0.),polY(0.),polZ(0.),
48  Weight0(1.0),properTime(0.0),userInfo(0)
49 {;}
50 
52 :PDGcode(Pcode),
53  direction(0.,0.,1.),kinE(0.),
54  nextParticle(0),daughterParticle(0),trackID(-1),
55  mass(-1.),charge(0.),polX(0.),polY(0.),polZ(0.),
56  Weight0(1.0),properTime(0.0),userInfo(0)
57 {
59  if (G4code !=0) {
60  mass = G4code->GetPDGMass();
62  }
63 }
64 
66  G4double px,G4double py,G4double pz)
67 :PDGcode(Pcode),
68  direction(0.,0.,1.),kinE(0.),
69  nextParticle(0),daughterParticle(0),trackID(-1),
70  mass(-1.),charge(0.),polX(0.),polY(0.),polZ(0.),
71  Weight0(1.0),properTime(0.0),userInfo(0)
72 {
74  if (G4code !=0) {
75  mass = G4code->GetPDGMass();
77  }
78  SetMomentum( px, py, pz);
79 }
80 
83 :PDGcode(Pcode),
84  direction(0.,0.,1.),kinE(0.),
85  nextParticle(0),daughterParticle(0),trackID(-1),
86  mass(-1.),charge(0.),polX(0.),polY(0.),polZ(0.),
87  Weight0(1.0),properTime(0.0),userInfo(0)
88 {
90  if (G4code !=0) {
91  mass = G4code->GetPDGMass();
93  }
94  Set4Momentum( px, py, pz, E);
95 }
96 
98 :PDGcode(0),G4code(Gcode),
99  direction(0.,0.,1.),kinE(0.),
100  nextParticle(0),daughterParticle(0),trackID(-1),
101  mass(-1.),charge(0.),polX(0.),polY(0.),polZ(0.),
102  Weight0(1.0),properTime(0.0),userInfo(0)
103 {
104  if (G4code !=0) {
105  PDGcode = Gcode->GetPDGEncoding();
106  mass = G4code->GetPDGMass();
108  }
109 }
110 
112  G4double px,G4double py,G4double pz)
113 :PDGcode(0),G4code(Gcode),
114  direction(0.,0.,1.),kinE(0.),
115  nextParticle(0),daughterParticle(0),trackID(-1),
116  mass(-1.),charge(0.),polX(0.),polY(0.),polZ(0.),
117  Weight0(1.0),properTime(0.0),userInfo(0)
118 {
119  if (G4code !=0) {
120  PDGcode = Gcode->GetPDGEncoding();
121  mass = G4code->GetPDGMass();
123  }
124  SetMomentum( px, py, pz);
125 }
126 
129 :PDGcode(0),G4code(Gcode),
130  direction(0.,0.,1.),kinE(0.),
131  nextParticle(0),daughterParticle(0),trackID(-1),
132  mass(-1.),charge(0.),polX(0.),polY(0.),polZ(0.),
133  Weight0(1.0),properTime(0.0),userInfo(0)
134 {
135  if (G4code !=0) {
136  PDGcode = Gcode->GetPDGEncoding();
137  mass = G4code->GetPDGMass();
139  }
140  Set4Momentum( px, py, pz, E);
141 }
142 
144 :PDGcode(0),G4code(0),
145  direction(0.,0.,1.),kinE(0.),
146  nextParticle(0),daughterParticle(0),trackID(-1),
147  mass(-1.),charge(0.),polX(0.),polY(0.),polZ(0.),
148  Weight0(1.0),properTime(0.0),userInfo(0)
149 {
150  *this = right;
151 }
152 
154 {
155  if (this != &right) {
156  PDGcode = right.PDGcode;
157  G4code = right.G4code;
158  direction = right.direction;
159  kinE = right.kinE;
160  if (nextParticle !=0) delete nextParticle;
161  if ( right.nextParticle ==0 ){
162  nextParticle = 0;
163  } else {
165  }
166  if (daughterParticle !=0) delete daughterParticle;
167  if ( right.daughterParticle ==0 ){
168  daughterParticle = 0;
169  } else {
171  }
172  trackID = right.trackID;
173  mass = right.mass;
174  charge = right.charge;
175  polX = right.polX;
176  polY = right.polY;
177  polZ = right.polZ;
178  Weight0 = right.Weight0;
179  properTime = right.properTime;
180 
181  // userInfo can not be copied
182  userInfo = 0;
183  }
184 
185  return *this;
186 }
187 
189 { return (this==&right); }
190 
192 { return (this!=&right); }
193 
195 {
196  if(nextParticle != 0){
197  delete nextParticle;
198  nextParticle = 0;
199  }
200  if(daughterParticle != 0){
201  delete daughterParticle;
202  daughterParticle =0;
203  }
204  if(userInfo!=0) {
205  delete userInfo;
206  userInfo=0;
207  }
208 }
209 
211 {
212  if ((mass<0.)&&(G4code!=0)){
213  mass = G4code->GetPDGMass();
214  }
215  G4double pmom = std::sqrt(px*px+py*py+pz*pz);
216  if (pmom>0.0) {
217  direction.setX(px/pmom);
218  direction.setY(py/pmom);
219  direction.setZ(pz/pmom);
220  }
221  kinE = std::sqrt(px*px+py*py+pz*pz+mass*mass)-mass;
222 }
223 
225 {
226  G4double pmom = std::sqrt(px*px+py*py+pz*pz);
227  if (pmom>0.0) {
228  direction.setX(px/pmom);
229  direction.setY(py/pmom);
230  direction.setZ(pz/pmom);
231  }
232  G4double mas2 = E*E - pmom*pmom;
233  if(mas2>=0.){
234  mass = std::sqrt(mas2);
235  } else {
236  if (G4code!=0){
237  mass = G4code->GetPDGMass();
238  }
239  E = std::sqrt(pmom*pmom+mass*mass);
240  }
241  kinE = E - mass;
242 }
243 
245 {
246  PDGcode = Pcode;
248  if (G4code!=0){
249  mass = G4code->GetPDGMass();
251  }
252 }
253 
255 {
256  G4code = Gcode;
257  if (G4code!=0){
258  PDGcode = Gcode->GetPDGEncoding();
259  mass = G4code->GetPDGMass();
261  }
262 }
263 
265 {
266  G4cout << "==== PDGcode " << PDGcode << " Particle name ";
267  if(G4code != 0)
268  { G4cout << G4code->GetParticleName() << G4endl; }
269  else
270  { G4cout << " is not defined in G4." << G4endl; }
271  G4cout << " Assigned charge : " << charge/eplus << G4endl;
272  G4cout << " Momentum ( "
273  << GetTotalMomentum()*direction.x()/GeV << "[GeV/c], "
274  << GetTotalMomentum()*direction.y()/GeV << "[GeV/c], "
275  << GetTotalMomentum()*direction.z()/GeV << "[GeV/c] )" << G4endl;
276  G4cout << " kinetic Energy : " << kinE/GeV << " [GeV]" << G4endl;
277  if(mass>=0.){
278  G4cout << " Mass : " << mass/GeV << " [GeV]" << G4endl;
279  } else {
280  G4cout << " Mass is not assigned " << G4endl;
281  }
282  G4cout << " Polarization ( "
283  << polX << ", "
284  << polY << ", "
285  << polZ << " )"
286  << G4endl;
287  G4cout << " Weight : " << Weight0 << G4endl;
288  if(properTime>0.0) {
289  G4cout << " PreAssigned proper decay time : " << properTime/ns << " [ns] " << G4endl;
290  }
291  if(userInfo != 0) { userInfo->Print(); }
292  if(daughterParticle != 0) {
293  G4cout << ">>>> Daughters" << G4endl;
295  }
296  if(nextParticle != 0) {
297  nextParticle->Print();
298  } else {
299  G4cout << "<<<< End of link" << G4endl;
300  }
301 }
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()
G4PART_DLL G4Allocator< G4PrimaryParticle > *& aPrimaryParticleAllocator()
G4int operator!=(const G4PrimaryParticle &right) const
G4PrimaryParticle & operator=(const G4PrimaryParticle &right)
#define G4endl
Definition: G4ios.hh:61
const G4String & GetParticleName() const
G4double GetPDGCharge() const
double z() const
void SetMomentum(G4double px, G4double py, G4double pz)
G4ThreeVector direction
#define G4ThreadLocalStatic
Definition: tls.hh:68
G4double GetPDGMass() const
void setX(double)
G4double GetTotalMomentum() const
virtual void Print() const =0
double G4double
Definition: G4Types.hh:76
G4PrimaryParticle * daughterParticle
G4int operator==(const G4PrimaryParticle &right) const
void setZ(double)
void SetParticleDefinition(const G4ParticleDefinition *pdef)
void SetPDGcode(G4int Pcode)
void Set4Momentum(G4double px, G4double py, G4double pz, G4double E)
G4PrimaryParticle * nextParticle
static constexpr double eplus
Definition: G4SIunits.hh:199
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
double x() const
const G4ParticleDefinition * G4code
double y() const
static constexpr double GeV
Definition: G4SIunits.hh:217
#define ns
Definition: xmlparse.cc:614
void setY(double)
G4VUserPrimaryParticleInformation * userInfo