Go to the documentation of this file.00001 #include <SimG4Core/CustomPhysics/interface/CustomPDGParser.h>
00002
00003 #include <cstdlib>
00004
00005
00006
00007
00008
00009
00010 bool CustomPDGParser::s_isRHadron(int pdg)
00011 {
00012 int pdgAbs=abs(pdg);
00013 return ( (pdgAbs % 100000 / 10000 == 9) || (pdgAbs % 10000 / 1000 == 9) || s_isRGlueball(pdg) );
00014 }
00015
00016 bool CustomPDGParser::s_isstopHadron(int pdg)
00017 {
00018 int pdgAbs=abs(pdg);
00019 return ( (pdgAbs % 10000 / 1000 == 6) || (pdgAbs % 1000 / 100 == 6) );
00020 }
00021
00022
00023 bool CustomPDGParser::s_isSLepton(int pdg)
00024 {
00025 int pdgAbs=abs(pdg);
00026 return (pdgAbs / 100 % 10000 == 0 && pdgAbs / 10 % 10 == 1);
00027 }
00028
00029 bool CustomPDGParser::s_isRBaryon(int pdg)
00030 {
00031 int pdgAbs=abs(pdg);
00032 return (pdgAbs % 100000 / 10000 == 9);
00033
00034 }
00035
00036 bool CustomPDGParser::s_isRGlueball(int pdg)
00037 {
00038 int pdgAbs=abs(pdg);
00039 return (pdgAbs % 100000 / 10 == 99);
00040
00041 }
00042
00043 bool CustomPDGParser::s_isRMeson(int pdg)
00044 {
00045 int pdgAbs=abs(pdg);
00046 return (pdgAbs % 10000 / 1000 == 9);
00047
00048 }
00049
00050 bool CustomPDGParser::s_isMesonino(int pdg)
00051 {
00052 int pdgAbs=abs(pdg);
00053 return (pdgAbs % 10000 / 100 == 6);
00054
00055 }
00056
00057 bool CustomPDGParser::s_isSbaryon(int pdg)
00058 {
00059 int pdgAbs=abs(pdg);
00060 return (pdgAbs % 10000 / 1000 == 6);
00061
00062 }
00063
00064
00065 double CustomPDGParser::s_charge(int pdg)
00066 {
00067 float charge=0,sign=1;
00068 int pdgAbs=abs(pdg);
00069 if(pdg < 0 ) sign=-1;
00070
00071 if(s_isSLepton(pdg))
00072 {
00073 if(pdgAbs %2 == 0)
00074 return 0;
00075 else
00076 return -sign;
00077 }
00078
00079 if(s_isRMeson(pdg))
00080 {
00081 std::vector<int> quarks = s_containedQuarks(pdg);
00082 if((quarks[1] % 2 == 0 && quarks[0] % 2 == 1)||(quarks[1] % 2 == 1 && quarks[0] % 2 == 0 )) charge=1;
00083 charge*=sign;
00084 return charge;
00085 }
00086
00087 if(s_isRBaryon(pdg))
00088 {
00089 int baryon = s_containedQuarksCode(pdg);
00090 for(int q=1; q< 1000; q*=10)
00091 {
00092 if(baryon / q % 2 == 0) charge+=2; else charge -=1;
00093 }
00094 charge/=3;
00095 charge*=sign;
00096 return charge;
00097 }
00098
00099 if(s_isMesonino(pdg))
00100 {
00101 int quark = s_containedQuarks(pdg)[0];
00102 int squark = abs(pdg/100%10);
00103 if (squark % 2 == 0 && quark % 2 == 1) charge = 1;
00104 if (squark % 2 == 1 && quark % 2 == 0) charge = 1;
00105 charge *= sign;
00106 return charge;
00107 }
00108
00109 if(s_isSbaryon(pdg))
00110 {
00111 int baryon = s_containedQuarksCode(pdg)+100*(abs(pdg/1000%10));
00112 for(int q=1; q< 1000; q*=10)
00113 {
00114 if(baryon / q % 2 == 0) charge+=2; else charge -=1;
00115 }
00116 charge/=3;
00117 charge*=sign;
00118 return charge;
00119 }
00120
00121 return 0;
00122 }
00123
00124 double CustomPDGParser::s_spin(int pdg)
00125 {
00126 int pdgAbs=abs(pdg);
00127 return pdgAbs % 10;
00128 }
00129
00130 std::vector<int> CustomPDGParser::s_containedQuarks(int pdg)
00131 {
00132 std::vector<int> quarks;
00133 for(int i=s_containedQuarksCode(pdg); i > 0; i /= 10)
00134 {
00135 quarks.push_back(i % 10);
00136 }
00137 return quarks;
00138 }
00139
00140 int CustomPDGParser::s_containedQuarksCode(int pdg)
00141 {
00142 int pdgAbs=abs(pdg);
00143 if(s_isRBaryon(pdg))
00144 return pdgAbs / 10 % 1000;
00145
00146 if(s_isRMeson(pdg))
00147 return pdgAbs / 10 % 100;
00148
00149 if(s_isMesonino(pdg))
00150 return pdgAbs / 10 % 1000 % 10;
00151
00152 if(s_isSbaryon(pdg))
00153 return pdgAbs / 10 % 1000 % 100;
00154
00155
00156 return 0;
00157 }