source: trunk/source/particles/management/include/G4DynamicParticle.icc@ 1192

Last change on this file since 1192 was 992, checked in by garnier, 17 years ago

fichiers oublies

File size: 8.1 KB
Line 
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: G4DynamicParticle.icc,v 1.16 2007/03/11 07:17:35 kurasige Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
29//
30//
31// ------------------------------------------------------------
32// GEANT 4 class header file
33//
34// History: first implementation, based on object model of
35// 17 AUg. 1999 H.Kurashige
36// ------------------------------------------------------------
37
38#if defined G4PARTICLES_ALLOC_EXPORT
39 extern G4DLLEXPORT G4Allocator<G4DynamicParticle> aDynamicParticleAllocator;
40#else
41 extern G4DLLIMPORT G4Allocator<G4DynamicParticle> aDynamicParticleAllocator;
42#endif
43
44// ------------------------
45// Inlined operators
46// ------------------------
47
48inline void * G4DynamicParticle::operator new(size_t)
49{
50 void * aDynamicParticle;
51 aDynamicParticle = (void *) aDynamicParticleAllocator.MallocSingle();
52 return aDynamicParticle;
53}
54
55inline void G4DynamicParticle::operator delete(void * aDynamicParticle)
56{
57 aDynamicParticleAllocator.FreeSingle((G4DynamicParticle *) aDynamicParticle);
58}
59
60// ------------------------
61// Inlined functions
62// ------------------------
63
64inline const G4ElectronOccupancy* G4DynamicParticle::GetElectronOccupancy() const
65{
66 return theElectronOccupancy;
67}
68
69inline G4int G4DynamicParticle::GetTotalOccupancy() const
70{
71 G4int value = 0;
72 if ( theElectronOccupancy != 0) {
73 value = theElectronOccupancy->GetTotalOccupancy();
74 }
75 return value;
76}
77
78inline G4int G4DynamicParticle::GetOccupancy(G4int orbit) const
79{
80 G4int value = 0;
81 if ( theElectronOccupancy != 0) {
82 value = theElectronOccupancy->GetOccupancy(orbit);
83 }
84 return value;
85}
86
87inline void G4DynamicParticle::AddElectron(G4int orbit, G4int number )
88{
89 if ( theElectronOccupancy != 0) {
90 G4int n = theElectronOccupancy->AddElectron(orbit, number );
91 theDynamicalCharge -= eplus * n;
92 theDynamicalMass += GetElectronMass() * n;
93 }
94}
95
96inline void G4DynamicParticle::RemoveElectron(G4int orbit, G4int number)
97{
98 if ( theElectronOccupancy != 0) {
99 G4int n = theElectronOccupancy->RemoveElectron(orbit, number );
100 theDynamicalCharge += eplus * n;
101 theDynamicalMass -= GetElectronMass() * n;
102 }
103}
104
105
106
107inline G4double G4DynamicParticle::GetCharge() const
108{
109 return theDynamicalCharge;
110}
111
112inline void G4DynamicParticle::SetCharge(G4double newCharge)
113{
114 theDynamicalCharge = newCharge;
115}
116
117inline void G4DynamicParticle::SetCharge(G4int newCharge)
118{
119 theDynamicalCharge = newCharge*eplus;
120}
121
122inline G4double G4DynamicParticle::GetMass() const
123{
124 return theDynamicalMass;
125}
126
127
128inline G4double G4DynamicParticle::GetSpin() const
129{
130 return theDynamicalSpin;
131}
132
133inline void G4DynamicParticle::SetSpin(G4double spin)
134{
135 theDynamicalSpin = spin;
136}
137
138inline void G4DynamicParticle::SetSpin(G4int spinInUnitOfHalfInteger)
139{
140 theDynamicalSpin = spinInUnitOfHalfInteger * 0.5;
141}
142
143inline G4double G4DynamicParticle::GetMagneticMoment() const
144{
145 return theDynamicalMagneticMoment;
146}
147
148inline void G4DynamicParticle::SetMagneticMoment(G4double magneticMoment)
149{
150 theDynamicalMagneticMoment = magneticMoment;
151}
152
153inline void G4DynamicParticle::SetMass(G4double newMass)
154{
155 theDynamicalMass = newMass;
156}
157
158inline const G4ThreeVector& G4DynamicParticle::GetMomentumDirection() const
159{
160 return theMomentumDirection;
161}
162
163inline G4ThreeVector G4DynamicParticle::GetMomentum() const
164{
165 G4double pModule = std::sqrt(theKineticEnergy*theKineticEnergy +
166 2*theKineticEnergy*theDynamicalMass);
167 G4ThreeVector pMomentum(theMomentumDirection.x()*pModule,
168 theMomentumDirection.y()*pModule,
169 theMomentumDirection.z()*pModule);
170 return pMomentum;
171}
172
173inline G4LorentzVector G4DynamicParticle::Get4Momentum() const
174{
175 G4double mass = theDynamicalMass;
176 G4double energy = theKineticEnergy;
177 G4double momentum = std::sqrt(energy*energy+2.0*mass*energy);
178 G4LorentzVector p4( theMomentumDirection.x()*momentum,
179 theMomentumDirection.y()*momentum,
180 theMomentumDirection.z()*momentum,
181 energy+mass);
182 return p4;
183}
184
185inline G4double G4DynamicParticle::GetTotalMomentum() const
186{
187 // The momentum is returned in energy equivalent.
188 return std::sqrt((theKineticEnergy + 2.*theDynamicalMass)* theKineticEnergy);
189}
190
191inline G4ParticleDefinition* G4DynamicParticle::GetDefinition() const
192{
193 return theParticleDefinition;
194}
195
196inline const G4ThreeVector& G4DynamicParticle::GetPolarization() const
197{
198 return thePolarization;
199}
200
201inline G4double G4DynamicParticle::GetProperTime() const
202{
203 return theProperTime;
204}
205
206inline G4double G4DynamicParticle::GetTotalEnergy() const
207{
208 return (theKineticEnergy+theDynamicalMass);
209}
210
211inline G4double G4DynamicParticle::GetKineticEnergy() const
212{
213 return theKineticEnergy;
214}
215
216inline void G4DynamicParticle::SetMomentumDirection(const G4ThreeVector &aDirection)
217{
218 theMomentumDirection = aDirection;
219}
220
221inline void G4DynamicParticle::SetMomentumDirection(G4double px, G4double py, G4double pz)
222{
223 theMomentumDirection.setX(px);
224 theMomentumDirection.setY(py);
225 theMomentumDirection.setZ(pz);
226}
227
228
229inline void G4DynamicParticle::SetPolarization(G4double polX, G4double polY, G4double polZ)
230{
231 thePolarization.setX(polX);
232 thePolarization.setY(polY);
233 thePolarization.setZ(polZ);
234}
235
236inline void G4DynamicParticle::SetKineticEnergy(G4double aEnergy)
237{
238 theKineticEnergy = aEnergy;
239}
240
241inline void G4DynamicParticle::SetProperTime(G4double atime)
242{
243 theProperTime = atime;
244}
245
246inline const G4DecayProducts* G4DynamicParticle::GetPreAssignedDecayProducts() const
247{
248 return thePreAssignedDecayProducts;
249}
250
251inline void G4DynamicParticle::SetPreAssignedDecayProducts(G4DecayProducts* aDecayProducts)
252{
253 thePreAssignedDecayProducts = aDecayProducts;
254}
255
256inline G4double G4DynamicParticle::GetPreAssignedDecayProperTime() const
257{
258 return thePreAssignedDecayTime;
259}
260
261inline void G4DynamicParticle::SetPreAssignedDecayProperTime(G4double aTime)
262{
263 thePreAssignedDecayTime = aTime;
264}
265
266inline
267void G4DynamicParticle::SetVerboseLevel(G4int value)
268{
269 verboseLevel = value;
270}
271
272inline
273G4int G4DynamicParticle::GetVerboseLevel() const
274{
275 return verboseLevel;
276}
277
278inline
279void G4DynamicParticle::SetPrimaryParticle(G4PrimaryParticle* p)
280{
281 primaryParticle=p;
282}
283
284inline
285G4PrimaryParticle* G4DynamicParticle::GetPrimaryParticle() const
286{
287 return primaryParticle;
288}
289
290inline
291G4int G4DynamicParticle::GetPDGcode() const
292{
293 G4int code = theParticleDefinition->GetPDGEncoding();
294 if(code==0) code = thePDGcode;
295 return code;
296}
297
298inline
299void G4DynamicParticle::SetPDGcode(G4int c)
300{
301 thePDGcode = c;
302}
303
304
305
306
307
308
309
Note: See TracBrowser for help on using the repository browser.