9 #include "GaudiKernel/ISvcLocator.h"
10 #include "GaudiKernel/Bootstrap.h"
13 #include "G4PrimaryParticle.hh"
14 #include "G4Proton.hh"
15 #include "G4Neutron.hh"
17 #include "G4Lambda.hh"
18 #include "G4Geantino.hh"
19 #include "G4ChargedGeantino.hh"
20 #include "G4ParticleTable.hh"
29 : G4VFastSimulationModel(
name)
30 , m_verboseLevel(verboseLevel)
31 , m_FwdTrSvcName(FwdTrSvcName)
33 ISvcLocator* svcLocator = Gaudi::svcLocator();
34 if (svcLocator->service(FwdTrSvcName,
m_fwdSvc).isFailure()) {
36 description <<
"ForwardTransportModel::ForwardTransportModel Attempt to access ForwardTransportSvc failed.";
37 G4Exception(
"ForwardTransportModel",
"ForwardTransportModel01", FatalException,
description);
54 const G4Track *
track = fastTrack.GetPrimaryTrack();
55 const G4DynamicParticle *
dp =
track->GetDynamicParticle();
57 const G4PrimaryParticle *pp =
dp->GetPrimaryParticle();
61 ( pp->GetUserInformation() );
72 G4cout <<
"ForwardTransportModel::DoIt" << G4endl;
75 const int pdgcode = fastTrack.GetPrimaryTrack()->GetDefinition()->GetPDGEncoding();
76 const G4ThreeVector& initialMomentum = fastTrack.GetPrimaryTrack()->GetMomentum();
82 const double charge = fastTrack.GetPrimaryTrack()->GetDefinition()->GetPDGCharge();
83 const G4ThreeVector& initialPosition = fastTrack.GetPrimaryTrack()->GetPosition();
84 const double time = fastTrack.GetPrimaryTrack()->GetGlobalTime();
85 const double energy = fastTrack.GetPrimaryTrack()->GetTotalEnergy();
88 G4cout <<
" pdgCode: " << pdgcode <<
" energy[GeV]: " <<
energy/
CLHEP::GeV <<
" charge: " <<
charge << G4endl;
98 G4cout << fParticle << G4endl;
102 if (!isTransported) {
119 HepMC::GenEvent* gEvent = (
part) ?
const_cast<HepMC::GenEvent*
>(
part->parent_event()) :
nullptr;
122 description <<
"ForwardTransportModel::DoIt Cannot get HepMC::GenEvent pointer";
123 G4Exception(
"ForwardTransportModel",
"ForwardTransportModel03", FatalException,
description);
129 postTransportPosition.x(),
130 postTransportPosition.y(),
131 postTransportPosition.z(),
133 gEvent->add_vertex(gVertex);
134 gVertex->add_particle_in(
part);
137 postTransportMomentum.x(),
138 postTransportMomentum.y(),
139 postTransportMomentum.z(),
143 gVertex->add_particle_out(gParticle);
147 fastStep.SetNumberOfSecondaryTracks(1);
149 const G4ParticleDefinition *aParticleDefinition{};
151 if (pdgcode == MC::GEANTINOPLUS) {
152 aParticleDefinition = G4ChargedGeantino::Definition();
154 if (pdgcode == MC::GEANTINO0) {
155 aParticleDefinition = G4Geantino::GeantinoDefinition();
157 if (!aParticleDefinition) {
159 G4ParticleTable *ptable = G4ParticleTable::GetParticleTable();
161 aParticleDefinition = ptable->FindParticle(pdgcode);
164 G4DynamicParticle dp2(aParticleDefinition,
energy, postTransportMomentum);
168 std::unique_ptr<ISF::ISFParticle> postTransportISP{};
173 const int status = gParticle->status();
174 auto tBinding = std::make_unique<ISF::TruthBinding>(gParticle);
176 const Amg::Vector3D pos(postTransportPosition.x(), postTransportPosition.y(), postTransportPosition.z());
177 const Amg::Vector3D mom(postTransportMomentum.x(), postTransportMomentum.y(), postTransportMomentum.z());
178 postTransportISP = std::make_unique<ISF::ISFParticle>(
pos,
191 std::unique_ptr<PrimaryParticleInformation> ppi2 = std::make_unique<PrimaryParticleInformation>(gParticle,postTransportISP.release());
192 std::unique_ptr<G4PrimaryParticle> pp2 = std::make_unique<G4PrimaryParticle>(
194 postTransportMomentum.x(),
195 postTransportMomentum.y(),
196 postTransportMomentum.z());
197 pp2->SetUserInformation(ppi2.release());
198 dp2.SetPrimaryParticle(pp2.release());
200 G4Track* postTransportTrack =
201 fastStep.CreateSecondaryTrack(
203 postTransportPosition,
206 if (!postTransportTrack) {
208 description <<
"ForwardTransportModel::DoIt Failed to create secondary G4Track.";
209 G4Exception(
"ForwardTransportModel",
"ForwardTransportModel04", FatalException,
description);
212 fastStep.ProposePrimaryTrackFinalPosition(postTransportPosition,
false);
213 fastStep.SetPrimaryTrackFinalMomentum(postTransportMomentum,
false);
214 fastStep.KillPrimaryTrack();
221 HepMC::GenEvent* gEvent = (
part) ?
const_cast<HepMC::GenEvent*
>(
part->parent_event()) :
nullptr;
224 description <<
"ForwardTransportModel::KillPrimaryTrack Cannot get HepMC::GenEvent pointer";
225 G4Exception(
"ForwardTransportModel",
"ForwardTransportModel02", FatalException,
description);
228 const G4ThreeVector& initialPosition = fastTrack.GetPrimaryTrack()->GetPosition();
235 fastTrack.GetPrimaryTrack()->GetGlobalTime()));
242 gEvent->add_vertex(gVertex);
243 gVertex->add_particle_in(
part);
245 fastStep.KillPrimaryTrack();
246 fastStep.ProposePrimaryTrackPathLength(0.0);
247 fastStep.ProposeTotalEnergyDeposited(fastTrack.GetPrimaryTrack()->GetTotalEnergy());