CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TtSemiLepEvtPartons.cc
Go to the documentation of this file.
3 
5 
6 TtSemiLepEvtPartons::TtSemiLepEvtPartons(const std::vector<std::string>& partonsToIgnore) {
7  // default: use all partons
8  for (unsigned int i = 0; i < 4; 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) == "LightQ")
13  ignorePartons_[LightQ] = true;
14  else if ((*str) == "LightQBar")
15  ignorePartons_[LightQBar] = true;
16  else if ((*str) == "HadB")
17  ignorePartons_[HadB] = true;
18  else if ((*str) == "LepB")
19  ignorePartons_[LepB] = true;
20  else
21  throw cms::Exception("Configuration")
22  << "The following string in partonsToIgnore is not supported: " << (*str) << "\n";
23  }
24 }
25 
26 std::vector<const reco::Candidate*> TtSemiLepEvtPartons::vec(const TtGenEvent& genEvt) const {
27  std::vector<const reco::Candidate*> vec;
28 
29  if (genEvt.isSemiLeptonic()) {
30  // fill vector with partons from genEvent
31  // (use enum for positions of the partons in the vector)
32  vec.resize(4);
33  vec[LightQ] = genEvt.hadronicDecayQuark() ? genEvt.hadronicDecayQuark() : dummyCandidatePtr();
35  vec[HadB] = genEvt.hadronicDecayB() ? genEvt.hadronicDecayB() : dummyCandidatePtr();
36  vec[LepB] = genEvt.leptonicDecayB() ? genEvt.leptonicDecayB() : dummyCandidatePtr();
37  } else {
38  // fill vector with dummy objects if the event is not semi-leptonic ttbar
39  for (unsigned i = 0; i < 4; i++)
40  vec.push_back(dummyCandidatePtr());
41  }
42 
43  // erase partons from vector if they where chosen to be ignored
44  prune(vec);
45 
46  return vec;
47 }
const reco::GenParticle * hadronicDecayB(bool excludeTauLeptons=false) const
get b of hadronic decay branch
Definition: TtGenEvent.cc:181
bool isSemiLeptonic(bool excludeTauLeptons=false) const
check if the event can be classified as semi-laptonic
Definition: TtGenEvent.h:38
const reco::GenParticle * hadronicDecayQuarkBar() const
get light anti-quark of hadronic decay branch
Definition: TtGenEvent.h:78
TtSemiLepEvtPartons(const std::vector< std::string > &partonsToIgnore=std::vector< std::string >())
default constructor
void prune(std::vector< const reco::Candidate * > &vec) const
erase partons from vector if they where chosen to be ignored
std::vector< const reco::Candidate * > vec(const TtGenEvent &genEvt) const override
return vector of partons in the order defined in the corresponding enum
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
const reco::GenParticle * hadronicDecayQuark(bool invertFlavor=false) const
get light quark of hadronic decay branch
Definition: TtGenEvent.cc:153
const reco::GenParticle * leptonicDecayB(bool excludeTauLeptons=false) const
get b of leptonic decay branch
Definition: TtGenEvent.cc:227
reco::Candidate * dummyCandidatePtr() const
return pointer to an empty reco::Candidate
#define str(s)