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 
00123         int                  barcode() const; 
00124 
00126         // mutator methods //
00128 
00130         bool                 suggest_barcode( int the_bar_code );
00131 
00132         void   set_momentum( const FourVector& vec4 ); 
00133         void   set_pdg_id( int id ); 
00134         void   set_status( int status = 0 ); 
00135         void   set_flow( const Flow& f ); 
00136         void   set_flow( int code_index, int code = 0 ); 
00137 
00138         void   set_polarization( const Polarization& pol = Polarization(0,0) );
00141         void   set_generated_mass( const double & m ); 
00142 
00144         void   setGeneratedMass( const double & m )  
00145                          { return set_generated_mass(m); }
00146 
00147     protected: // for internal use only by friend GenVertex class
00148 
00149         //static unsigned int counter(); //!< temporary for debugging
00150 
00152         void   set_production_vertex_( GenVertex* productionvertex = 0);
00154         void   set_end_vertex_( GenVertex* decayvertex = 0 );
00155         void   set_barcode_( int the_bar_code ); 
00156 
00159         void convert_momentum( const double& );
00160 
00161     private:
00162         FourVector       m_momentum;          // momentum vector
00163         int              m_pdg_id;            // id according to PDG convention
00164         int              m_status;            // As defined for HEPEVT
00165         Flow             m_flow;
00166         Polarization     m_polarization;
00167         GenVertex*       m_production_vertex; // null if vacuum or beam
00168         GenVertex*       m_end_vertex;        // null if not-decayed
00169         int              m_barcode;           // unique identifier in the event
00170         double           m_generated_mass;    // mass of this particle when it was generated
00171 
00172         //static unsigned int       s_counter;
00173     };  
00174 
00176     // INLINES  //
00178 
00179     inline GenParticle::operator HepMC::FourVector() const 
00180     { return m_momentum; }
00181 
00182     inline const FourVector & GenParticle::momentum() const 
00183     { return m_momentum; }
00184 
00185     inline int GenParticle::pdg_id() const { return m_pdg_id; }
00186 
00187     inline int GenParticle::status() const { return m_status; }
00188 
00189     inline GenVertex* GenParticle::production_vertex() const 
00190     { return m_production_vertex; }
00191 
00192     inline GenVertex* GenParticle::end_vertex() const { return m_end_vertex; }
00193 
00194     inline const Flow & GenParticle::flow() const { return m_flow; }
00195 
00196     inline int GenParticle::flow( int code_index ) const
00197     { return m_flow.icode( code_index ); }
00198 
00199     inline const Polarization & GenParticle::polarization() const 
00200     { return m_polarization; }
00201 
00202     inline void GenParticle::set_momentum( const FourVector& vec4 )
00203     { m_momentum = vec4; }
00204 
00205     inline void GenParticle::set_pdg_id( int id ) { m_pdg_id = id; }
00206 
00207     inline void GenParticle::set_status( int status ) { m_status = status; }
00208 
00209     inline void GenParticle::set_flow( const Flow& f ) { m_flow = f; }
00210 
00211     inline void GenParticle::set_flow( int code_index, int code ) 
00212     {
00213         if ( code == 0 ) { 
00214             m_flow.set_unique_icode( code_index );
00215         } else { 
00216             m_flow.set_icode( code_index, code );
00217         }
00218     }
00219 
00220     inline void GenParticle::set_polarization( const Polarization& polar )
00221     { m_polarization = polar; }
00222 
00223     inline int  GenParticle::barcode() const { return m_barcode; }
00224 
00225     inline void GenParticle::set_barcode_( int bc ) { m_barcode = bc; }
00226 
00227 } // HepMC
00228 
00229 #endif  // HEPMC_GEN_PARTICLE_H
00230 //--------------------------------------------------------------------------
00231 

Generated on Wed Jun 3 16:53:01 2009 for HepMC by  doxygen 1.5.1-3