1 #include "HepMC/GenEvent.h" 
   53     HepMC::GenParticle * part;
 
   57     HepMC::GenVertex * production_vertex = part->end_vertex();
 
   58     HepMC::GenVertex * orig_production_vertex = production_vertex;
 
   60     if(!production_vertex){ 
 
   61       production_vertex = 
new HepMC::GenVertex();
 
   62       part->parent_event()->add_vertex(production_vertex);
 
   66     vector<PhotosParticle*>::iterator mother_itr;
 
   67     for(mother_itr = mothers.begin(); mother_itr != mothers.end();
 
   70       HepMC::GenParticle * moth;
 
   73       if(moth->end_vertex()!=orig_production_vertex)
 
   74         Log::Fatal(
"PhotosHepMCParticle::setMothers(): Mother production_vertices point to difference places. Can not override. Please delete vertices first.",1);
 
   76         production_vertex->add_particle_in(moth);
 
   82     production_vertex->add_particle_out(
m_particle);
 
   96     Log::Fatal(
"PhotosHepMCParticle::addDaughter(): This method assumes an end_vertex exists. Maybe you really want to use setDaughters.",2);
 
   99   m_particle->end_vertex()->add_particle_out(daugh);
 
  106     Log::Fatal(
"PhotosHepMCParticle::setDaughters(): New particle needs the event set before it's daughters can be added",3);
 
  111   if(daughters.size()>0){
 
  114     HepMC::GenParticle * first_daughter;
 
  117     HepMC::GenVertex * end_vertex;
 
  118     end_vertex=first_daughter->production_vertex();
 
  119     HepMC::GenVertex * orig_end_vertex = end_vertex;
 
  122       end_vertex = 
new HepMC::GenVertex();
 
  123       m_particle->parent_event()->add_vertex(end_vertex);
 
  127     vector<PhotosParticle*>::iterator daughter_itr;
 
  128     for(daughter_itr = daughters.begin(); daughter_itr != daughters.end();
 
  131       HepMC::GenParticle * daug;
 
  135       if(daug->production_vertex()!=orig_end_vertex)
 
  136         Log::Fatal(
"PhotosHepMCParticle::setDaughters(): Daughter production_vertices point to difference places. Can not override. Please delete vertices first.",4);
 
  138         end_vertex->add_particle_out(daug);
 
  149     HepMC::GenVertex::particles_in_const_iterator pcle_itr;
 
  150     pcle_itr=
m_particle->production_vertex()->particles_in_const_begin();
 
  152     HepMC::GenVertex::particles_in_const_iterator pcle_itr_end;
 
  153     pcle_itr_end=
m_particle->production_vertex()->particles_in_const_end();
 
  155     for(;pcle_itr != pcle_itr_end; pcle_itr++){
 
  165     HepMC::GenVertex::particles_out_const_iterator pcle_itr;
 
  166     pcle_itr=
m_particle->end_vertex()->particles_out_const_begin();
 
  168     HepMC::GenVertex::particles_out_const_iterator pcle_itr_end;
 
  169     pcle_itr_end=
m_particle->end_vertex()->particles_out_const_end();
 
  171     for(;pcle_itr != pcle_itr_end; pcle_itr++){
 
  190   std::vector<PhotosParticle*> daughters = 
getDaughters();
 
  206     for(
unsigned int j=0;j<daughters2.size();j++)
 
  230   double sumpx = 0, sumpy = 0, sumpz = 0, sume = 0;
 
  231   for( HepMC::GenVertex::particles_in_const_iterator part1 = 
m_particle->end_vertex()->particles_in_const_begin();
 
  232        part1 != 
m_particle->end_vertex()->particles_in_const_end(); part1++ ){
 
  236     sumpx += (*part1)->momentum().px();
 
  237     sumpy += (*part1)->momentum().py();
 
  238     sumpz += (*part1)->momentum().pz();
 
  239     sume  += (*part1)->momentum().e();
 
  242   for( HepMC::GenVertex::particles_out_const_iterator part2 = 
m_particle->end_vertex()->particles_out_const_begin();
 
  243        part2 != 
m_particle->end_vertex()->particles_out_const_end(); part2++ ){
 
  247     sumpx -= (*part2)->momentum().px();
 
  248     sumpy -= (*part2)->momentum().py();
 
  249     sumpz -= (*part2)->momentum().pz();
 
  250     sume  -= (*part2)->momentum().e();
 
  254     Log::Warning()<<
"Momentum not conserved in the vertex:"<<endl;
 
  290                         int pdg_id, 
int status, 
double mass,
 
  291                         double px, 
double py, 
double pz, 
double e){
 
  294   new_particle->
getHepMC()->set_pdg_id(pdg_id);
 
  295   new_particle->
getHepMC()->set_status(status);
 
  296   new_particle->
getHepMC()->set_generated_mass(mass);
 
  298   HepMC::FourVector momentum(px,py,pz,e);
 
  299   new_particle->
getHepMC()->set_momentum(momentum);
 
  309     Log::Warning()<<
"PhotosHepMCParticle::createHistoryEntry(): particle without production vertex."<<endl;
 
  313   HepMC::GenParticle *part = 
new HepMC::GenParticle(*
m_particle);
 
  315   m_particle->production_vertex()->add_particle_out(part);
 
  322     Log::Error()<<
"PhotosHepMCParticle::createSelfDecayVertex: particle already has end vertex!"<<endl;
 
  326   if(
getHepMC()->parent_event()==NULL)
 
  328     Log::Error()<<
"PhotosHepMCParticle::createSelfDecayVertex: particle not in the HepMC event!"<<endl;
 
  333   HepMC::GenParticle *outgoing = 
new HepMC::GenParticle( *(dynamic_cast<PhotosHepMCParticle*>(out)->
m_particle) );
 
  334   HepMC::GenVertex   *
v        = 
new HepMC::GenVertex();
 
  337   v->set_position( 
m_particle->production_vertex()->position() );
 
  340   v->add_particle_out(outgoing);
 
  342   getHepMC()->parent_event()->add_vertex(v);
 
  375   HepMC::FourVector momentum(
m_particle->momentum());
 
  381   HepMC::FourVector momentum(
m_particle->momentum());
 
  388   HepMC::FourVector momentum(
m_particle->momentum());
 
  394   HepMC::FourVector momentum(
m_particle->momentum());
 
void clear(std::vector< PhotosParticle * > v)
friend F32vec4 sqrt(const F32vec4 &a)
void setMass(double mass)
std::vector< PhotosParticle * > m_created_particles
bool checkMomentumConservation()
static bool isStatusCodeIgnored(int status)
void createSelfDecayVertex(PhotosParticle *out)
void addDaughter(PhotosParticle *daughter)
PhotosHepMCParticle * createNewParticle(int pdg_id, int status, double mass, double px, double py, double pz, double e)
std::vector< PhotosParticle * > getMothers()
std::vector< PhotosParticle * > getDaughters()
std::vector< PhotosParticle * > m_decay_products
HepMC::GenParticle * m_particle
std::vector< PhotosParticle * > m_daughters
void setStatus(int statu)
static double momentum_conservation_threshold
static ostream & Warning(bool count=true)
void setPdgID(int pdg_id)
HepMC::GenParticle * getHepMC()
static void Fatal(string text, unsigned short int code=0)
std::vector< PhotosParticle * > m_mothers
void createHistoryEntry()
void setMothers(std::vector< PhotosParticle * > mothers)
static int historyEntriesStatus
static void RevertOutput()
void setDaughters(std::vector< PhotosParticle * > daughters)
std::vector< PhotosParticle * > getAllDecayProducts()
static void RedirectOutput(void(*func)(), ostream &where=*out)
static ostream & Error(bool count=true)