CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/SimG4Core/CustomPhysics/src/CustomPDGParser.cc

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