88 {
89
90 G4TouchableHandle theTouchable =
91 fastTrack.GetPrimaryTrack()->GetTouchableHandle();
92 G4String name = theTouchable->GetVolume()->GetName();
93
94 G4ThreeVector pdirection =
95 fastTrack.GetPrimaryTrack()->GetMomentum().unit();
96 G4ThreeVector localdir = fastTrack.GetPrimaryTrackLocalDirection();
97
98 G4ThreeVector worldPosition = fastTrack.GetPrimaryTrack()->GetPosition();
99 G4ThreeVector localPosition = fastTrack.GetPrimaryTrackLocalPosition();
100
101 double ekin_MeV = fastTrack.GetPrimaryTrack()->GetKineticEnergy() / MeV;
102 G4double globalTime = fastTrack.GetPrimaryTrack()->GetGlobalTime();
103
104 G4String particleName =
105 fastTrack.GetPrimaryTrack()->GetParticleDefinition()->GetParticleName();
106
107 fastStep.KillPrimaryTrack();
108 fastStep.SetPrimaryTrackPathLength(0.0);
109
110 if (particleName == "kaon+") {
111 particleName = "K+";
112 } else if (particleName == "kaon-") {
113 particleName = "K-";
114 } else if (particleName == "anti_proton") {
115 particleName = "anti-proton";
116 }
117
118 fGarfieldPhysics->
DoIt(particleName, ekin_MeV, globalTime,
119 localPosition.x() / CLHEP::cm, localPosition.y() / CLHEP::cm,
120 localPosition.z() / CLHEP::cm, localdir.x(), localdir.y(),
121 localdir.z());
122
124
126 std::vector<GarfieldParticle*>* secondaryParticles =
128
129 if (secondaryParticles->size() > 0) {
130 fastStep.SetNumberOfSecondaryTracks(secondaryParticles->size());
131
132 G4double totalEnergySecondaries_MeV = 0;
133
134 for (std::vector<GarfieldParticle*>::iterator it =
135 secondaryParticles->begin();
136 it != secondaryParticles->end(); ++it) {
137 G4double x = (*it)->getX_mm();
138 G4double y = (*it)->getY_mm();
139 G4double z = (*it)->getZ_mm();
140 G4double eKin_MeV = (*it)->getEkin_MeV();
141 G4double dx = (*it)->getDX();
142 G4double dy = (*it)->getDY();
143 G4double dz = (*it)->getDZ();
144 G4double time = (*it)->getTime();
145 G4ThreeVector momentumDirection(dx, dy, dz);
146 G4ThreeVector position(x, y, z);
147 if ((*it)->getParticleName() == "e-") {
148 G4DynamicParticle particle(G4Electron::ElectronDefinition(),
149 momentumDirection, eKin_MeV);
150 fastStep.CreateSecondaryTrack(particle, position, time,
151 true);
152 totalEnergySecondaries_MeV += eKin_MeV;
153 } else if ((*it)->getParticleName() == "gamma") {
154 G4DynamicParticle particle(G4Gamma::GammaDefinition(),
155 momentumDirection, eKin_MeV);
156 fastStep.CreateSecondaryTrack(particle, position, time,
157 true);
158 totalEnergySecondaries_MeV += eKin_MeV;
159 }
160
161 }
162 }
163 }
164}
bool GetCreateSecondariesInGeant4()
std::vector< GarfieldParticle * > * GetSecondaryParticles()
double GetEnergyDeposit_MeV()
void DoIt(std::string particleName, double ekin_MeV, double time, double x_cm, double y_cm, double z_cm, double dx, double dy, double dz)