StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StarGenParticle.cxx
1 #include "StarGenParticle.h"
2 ClassImp(StarGenParticle);
3 #include "g2t/St_g2t_particle_Module.h"
4 #include <iostream>
5 #include "StarGenerator/UTIL/StarParticleData.h"
6 using namespace std;
7 // --------------------------------------------------------------------------
8 StarGenParticle::StarGenParticle() :
9  mStatus(0),
10  mId(0),
11  mPx(0),
12  mPy(0),
13  mPz(0),
14  mEnergy(0),
15  mMass(0),
16  mVx(0),
17  mVy(0),
18  mVz(0),
19  mTof(0),
20  mIndex(0),
21  mStack(0),
22  mPrimaryKey(0),
23  mGeneratorId(-1)
24 {
25  for ( Int_t i=0;i<2;i++ ) { mMother[i]=0.0; mDaughter[i]=0.0; }
26 }
27 
28 void StarGenParticle::SetId( Int_t id )
29 {
30  mId = id;
31  TParticlePDG *pdg = StarParticleData::instance().GetParticle(mId);
32  if (pdg)
33  {
34  SetMass( pdg->Mass() );
35  }
36 }
37 
38 // --------------------------------------------------------------------------
39 void StarGenParticle::Print( const Char_t *opts ) const
40 {
41 
42  TParticlePDG *pdg = StarParticleData::instance().GetParticle(mId);
43  TString name = " ";
44  if ( pdg ) name = pdg->GetName();
45 
46  cout << Form("[%4i|%4i|%4i] id=%10i %10s stat=%02i p=(%8.3f,%8.3f,%8.3f,%8.3f; %8.3f) v=(%8.4f,%8.4f,%8.3f) [%i %i] [%i %i]",
47  mPrimaryKey, /* Index in primary record */
48  mIndex, /* Index in event generator record */
49  mStack, /* Index in particle stack for starsim */
50  mId,name.Data(),mStatus,mPx,mPy,mPz,mEnergy,mMass,mVx,mVy,mVz,
51  mMother[0], mMother[1],
52  mDaughter[0], mDaughter[1]
53  ) << endl;
54 
55 }
56 // --------------------------------------------------------------------------
57 
59 {
60 
61  // Does the particle decay to daughters? If so, do not stack.
62  if ( mDaughter[0]+mDaughter[1] > 0 )
63  {
64  return false;
65  }
66 
67  // Is the particle a neutrino? If so, do not stack.
68  Int_t id = TMath::Abs(mId);
69  if ( id==12 || id==14 || id==16 || id==18 /* tau prime? */ )
70  {
71  return false;
72  }
73 
74  // Is the particle flagged as final state? If so, stack it.
75  if ( mStatus == kFinal )
76  {
77  return true;
78  }
79 
80  // All other cases, do not stack
81  return false;
82 
83 }
Yet another particle class.
static StarParticleData & instance()
Returns a reference to the single instance of this class.
void SetId(Int_t id)
TParticlePDG * GetParticle(const Char_t *name)
Get a particle by name.
void SetMass(Float_t mass)
Set the mass.
void Print(const Option_t *opts="") const
Print the particle.