hepmc - Blame information for rev 14
Subversion Repositories:
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | garren | 1 | //-------------------------------------------------------------------------- |
| 2 | #ifndef HEPMC_GEN_PARTICLE_H | ||
| 3 | #define HEPMC_GEN_PARTICLE_H | ||
| 4 | |||
| 5 | ////////////////////////////////////////////////////////////////////////// | ||
| 6 | // Matt.Dobbs@Cern.CH, September 1999, refer to: | ||
| 7 | // M. Dobbs and J.B. Hansen, "The HepMC C++ Monte Carlo Event Record for | ||
| 8 | // High Energy Physics", Computer Physics Communications (to be published). | ||
| 9 | // | ||
| 10 | // particle within an event coming in/out of a vertex | ||
| 11 | // particle is the basic building block or unit of the event record | ||
| 12 | ////////////////////////////////////////////////////////////////////////// | ||
| 13 | // | ||
| 14 | // example: | ||
| 15 | // GenParticle* p = new GenParticle( HepLorentzVector(1,1,1,3), 11, 1 ); | ||
| 16 | // creates a particle with 4-vector (p,E)=1,1,1,3 - with pdg id 11 (electron) | ||
| 17 | // and give this particle status =1. | ||
| 18 | // | ||
| 19 | // The definition of a HepLorentzVector scope resolution operator allows for | ||
| 20 | // the use of 4 vector algebra with GenParticles. | ||
| 21 | // i.e. if two particles are defined: | ||
| 22 | // HepMC::GenParticle p_electron( HepLorentzVector(0,0,5,5), 11, 1 ); | ||
| 23 | // HepMC::GenParticle p_positron( HepLorentzVector(0,5,0,5), -11, 1 ); | ||
| 24 | // then you can find their cms 4 vector: | ||
| 25 | // HepLorentzVector v_cms = (HepLorentzVector)p_electron | ||
| 26 | // + (HepLorentzVector)p_positron; | ||
| 27 | // | ||
| 28 | // the pointers to end/production vertices can only be set by the | ||
| 29 | // vertices themselves - thus to set the production vertex for a particle, | ||
| 30 | // you add the particle to that vertex with GenVertex::add_particle_out() | ||
| 31 | // | ||
| 32 | // We decide not to have a separate 4 vector for the momentum | ||
| 33 | // at decay time (which MC++ includes to allow dE/dX losses etc). | ||
| 34 | // If you want that, just add a decay vertex with the | ||
| 35 | // same particle (modified momentum) going out | ||
| 36 | // | ||
| 37 | |||
| 38 | #include "HepMC/Flow.h" | ||
| 39 | #include "HepMC/Polarization.h" | ||
| 40 | #include "CLHEP/Vector/LorentzVector.h" | ||
| 41 | #include <iostream> | ||
| 42 | |||
| 43 | namespace HepMC { | ||
| 44 | |||
| 45 | class GenVertex; | ||
| 46 | class GenEvent; | ||
| 47 | |||
| 48 | class GenParticle { | ||
| 49 | |||
| 50 | friend class GenVertex; // so vertex can set decay/production vertexes | ||
| 51 | friend class GenEvent; // so event can set the barCodes | ||
| 52 | friend std::ostream& operator<<( std::ostream&, const GenParticle& ); | ||
| 53 | |||
| 54 | public: | ||
| 55 | GenParticle(void); | ||
| 56 | GenParticle( const HepLorentzVector& momentum, int pdg_id, | ||
| 57 | int status = 0, const Flow& itsflow = Flow(), | ||
| 58 | const Polarization& polar = Polarization(0,0) ); | ||
| 59 | GenParticle( const GenParticle& inparticle ); // shallow copy. | ||
| 60 | virtual ~GenParticle(); | ||
| 61 | |||
| 62 | GenParticle& operator=( const GenParticle& inparticle ); // shallow. | ||
| 63 | bool operator==( const GenParticle& ) const; | ||
| 64 | bool operator!=( const GenParticle& ) const; | ||
| 65 | |||
| 66 | // dump this particle's full info to ostr | ||
| 67 | void print( std::ostream& ostr = std::cout ) const; | ||
| 68 | |||
| 69 | operator HepLorentzVector() const; // conversion operator | ||
| 70 | |||
| 71 | //////////////////// | ||
| 72 | // access methods // | ||
| 73 | //////////////////// | ||
| 74 | |||
| 75 | HepLorentzVector momentum() const; | ||
| 76 | int pdg_id() const; | ||
| 77 | int status() const; | ||
| 78 | Flow flow() const; | ||
| 79 | int flow( int code_index ) const; | ||
| 80 | Polarization polarization() const; | ||
| 81 | GenVertex* production_vertex() const; | ||
| 82 | GenVertex* end_vertex() const; | ||
| 83 | GenEvent* parent_event() const; | ||
| 84 | |||
| 85 | // | ||
| 86 | // The barcode is the particle's reference number, every vertex in the | ||
| 87 | // event has a unique barcode. Particle barcodes are positive numbers, | ||
| 88 | // vertex barcodes are negative numbers. | ||
| 89 | // In general there is no reason to "suggest_barcode", if a particle is | ||
| 90 | // added to the event without a suggested barcode, the event will | ||
| 91 | // assign one for it. | ||
| 92 | int barcode() const; | ||
| 93 | bool suggest_barcode( int the_bar_code ); | ||
| 94 | |||
| 95 | void set_momentum( const HepLorentzVector& vec4 ); | ||
| 96 | void set_pdg_id( int id ); | ||
| 97 | void set_status( int status = 0 ); | ||
| 98 | void set_flow( const Flow& f ); | ||
| 99 | void set_flow( int code_index, int code = 0 ); | ||
| 100 | void set_polarization( const Polarization& polarization = | ||
| 101 | Polarization(0,0) ); | ||
| 102 | |||
| 103 | protected: // for internal use only by friend GenVertex class | ||
| 104 | |||
| 105 | static unsigned int counter(); // temporary for debugging | ||
| 106 | |||
| 107 | void set_production_vertex_( GenVertex* productionvertex = 0); | ||
| 108 | void set_end_vertex_( GenVertex* decayvertex = 0 ); | ||
| 109 | void set_barcode_( int the_bar_code ); // for use by GenEvent only | ||
| 110 | |||
| 111 | private: | ||
| 112 | HepLorentzVector m_momentum; // 4 vector | ||
| 113 | int m_pdg_id; // id according to PDG convention | ||
| 114 | int m_status; // As defined for HEPEVT | ||
| 115 | Flow m_flow; | ||
| 116 | Polarization m_polarization; | ||
| 117 | GenVertex* m_production_vertex; // null if vacuum or beam | ||
| 118 | GenVertex* m_end_vertex; // null if not-decayed | ||
| 119 | int m_barcode; // unique identifier in the event | ||
| 120 | |||
| 121 | static unsigned int s_counter; | ||
| 122 | }; | ||
| 123 | |||
| 124 | ////////////// | ||
| 125 | // INLINES // | ||
| 126 | ////////////// | ||
| 127 | |||
| 128 | inline GenParticle::operator HepLorentzVector() const | ||
| 129 | { return m_momentum; } | ||
| 130 | |||
| 131 | inline HepLorentzVector GenParticle::momentum() const | ||
| 132 | { return m_momentum; } | ||
| 133 | |||
| 134 | inline int GenParticle::pdg_id() const { return m_pdg_id; } | ||
| 135 | |||
| 136 | inline int GenParticle::status() const { return m_status; } | ||
| 137 | |||
| 138 | inline GenVertex* GenParticle::production_vertex() const | ||
| 139 | { return m_production_vertex; } | ||
| 140 | |||
| 141 | inline GenVertex* GenParticle::end_vertex() const { return m_end_vertex; } | ||
| 142 | |||
| 143 | inline Flow GenParticle::flow() const { return m_flow; } | ||
| 144 | |||
| 145 | inline int GenParticle::flow( int code_index ) const | ||
| 146 | { return m_flow.icode( code_index ); } | ||
| 147 | |||
| 148 | inline Polarization GenParticle::polarization() const | ||
| 149 | { return m_polarization; } | ||
| 150 | |||
| 151 | inline void GenParticle::set_momentum( const HepLorentzVector& vec4 ) | ||
| 152 | { m_momentum = vec4; } | ||
| 153 | |||
| 154 | inline void GenParticle::set_pdg_id( int id ) { m_pdg_id = id; } | ||
| 155 | |||
| 156 | inline void GenParticle::set_status( int status ) { m_status = status; } | ||
| 157 | |||
| 158 | inline void GenParticle::set_flow( const Flow& f ) { m_flow = f; } | ||
| 159 | |||
| 160 | inline void GenParticle::set_flow( int code_index, int code ) | ||
| 161 | { | ||
| 162 | if ( code == 0 ) { | ||
| 163 | m_flow.set_unique_icode( code_index ); | ||
| 164 | } else { | ||
| 165 | m_flow.set_icode( code_index, code ); | ||
| 166 | } | ||
| 167 | } | ||
| 168 | |||
| 169 | inline void GenParticle::set_polarization( const Polarization& polar ) | ||
| 170 | { m_polarization = polar; } | ||
| 171 | |||
| 172 | inline int GenParticle::barcode() const { return m_barcode; } | ||
| 173 | |||
| 174 | inline void GenParticle::set_barcode_( int bc ) { m_barcode = bc; } | ||
| 175 | |||
| 176 | } // HepMC | ||
| 177 | |||
| 178 | #endif // HEPMC_GEN_PARTICLE_H | ||
| 179 | //-------------------------------------------------------------------------- | ||
| 180 |
