Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:52

0001 #include "SimDataFormats/Track/interface/CoreSimTrack.h"
0002 
0003 const float onethird = 1. / 3.;
0004 const float twothird = 2. / 3.;
0005 const float chg[109] = {-onethird, twothird, -onethird, twothird, -onethird, twothird, -onethird, twothird, 0, 0,
0006                         -1,        0,        -1,        0,        -1,        0,        -1,        0,        0, 0,
0007                         0,         0,        0,         1,        0,         0,        0,         0,        0, 0,
0008                         1,         0,        1,         2,        0,         0,        1,         2,        0, 0,
0009                         -onethird, twothird, -onethird, twothird, -onethird, twothird, 0,         0,        0, 0,
0010                         -1,        0,        -1,        0,        -1,        0,        0,         0,        0, 0,
0011                         -onethird, twothird, -onethird, twothird, -onethird, twothird, 0,         0,        0, 0,
0012                         -1,        0,        -1,        0,        -1,        0,        1,         1,        0, 0,
0013                         0,         0,        0,         0,        0,         0,        0,         0,        0, 0,
0014                         0,         0,        0,         0,        0,         0,        0,         0,        0, 0,
0015                         0,         0,        0,         0,        0,         0,        0,         0,        0};
0016 
0017 float CoreSimTrack::charge() const {
0018   float hepchg = 0;
0019   if (thePID != 0) {
0020     int kqa = std::abs(thePID);
0021     if (kqa < 10000000) {
0022       //... direct translation
0023       if (kqa <= 100) {
0024         hepchg = chg[kqa - 1];
0025       }
0026       //... deuteron or tritium
0027       else if (kqa == 100 || kqa == 101) {
0028         hepchg = -1;
0029       }
0030       //... alpha or He3
0031       else if (kqa == 102 || kqa == 104) {
0032         hepchg = -2;
0033       } else if (kqa % 10 != 0) {
0034         int kqx = kqa / 1000000 % 10;
0035         int kq3 = kqa / 1000 % 10;
0036         int kq2 = kqa / 100 % 10;
0037         int kq1 = kqa / 10 % 10;
0038         int irt = kqa % 10000;
0039         if (kqx > 0 && irt < 100) {
0040           hepchg = chg[irt - 1];
0041           if (kqa == 5100061 || kqa == 5100062) {
0042             hepchg = 2;
0043           }
0044         } else if (kq3 == 0) {
0045           //   Construction from quark content for heavy meson,
0046           //   diquark, baryon, mesons.
0047           hepchg = chg[kq2 - 1] - chg[kq1 - 1];
0048           //...Strange or beauty mesons.
0049           if ((kq2 == 3) || (kq2 == 5)) {
0050             hepchg = chg[kq1 - 1] - chg[kq2 - 1];
0051           }
0052         } else if (kq1 == 0) {
0053           //...Diquarks.
0054           hepchg = chg[kq3 - 1] + chg[kq2 - 1];
0055         } else {
0056           //...Baryons
0057           hepchg = chg[kq3 - 1] + chg[kq2 - 1] + chg[kq1 - 1];
0058         }
0059       }
0060       //... fix sign of charge
0061       if (thePID < 0) {
0062         hepchg = -hepchg;
0063       }
0064     }
0065   }
0066   return hepchg;
0067 }
0068 
0069 std::ostream& operator<<(std::ostream& o, const CoreSimTrack& t) {
0070   o << t.type() << ", ";
0071   o << t.momentum();
0072   return o;
0073 }