Fork me on GitHub

source: svn/trunk/Utilities/HepMC/interface/GenParticle.h@ 349

Last change on this file since 349 was 349, checked in by severine ovyn, 15 years ago

first test

File size: 8.3 KB
Line 
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( FourVector(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 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 "Flow.h"
30#include "Polarization.h"
31#include "SimpleVector.h"
32#include <iostream>
33#ifdef _WIN32
34#define hepmc_uint64_t __int64
35#else
36#include <stdint.h> // for uint64_t
37#define hepmc_uint64_t uint64_t
38#endif
39
40namespace HepMC {
41
42 class GenVertex;
43 class GenEvent;
44
45
46 //! The GenParticle class contains information about generated particles
47
48 ///
49 /// \class GenParticle
50 /// HepMC::GenParticle
51 /// contains momentum, generated mass, particle ID, decay status,
52 /// flow, polarization, pointers to production and decay vertices
53 /// and a unique barcode identfier.
54 ///
55 class GenParticle {
56
57 friend class GenVertex; // so vertex can set decay/production vertexes
58 friend class GenEvent; // so event can set the barCodes
59 /// print particle
60 friend std::ostream& operator<<( std::ostream&, const GenParticle& );
61
62 public:
63 /// default constructor
64 GenParticle(void);
65 /// constructor requires momentum and particle ID
66 GenParticle( const FourVector& momentum, int pdg_id,
67 int status = 0, const Flow& itsflow = Flow(),
68 const Polarization& polar = Polarization(0,0) );
69 GenParticle( const GenParticle& inparticle ); //!< shallow copy.
70 virtual ~GenParticle();
71
72 void swap( GenParticle & other); //!< swap
73 GenParticle& operator=( const GenParticle& inparticle ); //!< shallow.
74 /// check for equality
75 bool operator==( const GenParticle& ) const;
76 /// check for inequality
77 bool operator!=( const GenParticle& ) const;
78
79 /// dump this particle's full info to ostr
80 void print( std::ostream& ostr = std::cout ) const;
81
82 operator HepMC::FourVector() const; //!< conversion operator
83
84 ////////////////////
85 // access methods //
86 ////////////////////
87
88 /// standard 4 momentum
89 const FourVector & momentum() const;
90 /// particle ID
91 int pdg_id() const;
92 /// HEPEVT decay status
93 int status() const;
94 /// particle flow
95 const Flow & flow() const;
96 /// particle flow index
97 int flow( int code_index ) const;
98 /// polarization information
99 const Polarization & polarization() const;
100 /// pointer to the production vertex
101 GenVertex* production_vertex() const;
102 /// pointer to the decay vertex
103 GenVertex* end_vertex() const;
104 /// pointer to the event that owns this particle
105 GenEvent* parent_event() const;
106
107 /// Because of precision issues, the generated mass is not always the
108 /// same as the mass calculated from the momentum 4 vector.
109 /// If the generated mass has been set, then generated_mass()
110 /// returns that value.
111 /// If the generated mass has not been set, then generated_mass()
112 /// returns the mass calculated from the momentum 4 vector.
113 double generated_mass() const; //!< mass as generated
114
115 /// generatedMass() is included for backwards compatibility with CLHEP HepMC
116 double generatedMass() const { return generated_mass(); }
117
118
119 ///
120 /// The barcode is the particle's reference number, every vertex in the
121 /// event has a unique barcode. Particle barcodes are positive numbers,
122 /// vertex barcodes are negative numbers.
123 int barcode() const; //!< particle barcode
124
125 /////////////////////
126 // mutator methods //
127 /////////////////////
128
129 /// In general there is no reason to "suggest_barcode"
130 bool suggest_barcode( int the_bar_code );
131
132 void set_momentum( const FourVector& vec4 ); //!< set standard 4 momentum
133 void set_pdg_id( int id ); //!< set particle ID
134 void set_status( int status = 0 ); //!< set decay status
135 void set_flow( const Flow& f ); //!< set particle flow
136 void set_flow( int code_index, int code = 0 ); //!< set particle flow index
137 /// set polarization
138 void set_polarization( const Polarization& pol = Polarization(0,0) );
139 /// If you do not call set_generated_mass(), then
140 /// generated_mass() will simply return the mass calculated from momentum()
141 void set_generated_mass( const double & m ); //!< define the actual generated mass
142
143 /// setGeneratedMass() is included for backwards compatibility with CLHEP HepMC
144 void setGeneratedMass( const double & m )
145 { return set_generated_mass(m); }
146
147 protected: // for internal use only by friend GenVertex class
148
149 //static unsigned int counter(); //!< temporary for debugging
150
151 /// set production vertex - for internal use only
152 void set_production_vertex_( GenVertex* productionvertex = 0);
153 /// set decay vertex - for internal use only
154 void set_end_vertex_( GenVertex* decayvertex = 0 );
155 void set_barcode_( int the_bar_code ); //!< for use by GenEvent only
156
157 /// scale the momentum vector and generated mass
158 /// this method is only for use by GenEvent
159 void convert_momentum( const double& );
160
161 private:
162 FourVector m_momentum; // momentum vector
163 int m_pdg_id; // id according to PDG convention
164 int m_status; // As defined for HEPEVT
165 Flow m_flow;
166 Polarization m_polarization;
167 GenVertex* m_production_vertex; // null if vacuum or beam
168 GenVertex* m_end_vertex; // null if not-decayed
169 int m_barcode; // unique identifier in the event
170 double m_generated_mass; // mass of this particle when it was generated
171
172 //static unsigned int s_counter;
173 };
174
175 //////////////
176 // INLINES //
177 //////////////
178
179 inline GenParticle::operator HepMC::FourVector() const
180 { return m_momentum; }
181
182 inline const FourVector & GenParticle::momentum() const
183 { return m_momentum; }
184
185 inline int GenParticle::pdg_id() const { return m_pdg_id; }
186
187 inline int GenParticle::status() const { return m_status; }
188
189 inline GenVertex* GenParticle::production_vertex() const
190 { return m_production_vertex; }
191
192 inline GenVertex* GenParticle::end_vertex() const { return m_end_vertex; }
193
194 inline const Flow & GenParticle::flow() const { return m_flow; }
195
196 inline int GenParticle::flow( int code_index ) const
197 { return m_flow.icode( code_index ); }
198
199 inline const Polarization & GenParticle::polarization() const
200 { return m_polarization; }
201
202 inline void GenParticle::set_momentum( const FourVector& vec4 )
203 { m_momentum = vec4; }
204
205 inline void GenParticle::set_pdg_id( int id ) { m_pdg_id = id; }
206
207 inline void GenParticle::set_status( int status ) { m_status = status; }
208
209 inline void GenParticle::set_flow( const Flow& f ) { m_flow = f; }
210
211 inline void GenParticle::set_flow( int code_index, int code )
212 {
213 if ( code == 0 ) {
214 m_flow.set_unique_icode( code_index );
215 } else {
216 m_flow.set_icode( code_index, code );
217 }
218 }
219
220 inline void GenParticle::set_polarization( const Polarization& polar )
221 { m_polarization = polar; }
222
223 inline int GenParticle::barcode() const { return m_barcode; }
224
225 inline void GenParticle::set_barcode_( int bc ) { m_barcode = bc; }
226
227} // HepMC
228
229#endif // HEPMC_GEN_PARTICLE_H
230//--------------------------------------------------------------------------
231
Note: See TracBrowser for help on using the repository browser.