89 HepMC::GenParticle* particle =
new HepMC::GenParticle(momentum, pdg_id);
90 particle->suggest_barcode(partID);
93 fSegmentations[partID] = 1;
96 HepMC::GenVertex* endvertex =
new HepMC::GenVertex(endpos);
99 endvertex->suggest_barcode(-partID);
100 endvertex->add_particle_in(particle);
101 fEvent->add_vertex(endvertex);
107 HepMC::GenParticle* mother = fEvent->barcode_to_particle(motherID);
113 HepMC::GenVertex* motherendvtx = mother->end_vertex();
114 HepMC::FourVector mp0 = motherendvtx->position();
117 if( motherendpos.x() == prodpos.
x() &&
118 motherendpos.y() == prodpos.
y() &&
119 motherendpos.z() == prodpos.
z() )
121 motherendvtx->add_particle_out(particle);
132 for(HepMC::GenVertex::particles_out_const_iterator
133 it=motherendvtx->particles_out_const_begin();
134 it!=motherendvtx->particles_out_const_end();it++)
136 if((*it)->pdg_id()==-999999)
138 HepMC::FourVector dp0 = (*it)->end_vertex()->position();
141 if( dummypos.
x() == prodpos.
x() &&
142 dummypos.
y() == prodpos.
y() &&
143 dummypos.
z() == prodpos.
z() )
145 (*it)->end_vertex()->add_particle_out(particle);
157 HepMC::GenVertex* childvtx =
new HepMC::GenVertex(prodpos);
158 childvtx->add_particle_out(particle);
163 childvtx->suggest_barcode(-500000-partID);
164 fEvent->add_vertex(childvtx);
166 HepMC::GenParticle* dummypart =
172 dummypart->suggest_barcode(500000+partID);
173 childvtx->add_particle_in(dummypart);
174 motherendvtx->add_particle_out(dummypart);
183 G4int number_of_segments = fSegmentations[motherID];
188 while ( !((mother->end_vertex()->position().t()>prodpos.
t()) &&
189 (mother->production_vertex()->position().t()<prodpos.
t())) )
192 if (segment == number_of_segments)
193 G4cerr <<
"Problem!!!! Time coordinates incompatible!" <<
G4endl;
195 mother = fEvent->barcode_to_particle(segment*10000000 + motherID);
201 HepMC::GenVertex* childvtx =
new HepMC::GenVertex(prodpos);
202 childvtx->add_particle_out(particle);
203 fEvent->add_vertex(childvtx);
207 HepMC::GenVertex* orig_mother_end_vtx = mother->end_vertex();
208 orig_mother_end_vtx->remove_particle(mother);
212 childvtx->add_particle_in(mother);
218 HepMC::GenParticle* mothertwo =
new HepMC::GenParticle(*mother);
219 mothertwo->suggest_barcode(fSegmentations[motherID]*10000000
220 + mother->barcode());
224 orig_mother_end_vtx->suggest_barcode(-fSegmentations[motherID]
225 *10000000 - mother->barcode());
226 childvtx->suggest_barcode(-mother->barcode());
230 childvtx->add_particle_out(mothertwo);
234 orig_mother_end_vtx->add_particle_in(mothertwo);
238 fSegmentations[motherID] = fSegmentations[motherID]+1;
248 G4cerr <<
"barcode " << motherID <<
" mother not there! "<<
G4endl;
253 HepMC::GenVertex* primaryvtx =
new HepMC::GenVertex(prodpos);
254 primaryvtx->add_particle_out(particle);
255 fEvent->add_vertex(primaryvtx);
259 fPrimarybarcodes.push_back(partID);
G4GLOB_DLL std::ostream G4cerr
CLHEP::HepLorentzVector G4LorentzVector