StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GenParticle.h
1 //--------------------------------------------------------------------------
2 #ifndef HEPMC_GEN_PARTICLE_H
3 #define HEPMC_GEN_PARTICLE_H
4 
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
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 "HepMC/Flow.h"
30 #include "HepMC/Polarization.h"
31 #include "HepMC/SimpleVector.h"
32 #include "HepMC/IteratorRange.h"
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 
41 namespace HepMC {
42 
43  class GenVertex;
44  class GenEvent;
45 
46  class GenParticleProductionRange;
47  class ConstGenParticleProductionRange;
48  class GenParticleEndRange;
49  class ConstGenParticleEndRange;
50 
52 
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
65  friend std::ostream& operator<<( std::ostream&, const GenParticle& );
66 
67  public:
69  GenParticle(void);
72  int status = 0, const Flow& itsflow = Flow(),
73  const Polarization& polar = Polarization(0,0) );
74  GenParticle( const GenParticle& inparticle );
75  virtual ~GenParticle();
76 
77  void swap( GenParticle & other);
78  GenParticle& operator=( const GenParticle& inparticle );
79  bool operator==( const GenParticle& ) const;
82  bool operator!=( const GenParticle& ) const;
83 
85  void print( std::ostream& ostr = std::cout ) const;
86 
87  operator HepMC::FourVector() const;
88 
90  // access methods //
92 
94  const FourVector & momentum() const;
96  int pdg_id() const;
98  int status() const;
100  const Flow & flow() const;
102  int flow( int code_index ) const;
104  const Polarization & polarization() const;
106  GenVertex* production_vertex() const;
108  GenVertex* end_vertex() const;
110  GenEvent* parent_event() const;
111 
118  double generated_mass() const;
119 
121  double generatedMass() const { return generated_mass(); }
122 
123 
134  int barcode() const;
135 
137  bool is_undecayed() const;
139  bool has_decayed() const;
143  bool is_beam() const;
144 
150  GenParticleEndRange particles_out( IteratorRange range = relatives );
152  ConstGenParticleEndRange particles_out( IteratorRange range = relatives ) const;
153 
155  // mutator methods //
157 
159  bool suggest_barcode( int the_bar_code );
160 
161  void set_momentum( const FourVector& vec4 );
162  void set_pdg_id( int id );
163  void set_status( int status = 0 );
164  void set_flow( const Flow& f );
165  void set_flow( int code_index, int code = 0 );
166  void set_polarization( const Polarization& pol = Polarization(0,0) );
170  void set_generated_mass( const double & m );
171 
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 
181  void set_production_vertex_( GenVertex* productionvertex = 0);
183  void set_end_vertex_( GenVertex* decayvertex = 0 );
184  void set_barcode_( int the_bar_code );
185 
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 
205  // INLINES //
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 
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 st ) { m_status = st; }
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 
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 
266 } // HepMC
267 
268 #endif // HEPMC_GEN_PARTICLE_H
269 //--------------------------------------------------------------------------
270 
Flow set_unique_icode(int code_index=1)
set unique flow code
Definition: Flow.h:171
bool operator==(const GenParticle &) const
check for equality
Definition: GenParticle.cc:89
GenEvent * parent_event() const
pointer to the event that owns this particle
Definition: GenParticle.cc:123
void set_generated_mass(const double &m)
define the actual generated mass
Definition: GenParticle.cc:240
int pdg_id() const
particle ID
Definition: GenParticle.h:214
GenParticle(void)
default constructor
Definition: GenParticle.cc:14
void set_status(int status=0)
set decay status
Definition: GenParticle.h:236
int barcode() const
particle barcode
Definition: GenParticle.h:252
double generatedMass() const
generatedMass() is included for backwards compatibility with CLHEP HepMC
Definition: GenParticle.h:121
GenParticle & operator=(const GenParticle &inparticle)
Definition: GenParticle.cc:77
void set_flow(const Flow &f)
set particle flow
Definition: GenParticle.h:238
GenVertex * production_vertex() const
pointer to the production vertex
Definition: GenParticle.h:218
GenVertex contains information about decay vertices.
Definition: GenVertex.h:52
bool has_decayed() const
Convenience method. Returns true if status==2.
Definition: GenParticle.h:259
bool suggest_barcode(int the_bar_code)
In general there is no reason to &quot;suggest_barcode&quot;.
Definition: GenParticle.cc:153
The GenEvent class is the core of HepMC.
Definition: GenEvent.h:155
bool is_undecayed() const
Convenience method. Returns true if status==1.
Definition: GenParticle.h:256
Flow set_icode(int code_index, int code)
set flow code
Definition: Flow.h:167
GenParticleEndRange acts like a collection of particles.
Definition: GenRanges.h:224
int status() const
HEPEVT decay status.
Definition: GenParticle.h:216
double generated_mass() const
mass as generated
Definition: GenParticle.cc:236
void set_barcode_(int the_bar_code)
for use by GenEvent only
Definition: GenParticle.h:254
GenParticleProductionRange particles_in(IteratorRange range=relatives)
incoming particle range
Definition: GenRanges.cc:61
void set_production_vertex_(GenVertex *productionvertex=0)
set production vertex - for internal use only
Definition: GenParticle.cc:129
The Polarization class stores theta and phi for a GenParticle.
Definition: Polarization.h:29
void swap(GenParticle &other)
swap
Definition: GenParticle.cc:63
void set_momentum(const FourVector &vec4)
set standard 4 momentum
Definition: GenParticle.h:231
const Flow & flow() const
particle flow
Definition: GenParticle.h:223
const Polarization & polarization() const
polarization information
Definition: GenParticle.h:228
GenParticleProductionRange acts like a collection of particles.
Definition: GenRanges.h:170
GenParticleEndRange particles_out(IteratorRange range=relatives)
outgoing particle range
Definition: GenRanges.cc:73
void print(std::ostream &ostr=std::cout) const
dump this particle&#39;s full info to ostr
Definition: GenParticle.cc:106
const FourVector & momentum() const
standard 4 momentum
Definition: GenParticle.h:211
friend std::ostream & operator<<(std::ostream &, const GenParticle &)
print particle
Definition: GenParticle.cc:189
FourVector is a simple representation of a physics 4 vector.
Definition: SimpleVector.h:42
bool operator!=(const GenParticle &) const
check for inequality
Definition: GenParticle.cc:102
GenVertex * end_vertex() const
pointer to the decay vertex
Definition: GenParticle.h:221
IteratorRange
type of iteration
Definition: IteratorRange.h:17
void setGeneratedMass(const double &m)
setGeneratedMass() is included for backwards compatibility with CLHEP HepMC
Definition: GenParticle.h:173
void convert_momentum(const double &)
Definition: GenParticle.cc:246
void set_pdg_id(int id)
set particle ID
Definition: GenParticle.h:234
void set_polarization(const Polarization &pol=Polarization(0, 0))
set polarization
Definition: GenParticle.h:249
bool is_beam() const
Definition: GenParticle.h:262
void set_end_vertex_(GenVertex *decayvertex=0)
set decay vertex - for internal use only
Definition: GenParticle.cc:142
int icode(int code_index=1) const
flow code
Definition: Flow.h:163
The GenParticle class contains information about generated particles.
Definition: GenParticle.h:60
The flow object.
Definition: Flow.h:66