StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StGenParticle.cxx
1 // @(#)root/eg:$Id: StGenParticle.cxx,v 1.10 2015/12/03 23:19:22 jwebb Exp $
2 
3 
4 //______________________________________________________________________________
5 #include "stdlib.h"
6 #include "math.h"
7 #include <map>
8 #include "StGenParticle.h"
9 #include <iostream>
10 using namespace std;
11 //#include "StMessMgr.h"
12 //______________________________________________________________________________
13 void StGenParticle::Print(const char *opt) const
14 {
15  static int nCall=0; nCall++;
16  cout << GetIdx() << " -" << endl;
17  cout << " Ist=" << GetStatusCode() << endl;
18  cout << " Pdg=" << GetPdgCode() << endl;
19  cout << " Gea=" << GetGeaCode() << endl;
20 
21  double V[3]; Vertex(V); cout << " Z=" << V[2] << endl;
22 
23  if (GetNDaughters()) cout << "\tKids=" << GetNDaughters() << endl;
24 
25  int moth1 = -1,moth2=-1;
26  const StGenParticle *m = GetMother(0);
27  if (m) moth1 = m->GetIdx();
28  m = GetMother(1);
29  if (m) moth2 = m->GetIdx();
30 
31  if (moth1>=0 || moth2>=0) {
32  cout << "\tMoth=(" << endl;
33  if (moth1>=0) {cout << moth1 << endl;} else {cout << "_" <<endl;}
34  cout << " " << endl;
35  if (moth2>=0) {cout << moth2 << endl;} else {cout << "_" << endl;}
36  cout << ")" <<endl;
37  }
38 
39  // cout << endl;
40 
41 }
42 //______________________________________________________________________________
43 double StGenParticle::GetCalcMass() const
44 {
45  double p[4];
46  Momentum(p);
47  double m =p[3]*p[3]-(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
48  return (m>0) ? sqrt(m) : -sqrt(-m);
49 }
50 //______________________________________________________________________________
51 double StGenParticle::R() const
52 {
53  double x[3]; Vertex(x); return sqrt(x[0]*x[0]+x[1]*x[1]);
54 
55 }
56 //______________________________________________________________________________
57 double StGenParticle::Rho() const
58 {
59  double x[3]; Vertex(x); return sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2]);
60 
61 }
62 //______________________________________________________________________________
63 double StGenParticle::P() const
64 {
65  double p[4]; Momentum(p); return sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
66 
67 }
68 //______________________________________________________________________________
69 double StGenParticle::Pt() const
70 {
71  double p[4]; Momentum(p); return sqrt(p[0]*p[0]+p[1]*p[1]);
72 
73 }
74 //______________________________________________________________________________
75 double StGenParticle::Energy() const
76 {
77  double p[4]; Momentum(p); return p[3];
78 
79 }
80 //______________________________________________________________________________
81 double StGenParticle::Eta() const
82 {
83  double p[4]; Momentum(p);
84  double pmom = P();
85  if (pmom > fabs(p[2])) return 0.5*log((pmom+p[2])/(pmom-p[2]));
86  else return 1.e30;
87 }
88 //______________________________________________________________________________
89 double StGenParticle::Phi() const
90 {
91  double p[4]; Momentum(p);
92  return atan2(p[1],p[0]);
93 }
94 //______________________________________________________________________________
95 double StGenParticle::Theta() const
96 {
97  double p[4]; Momentum(p);
98  return acos(p[2]/P());
99 }
100 int StGenParticle::GetPdgCode() const { return StGenParticleMaster::Gea2Pdg(GetGeaCode());}
101 int StGenParticle::GetGeaCode() const { return StGenParticleMaster::Pdg2Gea(GetPdgCode());}
102 //______________________________________________________________________________
103 //______________________________________________________________________________
104 //______________________________________________________________________________
105 void StGenParticleMaster::Print(const char *tit) const
106 {
107  if (!tit) tit = "";
108  cout << "StGenParticleMaster::Print(" << tit << ")" << endl;
109  const StGenParticle *p=0;
110 
111  // Loop over all particles stored by the particle master list and print them
112  int i = 0;
113  p = (*this)(i);
114  while (p) {
115  p->Print();
116  p = (*this)(++i);
117  };
118  cout << endl;
119 
120 }
121 
122 // *
123 // * In rough order of multiplicity: gamma,pi+,pi-,pi0,etc
124 // * - gamma pi+ pi- pi0 K0L K+ K- K0S Eta
125 // * prot neut ~p ~n e+ e- nu_e ~nu_e mu+ mu-
126 // * lamda sigm+ sigm0 sigm- xi0 xi- omeg-
127 // * ~: lamda sigm- sigm0 sigm+ xi0 xi+ omeg+
128 // * tau+ tau- D+ D- D0 ~D0 DS+ DS- LamC+
129 // * W+ W- Z0 nu_m ~nu_m nu_t ~nu_t geant geant geant
130 // * Deutron Triton Alpha HE3
131 enum {kNGEA = 50};
132 static const int IDGEA[] = {
133  0, 1, 8, 9, 7, 10, 11, 12, 16, 17,
134  14, 13, 15, 25, 2, 3, 4, 4, 5, 6,
135  18, 19, 20, 21, 22, 23, 24,
136  26, 27, 28, 29, 30, 31, 32,
137  33, 34, 35, 36, 37, 38, 39, 40, 41,
138  42, 43, 44, 4, 4, 4, 4, 48, 48, 48,
139  45, 46, 47, 49};
140 
141 static const int IDPDG[] = {
142  0, 22, 211, -211, 111, 130, 321, -321, 310, 221,
143  2212, 2112,-2212,-2112, -11, 11, -12, 12, -13, 13,
144  3122, 3222, 3212, 3112, 3322, 3312, 3334,
145  -3122,-3222,-3212,-3112,-3322,-3312,-3334,
146  -15, 15, 411, -411, 421, -421, 431, -431, 4122,
147  24, -24, 23, -14, 14, -16, 16, 71, 72, 75,
148  700201,700301,700202,700302};
149 //______________________________________________________________________________
150 int StGenParticleMaster::Gea2Pdg(int igea)
151 {
152 
153 static int PdgOfGea[kNGEA]={0};
154 
155  if (! PdgOfGea[1]) {
156  for (int i = 0;i<kNGEA; i++) { PdgOfGea[IDGEA[i]] = IDPDG[i]; }
157  }
158  if (igea >=kNGEA) return 0;
159  return PdgOfGea[igea];
160 }
161 //______________________________________________________________________________
162 double StGenParticleMaster::Gea2Mas(int igea)
163 {
164 static double mass[kNGEA]={
165  0 ,0 ,0.00051 ,0.00051 ,0
166  ,0.10566 ,0.10566 ,0.13498 ,0.13957 ,0.13957
167  ,0.49767 ,0.4936 ,0.4936 ,0.93957 ,0.93827
168  ,0.93827 ,0.49767 ,0.54745 ,1.11568 ,1.18937
169  ,1.19255 ,1.19744 ,1.3149 ,1.3213 ,1.67245
170  ,0.93957 ,1.11568 ,1.18937 ,1.19255 ,1.19744
171  ,1.3149 ,1.3213 ,1.67245 ,1.777 ,1.777
172  ,1.8693 ,1.8693 ,1.8645 ,1.8645 ,1.9685
173  ,1.9685 ,2.2849 ,80.33 ,80.33 ,91.187
174  ,0 ,0 ,0 ,0 ,0};
175 
176  if (igea>=kNGEA) return 0.;
177  return mass[igea];
178 }
179 
180 //______________________________________________________________________________
181 int StGenParticleMaster::Pdg2Gea(int ipdg)
182 {
183 typedef std::map<int, int > pdgMap_t;
184 static pdgMap_t pdgMap;
185 static int once = 2009;
186 
187  if (once) { once=0; for (int i=0;i<kNGEA;i++) {pdgMap[IDPDG[i]] = IDGEA[i];}}
188 
189  pdgMap_t::iterator it = pdgMap.find(ipdg);
190  if (it == pdgMap.end()) return 0;
191  return (*it).second;
192 }
Abstract base class for particles related to common /HEPEVT/.