CMS 3D CMS Logo

CoreSimTrack.cc
Go to the documentation of this file.
2 
3 const float onethird = 1. / 3.;
4 const float twothird = 2. / 3.;
5 const float chg[109] = {-onethird, twothird, -onethird, twothird, -onethird, twothird, -onethird, twothird, 0, 0,
6  -1, 0, -1, 0, -1, 0, -1, 0, 0, 0,
7  0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
8  1, 0, 1, 2, 0, 0, 1, 2, 0, 0,
10  -1, 0, -1, 0, -1, 0, 0, 0, 0, 0,
11  -onethird, twothird, -onethird, twothird, -onethird, twothird, 0, 0, 0, 0,
12  -1, 0, -1, 0, -1, 0, 1, 1, 0, 0,
13  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
14  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15  0, 0, 0, 0, 0, 0, 0, 0, 0};
16 
17 float CoreSimTrack::charge() const {
18  float hepchg = 0;
19  if (thePID != 0) {
20  int kqa = std::abs(thePID);
21  if (kqa < 10000000) {
22  //... direct translation
23  if (kqa <= 100) {
24  hepchg = chg[kqa - 1];
25  }
26  //... deuteron or tritium
27  else if (kqa == 100 || kqa == 101) {
28  hepchg = -1;
29  }
30  //... alpha or He3
31  else if (kqa == 102 || kqa == 104) {
32  hepchg = -2;
33  } else if (kqa % 10 != 0) {
34  int kqx = kqa / 1000000 % 10;
35  int kq3 = kqa / 1000 % 10;
36  int kq2 = kqa / 100 % 10;
37  int kq1 = kqa / 10 % 10;
38  int irt = kqa % 10000;
39  if (kqx > 0 && irt < 100) {
40  hepchg = chg[irt - 1];
41  if (kqa == 5100061 || kqa == 5100062) {
42  hepchg = 2;
43  }
44  } else if (kq3 == 0) {
45  // Construction from quark content for heavy meson,
46  // diquark, baryon, mesons.
47  hepchg = chg[kq2 - 1] - chg[kq1 - 1];
48  //...Strange or beauty mesons.
49  if ((kq2 == 3) || (kq2 == 5)) {
50  hepchg = chg[kq1 - 1] - chg[kq2 - 1];
51  }
52  } else if (kq1 == 0) {
53  //...Diquarks.
54  hepchg = chg[kq3 - 1] + chg[kq2 - 1];
55  } else {
56  //...Baryons
57  hepchg = chg[kq3 - 1] + chg[kq2 - 1] + chg[kq1 - 1];
58  }
59  }
60  //... fix sign of charge
61  if (thePID < 0) {
62  hepchg = -hepchg;
63  }
64  }
65  }
66  return hepchg;
67 }
68 
69 std::ostream& operator<<(std::ostream& o, const CoreSimTrack& t) {
70  o << t.type() << ", ";
71  o << t.momentum();
72  return o;
73 }
std::ostream & operator<<(std::ostream &o, const CoreSimTrack &t)
Definition: CoreSimTrack.cc:69
const float chg[109]
Definition: CoreSimTrack.cc:5
float charge() const
charge
Definition: CoreSimTrack.cc:17
const float onethird
Definition: CoreSimTrack.cc:3
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const float twothird
Definition: CoreSimTrack.cc:4
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:22
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:19