File indexing completed on 2023-03-17 11:15:57
0001 #include "PhysicsTools/JetMCUtils/interface/CandMCTag.h"
0002 #include <iostream>
0003
0004 using namespace std;
0005 using namespace reco;
0006 using namespace CandMCTagUtils;
0007
0008
0009
0010 std::vector<const reco::Candidate *> CandMCTagUtils::getAncestors(const reco::Candidate &c) {
0011 vector<const reco::Candidate *> moms;
0012 if (c.numberOfMothers() == 1) {
0013 const Candidate *dau = &c;
0014 const Candidate *mom = c.mother();
0015 while (dau->numberOfMothers() == 1) {
0016 moms.push_back(dau);
0017 dau = mom;
0018 mom = dau->mother();
0019 }
0020 }
0021 return moms;
0022 }
0023
0024 bool CandMCTagUtils::hasBottom(const reco::Candidate &c) {
0025 int code1;
0026 int code2;
0027 bool tmpHasBottom = false;
0028 code1 = (int)((abs(c.pdgId()) / 100) % 10);
0029 code2 = (int)((abs(c.pdgId()) / 1000) % 10);
0030 if (code1 == 5 || code2 == 5)
0031 tmpHasBottom = true;
0032 return tmpHasBottom;
0033 }
0034
0035 bool CandMCTagUtils::hasCharm(const reco::Candidate &c) {
0036 int code1;
0037 int code2;
0038 bool tmpHasCharm = false;
0039 code1 = (int)((abs(c.pdgId()) / 100) % 10);
0040 code2 = (int)((abs(c.pdgId()) / 1000) % 10);
0041 if (code1 == 4 || code2 == 4)
0042 tmpHasCharm = true;
0043 return tmpHasCharm;
0044 }
0045
0046 bool CandMCTagUtils::isParton(const reco::Candidate &c) {
0047 int id = abs(c.pdgId());
0048
0049 if (id == 1 || id == 2 || id == 3 || id == 4 || id == 5 || id == 21)
0050 return true;
0051 else
0052 return false;
0053 }
0054
0055 bool CandMCTagUtils::isLightParton(const reco::Candidate &c) {
0056 int id = abs(c.pdgId());
0057
0058 if (id == 1 || id == 2 || id == 3 || id == 21)
0059 return true;
0060 else
0061 return false;
0062 }