CMS 3D CMS Logo

CustomPDGParser.cc

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

Generated on Tue Jun 9 17:47:00 2009 for CMSSW by  doxygen 1.5.4