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