1 #include "TauolaHepMC3Particle.h"
4 #include "HepMC3/GenVertex.h"
5 #include "HepMC3/Print.h"
15 TauolaHepMC3Particle::~TauolaHepMC3Particle(){
91 GenVertexPtr production_vertex = part->end_vertex();
92 GenVertexPtr orig_production_vertex = production_vertex;
97 if(!production_vertex){
98 production_vertex = make_shared<GenVertex>();
99 FourVector point = part->production_vertex()->position();
100 production_vertex->set_position(point);
101 part->parent_event()->add_vertex(production_vertex);
105 vector<TauolaParticle*>::iterator mother_itr;
106 for(mother_itr = mothers.begin(); mother_itr != mothers.end();
112 if(moth->end_vertex()!=orig_production_vertex)
113 Log::Fatal(
"Mother production_vertices point to difference places. Can not override. Please delete vertices first.",1);
115 production_vertex->add_particle_in(moth);
122 production_vertex->add_particle_out(
m_particle);
129 Log::Fatal(
"New particle needs the event set before it's daughters can be added",2);
132 if(daughters.size()>0){
137 GenParticlePtr first_daughter;
140 GenVertexPtr end_vertex;
141 end_vertex=first_daughter->production_vertex();
142 GenVertexPtr orig_end_vertex = end_vertex;
145 end_vertex = make_shared<GenVertex>();
146 m_particle->parent_event()->add_vertex(end_vertex);
150 vector<TauolaParticle*>::iterator daughter_itr;
151 for(daughter_itr = daughters.begin(); daughter_itr != daughters.end();
158 if(daug->production_vertex()!=orig_end_vertex)
159 Log::Fatal(
"Daughter production_vertices point to difference places. Can not override. Please delete vertices first.",3);
161 end_vertex->add_particle_out(daug);
170 for(
auto p:
m_particle->production_vertex()->particles_in() ) {
180 for(
auto p:
m_particle->end_vertex()->particles_out() ) {
195 for(ConstGenParticlePtr p:
m_particle->end_vertex()->particles_in() ) {
196 sum += p->momentum();
199 for(ConstGenParticlePtr p:
m_particle->end_vertex()->particles_out() ) {
200 sum -= p->momentum();
203 if( sum.length() > Tauola::momentum_conservation_threshold ) {
204 Log::Warning()<<
"Momentum not conserved in the vertex:"<<endl;
243 double lifetime = Tauola::tau_lifetime * (-log( Tauola::randomDouble() ));
244 FourVector tau_momentum =
m_particle->momentum();
246 double mass = sqrt(abs( tau_momentum.e()*tau_momentum.e()
247 - tau_momentum.px()*tau_momentum.px()
248 - tau_momentum.py()*tau_momentum.py()
249 - tau_momentum.pz()*tau_momentum.pz()
253 FourVector previous_position =
m_particle->production_vertex()->position();
256 FourVector new_position(previous_position.x()+tau_momentum.px()/mass*lifetime,
257 previous_position.y()+tau_momentum.py()/mass*lifetime,
258 previous_position.z()+tau_momentum.pz()/mass*lifetime,
259 previous_position.t()+tau_momentum.e() /mass*lifetime);
262 m_particle->end_vertex()->set_position(new_position);
268 if(!p->end_vertex())
return;
271 for(
auto pp: p->end_vertex()->particles_out() ) {
272 if( !pp->end_vertex() )
continue;
282 int pdg_id,
int status,
double mass,
283 double px,
double py,
double pz,
double e){
286 new_particle->
getHepMC3()->set_pid(pdg_id);
287 new_particle->
getHepMC3()->set_status(status);
288 new_particle->
getHepMC3()->set_generated_mass(mass);
290 FourVector momentum(px,py,pz,e);
291 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)