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

Last change on this file since 1355 was 1340, checked in by garnier, 14 years ago

update ti head

File size: 8.4 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.21 2010/10/27 07:47:05 gcosmo Exp $
28// GEANT4 tag $Name: particles-V09-03-15 $
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) AllocateElectronOccupancy();
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{
99 if ( theElectronOccupancy == 0) AllocateElectronOccupancy();
100 if ( theElectronOccupancy != 0) {
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 const_cast<G4ParticleDefinition*>(theParticleDefinition);
196}
197
198inline const G4ParticleDefinition* G4DynamicParticle::GetParticleDefinition() const
199{
200  return const_cast<G4ParticleDefinition*>(theParticleDefinition);
201}
202
203inline const G4ThreeVector& G4DynamicParticle::GetPolarization() const
204{
205  return thePolarization;
206}
207
208inline G4double G4DynamicParticle::GetProperTime() const
209{
210  return theProperTime;
211}
212
213inline G4double G4DynamicParticle::GetTotalEnergy() const
214{
215  return (theKineticEnergy+theDynamicalMass);
216}
217
218inline G4double G4DynamicParticle::GetKineticEnergy() const
219{
220  return theKineticEnergy;
221}
222
223inline void G4DynamicParticle::SetMomentumDirection(const G4ThreeVector &aDirection)
224{
225  theMomentumDirection = aDirection;
226}
227
228inline void G4DynamicParticle::SetMomentumDirection(G4double px, G4double py, G4double pz)
229{
230  theMomentumDirection.setX(px);
231  theMomentumDirection.setY(py);
232  theMomentumDirection.setZ(pz);
233}
234
235
236inline void G4DynamicParticle::SetPolarization(G4double polX, G4double polY, G4double polZ)
237{
238  thePolarization.setX(polX);
239  thePolarization.setY(polY);
240  thePolarization.setZ(polZ);
241}
242
243inline void G4DynamicParticle::SetKineticEnergy(G4double aEnergy)
244{
245  theKineticEnergy = aEnergy;
246}
247
248inline void G4DynamicParticle::SetProperTime(G4double atime)
249{
250  theProperTime = atime;
251}
252
253inline const G4DecayProducts* G4DynamicParticle::GetPreAssignedDecayProducts() const
254{
255  return thePreAssignedDecayProducts;
256}
257
258inline void G4DynamicParticle::SetPreAssignedDecayProducts(G4DecayProducts* aDecayProducts)
259{
260 thePreAssignedDecayProducts = aDecayProducts;
261}
262
263inline G4double G4DynamicParticle::GetPreAssignedDecayProperTime() const
264{
265  return thePreAssignedDecayTime;
266}
267 
268inline void G4DynamicParticle::SetPreAssignedDecayProperTime(G4double aTime)
269{
270  thePreAssignedDecayTime = aTime;
271}
272
273inline
274void G4DynamicParticle::SetVerboseLevel(G4int value)
275{
276   verboseLevel = value;
277}
278
279inline
280G4int G4DynamicParticle::GetVerboseLevel() const
281{
282   return verboseLevel;
283}
284
285inline
286void G4DynamicParticle::SetPrimaryParticle(G4PrimaryParticle* p)
287{
288   primaryParticle=p;
289}
290
291inline
292G4PrimaryParticle* G4DynamicParticle::GetPrimaryParticle() const
293{
294   return primaryParticle;
295}
296
297inline
298G4int G4DynamicParticle::GetPDGcode() const
299{
300  G4int code = theParticleDefinition->GetPDGEncoding();
301  if(code==0) code = thePDGcode;
302  return code;
303}
304
305inline
306void G4DynamicParticle::SetPDGcode(G4int c)
307{
308  thePDGcode = c;
309}
310
311
312
313
314
315
316
Note: See TracBrowser for help on using the repository browser.