CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TtSemiLepHypGenMatch.cc
Go to the documentation of this file.
5 
7 public:
9 
10 private:
14  void buildHypo(edm::Event&,
16  const edm::Handle<std::vector<pat::MET> >&,
17  const edm::Handle<std::vector<pat::Jet> >&,
18  std::vector<int>&,
19  const unsigned int iComb) override;
22 
23 protected:
25 };
26 
28  : TtSemiLepHypothesis(cfg), genEvtToken_(consumes<TtGenEvent>(edm::InputTag("genEvt"))) {}
29 
32  const edm::Handle<std::vector<pat::MET> >& mets,
33  const edm::Handle<std::vector<pat::Jet> >& jets,
34  std::vector<int>& match,
35  const unsigned int iComb) {
36  // -----------------------------------------------------
37  // get genEvent (to distinguish between uds and c quarks
38  // and for the lepton matching)
39  // -----------------------------------------------------
41  evt.getByToken(genEvtToken_, genEvt);
42 
43  // -----------------------------------------------------
44  // add jets
45  // -----------------------------------------------------
46  for (unsigned idx = 0; idx < match.size(); ++idx) {
47  if (isValid(match[idx], jets)) {
48  switch (idx) {
50  if (std::abs(genEvt->hadronicDecayQuark()->pdgId()) == 4)
51  lightQ_ = makeCandidate(jets, match[idx], jetCorrectionLevel("cQuark"));
52  else
53  lightQ_ = makeCandidate(jets, match[idx], jetCorrectionLevel("udsQuark"));
54  break;
56  if (std::abs(genEvt->hadronicDecayQuarkBar()->pdgId()) == 4)
57  lightQBar_ = makeCandidate(jets, match[idx], jetCorrectionLevel("cQuark"));
58  else
59  lightQBar_ = makeCandidate(jets, match[idx], jetCorrectionLevel("udsQuark"));
60  break;
62  hadronicB_ = makeCandidate(jets, match[idx], jetCorrectionLevel("bQuark"));
63  break;
65  leptonicB_ = makeCandidate(jets, match[idx], jetCorrectionLevel("bQuark"));
66  break;
67  }
68  }
69  }
70 
71  // -----------------------------------------------------
72  // add lepton
73  // -----------------------------------------------------
74  int iLepton = findMatchingLepton(genEvt, leps);
75  if (iLepton < 0)
76  return;
77  lepton_ = makeCandidate(leps, iLepton);
78  match.push_back(iLepton);
79 
80  // -----------------------------------------------------
81  // add neutrino
82  // -----------------------------------------------------
83  if (mets->empty())
84  return;
85  if (neutrinoSolutionType_ == -1)
86  neutrino_ = makeCandidate(mets, 0);
87  else
88  setNeutrino(mets, leps, iLepton, neutrinoSolutionType_);
89 }
90 
94  int genIdx = -1;
95 
96  // jump out with -1 when the collection is empty
97  if (leps->empty())
98  return genIdx;
99 
100  if (genEvt->isTtBar() && genEvt->isSemiLeptonic(leptonType(&(leps->front()))) && genEvt->singleLepton()) {
101  double minDR = -1;
102  for (unsigned i = 0; i < leps->size(); ++i) {
103  double dR =
104  deltaR(genEvt->singleLepton()->eta(), genEvt->singleLepton()->phi(), (*leps)[i].eta(), (*leps)[i].phi());
105  if (minDR < 0 || dR < minDR) {
106  minDR = dR;
107  genIdx = i;
108  }
109  }
110  }
111  return genIdx;
112 }
113 
tuple cfg
Definition: looper.py:296
WDecay::LeptonType leptonType(const reco::RecoCandidate *cand)
determine lepton type of reco candidate and return a corresponding WDecay::LeptonType; the type is kN...
bool isValid(const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
check if index is in valid range of selected jets
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
genEvtToken_(mayConsume< TtGenEvent >(genEvt_))
std::unique_ptr< reco::ShallowClonePtrCandidate > leptonicB_
std::unique_ptr< reco::ShallowClonePtrCandidate > lepton_
Class derived from the TopGenEvent for ttbar events.
Definition: TtGenEvent.h:18
void buildHypo(edm::Event &, const edm::Handle< edm::View< reco::RecoCandidate > > &, const edm::Handle< std::vector< pat::MET > > &, const edm::Handle< std::vector< pat::Jet > > &, std::vector< int > &, const unsigned int iComb) override
build event hypothesis from the reco objects of a semi-leptonic event
vector< PseudoJet > jets
std::unique_ptr< reco::ShallowClonePtrCandidate > makeCandidate(const edm::Handle< C > &handle, const int &idx)
use one object in a collection to set a ShallowClonePtrCandidate
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int findMatchingLepton(const edm::Handle< TtGenEvent > &genEvt, const edm::Handle< edm::View< reco::RecoCandidate > > &)
find index of the candidate nearest to the singleLepton of the generator event in the collection; ret...
std::unique_ptr< reco::ShallowClonePtrCandidate > lightQBar_
TtSemiLepHypGenMatch(const edm::ParameterSet &)
void buildKey() override
build the event hypothesis key
void setNeutrino(const edm::Handle< std::vector< pat::MET > > &met, const edm::Handle< edm::View< reco::RecoCandidate > > &leps, const int &idx, const int &type)
set neutrino, using mW = 80.4 to calculate the neutrino pz
std::unique_ptr< reco::ShallowClonePtrCandidate > neutrino_
std::unique_ptr< reco::ShallowClonePtrCandidate > lightQ_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
int neutrinoSolutionType_
algorithm used to calculate neutrino solutions (see cfi for further details)
edm::EDGetTokenT< TtGenEvent > genEvtToken_
std::unique_ptr< reco::ShallowClonePtrCandidate > hadronicB_
std::string jetCorrectionLevel(const std::string &quarkType)
helper function to construct the proper correction level string for corresponding quarkType ...
int key_
hypothesis key (to be set by the buildKey function)