CMS 3D CMS Logo

TtSemiLepEvtPartons.cc
Go to the documentation of this file.
3 
5 
7 {
8  // default: use all partons
9  for(unsigned int i = 0; i < 4; i++)
10  ignorePartons_.push_back(false);
11  // read vector of strings and flag partons to be ignored
12  for(std::vector<std::string>::const_iterator str = partonsToIgnore.begin(); str != partonsToIgnore.end(); ++str) {
13  if ((*str) == "LightQ" ) ignorePartons_[LightQ ] = true;
14  else if((*str) == "LightQBar") ignorePartons_[LightQBar] = true;
15  else if((*str) == "HadB" ) ignorePartons_[HadB ] = true;
16  else if((*str) == "LepB" ) ignorePartons_[LepB ] = true;
17  else throw cms::Exception("Configuration")
18  << "The following string in partonsToIgnore is not supported: " << (*str) << "\n";
19  }
20 }
21 
22 std::vector<const reco::Candidate*>
24 {
25  std::vector<const reco::Candidate*> vec;
26 
27  if(genEvt.isSemiLeptonic()) {
28  // fill vector with partons from genEvent
29  // (use enum for positions of the partons in the vector)
30  vec.resize(4);
31  vec[LightQ ] = genEvt.hadronicDecayQuark() ? genEvt.hadronicDecayQuark() : dummyCandidatePtr();
33  vec[HadB ] = genEvt.hadronicDecayB() ? genEvt.hadronicDecayB() : dummyCandidatePtr();
34  vec[LepB ] = genEvt.leptonicDecayB() ? genEvt.leptonicDecayB() : dummyCandidatePtr();
35  }
36  else {
37  // fill vector with dummy objects if the event is not semi-leptonic ttbar
38  for(unsigned i=0; i<4; i++)
39  vec.push_back( dummyCandidatePtr() );
40  }
41 
42  // erase partons from vector if they where chosen to be ignored
43  prune(vec);
44 
45  return vec;
46 }
const reco::GenParticle * hadronicDecayB(bool excludeTauLeptons=false) const
get b of hadronic decay branch
Definition: TtGenEvent.cc:196
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:72
TtSemiLepEvtPartons(const std::vector< std::string > &partonsToIgnore=std::vector< std::string >())
default constructor
void prune(std::vector< const reco::Candidate * > &vec)
erase partons from vector if they where chosen to be ignored
std::vector< const reco::Candidate * > vec(const TtGenEvent &genEvt) 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:166
const reco::GenParticle * leptonicDecayB(bool excludeTauLeptons=false) const
get b of leptonic decay branch
Definition: TtGenEvent.cc:248
reco::Candidate * dummyCandidatePtr() const
return pointer to an empty reco::Candidate