CMS 3D CMS Logo

TtFullLepHypothesis.cc
Go to the documentation of this file.
3 
6  : elecsToken_(consumes<std::vector<pat::Electron> >(cfg.getParameter<edm::InputTag>("electrons"))),
7  musToken_(consumes<std::vector<pat::Muon> >(cfg.getParameter<edm::InputTag>("muons"))),
8  jetsToken_(consumes<std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("jets"))),
9  metsToken_(consumes<std::vector<pat::MET> >(cfg.getParameter<edm::InputTag>("mets"))) {
10  getMatch_ = false;
11  if (cfg.exists("match")) {
12  getMatch_ = true;
13  matchToken_ = consumes<std::vector<std::vector<int> > >(cfg.getParameter<edm::InputTag>("match"));
14  }
15  // if no other correction is given apply L3 (abs) correction
16  jetCorrectionLevel_ = "abs";
17  if (cfg.exists("jetCorrectionLevel")) {
18  jetCorrectionLevel_ = cfg.getParameter<std::string>("jetCorrectionLevel");
19  } else { // if no other correction is given apply L3 (abs) correction
20  jetCorrectionLevel_ = "abs";
21  }
22  produces<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > >();
23  produces<int>("Key");
24 }
25 
30 
32  evt.getByToken(musToken_, mus);
33 
36 
39 
40  std::vector<std::vector<int> > matchVec;
41  if (getMatch_) {
43  evt.getByToken(matchToken_, matchHandle);
44  ;
45  matchVec = *matchHandle;
46  } else {
47  std::vector<int> dummyMatch;
48  for (unsigned int i = 0; i < 4; ++i)
49  dummyMatch.push_back(-1);
50  matchVec.push_back(dummyMatch);
51  }
52 
53  // declare unique_ptr for products
54  std::unique_ptr<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > > pOut(
55  new std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > >);
56  std::unique_ptr<int> pKey(new int);
57 
58  // build and feed out key
59  buildKey();
60  *pKey = key();
61  evt.put(std::move(pKey), "Key");
62 
63  // go through given vector of jet combinations
64  unsigned int idMatch = 0;
65  typedef std::vector<std::vector<int> >::iterator MatchVecIterator;
66  for (MatchVecIterator match = matchVec.begin(); match != matchVec.end(); ++match) {
67  // reset pointers
69  // build hypothesis
70  buildHypo(evt, elecs, mus, jets, mets, *match, idMatch++);
71  pOut->push_back(std::make_pair(hypo(), *match));
72  }
73  // feed out hyps and matches
74  evt.put(std::move(pOut));
75 }
76 
79  lepton_.reset();
80  leptonBar_.reset();
81  b_.reset();
82  bBar_.reset();
83  neutrino_.reset();
84  neutrinoBar_.reset();
85  //met_ = 0;
86 }
87 
90  // check for sanity of the hypothesis
91  if (!lepton_ || !leptonBar_ || !b_ || !bBar_) {
92  return reco::CompositeCandidate();
93  }
94 
95  if (key() == TtFullLeptonicEvent::kGenMatch && (!recNu || !recNuBar)) {
96  edm::LogInfo("TtFullHypothesis") << "no neutrinos for gen match" << std::endl;
97  return reco::CompositeCandidate();
98  }
100  edm::LogInfo("TtFullHypothesis") << "no neutrinos for kin solution" << std::endl;
101  return reco::CompositeCandidate();
102  }
103 
104  // setup transient references
106 
107  AddFourMomenta addFourMomenta;
108 
109  // build up the top branch
113  else if (key() == TtFullLeptonicEvent::kGenMatch)
115  addFourMomenta.set(WPlus);
116  Top.addDaughter(WPlus, TtFullLepDaughter::WPlus);
117  Top.addDaughter(std::move(b_), TtFullLepDaughter::B);
118  addFourMomenta.set(Top);
119 
120  // build up the anti top branch
124  else if (key() == TtFullLeptonicEvent::kGenMatch)
126  addFourMomenta.set(WMinus);
129  addFourMomenta.set(TopBar);
130 
131  // build ttbar hypothesis
134  addFourMomenta.set(hyp);
135 
136  // the four momentum of the met is not added to the hypothesis
137  // because it is allready included through the neutrinos
138  //hyp.addDaughter(*met_, TtFullLepDaughter::Met);
139  return hyp;
140 }
141 
143 std::unique_ptr<reco::ShallowClonePtrCandidate> TtFullLepHypothesis::makeCandidate(
144  const edm::Handle<std::vector<pat::Jet> >& handle, const int& idx, const std::string& correctionLevel) {
146  return std::make_unique<reco::ShallowClonePtrCandidate>(
147  ptr, ptr->charge(), ptr->correctedJet(jetCorrectionLevel_, "bottom").p4(), ptr->vertex());
148 }
std::unique_ptr< reco::LeafCandidate > recNu
candidates needed for the genmatch hypothesis
std::unique_ptr< reco::ShallowClonePtrCandidate > leptonBar_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
static const std::string WMinus
void set(reco::Candidate &c) const
set up a candidate
static const std::string Nu
virtual void buildKey()=0
build the event hypothesis key
static const std::string WPlus
int key() const
return key
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
const Point & vertex() const override
vertex position (overwritten by PF...)
static const std::string B
static const std::string Top
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: HeavyIon.h:7
static const std::string Top
static const std::string TopBar
Definition: Muon.py:1
Definition: Jet.py:1
static const std::string WMinus
static const std::string LepBar
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
Jet correctedJet(const std::string &level, const std::string &flavor="none", const std::string &set="") const
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
void resetCandidates()
reset candidate pointers before hypo build process
reco::CompositeCandidate hypo()
return event hypothesis
static const std::string WPlus
Log< level::Info, false > LogInfo
std::unique_ptr< reco::ShallowClonePtrCandidate > neutrino_
static const std::string TopBar
std::unique_ptr< reco::ShallowClonePtrCandidate > neutrinoBar_
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
input label for all necessary collections
virtual void buildHypo(edm::Event &evt, const edm::Handle< std::vector< pat::Electron > > &elecs, const edm::Handle< std::vector< pat::Muon > > &mus, const edm::Handle< std::vector< pat::Jet > > &jets, const edm::Handle< std::vector< pat::MET > > &mets, std::vector< int > &match, const unsigned int iComb)=0
build event hypothesis from the reco objects of a semi-leptonic event
edm::EDGetTokenT< std::vector< pat::Electron > > elecsToken_
void produce(edm::Event &, const edm::EventSetup &) override
produce the event hypothesis as CompositeCandidate and Key
std::unique_ptr< reco::LeafCandidate > recNuBar
std::string jetCorrectionLevel_
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
static const std::string BBar
std::unique_ptr< reco::ShallowClonePtrCandidate > lepton_
HLT enums.
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
std::unique_ptr< reco::ShallowClonePtrCandidate > b_
std::unique_ptr< reco::ShallowClonePtrCandidate > makeCandidate(const edm::Handle< C > &handle, const int &idx)
use one object in a collection to set a ShallowClonePtrCandidate
TtFullLepHypothesis(const edm::ParameterSet &)
default constructor
static const std::string NuBar
static const std::string Lep
def move(src, dest)
Definition: eostools.py:511
int charge() const final
electric charge
edm::EDGetTokenT< std::vector< pat::Muon > > musToken_
std::unique_ptr< reco::ShallowClonePtrCandidate > bBar_