Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:24:51

0001 #include <SimG4Core/CustomPhysics/interface/CustomPDGParser.h>
0002 #include <cstdlib>
0003 
0004 // check for R-hadron with gluino content
0005 bool CustomPDGParser::s_isgluinoHadron(int pdg) {
0006   int pdgAbs = abs(pdg);
0007   return ((pdgAbs % 100000 / 10000 == 9) || (pdgAbs % 10000 / 1000 == 9) || s_isRGlueball(pdg));
0008 }
0009 
0010 bool CustomPDGParser::s_isstopHadron(int pdg) {
0011   int pdgAbs = abs(pdg);
0012   return ((pdgAbs % 10000 / 1000 == 6) || (pdgAbs % 1000 / 100 == 6));
0013 }
0014 
0015 bool CustomPDGParser::s_issbottomHadron(int pdg) {
0016   int pdgAbs = abs(pdg);
0017   return ((pdgAbs % 10000 / 1000 == 5) || (pdgAbs % 10000 / 100 == 5));
0018 }
0019 
0020 bool CustomPDGParser::s_isSLepton(int pdg) {
0021   int pdgAbs = abs(pdg);
0022   return (pdgAbs / 100 % 10000 == 0 && pdgAbs / 10 % 10 == 1);
0023 }
0024 
0025 bool CustomPDGParser::s_isRBaryon(int pdg) {
0026   int pdgAbs = abs(pdg);
0027   return (pdgAbs % 100000 / 10000 == 9);
0028 }
0029 
0030 bool CustomPDGParser::s_isRGlueball(int pdg) {
0031   int pdgAbs = abs(pdg);
0032   return (pdgAbs % 100000 / 10 == 99);
0033 }
0034 
0035 bool CustomPDGParser::s_isDphoton(int pdg) {
0036   int pdgAbs = abs(pdg);
0037   return (pdgAbs == 1072000) || (pdgAbs == 1023);
0038 }
0039 
0040 bool CustomPDGParser::s_isRMeson(int pdg) {
0041   int pdgAbs = abs(pdg);
0042   return (pdgAbs % 10000 / 1000 == 9);
0043 }
0044 
0045 bool CustomPDGParser::s_isMesonino(int pdg) {
0046   int pdgAbs = abs(pdg);
0047   return ((pdgAbs % 10000 / 100 == 6) || (pdgAbs % 10000 / 100 == 5));
0048 }
0049 
0050 bool CustomPDGParser::s_isSbaryon(int pdg) {
0051   int pdgAbs = abs(pdg);
0052   return ((pdgAbs % 10000 / 1000 == 6) || (pdgAbs % 10000 / 1000 == 5));
0053 }
0054 
0055 bool CustomPDGParser::s_isChargino(int pdg) {
0056   int pdgAbs = abs(pdg);
0057   return (pdgAbs == 1000024);
0058 }
0059 
0060 bool CustomPDGParser::s_isSIMP(int pdg) {
0061   int pdgAbs = abs(pdg);
0062   return (pdgAbs == 9000006);
0063 }
0064 
0065 double CustomPDGParser::s_charge(int pdg) {
0066   float charge = 0, sign = 1;
0067   int pdgAbs = abs(pdg);
0068   if (pdg < 0)
0069     sign = -1;
0070 
0071   if (s_isSLepton(pdg))  //Sleptons
0072   {
0073     if (pdgAbs % 2 == 0)
0074       return 0;
0075     else
0076       return -sign;
0077   }
0078 
0079   if (s_isDphoton(pdg)) {
0080     return charge;
0081   }
0082   if (s_isChargino(pdg)) {
0083     return sign;
0084   }
0085   if (s_isSIMP(pdg)) {
0086     return 0;
0087   }
0088   if (s_isRMeson(pdg)) {
0089     std::vector<int> quarks = s_containedQuarks(pdg);
0090     if ((quarks[1] % 2 == 0 && quarks[0] % 2 == 1) || (quarks[1] % 2 == 1 && quarks[0] % 2 == 0))
0091       charge = 1;
0092     charge *= sign;
0093     return charge;
0094   }
0095 
0096   if (s_isRBaryon(pdg)) {
0097     int baryon = s_containedQuarksCode(pdg);
0098     for (int q = 1; q < 1000; q *= 10) {
0099       if (baryon / q % 2 == 0)
0100         charge += 2;
0101       else
0102         charge -= 1;
0103     }
0104     charge /= 3;
0105     charge *= sign;
0106     return charge;
0107   }
0108 
0109   if (s_isMesonino(pdg)) {
0110     int quark = s_containedQuarks(pdg)[0];
0111     int squark = abs(pdg / 100 % 10);
0112     if (squark % 2 == 0 && quark % 2 == 1)
0113       charge = 1;
0114     if (squark % 2 == 1 && quark % 2 == 0)
0115       charge = 1;
0116     charge *= sign;
0117     if (s_issbottomHadron(pdg))
0118       charge *= -1;
0119     return charge;
0120   }
0121 
0122   if (s_isSbaryon(pdg)) {
0123     int baryon = s_containedQuarksCode(pdg) + 100 * (abs(pdg / 1000 % 10));  //Adding the squark back on
0124     for (int q = 1; q < 1000; q *= 10) {
0125       if (baryon / q % 2 == 0)
0126         charge += 2;
0127       else
0128         charge -= 1;
0129     }
0130     charge /= 3;
0131     charge *= sign;
0132     if (s_issbottomHadron(pdg))
0133       charge *= -1;
0134     return charge;
0135   }
0136 
0137   return 0;
0138 }
0139 
0140 double CustomPDGParser::s_spin(int pdg) {
0141   // The PDG numbering is described in the Review of Particle Physics:
0142   // "3. In composite quark systems (diquarks, mesons, and baryons) ...
0143   // the rightmost digit nJ = 2J + 1 gives the system's spin."
0144   // Since this does not apply to SUSY / exotic particles,
0145   // if the spin is important for the simulation
0146   // it should be hard-coded based on PDG ID in this function.
0147   int pdgAbs = abs(pdg);
0148   return pdgAbs % 10;
0149 }
0150 
0151 std::vector<int> CustomPDGParser::s_containedQuarks(int pdg) {
0152   std::vector<int> quarks;
0153   for (int i = s_containedQuarksCode(pdg); i > 0; i /= 10) {
0154     quarks.push_back(i % 10);
0155   }
0156   return quarks;
0157 }
0158 
0159 int CustomPDGParser::s_containedQuarksCode(int pdg) {
0160   int pdgAbs = abs(pdg);
0161   if (s_isRBaryon(pdg))
0162     return pdgAbs / 10 % 1000;
0163 
0164   if (s_isRMeson(pdg))
0165     return pdgAbs / 10 % 100;
0166 
0167   if (s_isMesonino(pdg))
0168     return pdgAbs / 10 % 1000 % 10;
0169 
0170   if (s_isSbaryon(pdg))
0171     return pdgAbs / 10 % 1000 % 100;
0172 
0173   return 0;
0174 }