]>
Commit | Line | Data |
---|---|---|
676fb573 | 1 | // $Id$ |
2 | // Category: event | |
3 | // | |
4 | // See the class description in the header file. | |
5 | ||
6 | #include "AliGunParticle.h" | |
7 | ||
c97337f9 | 8 | #include <G4ParticleDefinition.hh> |
676fb573 | 9 | |
78ca1e9c | 10 | //_____________________________________________________________________________ |
676fb573 | 11 | AliGunParticle::AliGunParticle() |
12 | : fParticleDefinition(0), | |
13 | fParticleMomentum(G4ThreeVector(0., 0., 1.)), | |
14 | fPosition(G4ThreeVector()), | |
15 | fTime(0), | |
16 | fPolarization(G4ThreeVector()) | |
17 | { | |
18 | // | |
19 | } | |
20 | ||
78ca1e9c | 21 | //_____________________________________________________________________________ |
676fb573 | 22 | AliGunParticle::AliGunParticle(G4ParticleDefinition* particleDef, |
23 | G4ParticleMomentum momentum, G4ThreeVector position, | |
24 | G4double time, G4ThreeVector polarization ) | |
25 | : fParticleDefinition(particleDef), | |
26 | fParticleMomentum(momentum), | |
27 | fPosition(position), | |
28 | fTime(time), | |
29 | fPolarization(polarization) | |
30 | { | |
31 | // | |
32 | } | |
33 | ||
78ca1e9c | 34 | //_____________________________________________________________________________ |
676fb573 | 35 | AliGunParticle::AliGunParticle( G4ParticleDefinition* particleDef, |
36 | G4ParticleMomentum momentumDir, G4double kinEnergy, | |
37 | G4ThreeVector position, G4double time, | |
38 | G4ThreeVector polarization ) | |
39 | : fParticleDefinition(particleDef), | |
40 | fPosition(position), | |
41 | fTime(time), | |
42 | fPolarization(polarization) | |
43 | { | |
44 | // | |
45 | G4double mass = fParticleDefinition->GetPDGMass(); | |
46 | G4double energy = kinEnergy + mass; | |
47 | G4double pmag = sqrt(energy*energy - mass*mass); | |
48 | fParticleMomentum = pmag*momentumDir; | |
49 | } | |
50 | ||
78ca1e9c | 51 | //_____________________________________________________________________________ |
676fb573 | 52 | AliGunParticle::AliGunParticle(const AliGunParticle& right) { |
53 | // | |
58c0119e | 54 | // copy stuff |
55 | *this = right; | |
676fb573 | 56 | } |
57 | ||
78ca1e9c | 58 | //_____________________________________________________________________________ |
676fb573 | 59 | AliGunParticle::~AliGunParticle() { |
60 | // | |
61 | } | |
62 | ||
63 | // operators | |
64 | ||
78ca1e9c | 65 | //_____________________________________________________________________________ |
676fb573 | 66 | AliGunParticle& AliGunParticle::operator=(const AliGunParticle& right) |
67 | { | |
68 | // check assignement to self | |
69 | if (this == &right) return *this; | |
70 | ||
71 | fParticleDefinition = right.fParticleDefinition; | |
72 | fParticleMomentum = right.fParticleMomentum; | |
73 | fPosition = right.fPosition; | |
74 | fTime = right.fTime; | |
75 | fPolarization = right.fPolarization; | |
76 | ||
77 | return *this; | |
78 | } | |
79 | ||
78ca1e9c | 80 | //_____________________________________________________________________________ |
676fb573 | 81 | G4int AliGunParticle::operator==(const AliGunParticle& right) const |
82 | { | |
83 | // | |
84 | G4int returnValue = 0; | |
85 | if (fParticleDefinition == right.fParticleDefinition | |
86 | && fParticleMomentum == right.fParticleMomentum | |
87 | && fPosition == right.fPosition | |
88 | && fTime == right.fTime | |
89 | && fPolarization == right.fPolarization) returnValue = 1; | |
90 | ||
91 | return returnValue; | |
92 | } | |
93 | ||
78ca1e9c | 94 | //_____________________________________________________________________________ |
676fb573 | 95 | G4int AliGunParticle::operator!=(const AliGunParticle& right) const |
96 | { | |
97 | // | |
98 | G4int returnValue = 1; | |
99 | if (*this == right) returnValue = 0; | |
100 | ||
101 | return returnValue; | |
102 | } | |
103 | ||
104 | // public methods | |
105 | ||
78ca1e9c | 106 | //_____________________________________________________________________________ |
676fb573 | 107 | void AliGunParticle::Print() const |
108 | { | |
109 | // Prints particle properties. | |
110 | // --- | |
111 | ||
112 | G4cout << " particle name: "; | |
5f1d09c5 | 113 | G4cout << fParticleDefinition->GetParticleName() << G4endl; |
676fb573 | 114 | G4cout << " particle momentum: "; |
5f1d09c5 | 115 | G4cout << fParticleMomentum << G4endl; |
676fb573 | 116 | G4cout << " particle position: "; |
5f1d09c5 | 117 | G4cout << fPosition << " mm" << G4endl; |
676fb573 | 118 | G4cout << " particle time: "; |
5f1d09c5 | 119 | G4cout << fTime << " s" << G4endl; |
676fb573 | 120 | G4cout << " particle polarization: "; |
5f1d09c5 | 121 | G4cout << fPolarization << G4endl; |
676fb573 | 122 | } |
123 | ||
78ca1e9c | 124 | //_____________________________________________________________________________ |
676fb573 | 125 | void AliGunParticle::SetKineticEnergy(G4double kinEnergy) |
126 | { | |
127 | // Sets kinetic energy. | |
128 | // --- | |
129 | ||
130 | G4double mass = fParticleDefinition->GetPDGMass(); | |
131 | G4double energy = kinEnergy + mass; | |
132 | G4double pmag = sqrt(energy*energy - mass*mass); | |
133 | fParticleMomentum.setMag(pmag); | |
134 | } | |
135 | ||
78ca1e9c | 136 | //_____________________________________________________________________________ |
676fb573 | 137 | G4double AliGunParticle::GetKineticEnergy() const |
138 | { | |
139 | // Gets kinetic energy. | |
140 | // --- | |
141 | ||
142 | G4double mass = fParticleDefinition->GetPDGMass(); | |
143 | G4double energy | |
144 | = sqrt(fParticleMomentum.mag()*fParticleMomentum.mag() + mass*mass); | |
145 | return energy - mass; | |
146 | } |