65 {
66
67
69 G4cout <<"ForwardTransportModel::DoIt" << G4endl;
70 }
71
72 const int pdgcode = fastTrack.GetPrimaryTrack()->GetDefinition()->GetPDGEncoding();
73 const G4ThreeVector& initialMomentum = fastTrack.GetPrimaryTrack()->GetMomentum();
74 if (!
m_fwdSvc->selectedParticle(initialMomentum, pdgcode)) {
76 return;
77 }
78
79 const double charge = fastTrack.GetPrimaryTrack()->GetDefinition()->GetPDGCharge();
80 const G4ThreeVector& initialPosition = fastTrack.GetPrimaryTrack()->GetPosition();
81 const double time = fastTrack.GetPrimaryTrack()->GetGlobalTime();
82 const double energy = fastTrack.GetPrimaryTrack()->GetTotalEnergy();
83
85 G4cout <<
" pdgCode: " << pdgcode <<
" energy[GeV]: " <<
energy/CLHEP::GeV <<
" charge: " <<
charge << G4endl;
86 }
87 ForwardTracker::Particle fParticle = ForwardTracker::Particle(initialPosition.x()/CLHEP::m,
88 initialPosition.y()/CLHEP::m,
89 initialPosition.z()/CLHEP::m,
90 initialMomentum.x()/CLHEP::GeV,
91 initialMomentum.y()/CLHEP::GeV,
92 initialMomentum.z()/CLHEP::GeV,
95 G4cout << fParticle << G4endl;
96 }
97
98 bool isTransported =
m_fwdTrack.TrackParticle(fParticle);
99 if (!isTransported) {
101 return;
102 }
103
106 }
107
108 ForwardTracker::Point fPos =
m_fwdTrack.fPos();
109 G4ThreeVector postTransportPosition(fPos.
x()*CLHEP::m, fPos.
y()*CLHEP::m, fPos.
z()*CLHEP::m);
110
111 ForwardTracker::Point fMom =
m_fwdTrack.fMom();
112 G4ThreeVector postTransportMomentum(fMom.
x()*CLHEP::GeV, fMom.
y()*CLHEP::GeV, fMom.
z()*CLHEP::GeV);
113
116 HepMC::GenEvent* gEvent = (
part) ?
const_cast<HepMC::GenEvent*
>(
part->parent_event()) :
nullptr;
117 if (!gEvent) {
119 description <<
"ForwardTransportModel::DoIt Cannot get HepMC::GenEvent pointer";
120 G4Exception(
"ForwardTransportModel",
"ForwardTransportModel03", FatalException,
description);
121 abort();
122 }
123
125 HepMC::FourVector(
126 postTransportPosition.x(),
127 postTransportPosition.y(),
128 postTransportPosition.z(),
129 time));
130 gEvent->add_vertex(gVertex);
131 gVertex->add_particle_in(part);
133 HepMC::FourVector(
134 postTransportMomentum.x(),
135 postTransportMomentum.y(),
136 postTransportMomentum.z(),
137 energy),
138 pdgcode,
140 gVertex->add_particle_out(gParticle);
142
143
144 fastStep.SetNumberOfSecondaryTracks(1);
145
146 const G4ParticleDefinition *aParticleDefinition{};
149 aParticleDefinition = G4ChargedGeantino::Definition();
150 }
152 aParticleDefinition = G4Geantino::GeantinoDefinition();
153 }
154 if (!aParticleDefinition) {
156 G4ParticleTable *ptable = G4ParticleTable::GetParticleTable();
157 if (ptable) {
158 aParticleDefinition = ptable->FindParticle(pdgcode);
159 }
160 }
161 G4DynamicParticle dp2(aParticleDefinition, energy, postTransportMomentum);
162
163
165 std::unique_ptr<ISF::ISFParticle> postTransportISP{};
166 if (initialISP) {
167
170 const int status = gParticle->status();
171 auto tBinding = std::make_unique<ISF::TruthBinding>(gParticle);
173 const Amg::Vector3D pos(postTransportPosition.x(), postTransportPosition.y(), postTransportPosition.z());
174 const Amg::Vector3D mom(postTransportMomentum.x(), postTransportMomentum.y(), postTransportMomentum.z());
175 postTransportISP = std::make_unique<ISF::ISFParticle>(pos,
176 mom,
180 status,
181 time,
182 *initialISP,
183 particleID,
184 pBarcode,
185 tBinding.release(),
186 hmpl.release());
187 }
188 std::unique_ptr<PrimaryParticleInformation> ppi2 = std::make_unique<PrimaryParticleInformation>(gParticle,postTransportISP.release());
189 std::unique_ptr<G4PrimaryParticle> pp2 = std::make_unique<G4PrimaryParticle>(
190 aParticleDefinition,
191 postTransportMomentum.x(),
192 postTransportMomentum.y(),
193 postTransportMomentum.z());
194 pp2->SetUserInformation(ppi2.release());
195 dp2.SetPrimaryParticle(pp2.release());
196
197 G4Track* postTransportTrack =
198 fastStep.CreateSecondaryTrack(
199 dp2,
200 postTransportPosition,
201 time,
202 false);
203 if (!postTransportTrack) {
205 description <<
"ForwardTransportModel::DoIt Failed to create secondary G4Track.";
206 G4Exception(
"ForwardTransportModel",
"ForwardTransportModel04", FatalException,
description);
207 abort();
208 }
209 fastStep.ProposePrimaryTrackFinalPosition(postTransportPosition, false);
210 fastStep.ProposePrimaryTrackFinalMomentumDirection(postTransportMomentum, false);
211 fastStep.KillPrimaryTrack();
212}
double charge(const T &p)
PrimaryParticleInformation * getPrimaryParticleInformation(const G4FastTrack &fastTrack) const
void KillPrimaryTrack(const G4FastTrack &, G4FastStep &)
double charge() const
charge of the particle
int pdgCode() const
PDG value.
double mass() const
mass of the particle
const ISF::ISFParticle * GetISFParticle() const
return a pointer to the ISFParticle used to create the G4PrimaryParticle
HepMC::ConstGenParticlePtr GetHepMCParticle() const
return a pointer to the GenParticle used to create the G4PrimaryParticle
Eigen::Matrix< double, 3, 1 > Vector3D
time(flags, cells_name, *args, **kw)
constexpr int SIM_STATUS_INCREMENT
Constant defining the barcode threshold for regenerated particles, i.e. particles surviving an intera...
HepMC::GenVertex * GenVertexPtr
bool suggest_barcode(T &p, int i)
GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), const int i=0)
GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), int pid=0, int status=0)
GenParticle * GenParticlePtr
constexpr int SIM_REGENERATION_INCREMENT
Constant defining the barcode threshold for regenerated particles, i.e. particles surviving an intera...
static const int GEANTINOPLUS
PDG rule 10: Codes 81–100 are reserved for generator-specific pseudoparticles and concepts.
static const int GEANTINO0