CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CoreSimTrack.cc
Go to the documentation of this file.
2 
3 float CoreSimTrack::charge()const {
4  return float(CoreSimTrack::chargeValue(thePID)/3.);
5 }
6 
7 
8 int CoreSimTrack::chargeValue(const int& Id)const{
9 
10 
11  //...Purpose: to give three times the charge for a particle/parton.
12 
13  // ID = particle ID
14  // hepchg = particle charge times 3
15 
16  int kqa,kq1,kq2,kq3,kqj,irt,kqx,kqn;
17  int hepchg;
18 
19 
20  int ichg[109]={-1,2,-1,2,-1,2,-1,2,0,0,-3,0,-3,0,-3,0,
21 -3,0,0,0,0,0,0,3,0,0,0,0,0,0,3,0,3,6,0,0,3,6,0,0,-1,2,-1,2,-1,2,0,0,0,0,
22 -3,0,-3,0,-3,0,0,0,0,0,-1,2,-1,2,-1,2,0,0,0,0,
23 -3,0,-3,0,-3,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
24 
25 
26  //...Initial values. Simple case of direct readout.
27  hepchg=0;
28  kqa=abs(Id);
29  kqn=kqa/1000000000%10;
30  kqx=kqa/1000000%10;
31  kq3=kqa/1000%10;
32  kq2=kqa/100%10;
33  kq1=kqa/10%10;
34  kqj=kqa%10;
35  irt=kqa%10000;
36 
37  //...illegal or ion
38  //...set ion charge to zero - not enough information
39  if(kqa==0 || kqa >= 10000000) {
40 
41  if(kqn==1) {hepchg=0;}
42  }
43  //... direct translation
44  else if(kqa<=100) {hepchg = ichg[kqa-1];}
45  //... deuteron or tritium
46  else if(kqa==100 || kqa==101) {hepchg = -3;}
47  //... alpha or He3
48  else if(kqa==102 || kqa==104) {hepchg = -6;}
49  //... KS and KL (and undefined)
50  else if(kqj == 0) {hepchg = 0;}
51  //C... direct translation
52  else if(kqx>0 && irt<100)
53  {
54  hepchg = ichg[irt-1];
55  if(kqa==1000017 || kqa==1000018) {hepchg = 0;}
56  if(kqa==1000034 || kqa==1000052) {hepchg = 0;}
57  if(kqa==1000053 || kqa==1000054) {hepchg = 0;}
58  if(kqa==5100061 || kqa==5100062) {hepchg = 6;}
59  }
60  //...Construction from quark content for heavy meson, diquark, baryon.
61  //...Mesons.
62  else if(kq3==0)
63  {
64  hepchg = ichg[kq2-1]-ichg[kq1-1];
65  //...Strange or beauty mesons.
66  if((kq2==3) || (kq2==5)) {hepchg = ichg[kq1-1]-ichg[kq2-1];}
67  }
68  else if(kq1 == 0) {
69  //...Diquarks.
70  hepchg = ichg[kq3-1] + ichg[kq2-1];
71  }
72 
73  else{
74  //...Baryons
75  hepchg = ichg[kq3-1]+ichg[kq2-1]+ichg[kq1-1];
76  }
77 
78  //... fix sign of charge
79  if(Id<0 && hepchg!=0) {hepchg = -1*hepchg;}
80 
81  // cout << hepchg<< endl;
82  return hepchg;
83 }
84 
85 
86 
87 std::ostream & operator <<(std::ostream & o , const CoreSimTrack& t)
88 {
89  o << t.type() << ", ";
90  o << t.momentum();
91  return o;
92 }
#define abs(x)
Definition: mlp_lapack.h:159
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
float charge() const
charge
Definition: CoreSimTrack.cc:3
int chargeValue(const int &) const
Definition: CoreSimTrack.cc:8
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:40
const math::XYZTLorentzVectorD & momentum() const
particle info...
Definition: CoreSimTrack.h:36