Go to the documentation of this file.00001 #include "PhysicsTools/JetMCUtils/interface/CandMCTag.h"
00002 #include <iostream>
00003
00004 using namespace std;
00005 using namespace reco;
00006 using namespace CandMCTagUtils;
00007
00009
00010 std::vector<const reco::Candidate *> CandMCTagUtils::getAncestors(const reco::Candidate &c)
00011 {
00012 vector<const reco::Candidate *> moms;
00013 if( c.numberOfMothers() == 1 ) {
00014 const Candidate * dau = &c;
00015 const Candidate * mom = c.mother();
00016 while ( dau->numberOfMothers() == 1) {
00017 moms.push_back( dau );
00018 dau = mom ;
00019 mom = dau->mother();
00020 }
00021 }
00022 return moms;
00023 }
00024
00025
00026 bool CandMCTagUtils::hasBottom(const reco::Candidate &c)
00027 {
00028 int code1;
00029 int code2;
00030 bool tmpHasBottom = false;
00031 code1 = (int)( ( abs(c.pdgId() ) / 100)%10 );
00032 code2 = (int)( ( abs(c.pdgId() ) /1000)%10 );
00033 if ( code1 == 5 || code2 == 5) tmpHasBottom = true;
00034 return tmpHasBottom;
00035 }
00036
00037 bool CandMCTagUtils::hasCharm(const reco::Candidate &c)
00038 {
00039 int code1;
00040 int code2;
00041 bool tmpHasCharm = false;
00042 code1 = (int)( ( abs(c.pdgId() ) / 100)%10 );
00043 code2 = (int)( ( abs(c.pdgId() ) /1000)%10 );
00044 if ( code1 == 4 || code2 == 4) tmpHasCharm = true;
00045 return tmpHasCharm;
00046 }