00001 #include <iostream> 00002 using namespace std; 00003 00004 #include "RecoBTag/MCTools/interface/MCParticleInfo.h" 00005 00006 MCParticleInfo::MCParticleInfo( int LC ) { 00007 reset(); 00008 setCode( LC ); 00009 } 00010 00011 MCParticleInfo::~MCParticleInfo() { 00012 } 00013 00014 void MCParticleInfo::reset () { 00015 isInitialised = false; 00016 // particle info 00017 lundCode_ = 0; 00018 lundCodeOfHeaviestQuark_ = 0; 00019 // for hadrons 00020 isHadron_ = false; 00021 isBottomHadron_ = false; 00022 isCharmHadron_ = false; 00023 isStrangeHadron_ = false; 00024 hasStrangeness_ = false; 00025 isBaryon_ = false; 00026 // for partons 00027 isParton_ = false; 00028 isD_ = false; 00029 isU_ = false; 00030 isS_ = false; 00031 isC_ = false; 00032 isB_ = false; 00033 isGluon_ = false; 00034 isQuark_ = false; 00035 // for light charged leptons 00036 isLepton_ = false; 00037 } 00038 00039 void MCParticleInfo::setCode( int LC ) { 00040 lundCode_ = LC; 00041 // decode this code and set data members accordingly 00042 // decompose in digits 00043 int kfa = abs(lundCode_); 00044 int kf2 = kfa; 00045 int n4 = kf2 / 10000; 00046 kf2 = kf2 - n4*10000; 00047 int n3 = kf2 / 1000; 00048 kf2 = kf2 - n3*1000 ; 00049 int n2 = kf2 / 100; 00050 kf2 = kf2 - n2*100; 00051 int n1 = kf2 / 10; 00052 kf2 = kf2 - n1*10; 00053 00054 int isign; 00055 if ( lundCode_ >= 0 ) { 00056 isign = 1; 00057 } 00058 else { 00059 isign = -1; 00060 } 00061 00062 //hadron? 00063 isHadron_ = false; 00064 if ( n3 != 0 || n2 != 0 ) isHadron_ = true; 00065 00066 //baryon? 00067 isBaryon_ = false; 00068 if ( n3 != 0 ) isBaryon_ = true; 00069 00070 // imax: if baryon: n3 00071 // meson : n2 * (-1)**max(...) 00072 // def.: imax > 0 for quark; < 0 for antiquark 00073 // strange: if baryon: n3 or n2 or n1 00074 // meson : n2 or n1 00075 00076 int iqmax; // flavour of heaviest quark 00077 hasStrangeness_ = false; 00078 00079 if ( isBaryon_ ) { 00080 iqmax = n3; 00081 iqmax = iqmax * isign; 00082 if ( n3==3 || n2==3 || n1==3 ) hasStrangeness_ = true; 00083 } 00084 else { 00085 iqmax = n2; 00086 // adjust sign 00087 iqmax = iqmax * isign; 00088 for ( int ii=1; ii<=n2; ii++ ) iqmax = iqmax * -1; 00089 if (n2==3 || n1==3) hasStrangeness_ = true; 00090 } 00091 00092 // hadron type 00093 isBottomHadron_ = false; 00094 isCharmHadron_ = false; 00095 isStrangeHadron_ = false; 00096 if ( abs(iqmax) == 5 ) isBottomHadron_ = true; 00097 if ( abs(iqmax) == 4 ) isCharmHadron_ = true; 00098 if ( abs(iqmax) == 3 ) isStrangeHadron_ = true; 00099 00100 00101 // partons 00102 if ( abs ( lundCode_ ) == 1 ) isD_ = true ; 00103 if ( abs ( lundCode_ ) == 2 ) isU_ = true ; 00104 if ( abs ( lundCode_ ) == 3 ) isS_ = true ; 00105 if ( abs ( lundCode_ ) == 4 ) isC_ = true ; 00106 if ( abs ( lundCode_ ) == 5 ) isB_ = true ; 00107 if ( abs ( lundCode_ ) == 21 ) isGluon_ = true ; 00108 isParton_ = isD_ || isU_ || isS_ || isC_ || isB_ || isGluon_ ; 00109 isQuark_ = isD_ || isU_ || isS_ || isC_ || isB_ ; 00110 00111 lundCodeOfHeaviestQuark_ = iqmax ; 00112 00113 // light charged leptons 00114 if (( abs ( lundCode_ ) == 11 ) || 00115 ( abs ( lundCode_ ) == 13 )) isLepton_ = true; 00116 00117 // now it's initialised properly 00118 isInitialised = true; 00119 } 00120 00121 void MCParticleInfo::print() const { 00122 // print all particle Info 00123 cout << "--> MCParticleInfo:" << endl; 00124 cout << "--> LundCode :" << lundCode_ << endl; 00125 cout << "--> LundCodeOfHeaviestQuark:" << lundCodeOfHeaviestQuark_ << endl; 00126 cout << "--> BottomHadron :" << isBottomHadron_ << endl; 00127 cout << "--> CharmHadron :" << isCharmHadron_ << endl; 00128 cout << "--> StrangeHadron :" << isStrangeHadron_ << endl; 00129 cout << "--> strange :" << hasStrangeness_ << endl; 00130 cout << "--> baryon :" << isBaryon_ << endl; 00131 cout << "--> Parton :" << isParton_ << endl; 00132 cout << "--> D :" << isD_ << endl; 00133 cout << "--> U :" << isU_ << endl; 00134 cout << "--> S :" << isS_ << endl; 00135 cout << "--> C :" << isC_ << endl; 00136 cout << "--> B :" << isB_ << endl; 00137 cout << "--> Gluon :" << isGluon_ << endl; 00138 cout << "--> Quark :" << isQuark_ << endl; 00139 cout << "--> Lepton :" << isLepton_ << endl; 00140 } 00141