76 fEvent =
new HepMC::GenEvent();
88 HepMC::GenParticle*
particle =
new HepMC::GenParticle(momentum, pdg_id);
89 particle->suggest_barcode(partID);
95 HepMC::GenVertex* endvertex =
new HepMC::GenVertex(endpos);
98 endvertex->suggest_barcode(-partID);
99 endvertex->add_particle_in(particle);
100 fEvent->add_vertex(endvertex);
106 HepMC::GenParticle* mother =
fEvent->barcode_to_particle(motherID);
112 HepMC::GenVertex* motherendvtx = mother->end_vertex();
113 HepMC::FourVector mp0 = motherendvtx->position();
116 if( motherendpos.x() == prodpos.
x() &&
117 motherendpos.y() == prodpos.
y() &&
118 motherendpos.z() == prodpos.
z() )
120 motherendvtx->add_particle_out(particle);
131 for(HepMC::GenVertex::particles_out_const_iterator
132 it=motherendvtx->particles_out_const_begin();
133 it!=motherendvtx->particles_out_const_end();
it++)
135 if((*it)->pdg_id()==-999999)
137 HepMC::FourVector dp0 = (*it)->end_vertex()->position();
140 if( dummypos.
x() == prodpos.
x() &&
141 dummypos.
y() == prodpos.
y() &&
142 dummypos.
z() == prodpos.
z() )
144 (*it)->end_vertex()->add_particle_out(particle);
156 HepMC::GenVertex* childvtx =
new HepMC::GenVertex(prodpos);
157 childvtx->add_particle_out(particle);
162 childvtx->suggest_barcode(-500000-partID);
163 fEvent->add_vertex(childvtx);
165 HepMC::GenParticle* dummypart =
171 dummypart->suggest_barcode(500000+partID);
172 childvtx->add_particle_in(dummypart);
173 motherendvtx->add_particle_out(dummypart);
187 while ( !((mother->end_vertex()->position().t()>prodpos.
t()) &&
188 (mother->production_vertex()->position().t()<prodpos.
t())) )
191 if (segment == number_of_segments)
192 G4cerr <<
"Problem!!!! Time coordinates incompatible!" <<
G4endl;
194 mother =
fEvent->barcode_to_particle(segment*10000000 + motherID);
200 HepMC::GenVertex* childvtx =
new HepMC::GenVertex(prodpos);
201 childvtx->add_particle_out(particle);
202 fEvent->add_vertex(childvtx);
206 HepMC::GenVertex* orig_mother_end_vtx = mother->end_vertex();
207 orig_mother_end_vtx->remove_particle(mother);
211 childvtx->add_particle_in(mother);
217 HepMC::GenParticle* mothertwo =
new HepMC::GenParticle(*mother);
219 + mother->barcode());
224 *10000000 - mother->barcode());
225 childvtx->suggest_barcode(-mother->barcode());
229 childvtx->add_particle_out(mothertwo);
233 orig_mother_end_vtx->add_particle_in(mothertwo);
247 G4cerr <<
"barcode " << motherID <<
" mother not there! "<<
G4endl;
252 HepMC::GenVertex* primaryvtx =
new HepMC::GenVertex(prodpos);
253 primaryvtx->add_particle_out(particle);
254 fEvent->add_vertex(primaryvtx);
281 G4cout << offset <<
"--- barcode: " << particle->barcode() <<
" pdg: "
282 << particle->pdg_id() <<
" energy: " << particle->momentum().e()
283 <<
" production vertex: "
284 << particle->production_vertex()->position().x() <<
", "
285 << particle->production_vertex()->position().y() <<
", "
286 << particle->production_vertex()->position().z() <<
", "
287 << particle->production_vertex()->position().t()
290 for(HepMC::GenVertex::particles_out_const_iterator
291 it=particle->end_vertex()->particles_out_const_begin();
292 it!=particle->end_vertex()->particles_out_const_end();
297 G4int curr = std::fmod(
double((*it)->barcode()),10000000.);
298 G4int part = std::fmod(
double(particle->barcode()),10000000.);