hepmc - Blame information for rev 43

Subversion Repositories:
Rev:
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:
43 garren 15 //      GenParticle* p = new GenParticle( FourVector(1,1,1,3), 11, 1 );
2 garren 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 pointers to end/production vertices can only be set by the
20 //  vertices themselves - thus to set the production vertex for a particle,
21 //  you add the particle to that vertex with GenVertex::add_particle_out()
22 //
23 // We decide not to have a separate 4 vector for the momentum
24 //  at decay time (which MC++ includes to allow dE/dX losses etc).
25 //  If you want that, just add a decay vertex with the
26 //  same particle (modified momentum) going out
27 //
28  
29 #include "HepMC/Flow.h"
30 #include "HepMC/Polarization.h"
43 garren 31 #include "HepMC/SimpleVector.h"
2 garren 32 #include <iostream>
33  
34 namespace HepMC {
35  
36     class GenVertex;
37     class GenEvent;
38  
39     class GenParticle {
40  
41         friend class GenVertex; // so vertex can set decay/production vertexes
42         friend class GenEvent;  // so event can set the barCodes
43         friend std::ostream& operator<<( std::ostream&, const GenParticle& );
44  
45     public:
46         GenParticle(void);
43 garren 47         GenParticle( const FourVector& momentum, int pdg_id,
2 garren 48                      int status = 0, const Flow& itsflow = Flow(),
49                      const Polarization& polar = Polarization(0,0) );
50         GenParticle( const GenParticle& inparticle ); // shallow copy.
51         virtual ~GenParticle();
43 garren 52  
2 garren 53         GenParticle& operator=( const GenParticle& inparticle ); // shallow.
54         bool         operator==( const GenParticle& ) const;
55         bool         operator!=( const GenParticle& ) const;
56  
57         // dump this particle's full info to ostr
58         void       print( std::ostream& ostr = std::cout ) const;
59  
43 garren 60         operator FourVector() const; // conversion operator
2 garren 61  
62         ////////////////////
63         // access methods //
64         ////////////////////
65  
43 garren 66         FourVector           momentum() const;
2 garren 67         int                  pdg_id() const;
68         int                  status() const;
69         Flow                 flow() const;
70         int                  flow( int code_index ) const;
71         Polarization         polarization() const;
72         GenVertex*           production_vertex() const;
73         GenVertex*           end_vertex() const;
74         GenEvent*            parent_event() const;
75  
43 garren 76         double               generated_mass() const;
77         inline double        generatedMass() const { return generated_mass(); }
78         //  generatedMass() is included for backwards compatibility with CLHEP HepMC
79         // because of precision issues, the generated mass is not always the same as the calculated mass
80         //         GenParticle.generated_mass() [generated mass]
81         //         GenParticle.momentum().m()  [calculated mass]
82         // by default, generated_mass() is the mass calculated from the momentum 4 vector
83         // call set_generated_mass(..) to define the actual generated mass
84  
85  
2 garren 86         //
87         // The barcode is the particle's reference number, every vertex in the
88         //  event has a unique barcode. Particle barcodes are positive numbers,
89         //  vertex barcodes are negative numbers.
90         // In general there is no reason to "suggest_barcode", if a particle is
91         //  added to the event without a suggested barcode, the event will
92         //  assign one for it.
93         int                  barcode() const;
94         bool                 suggest_barcode( int the_bar_code );
95  
43 garren 96         void   set_momentum( const FourVector& vec4 );
2 garren 97         void   set_pdg_id( int id );
98         void   set_status( int status = 0 );
99         void   set_flow( const Flow& f );
100         void   set_flow( int code_index, int code = 0 );
43 garren 101         void   set_polarization( const Polarization& pol = Polarization(0,0) );
102         void   set_generated_mass( const double & m );
103         void   setGeneratedMass( const double & m )  
104                          { return set_generated_mass(m); }
105         //  setGeneratedMass() is included for backwards compatibility with CLHEP HepMC
106         //  If you do not call set_generated_mass(), then
107         //  generated_mass() will simply return the mass calculated from momentum()
2 garren 108  
109     protected: // for internal use only by friend GenVertex class
110  
111         static unsigned int counter(); // temporary for debugging
112  
113         void   set_production_vertex_( GenVertex* productionvertex = 0);
114         void   set_end_vertex_( GenVertex* decayvertex = 0 );
115         void   set_barcode_( int the_bar_code ); // for use by GenEvent only
116  
117     private:
43 garren 118         FourVector       m_momentum;          // momentum vector
2 garren 119         int              m_pdg_id;            // id according to PDG convention
120         int              m_status;            // As defined for HEPEVT
121         Flow             m_flow;
122         Polarization     m_polarization;
123         GenVertex*       m_production_vertex; // null if vacuum or beam
124         GenVertex*       m_end_vertex;        // null if not-decayed
125         int              m_barcode;           // unique identifier in the event
43 garren 126         double           m_generated_mass;    // mass of this particle when it was generated
2 garren 127  
128         static unsigned int s_counter;
129     };  
130  
131     //////////////
132     // INLINES  //
133     //////////////
134  
43 garren 135     inline GenParticle::operator FourVector() const
2 garren 136     { return m_momentum; }
137  
43 garren 138     inline FourVector GenParticle::momentum() const
2 garren 139     { return m_momentum; }
140  
141     inline int GenParticle::pdg_id() const { return m_pdg_id; }
142  
143     inline int GenParticle::status() const { return m_status; }
144  
145     inline GenVertex* GenParticle::production_vertex() const
146     { return m_production_vertex; }
147  
148     inline GenVertex* GenParticle::end_vertex() const { return m_end_vertex; }
149  
150     inline Flow GenParticle::flow() const { return m_flow; }
151  
152     inline int GenParticle::flow( int code_index ) const
153     { return m_flow.icode( code_index ); }
154  
155     inline Polarization GenParticle::polarization() const
156     { return m_polarization; }
157  
43 garren 158     inline void GenParticle::set_momentum( const FourVector& vec4 )
2 garren 159     { m_momentum = vec4; }
160  
161     inline void GenParticle::set_pdg_id( int id ) { m_pdg_id = id; }
162  
163     inline void GenParticle::set_status( int status ) { m_status = status; }
164  
165     inline void GenParticle::set_flow( const Flow& f ) { m_flow = f; }
166  
167     inline void GenParticle::set_flow( int code_index, int code )
168     {
169         if ( code == 0 ) {
170             m_flow.set_unique_icode( code_index );
171         } else {
172             m_flow.set_icode( code_index, code );
173         }
174     }
175  
176     inline void GenParticle::set_polarization( const Polarization& polar )
177     { m_polarization = polar; }
178  
179     inline int  GenParticle::barcode() const { return m_barcode; }
180  
181     inline void GenParticle::set_barcode_( int bc ) { m_barcode = bc; }
182  
183 } // HepMC
184  
185 #endif  // HEPMC_GEN_PARTICLE_H
186 //--------------------------------------------------------------------------
187