1 #include "TauolaHepMC3Particle.h"
4 #include "HepMC3/GenVertex.h"
5 #include "HepMC3/Print.h"
15 TauolaHepMC3Particle::~TauolaHepMC3Particle(){
57 std::vector<TauolaParticle*>::iterator dIter = daughters.begin();
59 for(; dIter != daughters.end(); dIter++)
64 while(
m_particle->end_vertex()->particles_out().size())
66 m_particle->end_vertex()->remove_particle_out(
m_particle->end_vertex()->particles_out().front());
73 for(
unsigned int i=0;i<daughters.size();i++)
88 GenVertexPtr production_vertex = part->end_vertex();
89 GenVertexPtr orig_production_vertex = production_vertex;
94 if(!production_vertex){
95 production_vertex = make_shared<GenVertex>();
96 FourVector point = part->production_vertex()->position();
97 production_vertex->set_position(point);
98 part->parent_event()->add_vertex(production_vertex);
102 vector<TauolaParticle*>::iterator mother_itr;
103 for(mother_itr = mothers.begin(); mother_itr != mothers.end();
109 if(moth->end_vertex()!=orig_production_vertex)
110 Log::Fatal(
"Mother production_vertices point to difference places. Can not override. Please delete vertices first.",1);
112 production_vertex->add_particle_in(moth);
118 production_vertex->add_particle_out(
m_particle);
125 Log::Fatal(
"New particle needs the event set before it's daughters can be added",2);
128 if(daughters.size()>0){
133 GenParticlePtr first_daughter;
136 GenVertexPtr end_vertex;
137 end_vertex=first_daughter->production_vertex();
138 GenVertexPtr orig_end_vertex = end_vertex;
141 end_vertex = make_shared<GenVertex>();
142 m_particle->parent_event()->add_vertex(end_vertex);
146 vector<TauolaParticle*>::iterator daughter_itr;
147 for(daughter_itr = daughters.begin(); daughter_itr != daughters.end();
154 if(daug->production_vertex()!=orig_end_vertex)
155 Log::Fatal(
"Daughter production_vertices point to difference places. Can not override. Please delete vertices first.",3);
157 end_vertex->add_particle_out(daug);
166 for(
auto p:
m_particle->production_vertex()->particles_in() ) {
176 for(
auto p:
m_particle->end_vertex()->particles_out() ) {
191 for(ConstGenParticlePtr p:
m_particle->end_vertex()->particles_in() ) {
192 sum += p->momentum();
195 for(ConstGenParticlePtr p:
m_particle->end_vertex()->particles_out() ) {
196 sum -= p->momentum();
199 if( sum.length() > Tauola::momentum_conservation_threshold ) {
200 Log::Warning()<<
"Momentum not conserved in the vertex:"<<endl;
239 double lifetime = Tauola::tau_lifetime * (-log( Tauola::randomDouble() ));
240 FourVector tau_momentum =
m_particle->momentum();
242 double mass = sqrt(abs( tau_momentum.e()*tau_momentum.e()
243 - tau_momentum.px()*tau_momentum.px()
244 - tau_momentum.py()*tau_momentum.py()
245 - tau_momentum.pz()*tau_momentum.pz()
249 FourVector previous_position =
m_particle->production_vertex()->position();
252 FourVector new_position(previous_position.x()+tau_momentum.px()/mass*lifetime,
253 previous_position.y()+tau_momentum.py()/mass*lifetime,
254 previous_position.z()+tau_momentum.pz()/mass*lifetime,
255 previous_position.t()+tau_momentum.e() /mass*lifetime);
258 m_particle->end_vertex()->set_position(new_position);
264 if(!p->end_vertex())
return;
267 for(
auto pp: p->end_vertex()->particles_out() ) {
268 if( !pp->end_vertex() )
continue;
271 pp->end_vertex()->set_position(pos);
277 int pdg_id,
int status,
double mass,
278 double px,
double py,
double pz,
double e){
281 new_particle->
getHepMC3()->set_pid(pdg_id);
282 new_particle->
getHepMC3()->set_status(status);
283 new_particle->
getHepMC3()->set_generated_mass(mass);
285 FourVector momentum(px,py,pz,e);
286 new_particle->
getHepMC3()->set_momentum(momentum);
Interface to GenParticle objects.
Abstract base class for particle in the event. This class also handles boosting.
static void Fatal(string text, unsigned short int code=0)
static void RevertOutput()
static void RedirectOutput(void(*func)(), ostream &where=*out)
std::vector< TauolaParticle * > getDaughters()
void setStatus(int statu)
void setMothers(std::vector< TauolaParticle * > mothers)
GenParticlePtr getHepMC3()
std::vector< TauolaParticle * > m_mothers
std::vector< TauolaParticle * > m_created_particles
void setDaughters(std::vector< TauolaParticle * > daughters)
void checkMomentumConservation()
void recursiveSetPosition(GenParticlePtr p, FourVector pos)
std::vector< TauolaParticle * > getMothers()
TauolaHepMC3Particle * createNewParticle(int pdg_id, int status, double mass, double px, double py, double pz, double e)
GenParticlePtr m_particle
void setMass(double mass)
std::vector< TauolaParticle * > m_daughters
void setPdgID(int pdg_id)