52 std::vector<TauolaParticle*>::iterator dIter = daughters.begin();
54 for(; dIter != daughters.end(); dIter++)
59 while(
m_particle->end_vertex()->particles_out_size())
61 HepMC::GenParticle *p =
m_particle->end_vertex()->remove_particle(*(
m_particle->end_vertex()->particles_out_const_begin()));
70 for(
unsigned int i=0;i<daughters.size();i++)
81 HepMC::GenParticle * part;
85 HepMC::GenVertex * production_vertex = part->end_vertex();
86 HepMC::GenVertex * orig_production_vertex = production_vertex;
91 if(!production_vertex){
92 production_vertex =
new HepMC::GenVertex();
93 HepMC::FourVector point = part->production_vertex()->position();
94 production_vertex->set_position(point);
95 part->parent_event()->add_vertex(production_vertex);
99 vector<TauolaParticle*>::iterator mother_itr;
100 for(mother_itr = mothers.begin(); mother_itr != mothers.end();
103 HepMC::GenParticle * moth;
106 if(moth->end_vertex()!=orig_production_vertex)
107 Log::Fatal(
"Mother production_vertices point to difference places. Can not override. Please delete vertices first.",1);
109 production_vertex->add_particle_in(moth);
115 production_vertex->add_particle_out(
m_particle);
122 Log::Fatal(
"New particle needs the event set before it's daughters can be added",2);
125 if(daughters.size()>0){
130 HepMC::GenParticle * first_daughter;
133 HepMC::GenVertex * end_vertex;
134 end_vertex=first_daughter->production_vertex();
135 HepMC::GenVertex * orig_end_vertex = end_vertex;
138 end_vertex =
new HepMC::GenVertex();
139 m_particle->parent_event()->add_vertex(end_vertex);
143 vector<TauolaParticle*>::iterator daughter_itr;
144 for(daughter_itr = daughters.begin(); daughter_itr != daughters.end();
147 HepMC::GenParticle * daug;
151 if(daug->production_vertex()!=orig_end_vertex)
152 Log::Fatal(
"Daughter production_vertices point to difference places. Can not override. Please delete vertices first.",3);
154 end_vertex->add_particle_out(daug);
199 double sumpx = 0, sumpy = 0, sumpz = 0, sume = 0;
200 for( HepMC::GenVertex::particles_in_const_iterator part1 =
m_particle->end_vertex()->particles_in_const_begin();
201 part1 !=
m_particle->end_vertex()->particles_in_const_end(); part1++ ){
203 sumpx += (*part1)->momentum().px();
204 sumpy += (*part1)->momentum().py();
205 sumpz += (*part1)->momentum().pz();
206 sume += (*part1)->momentum().e();
209 for( HepMC::GenVertex::particles_out_const_iterator part2 =
m_particle->end_vertex()->particles_out_const_begin();
210 part2 !=
m_particle->end_vertex()->particles_out_const_end(); part2++ ){
212 sumpx -= (*part2)->momentum().px();
213 sumpy -= (*part2)->momentum().py();
214 sumpz -= (*part2)->momentum().pz();
215 sume -= (*part2)->momentum().e();
218 if( sqrt( sumpx*sumpx + sumpy*sumpy + sumpz*sumpz + sume*sume) > Tauola::momentum_conservation_threshold ) {
219 Log::Warning()<<
"Momentum not conserved in the vertex:"<<endl;
258 double lifetime = Tauola::tau_lifetime * (-log( Tauola::randomDouble() ));
259 HepMC::FourVector tau_momentum =
m_particle->momentum();
261 double mass = sqrt(abs( tau_momentum.e()*tau_momentum.e()
262 - tau_momentum.px()*tau_momentum.px()
263 - tau_momentum.py()*tau_momentum.py()
264 - tau_momentum.pz()*tau_momentum.pz()
268 HepMC::FourVector previous_position =
m_particle->production_vertex()->position();
271 HepMC::FourVector new_position(previous_position.x()+tau_momentum.px()/mass*lifetime,
272 previous_position.y()+tau_momentum.py()/mass*lifetime,
273 previous_position.z()+tau_momentum.pz()/mass*lifetime,
274 previous_position.t()+tau_momentum.e() /mass*lifetime);
277 m_particle->end_vertex()->set_position(new_position);
Abstract base class for particle in the event. This class also handles boosting.
std::vector< TauolaParticle * > getDaughters()
HepMC::GenParticle * getHepMC()
void recursiveSetPosition(HepMC::GenParticle *p, HepMC::FourVector pos)
void setStatus(int statu)
void setMothers(std::vector< TauolaParticle * > mothers)
HepMC::GenParticle * m_particle
std::vector< TauolaParticle * > m_mothers
TauolaHepMCParticle * createNewParticle(int pdg_id, int status, double mass, double px, double py, double pz, double e)
std::vector< TauolaParticle * > m_created_particles
void setDaughters(std::vector< TauolaParticle * > daughters)
void checkMomentumConservation()
std::vector< TauolaParticle * > getMothers()
void setMass(double mass)
std::vector< TauolaParticle * > m_daughters
void setPdgID(int pdg_id)