Fork me on GitHub

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

Last change on this file since 572 was 572, checked in by cp3-support, 13 years ago

upgrade HepMC to version 2.06.05

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