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 
11  lepton_(nullptr), leptonBar_(nullptr), b_(nullptr),
12  bBar_(nullptr), neutrino_(nullptr), neutrinoBar_(nullptr)
13 {
14  getMatch_ = false;
15  if( cfg.exists("match") ) {
16  getMatch_ = true;
17  matchToken_ = consumes<std::vector<std::vector<int> > >(cfg.getParameter<edm::InputTag>("match"));
18  }
19  // if no other correction is given apply L3 (abs) correction
20  jetCorrectionLevel_ = "abs";
21  if( cfg.exists("jetCorrectionLevel") ) {
22  jetCorrectionLevel_ = cfg.getParameter<std::string>("jetCorrectionLevel");
23  }
24  else{ // if no other correction is given apply L3 (abs) correction
25  jetCorrectionLevel_ = "abs";
26  }
27  produces<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > >();
28  produces<int>("Key");
29 }
30 
33 {
34  if( lepton_ ) delete lepton_;
35  if( leptonBar_ ) delete leptonBar_;
36  if( b_ ) delete b_;
37  if( bBar_ ) delete bBar_;
38  if( neutrino_ ) delete neutrino_;
39  if( neutrinoBar_ ) delete neutrinoBar_;
40  //if( met_ ) delete met_;
41 }
42 
44 void
46 {
48  evt.getByToken(elecsToken_, elecs);
49 
51  evt.getByToken(musToken_, mus);
52 
54  evt.getByToken(jetsToken_, jets);
55 
57  evt.getByToken(metsToken_, mets);
58 
59  std::vector<std::vector<int> > matchVec;
60  if( getMatch_ ) {
62  evt.getByToken(matchToken_, matchHandle);;
63  matchVec = *matchHandle;
64  }
65  else {
66  std::vector<int> dummyMatch;
67  for(unsigned int i = 0; i < 4; ++i)
68  dummyMatch.push_back( -1 );
69  matchVec.push_back( dummyMatch );
70  }
71 
72  // declare unique_ptr for products
73  std::unique_ptr<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > >
74  pOut( new std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > );
75  std::unique_ptr<int> pKey(new int);
76 
77  // build and feed out key
78  buildKey();
79  *pKey=key();
80  evt.put(std::move(pKey), "Key");
81 
82  // go through given vector of jet combinations
83  unsigned int idMatch = 0;
84  typedef std::vector<std::vector<int> >::iterator MatchVecIterator;
85  for(MatchVecIterator match = matchVec.begin(); match != matchVec.end(); ++match) {
86  // reset pointers
88  // build hypothesis
89  buildHypo(evt, elecs, mus, jets, mets, *match, idMatch++);
90  pOut->push_back( std::make_pair(hypo(), *match) );
91  }
92  // feed out hyps and matches
93  evt.put(std::move(pOut));
94 }
95 
97 void
99 {
100  lepton_ = nullptr;
101  leptonBar_ = nullptr;
102  b_ = nullptr;
103  bBar_ = nullptr;
104  neutrino_ = nullptr;
105  neutrinoBar_= nullptr;
106  //met_ = 0;
107 }
108 
112 {
113  // check for sanity of the hypothesis
114  if( !lepton_ || !leptonBar_ || !b_ || !bBar_ ){
115  return reco::CompositeCandidate();
116  }
117 
119  edm::LogInfo("TtFullHypothesis") << "no neutrinos for gen match" << std::endl;
120  return reco::CompositeCandidate();
121  }
123  edm::LogInfo("TtFullHypothesis") << "no neutrinos for kin solution" << std::endl;
124  return reco::CompositeCandidate();
125  }
126 
127  // setup transient references
129 
130  AddFourMomenta addFourMomenta;
131 
132  // build up the top branch
138  addFourMomenta.set(WPlus);
141  addFourMomenta.set(Top);
142 
143  // build up the anti top branch
149  addFourMomenta.set(WMinus);
150  TopBar.addDaughter(WMinus, TtFullLepDaughter::WMinus);
152  addFourMomenta.set(TopBar);
153 
154  // build ttbar hypothesis
157  addFourMomenta.set( hyp );
158 
159  // the four momentum of the met is not added to the hypothesis
160  // because it is allready included through the neutrinos
161  //hyp.addDaughter(*met_, TtFullLepDaughter::Met);
162  return hyp;
163 }
164 
166 void
167 TtFullLepHypothesis::setCandidate(const edm::Handle<std::vector<pat::Jet> >& handle, const int& idx, reco::ShallowClonePtrCandidate*& clone, const std::string& correctionLevel)
168 {
170  clone = new reco::ShallowClonePtrCandidate( ptr, ptr->charge(), ptr->correctedJet(jetCorrectionLevel_, "bottom").p4(), ptr->vertex() );
171 }
T getParameter(std::string const &) const
reco::ShallowClonePtrCandidate * neutrino_
reco::ShallowClonePtrCandidate * leptonBar_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
static const std::string WMinus
reco::LeafCandidate * recNuBar
static const std::string Nu
void setCandidate(const edm::Handle< C > &handle, const int &idx, reco::ShallowClonePtrCandidate *&clone)
use one object in a collection to set a ShallowClonePtrCandidate
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
virtual void buildKey()=0
build the event hypothesis key
bool exists(std::string const &parameterName) const
checks if a parameter exists
reco::LeafCandidate * recNu
candidates needed for the genmatch hypothesis
static const std::string WPlus
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
int charge() const final
electric charge
Definition: LeafCandidate.h:91
static const std::string B
static const std::string Top
#define nullptr
Definition: HeavyIon.h:7
static const std::string Top
static const std::string TopBar
Definition: Muon.py:1
Definition: Jet.py:1
vector< PseudoJet > jets
const Point & vertex() const override
vertex position (overwritten by PF...)
static const std::string WMinus
static const std::string LepBar
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
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
static const std::string TopBar
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_
reco::ShallowClonePtrCandidate * lepton_
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
reco::ShallowClonePtrCandidate * bBar_
void produce(edm::Event &, const edm::EventSetup &) override
produce the event hypothesis as CompositeCandidate and Key
std::string jetCorrectionLevel_
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
static const std::string BBar
HLT enums.
int key() const
return key
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
void set(reco::Candidate &c) const
set up a candidate
reco::ShallowClonePtrCandidate * b_
Jet correctedJet(const std::string &level, const std::string &flavor="none", const std::string &set="") const
TtFullLepHypothesis(const edm::ParameterSet &)
default constructor
static const std::string NuBar
~TtFullLepHypothesis() override
default destructor
static const std::string Lep
def move(src, dest)
Definition: eostools.py:511
reco::ShallowClonePtrCandidate * neutrinoBar_
edm::EDGetTokenT< std::vector< pat::Muon > > musToken_