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.hh,v 1.4 2006/09/28 14:29:43 kurasige Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
29 | // |
---|
30 | // |
---|
31 | |
---|
32 | |
---|
33 | #ifndef G4PrimaryParticle_h |
---|
34 | #define G4PrimaryParticle_h 1 |
---|
35 | |
---|
36 | #include "globals.hh" |
---|
37 | #include "G4Allocator.hh" |
---|
38 | #include "G4ThreeVector.hh" |
---|
39 | |
---|
40 | class G4ParticleDefinition; |
---|
41 | class G4VUserPrimaryParticleInformation; |
---|
42 | |
---|
43 | // class description: |
---|
44 | // |
---|
45 | // This is a class which represents a primary particle. |
---|
46 | // This is completely deferent class from G4Track or G4DynamicParticle. |
---|
47 | // This class is designed with taking into account the possibility of |
---|
48 | // making this class persistent, i.e. kept with G4Event class object |
---|
49 | // to ODBMS. Thus this class is almost free from any other Geant4 classes. |
---|
50 | // The only exception is a pointer to G4ParticleDefinition but it can be |
---|
51 | // rebuilt by the PDGcode. |
---|
52 | // |
---|
53 | // Primary particles are stored in G4PrimaryVertex object with a form |
---|
54 | // of linked list. Also, an object of this PrimaryParticle class can have |
---|
55 | // one or more objects of this class as its daughters with a form of |
---|
56 | // linked list. |
---|
57 | // A parimary particle represented by this class object needs not to be |
---|
58 | // a particle of type which Geant4 can simulate. |
---|
59 | // case a) mother particle is not a particle Geant4 can simulate |
---|
60 | // daughters associated to the mother will be examined. |
---|
61 | // case b) mother particle is a perticle Geant4 can simulate |
---|
62 | // daughters associated to the mother will be converted to G4Dynamic |
---|
63 | // particle and be set to the mother G4Track. For this case, dauthers |
---|
64 | // are used as the "pre-fixed" decay channel. |
---|
65 | // |
---|
66 | |
---|
67 | class G4PrimaryParticle |
---|
68 | { |
---|
69 | public: |
---|
70 | inline void *operator new(size_t); |
---|
71 | inline void operator delete(void *aStackedTrack); |
---|
72 | |
---|
73 | G4PrimaryParticle(); |
---|
74 | G4PrimaryParticle(G4int Pcode); |
---|
75 | G4PrimaryParticle(G4int Pcode, |
---|
76 | G4double px,G4double py,G4double pz); |
---|
77 | G4PrimaryParticle(G4int Pcode, |
---|
78 | G4double px,G4double py,G4double pz,G4double E); |
---|
79 | G4PrimaryParticle(G4ParticleDefinition* Gcode); |
---|
80 | G4PrimaryParticle(G4ParticleDefinition* Gcode, |
---|
81 | G4double px,G4double py,G4double pz); |
---|
82 | G4PrimaryParticle(G4ParticleDefinition* Gcode, |
---|
83 | G4double px,G4double py,G4double pz,G4double E); |
---|
84 | ~G4PrimaryParticle(); |
---|
85 | |
---|
86 | const G4PrimaryParticle & operator=(const G4PrimaryParticle &right); |
---|
87 | G4int operator==(const G4PrimaryParticle &right) const; |
---|
88 | G4int operator!=(const G4PrimaryParticle &right) const; |
---|
89 | |
---|
90 | public: // with description |
---|
91 | void Print() const; |
---|
92 | // Print the properties of the particle. |
---|
93 | |
---|
94 | private: |
---|
95 | G4int PDGcode; |
---|
96 | G4ParticleDefinition * G4code; |
---|
97 | G4double Px; |
---|
98 | G4double Py; |
---|
99 | G4double Pz; |
---|
100 | |
---|
101 | G4PrimaryParticle * nextParticle; |
---|
102 | G4PrimaryParticle * daughterParticle; |
---|
103 | |
---|
104 | G4int trackID; // This will be set if this particle is |
---|
105 | // sent to G4EventManager and converted to |
---|
106 | // G4Track. Otherwise = -1. |
---|
107 | |
---|
108 | G4double mass; |
---|
109 | G4double charge; |
---|
110 | G4double polX; |
---|
111 | G4double polY; |
---|
112 | G4double polZ; |
---|
113 | G4double Weight0; |
---|
114 | G4double properTime; |
---|
115 | G4VUserPrimaryParticleInformation* userInfo; |
---|
116 | |
---|
117 | public: // with description |
---|
118 | // followings are get methods available. |
---|
119 | // "trackID" will be set if this particle is sent to G4EventManager |
---|
120 | // and converted to G4Track. Otherwise = -1. |
---|
121 | // The mass and charge in G4ParticleDefinition will be used in default. |
---|
122 | // "SetMass" and "SetCharge" methods are used to set dynamical mass and charge |
---|
123 | // G4DynamicParticle."GetMass" and "GetCharge" methods will return |
---|
124 | // those in G4ParticleDefinition if users do not set dynamical ones. |
---|
125 | |
---|
126 | G4double GetMass() const; |
---|
127 | G4double GetCharge() const; |
---|
128 | |
---|
129 | inline G4int GetPDGcode() const |
---|
130 | { return PDGcode; } |
---|
131 | inline G4ParticleDefinition * GetG4code() const |
---|
132 | { return G4code; } |
---|
133 | inline G4ThreeVector GetMomentum() const |
---|
134 | { return G4ThreeVector(Px,Py,Pz); } |
---|
135 | inline G4double GetPx() const |
---|
136 | { return Px; } |
---|
137 | inline G4double GetPy() const |
---|
138 | { return Py; } |
---|
139 | inline G4double GetPz() const |
---|
140 | { return Pz; } |
---|
141 | inline G4PrimaryParticle * GetNext() const |
---|
142 | { return nextParticle; } |
---|
143 | inline G4PrimaryParticle * GetDaughter() const |
---|
144 | { return daughterParticle; } |
---|
145 | inline G4int GetTrackID() const |
---|
146 | { return trackID; } |
---|
147 | inline G4ThreeVector GetPolarization() const |
---|
148 | { return G4ThreeVector(polX,polY,polZ); } |
---|
149 | inline G4double GetPolX() const { return polX; } |
---|
150 | inline G4double GetPolY() const { return polY; } |
---|
151 | inline G4double GetPolZ() const { return polZ; } |
---|
152 | inline G4double GetWeight() const { return Weight0; } |
---|
153 | inline void SetWeight(G4double w) { Weight0 = w; } |
---|
154 | inline void SetProperTime(G4double t) { properTime = t; } |
---|
155 | inline G4double GetProperTime() const { return properTime; } |
---|
156 | inline void SetUserInformation(G4VUserPrimaryParticleInformation* anInfo) |
---|
157 | { userInfo = anInfo; } |
---|
158 | inline G4VUserPrimaryParticleInformation* GetUserInformation() const |
---|
159 | { return userInfo; } |
---|
160 | |
---|
161 | public: // with description |
---|
162 | // Followings are available Set methods. |
---|
163 | void SetPDGcode(G4int Pcode); |
---|
164 | void SetG4code(G4ParticleDefinition * Gcode); |
---|
165 | inline void SetMomentum(G4double px, G4double py, G4double pz) |
---|
166 | { |
---|
167 | Px = px; |
---|
168 | Py = py; |
---|
169 | Pz = pz; |
---|
170 | } |
---|
171 | inline void Set4Momentum(G4double px, G4double py, G4double pz, G4double E) |
---|
172 | { |
---|
173 | Px = px; |
---|
174 | Py = py; |
---|
175 | Pz = pz; |
---|
176 | G4double mas2 = E*E - px*px - py*py - pz*pz; |
---|
177 | if(mas2>=0.) |
---|
178 | { mass = std::sqrt(mas2); } |
---|
179 | else |
---|
180 | { mass = -1.0; } |
---|
181 | } |
---|
182 | inline void SetNext(G4PrimaryParticle * np) |
---|
183 | { |
---|
184 | if(nextParticle == 0) |
---|
185 | { nextParticle = np; } |
---|
186 | else |
---|
187 | { nextParticle->SetNext(np); } |
---|
188 | } |
---|
189 | inline void SetDaughter(G4PrimaryParticle * np) |
---|
190 | { |
---|
191 | if(daughterParticle == 0) |
---|
192 | { daughterParticle = np; } |
---|
193 | else |
---|
194 | { daughterParticle->SetNext(np); } |
---|
195 | } |
---|
196 | inline void SetTrackID(G4int id) |
---|
197 | { trackID = id; } |
---|
198 | inline void SetMass(G4double mas) |
---|
199 | { mass = mas; } |
---|
200 | inline void SetCharge(G4double chg) |
---|
201 | { charge = chg; } |
---|
202 | inline void SetPolarization(G4double px,G4double py,G4double pz) |
---|
203 | { |
---|
204 | polX = px; |
---|
205 | polY = py; |
---|
206 | polZ = pz; |
---|
207 | } |
---|
208 | }; |
---|
209 | |
---|
210 | #if defined G4PARTICLES_ALLOC_EXPORT |
---|
211 | extern G4DLLEXPORT G4Allocator<G4PrimaryParticle> aPrimaryParticleAllocator; |
---|
212 | #else |
---|
213 | extern G4DLLIMPORT G4Allocator<G4PrimaryParticle> aPrimaryParticleAllocator; |
---|
214 | #endif |
---|
215 | |
---|
216 | inline void * G4PrimaryParticle::operator new(size_t) |
---|
217 | { |
---|
218 | void * aPrimaryParticle; |
---|
219 | aPrimaryParticle = (void *) aPrimaryParticleAllocator.MallocSingle(); |
---|
220 | return aPrimaryParticle; |
---|
221 | } |
---|
222 | |
---|
223 | inline void G4PrimaryParticle::operator delete(void * aPrimaryParticle) |
---|
224 | { |
---|
225 | aPrimaryParticleAllocator.FreeSingle((G4PrimaryParticle *) aPrimaryParticle); |
---|
226 | } |
---|
227 | |
---|
228 | |
---|
229 | #endif |
---|
230 | |
---|