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