CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CandMCTag.cc
Go to the documentation of this file.
2 #include <iostream>
3 
4 using namespace std;
5 using namespace reco;
6 using namespace CandMCTagUtils;
7 
9 
10 std::vector<const reco::Candidate *> CandMCTagUtils::getAncestors(const reco::Candidate &c)
11 {
12  vector<const reco::Candidate *> moms;
13  if( c.numberOfMothers() == 1 ) {
14  const Candidate * dau = &c;
15  const Candidate * mom = c.mother();
16  while ( dau->numberOfMothers() == 1) {
17  moms.push_back( dau );
18  dau = mom ;
19  mom = dau->mother();
20  }
21  }
22  return moms;
23 }
24 
25 
27 {
28  int code1;
29  int code2;
30  bool tmpHasBottom = false;
31  code1 = (int)( ( abs(c.pdgId() ) / 100)%10 );
32  code2 = (int)( ( abs(c.pdgId() ) /1000)%10 );
33  if ( code1 == 5 || code2 == 5) tmpHasBottom = true;
34  return tmpHasBottom;
35  }
36 
38 {
39  int code1;
40  int code2;
41  bool tmpHasCharm = false;
42  code1 = (int)( ( abs(c.pdgId() ) / 100)%10 );
43  code2 = (int)( ( abs(c.pdgId() ) /1000)%10 );
44  if ( code1 == 4 || code2 == 4) tmpHasCharm = true;
45  return tmpHasCharm;
46 }
47 
49 {
50  int id = abs(c.pdgId());
51 
52  if( id == 1 ||
53  id == 2 ||
54  id == 3 ||
55  id == 4 ||
56  id == 5 ||
57  id == 21 )
58  return true;
59  else
60  return false;
61 }
62 
64 {
65  int id = abs(c.pdgId());
66 
67  if( id == 1 ||
68  id == 2 ||
69  id == 3 ||
70  id == 21 )
71  return true;
72  else
73  return false;
74 }
bool isLightParton(const reco::Candidate &c)
Definition: CandMCTag.cc:63
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
std::vector< const reco::Candidate * > getAncestors(const reco::Candidate &c)
Definition: CandMCTag.cc:10
bool hasCharm(const reco::Candidate &c)
Definition: CandMCTag.cc:37
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual int pdgId() const =0
PDG identifier.
bool isParton(const reco::Candidate &c)
Definition: CandMCTag.cc:48
bool hasBottom(const reco::Candidate &c)
Definition: CandMCTag.cc:26