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

Last change on this file since 1322 was 1315, checked in by garnier, 15 years ago

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File size: 8.2 KB
RevLine 
[824]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//
[1315]27// $Id: G4DynamicParticle.icc,v 1.17 2010/04/19 00:23:08 kurasige Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
[824]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{
[1315]89 if ( theElectronOccupancy == 0) AllocateElectronOccupancy();
[824]90 if ( theElectronOccupancy != 0) {
91 G4int n = theElectronOccupancy->AddElectron(orbit, number );
92 theDynamicalCharge -= eplus * n;
93 theDynamicalMass += GetElectronMass() * n;
94 }
95}
96
97inline void G4DynamicParticle::RemoveElectron(G4int orbit, G4int number)
98{
[1315]99 if ( theElectronOccupancy == 0) AllocateElectronOccupancy();
100 if ( theElectronOccupancy != 0) {
[824]101 G4int n = theElectronOccupancy->RemoveElectron(orbit, number );
102 theDynamicalCharge += eplus * n;
103 theDynamicalMass -= GetElectronMass() * n;
104 }
105}
106
107
108
109inline G4double G4DynamicParticle::GetCharge() const
110{
111 return theDynamicalCharge;
112}
113
114inline void G4DynamicParticle::SetCharge(G4double newCharge)
115{
116 theDynamicalCharge = newCharge;
117}
118
119inline void G4DynamicParticle::SetCharge(G4int newCharge)
120{
121 theDynamicalCharge = newCharge*eplus;
122}
123
124inline G4double G4DynamicParticle::GetMass() const
125{
126 return theDynamicalMass;
127}
128
129
130inline G4double G4DynamicParticle::GetSpin() const
131{
132 return theDynamicalSpin;
133}
134
135inline void G4DynamicParticle::SetSpin(G4double spin)
136{
137 theDynamicalSpin = spin;
138}
139
140inline void G4DynamicParticle::SetSpin(G4int spinInUnitOfHalfInteger)
141{
142 theDynamicalSpin = spinInUnitOfHalfInteger * 0.5;
143}
144
145inline G4double G4DynamicParticle::GetMagneticMoment() const
146{
147 return theDynamicalMagneticMoment;
148}
149
150inline void G4DynamicParticle::SetMagneticMoment(G4double magneticMoment)
151{
152 theDynamicalMagneticMoment = magneticMoment;
153}
154
155inline void G4DynamicParticle::SetMass(G4double newMass)
156{
157 theDynamicalMass = newMass;
158}
159
160inline const G4ThreeVector& G4DynamicParticle::GetMomentumDirection() const
161{
162 return theMomentumDirection;
163}
164
165inline G4ThreeVector G4DynamicParticle::GetMomentum() const
166{
167 G4double pModule = std::sqrt(theKineticEnergy*theKineticEnergy +
168 2*theKineticEnergy*theDynamicalMass);
169 G4ThreeVector pMomentum(theMomentumDirection.x()*pModule,
170 theMomentumDirection.y()*pModule,
171 theMomentumDirection.z()*pModule);
172 return pMomentum;
173}
174
175inline G4LorentzVector G4DynamicParticle::Get4Momentum() const
176{
177 G4double mass = theDynamicalMass;
178 G4double energy = theKineticEnergy;
179 G4double momentum = std::sqrt(energy*energy+2.0*mass*energy);
180 G4LorentzVector p4( theMomentumDirection.x()*momentum,
181 theMomentumDirection.y()*momentum,
182 theMomentumDirection.z()*momentum,
183 energy+mass);
184 return p4;
185}
186
187inline G4double G4DynamicParticle::GetTotalMomentum() const
188{
189 // The momentum is returned in energy equivalent.
190 return std::sqrt((theKineticEnergy + 2.*theDynamicalMass)* theKineticEnergy);
191}
192
193inline G4ParticleDefinition* G4DynamicParticle::GetDefinition() const
194{
195 return theParticleDefinition;
196}
197
198inline const G4ThreeVector& G4DynamicParticle::GetPolarization() const
199{
200 return thePolarization;
201}
202
203inline G4double G4DynamicParticle::GetProperTime() const
204{
205 return theProperTime;
206}
207
208inline G4double G4DynamicParticle::GetTotalEnergy() const
209{
210 return (theKineticEnergy+theDynamicalMass);
211}
212
213inline G4double G4DynamicParticle::GetKineticEnergy() const
214{
215 return theKineticEnergy;
216}
217
218inline void G4DynamicParticle::SetMomentumDirection(const G4ThreeVector &aDirection)
219{
220 theMomentumDirection = aDirection;
221}
222
223inline void G4DynamicParticle::SetMomentumDirection(G4double px, G4double py, G4double pz)
224{
225 theMomentumDirection.setX(px);
226 theMomentumDirection.setY(py);
227 theMomentumDirection.setZ(pz);
228}
229
230
231inline void G4DynamicParticle::SetPolarization(G4double polX, G4double polY, G4double polZ)
232{
233 thePolarization.setX(polX);
234 thePolarization.setY(polY);
235 thePolarization.setZ(polZ);
236}
237
238inline void G4DynamicParticle::SetKineticEnergy(G4double aEnergy)
239{
240 theKineticEnergy = aEnergy;
241}
242
243inline void G4DynamicParticle::SetProperTime(G4double atime)
244{
245 theProperTime = atime;
246}
247
248inline const G4DecayProducts* G4DynamicParticle::GetPreAssignedDecayProducts() const
249{
250 return thePreAssignedDecayProducts;
251}
252
253inline void G4DynamicParticle::SetPreAssignedDecayProducts(G4DecayProducts* aDecayProducts)
254{
255 thePreAssignedDecayProducts = aDecayProducts;
256}
257
258inline G4double G4DynamicParticle::GetPreAssignedDecayProperTime() const
259{
260 return thePreAssignedDecayTime;
261}
262
263inline void G4DynamicParticle::SetPreAssignedDecayProperTime(G4double aTime)
264{
265 thePreAssignedDecayTime = aTime;
266}
267
268inline
269void G4DynamicParticle::SetVerboseLevel(G4int value)
270{
271 verboseLevel = value;
272}
273
274inline
275G4int G4DynamicParticle::GetVerboseLevel() const
276{
277 return verboseLevel;
278}
279
280inline
281void G4DynamicParticle::SetPrimaryParticle(G4PrimaryParticle* p)
282{
283 primaryParticle=p;
284}
285
286inline
287G4PrimaryParticle* G4DynamicParticle::GetPrimaryParticle() const
288{
289 return primaryParticle;
290}
291
292inline
293G4int G4DynamicParticle::GetPDGcode() const
294{
295 G4int code = theParticleDefinition->GetPDGEncoding();
296 if(code==0) code = thePDGcode;
297 return code;
298}
299
300inline
301void G4DynamicParticle::SetPDGcode(G4int c)
302{
303 thePDGcode = c;
304}
305
306
307
308
309
310
311
Note: See TracBrowser for help on using the repository browser.