CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TtFullLepEvtPartons.cc
Go to the documentation of this file.
3 
5 
6 TtFullLepEvtPartons::TtFullLepEvtPartons(const std::vector<std::string>& partonsToIgnore) {
7  // default: use all partons
8  for (unsigned int i = 0; i < 2; i++)
9  ignorePartons_.push_back(false);
10  // read vector of strings and flag partons to be ignored
11  for (std::vector<std::string>::const_iterator str = partonsToIgnore.begin(); str != partonsToIgnore.end(); ++str) {
12  if ((*str) == "B")
13  ignorePartons_[B] = true;
14  else if ((*str) == "BBar")
15  ignorePartons_[BBar] = true;
16  else
17  throw cms::Exception("Configuration")
18  << "The following string in partonsToIgnore is not supported: " << (*str) << "\n";
19  }
20 }
21 
22 std::vector<const reco::Candidate*> TtFullLepEvtPartons::vec(const TtGenEvent& genEvt) {
23  std::vector<const reco::Candidate*> vec;
24 
25  if (genEvt.isFullLeptonic()) {
26  // fill vector with partons from genEvent
27  // (use enum for positions of the partons in the vector)
28  vec.resize(2);
29  vec[B] = genEvt.b() ? genEvt.b() : dummyCandidatePtr();
30  vec[BBar] = genEvt.bBar() ? genEvt.bBar() : dummyCandidatePtr();
31  } else {
32  // fill vector with dummy objects if the event is not fully-leptonic ttbar
33  for (unsigned i = 0; i < 2; i++)
34  vec.push_back(dummyCandidatePtr());
35  }
36 
37  // erase partons from vector if they where chosen to be ignored
38  prune(vec);
39 
40  return vec;
41 }
const reco::GenParticle * b() const
return b quark if available; 0 else
Definition: TopGenEvent.h:97
std::vector< const reco::Candidate * > vec(const TtGenEvent &genEvt) override
return vector of partons in the order defined in the corresponding enum
void prune(std::vector< const reco::Candidate * > &vec)
erase partons from vector if they where chosen to be ignored
const reco::GenParticle * bBar() const
return anti-b quark if available; 0 else
Definition: TopGenEvent.h:99
bool isFullLeptonic(bool excludeTauLeptons=false) const
check if the event can be classified as full leptonic
Definition: TtGenEvent.h:42
Class derived from the TopGenEvent for ttbar events.
Definition: TtGenEvent.h:18
std::vector< bool > ignorePartons_
flag partons that were chosen not to be used
TtFullLepEvtPartons(const std::vector< std::string > &partonsToIgnore=std::vector< std::string >())
default constructor
reco::Candidate * dummyCandidatePtr() const
return pointer to an empty reco::Candidate
#define str(s)