19 #include "G4Electron.hh"
21 #include "G4ParticleTable.hh"
22 #include "G4StackManager.hh"
23 #include "G4SystemOfUnits.hh"
24 #include "G4VPhysicalVolume.hh"
26 #include <TClonesArray.h>
27 #include <TGeoManager.h>
28 #include <TParticle.h>
30 #include <TVirtualMC.h>
37 : G4VFastSimulationModel(modelName, envelope)
41 : G4VFastSimulationModel(modelName)
63 LOG(debug) <<
"FairFastSimModel::DoIt() called";
68 int firstSecondary(0);
69 int nofSecondaries(0);
70 int movedParticleIndex(0);
71 std::tie(movedParticleIndex, firstSecondary, nofSecondaries) =
73 if (movedParticleIndex == -2) {
75 std::tie(movedParticleIndex, firstSecondary, nofSecondaries) =
78 TClonesArray* particles = ((
FairGenericStack*)(gMC->GetStack()))->GetListOfParticles();
79 if (nofSecondaries != 0) {
80 fastStep.SetNumberOfSecondaryTracks(nofSecondaries);
82 int addedParticleIndex = firstSecondary;
83 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
84 for (
int ipart = 0; ipart < nofSecondaries; ipart++) {
85 if (addedParticleIndex == movedParticleIndex)
87 TParticle* particle = (TParticle*)particles->At(addedParticleIndex);
89 G4ParticleDefinition* particleDefinition = 0;
90 particleDefinition = particleTable->FindParticle(particle->GetPdgCode());
91 if (!particleDefinition)
92 LOG(fatal) <<
"FairFastSimModel::DoIt() PDG " << particle->GetPdgCode() <<
" unknown!";
94 particle->Vx() * 10., particle->Vy() * 10., particle->Vz() * 10.);
95 G4ThreeVector mom(particle->Px() * 1000., particle->Py() * 1000., particle->Pz() * 1000.);
97 particle->GetPolarisation(polVect);
98 G4ThreeVector pol(polVect.X(), polVect.Y(), polVect.Z());
99 G4double tim = particle->T() * 10.e9;
100 G4double ek = particle->Ek() * 1000.;
101 G4DynamicParticle dynParticle(particleDefinition, mom.unit(), ek);
102 G4Track* tempTrack = fastStep.CreateSecondaryTrack(dynParticle, pos, tim,
false);
103 tempTrack->SetTouchableHandle(fastTrack.GetPrimaryTrack()->GetTouchableHandle());
104 addedParticleIndex++;
108 LOG(debug) <<
"FairFastSimModel::DoIt() moving particle " << gMC->GetStack()->GetCurrentTrackNumber() <<
" (pos #"
109 << movedParticleIndex <<
").";
110 if (movedParticleIndex != -1) {
111 TParticle* particle = (TParticle*)particles->At(movedParticleIndex);
113 LOG(debug) <<
"FAST SIM (moving particle to <" << particle->Vx() <<
"," << particle->Vy() <<
","
114 << particle->Vz() <<
"," << particle->T() <<
"> with p=<" << particle->Px() <<
"," << particle->Py()
115 <<
"," << particle->Pz() <<
"," << particle->Ek() <<
">)";
117 G4ThreeVector pos(particle->Vx() * 10., particle->Vy() * 10., particle->Vz() * 10.);
118 G4ThreeVector mom(particle->Px() * 1000., particle->Py() * 1000., particle->Pz() * 1000.);
119 G4ThreeVector pol(0., 0., 0.);
120 G4double tim = particle->T() * 10.e9;
122 G4double ek = particle->Ek() * 1000.;
124 fastStep.SetPrimaryTrackFinalPosition(pos,
false);
125 fastStep.SetPrimaryTrackFinalTime(tim);
126 fastStep.SetPrimaryTrackFinalProperTime(tim);
127 fastStep.SetPrimaryTrackFinalMomentum(mom,
false);
128 fastStep.SetPrimaryTrackFinalKineticEnergy(ek);
131 fastStep.SetPrimaryTrackFinalPolarization(pol,
false);
132 fastStep.SetPrimaryTrackPathLength(len);
136 particle->Vx(), particle->Vy(), particle->Vz(), particle->T());
139 gGeoManager->SetCurrentPoint(particle->Vx(), particle->Vy(), particle->Vz());
virtual G4bool IsApplicable([[gnu::unused]] const G4ParticleDefinition &)
virtual G4bool ModelTrigger([[gnu::unused]] const G4FastTrack &)
FairFastSimModel(G4String, G4Region *)
virtual void DoIt(const G4FastTrack &, G4FastStep &)
TGeoTrack * GetCurrentTrk()
static FairMCApplication * Instance()
static FairTrajFilter * Instance()