![]() |
HepMC Reference DocumentationHepMC |
00001 //-------------------------------------------------------------------------- 00002 #ifndef HEPMC_GEN_PARTICLE_H 00003 #define HEPMC_GEN_PARTICLE_H 00004 00006 // Matt.Dobbs@Cern.CH, September 1999, refer to: 00007 // M. Dobbs and J.B. Hansen, "The HepMC C++ Monte Carlo Event Record for 00008 // High Energy Physics", Computer Physics Communications (to be published). 00009 // 00010 // particle within an event coming in/out of a vertex 00011 // particle is the basic building block or unit of the event record 00013 // 00014 // example: 00015 // GenParticle* p = new GenParticle( FourVector(1,1,1,3), 11, 1 ); 00016 // creates a particle with 4-vector (p,E)=1,1,1,3 - with pdg id 11 (electron) 00017 // and give this particle status =1. 00018 // 00019 // the pointers to end/production vertices can only be set by the 00020 // vertices themselves - thus to set the production vertex for a particle, 00021 // you add the particle to that vertex with GenVertex::add_particle_out() 00022 // 00023 // We decide not to have a separate 4 vector for the momentum 00024 // at decay time (which MC++ includes to allow dE/dX losses etc). 00025 // If you want that, just add a decay vertex with the 00026 // same particle (modified momentum) going out 00027 // 00028 00029 #include "HepMC/Flow.h" 00030 #include "HepMC/Polarization.h" 00031 #include "HepMC/SimpleVector.h" 00032 #include <iostream> 00033 #ifdef _WIN32 00034 #define hepmc_uint64_t __int64 00035 #else 00036 #include <stdint.h> // for uint64_t 00037 #define hepmc_uint64_t uint64_t 00038 #endif 00039 00040 namespace HepMC { 00041 00042 class GenVertex; 00043 class GenEvent; 00044 00045 00047 00055 class GenParticle { 00056 00057 friend class GenVertex; // so vertex can set decay/production vertexes 00058 friend class GenEvent; // so event can set the barCodes 00060 friend std::ostream& operator<<( std::ostream&, const GenParticle& ); 00061 00062 public: 00064 GenParticle(void); 00066 GenParticle( const FourVector& momentum, int pdg_id, 00067 int status = 0, const Flow& itsflow = Flow(), 00068 const Polarization& polar = Polarization(0,0) ); 00069 GenParticle( const GenParticle& inparticle ); 00070 virtual ~GenParticle(); 00071 00072 void swap( GenParticle & other); 00073 GenParticle& operator=( const GenParticle& inparticle ); 00074 00075 bool operator==( const GenParticle& ) const; 00077 bool operator!=( const GenParticle& ) const; 00078 00080 void print( std::ostream& ostr = std::cout ) const; 00081 00082 operator HepMC::FourVector() const; 00083 00085 // access methods // 00087 00089 FourVector momentum() const; 00091 int pdg_id() const; 00093 int status() const; 00095 Flow flow() const; 00097 int flow( int code_index ) const; 00099 Polarization polarization() const; 00101 GenVertex* production_vertex() const; 00103 GenVertex* end_vertex() const; 00105 GenEvent* parent_event() const; 00106 00113 double generated_mass() const; 00114 00116 double generatedMass() const { return generated_mass(); } 00117 00118 00123 int barcode() const; 00124 00126 bool suggest_barcode( int the_bar_code ); 00127 00128 void set_momentum( const FourVector& vec4 ); 00129 void set_pdg_id( int id ); 00130 void set_status( int status = 0 ); 00131 void set_flow( const Flow& f ); 00132 void set_flow( int code_index, int code = 0 ); 00133 00134 void set_polarization( const Polarization& pol = Polarization(0,0) ); 00137 void set_generated_mass( const double & m ); 00138 00140 void setGeneratedMass( const double & m ) 00141 { return set_generated_mass(m); } 00142 00143 protected: // for internal use only by friend GenVertex class 00144 00145 //static unsigned int counter(); //!< temporary for debugging 00146 00148 void set_production_vertex_( GenVertex* productionvertex = 0); 00150 void set_end_vertex_( GenVertex* decayvertex = 0 ); 00151 void set_barcode_( int the_bar_code ); 00152 00153 private: 00154 FourVector m_momentum; // momentum vector 00155 int m_pdg_id; // id according to PDG convention 00156 int m_status; // As defined for HEPEVT 00157 Flow m_flow; 00158 Polarization m_polarization; 00159 GenVertex* m_production_vertex; // null if vacuum or beam 00160 GenVertex* m_end_vertex; // null if not-decayed 00161 int m_barcode; // unique identifier in the event 00162 double m_generated_mass; // mass of this particle when it was generated 00163 00164 //static unsigned int s_counter; 00165 }; 00166 00168 // INLINES // 00170 00171 inline GenParticle::operator HepMC::FourVector() const 00172 { return m_momentum; } 00173 00174 inline FourVector GenParticle::momentum() const 00175 { return m_momentum; } 00176 00177 inline int GenParticle::pdg_id() const { return m_pdg_id; } 00178 00179 inline int GenParticle::status() const { return m_status; } 00180 00181 inline GenVertex* GenParticle::production_vertex() const 00182 { return m_production_vertex; } 00183 00184 inline GenVertex* GenParticle::end_vertex() const { return m_end_vertex; } 00185 00186 inline Flow GenParticle::flow() const { return m_flow; } 00187 00188 inline int GenParticle::flow( int code_index ) const 00189 { return m_flow.icode( code_index ); } 00190 00191 inline Polarization GenParticle::polarization() const 00192 { return m_polarization; } 00193 00194 inline void GenParticle::set_momentum( const FourVector& vec4 ) 00195 { m_momentum = vec4; } 00196 00197 inline void GenParticle::set_pdg_id( int id ) { m_pdg_id = id; } 00198 00199 inline void GenParticle::set_status( int status ) { m_status = status; } 00200 00201 inline void GenParticle::set_flow( const Flow& f ) { m_flow = f; } 00202 00203 inline void GenParticle::set_flow( int code_index, int code ) 00204 { 00205 if ( code == 0 ) { 00206 m_flow.set_unique_icode( code_index ); 00207 } else { 00208 m_flow.set_icode( code_index, code ); 00209 } 00210 } 00211 00212 inline void GenParticle::set_polarization( const Polarization& polar ) 00213 { m_polarization = polar; } 00214 00215 inline int GenParticle::barcode() const { return m_barcode; } 00216 00217 inline void GenParticle::set_barcode_( int bc ) { m_barcode = bc; } 00218 00219 } // HepMC 00220 00221 #endif // HEPMC_GEN_PARTICLE_H 00222 //-------------------------------------------------------------------------- 00223