77 fEvent =
new HepMC::GenEvent();
89 HepMC::GenParticle* particle =
new HepMC::GenParticle(momentum, pdg_id);
90 particle->suggest_barcode(partID);
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);
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);
220 + mother->barcode());
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);
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);
282 G4cout << offset <<
"--- barcode: " << particle->barcode() <<
" pdg: "
283 << particle->pdg_id() <<
" energy: " << particle->momentum().e()
284 <<
" production vertex: "
285 << particle->production_vertex()->position().x() <<
", "
286 << particle->production_vertex()->position().y() <<
", "
287 << particle->production_vertex()->position().z() <<
", "
288 << particle->production_vertex()->position().t()
291 for(HepMC::GenVertex::particles_out_const_iterator
292 it=particle->end_vertex()->particles_out_const_begin();
293 it!=particle->end_vertex()->particles_out_const_end();
298 G4int curr = std::fmod(
double((*it)->barcode()),10000000.);
299 G4int part = std::fmod(
double(particle->barcode()),10000000.);
static MCTruthManager * GetInstance()
void AddParticle(G4LorentzVector &, G4LorentzVector &, G4LorentzVector &, G4int, G4int, G4int, G4bool)
virtual ~MCTruthManager()
Definition of the MCTruthManager class.
void PrintTree(HepMC::GenParticle *, G4String)
G4GLOB_DLL std::ostream G4cout
std::map< G4int, G4int > fSegmentations
static MCTruthManager * instance
std::vector< G4int > fPrimarybarcodes
G4GLOB_DLL std::ostream G4cerr
CLHEP::HepLorentzVector G4LorentzVector