CMS 3D CMS Logo

TtFullHadEvtPartons.cc
Go to the documentation of this file.
3 
5 
7 {
8  // default: use all partons
9  for(unsigned int i = 0; i < 6; 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) == "B" ) ignorePartons_[B ] = true;
16  else if((*str) == "LightP" ) ignorePartons_[LightP ] = true;
17  else if((*str) == "LightPBar" ) ignorePartons_[LightPBar] = true;
18  else if((*str) == "BBar" ) ignorePartons_[BBar ] = true;
19  else throw cms::Exception("Configuration")
20  << "The following string in partonsToIgnore is not supported: " << (*str) << "\n";
21  }
22 }
23 
24 std::vector<const reco::Candidate*>
26 {
27  std::vector<const reco::Candidate*> vec;
28 
29  if(genEvt.isFullHadronic()) {
30  // fill vector with partons from genEvent
31  // (use enum for positions of the partons in the vector)
32  vec.resize(6);
33  vec[LightQ ] = genEvt.daughterQuarkOfWPlus() ? genEvt.daughterQuarkOfWPlus() : dummyCandidatePtr();
35  vec[B ] = genEvt.b() ? genEvt.b() : dummyCandidatePtr();
38  vec[BBar ] = genEvt.bBar() ? genEvt.bBar() : dummyCandidatePtr();
39  }
40  else {
41  // fill vector with dummy objects if the event is not fully-hadronic ttbar
42  for(unsigned i=0; i<6; i++)
43  vec.push_back( dummyCandidatePtr() );
44  }
45 
46  // erase partons from vector if they where chosen to be ignored
47  prune(vec);
48 
49  return vec;
50 }
const reco::GenParticle * b() const
return b quark if available; 0 else
Definition: TopGenEvent.h:100
TtFullHadEvtPartons(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
const reco::GenParticle * daughterQuarkOfWPlus(bool invertQuarkCharge=false, bool invertBosonCharge=false) const
return quark daughter quark of W boson
Definition: TopGenEvent.cc:170
const reco::GenParticle * bBar() const
return anti-b quark if available; 0 else
Definition: TopGenEvent.h:102
bool isFullHadronic(bool excludeTauLeptons=false) const
check if the event can be classified as full hadronic
Definition: TtGenEvent.h:36
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 * daughterQuarkBarOfWMinus() const
return anti-quark daughter of anti-W boson
Definition: TopGenEvent.h:79
const reco::GenParticle * daughterQuarkBarOfWPlus() const
return anti-quark daughter of W boson
Definition: TopGenEvent.h:77
reco::Candidate * dummyCandidatePtr() const
return pointer to an empty reco::Candidate
#define str(s)
const reco::GenParticle * daughterQuarkOfWMinus() const
return quark daughter of anti-W boson
Definition: TopGenEvent.h:75
std::vector< const reco::Candidate * > vec(const TtGenEvent &genEvt) override
return vector of partons in the order defined in the corresponding enum