HepMC Reference Documentation

HepMC

GenParticle.h

Go to the documentation of this file.
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         const FourVector &          momentum() const;
00091         int                  pdg_id() const;
00093         int                  status() const;
00095         const Flow &         flow() const;
00097         int                  flow( int code_index ) const;
00099         const 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 
00129         int                  barcode() const; 
00130         
00132         bool                 is_undecayed() const;
00134         bool                 has_decayed() const;
00138         bool                 is_beam() const;
00139 
00141         // mutator methods //
00143 
00145         bool                 suggest_barcode( int the_bar_code );
00146 
00147         void   set_momentum( const FourVector& vec4 ); 
00148         void   set_pdg_id( int id ); 
00149         void   set_status( int status = 0 ); 
00150         void   set_flow( const Flow& f ); 
00151         void   set_flow( int code_index, int code = 0 ); 
00152 
00153         void   set_polarization( const Polarization& pol = Polarization(0,0) );
00156         void   set_generated_mass( const double & m ); 
00157 
00159         void   setGeneratedMass( const double & m )  
00160                          { return set_generated_mass(m); }
00161 
00162     protected: // for internal use only by friend GenVertex class
00163 
00164         //static unsigned int counter(); //!< temporary for debugging
00165 
00167         void   set_production_vertex_( GenVertex* productionvertex = 0);
00169         void   set_end_vertex_( GenVertex* decayvertex = 0 );
00170         void   set_barcode_( int the_bar_code ); 
00171 
00174         void convert_momentum( const double& );
00175 
00176     private:
00177         FourVector       m_momentum;          // momentum vector
00178         int              m_pdg_id;            // id according to PDG convention
00179         int              m_status;            // As defined for HEPEVT
00180         Flow             m_flow;
00181         Polarization     m_polarization;
00182         GenVertex*       m_production_vertex; // null if vacuum or beam
00183         GenVertex*       m_end_vertex;        // null if not-decayed
00184         int              m_barcode;           // unique identifier in the event
00185         double           m_generated_mass;    // mass of this particle when it was generated
00186 
00187         //static unsigned int       s_counter;
00188     };  
00189 
00191     // INLINES  //
00193 
00194     inline GenParticle::operator HepMC::FourVector() const 
00195     { return m_momentum; }
00196 
00197     inline const FourVector & GenParticle::momentum() const 
00198     { return m_momentum; }
00199 
00200     inline int GenParticle::pdg_id() const { return m_pdg_id; }
00201 
00202     inline int GenParticle::status() const { return m_status; }
00203 
00204     inline GenVertex* GenParticle::production_vertex() const 
00205     { return m_production_vertex; }
00206 
00207     inline GenVertex* GenParticle::end_vertex() const { return m_end_vertex; }
00208 
00209     inline const Flow & GenParticle::flow() const { return m_flow; }
00210 
00211     inline int GenParticle::flow( int code_index ) const
00212     { return m_flow.icode( code_index ); }
00213 
00214     inline const Polarization & GenParticle::polarization() const 
00215     { return m_polarization; }
00216 
00217     inline void GenParticle::set_momentum( const FourVector& vec4 )
00218     { m_momentum = vec4; }
00219 
00220     inline void GenParticle::set_pdg_id( int id ) { m_pdg_id = id; }
00221 
00222     inline void GenParticle::set_status( int status ) { m_status = status; }
00223 
00224     inline void GenParticle::set_flow( const Flow& f ) { m_flow = f; }
00225 
00226     inline void GenParticle::set_flow( int code_index, int code ) 
00227     {
00228         if ( code == 0 ) { 
00229             m_flow.set_unique_icode( code_index );
00230         } else { 
00231             m_flow.set_icode( code_index, code );
00232         }
00233     }
00234 
00235     inline void GenParticle::set_polarization( const Polarization& polar )
00236     { m_polarization = polar; }
00237 
00238     inline int  GenParticle::barcode() const { return m_barcode; }
00239 
00240     inline void GenParticle::set_barcode_( int bc ) { m_barcode = bc; }
00241 
00242     inline bool GenParticle::is_undecayed() const {
00243         return ( m_status==1 ) ?  true : false;
00244     }
00245     inline bool GenParticle::has_decayed() const {
00246         return ( m_status==2 ) ?  true : false;
00247     }
00248     inline bool GenParticle::is_beam() const {
00249         return ( m_status==4 ) ?  true : false;
00250     }
00251 
00252 } // HepMC
00253 
00254 #endif  // HEPMC_GEN_PARTICLE_H
00255 //--------------------------------------------------------------------------
00256 

Generated on Thu Jan 7 13:10:15 2010 for HepMC by  doxygen 1.4.7