1#include "HepMC3/GenEvent.h"
2#include "HepMC3/GenVertex.h"
3#include "HepMC3/GenParticle.h"
4#include "HepMC3/Print.h"
5#include "PhotosHepMC3Particle.h"
62 GenVertexPtr production_vertex = part->end_vertex();
63 GenVertexPtr orig_production_vertex = production_vertex;
65 if(!production_vertex){
66 production_vertex = make_shared<GenVertex>();
67 part->parent_event()->add_vertex(production_vertex);
72 for(mother_itr = mothers.begin(); mother_itr != mothers.end();
78 if(moth->end_vertex()!=orig_production_vertex)
79 Log::Fatal(
"PhotosHepMC3Particle::setMothers(): Mother production_vertices point to difference places. Can not override. Please delete vertices first.",1);
81 production_vertex->add_particle_in(moth);
90 production_vertex->add_particle_out(
m_particle);
104 Log::Fatal(
"PhotosHepMC3Particle::addDaughter(): This method assumes an end_vertex exists. Maybe you really want to use setDaughters.",2);
107 m_particle->end_vertex()->add_particle_out(daugh);
114 Log::Fatal(
"PhotosHepMC3Particle::setDaughters(): New particle needs the event set before it's daughters can be added",3);
119 if(daughters.size()>0){
122 GenParticlePtr first_daughter;
125 GenVertexPtr end_vertex;
126 end_vertex=first_daughter->production_vertex();
127 GenVertexPtr orig_end_vertex = end_vertex;
130 end_vertex = make_shared<GenVertex>();
131 m_particle->parent_event()->add_vertex(end_vertex);
136 for(daughter_itr = daughters.begin(); daughter_itr != daughters.end();
143 if(daug->production_vertex()!=orig_end_vertex)
144 Log::Fatal(
"PhotosHepMC3Particle::setDaughters(): Daughter production_vertices point to difference places. Can not override. Please delete vertices first.",4);
146 end_vertex->add_particle_out(daug);
157 for(
auto p:
m_particle->production_vertex()->particles_in() ) {
168 for(
auto p:
m_particle->end_vertex()->particles_out() ) {
187 std::vector<PhotosParticle*> daughters =
getDaughters();
200 std::vector<PhotosParticle*> daughters2 =
m_decay_products[i]->getDaughters();
203 for(
unsigned int j=0;j<daughters2.size();j++)
227 for(ConstGenParticlePtr p:
m_particle->end_vertex()->particles_in() ) {
230 sum += p->momentum();
233 for(ConstGenParticlePtr p:
m_particle->end_vertex()->particles_out() ) {
236 sum -= p->momentum();
240 Log::Warning()<<
"Momentum not conserved in the vertex:"<<endl;
276 int pdg_id,
int status,
double mass,
277 double px,
double py,
double pz,
double e){
280 new_particle->
getHepMC3()->set_pid(pdg_id);
281 new_particle->
getHepMC3()->set_status(status);
282 new_particle->
getHepMC3()->set_generated_mass(mass);
284 FourVector momentum(px,py,pz,e);
285 new_particle->
getHepMC3()->set_momentum(momentum);
295 Log::Warning()<<
"PhotosHepMC3Particle::createHistoryEntry(): particle without production vertex."<<endl;
299 GenParticlePtr part = make_shared<GenParticle>(*
m_particle);
301 m_particle->production_vertex()->add_particle_out(part);
308 Log::Error()<<
"PhotosHepMC3Particle::createSelfDecayVertex: particle already has end vertex!"<<endl;
314 Log::Error()<<
"PhotosHepMC3Particle::createSelfDecayVertex: particle not in the HepMC event!"<<endl;
320 GenVertexPtr v = make_shared<GenVertex>();
323 v->set_position(
m_particle->production_vertex()->position() );
326 v->add_particle_out(outgoing);
328 getHepMC3()->parent_event()->add_vertex(v);
static void Fatal(string text, unsigned short int code=0)
static void RevertOutput()
static void RedirectOutput(void(*func)(), ostream &where=*out)
void setMothers(std::vector< PhotosParticle * > mothers)
void setDaughters(std::vector< PhotosParticle * > daughters)
bool checkMomentumConservation()
void setStatus(int statu)
GenParticlePtr getHepMC3()
std::vector< PhotosParticle * > getAllDecayProducts()
void clear(std::vector< PhotosParticle * > v)
std::vector< PhotosParticle * > getDaughters()
void createSelfDecayVertex(PhotosParticle *out)
void addDaughter(PhotosParticle *daughter)
std::vector< PhotosParticle * > m_mothers
GenParticlePtr m_particle
std::vector< PhotosParticle * > m_created_particles
void setMass(double mass)
PhotosHepMC3Particle * createNewParticle(int pdg_id, int status, double mass, double px, double py, double pz, double e)
void createHistoryEntry()
std::vector< PhotosParticle * > m_daughters
std::vector< PhotosParticle * > m_decay_products
std::vector< PhotosParticle * > getMothers()
void setPdgID(int pdg_id)
static bool isStatusCodeIgnored(int status)
static int historyEntriesStatus
static double momentum_conservation_threshold