CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
TtFullLepHypothesis Class Referenceabstract

#include <TtFullLepHypothesis.h>

Inheritance diagram for TtFullLepHypothesis:
edm::stream::EDProducer<> TtFullLepHypGenMatch TtFullLepHypKinSolution

Public Member Functions

 TtFullLepHypothesis (const edm::ParameterSet &)
 default constructor More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Protected Member Functions

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 More...
 
virtual void buildKey ()=0
 build the event hypothesis key More...
 
reco::CompositeCandidate hypo ()
 return event hypothesis More...
 
bool isValid (const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
 check if index is in valid range of selected jets More...
 
int key () const
 return key More...
 
template<typename C >
std::unique_ptr
< reco::ShallowClonePtrCandidate
makeCandidate (const edm::Handle< C > &handle, const int &idx)
 use one object in a collection to set a ShallowClonePtrCandidate More...
 
std::unique_ptr
< reco::ShallowClonePtrCandidate
makeCandidate (const edm::Handle< std::vector< pat::Jet > > &handle, const int &idx, const std::string &correctionLevel)
 use one object in a jet collection to set a ShallowClonePtrCandidate with proper jet corrections More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 produce the event hypothesis as CompositeCandidate and Key More...
 
void resetCandidates ()
 reset candidate pointers before hypo build process More...
 

Protected Attributes

std::unique_ptr
< reco::ShallowClonePtrCandidate
b_
 
std::unique_ptr
< reco::ShallowClonePtrCandidate
bBar_
 
edm::EDGetTokenT< std::vector
< pat::Electron > > 
elecsToken_
 
bool getMatch_
 
std::string jetCorrectionLevel_
 
edm::EDGetTokenT< std::vector
< pat::Jet > > 
jetsToken_
 
int key_
 hypothesis key (to be set by the buildKey function) More...
 
std::unique_ptr
< reco::ShallowClonePtrCandidate
lepton_
 
std::unique_ptr
< reco::ShallowClonePtrCandidate
leptonBar_
 
edm::EDGetTokenT< std::vector
< std::vector< int > > > 
matchToken_
 input label for all necessary collections More...
 
edm::EDGetTokenT< std::vector
< pat::MET > > 
metsToken_
 
edm::EDGetTokenT< std::vector
< pat::Muon > > 
musToken_
 
std::unique_ptr
< reco::ShallowClonePtrCandidate
neutrino_
 
std::unique_ptr
< reco::ShallowClonePtrCandidate
neutrinoBar_
 
std::unique_ptr
< reco::LeafCandidate
recNu
 candidates needed for the genmatch hypothesis More...
 
std::unique_ptr
< reco::LeafCandidate
recNuBar
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 34 of file TtFullLepHypothesis.h.

Constructor & Destructor Documentation

TtFullLepHypothesis::TtFullLepHypothesis ( const edm::ParameterSet cfg)
explicit

default constructor

Definition at line 5 of file TtFullLepHypothesis.cc.

References edm::ParameterSet::exists(), getMatch_, edm::ParameterSet::getParameter(), jetCorrectionLevel_, matchToken_, and AlCaHLTBitMon_QueryRunRegistry::string.

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 }
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
input label for all necessary collections
edm::EDGetTokenT< std::vector< pat::Electron > > elecsToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string jetCorrectionLevel_
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
edm::EDGetTokenT< std::vector< pat::Muon > > musToken_

Member Function Documentation

virtual void TtFullLepHypothesis::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 
)
protectedpure virtual

build event hypothesis from the reco objects of a semi-leptonic event

Implemented in TtFullLepHypGenMatch, and TtFullLepHypKinSolution.

Referenced by produce().

virtual void TtFullLepHypothesis::buildKey ( )
protectedpure virtual

build the event hypothesis key

Implemented in TtFullLepHypGenMatch, and TtFullLepHypKinSolution.

Referenced by produce().

reco::CompositeCandidate TtFullLepHypothesis::hypo ( )
protected

return event hypothesis

Definition at line 89 of file TtFullLepHypothesis.cc.

References reco::CompositeCandidate::addDaughter(), TtFullLepDaughter::B, b_, TtFullLepDaughter::BBar, bBar_, key(), TtEvent::kGenMatch, TtEvent::kKinSolution, TtFullLepDaughter::Lep, TtFullLepDaughter::LepBar, lepton_, leptonBar_, eostools::move(), neutrino_, neutrinoBar_, TtFullLepDaughter::Nu, TtFullLepDaughter::NuBar, recNu, recNuBar, AddFourMomenta::set(), TtFullHadDaughter::Top, TtFullLepDaughter::Top, TtFullLepDaughter::TopBar, TtFullHadDaughter::TopBar, TtFullLepDaughter::WMinus, TtFullHadDaughter::WMinus, TtFullLepDaughter::WPlus, and TtFullHadDaughter::WPlus.

Referenced by produce().

89  {
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);
118  addFourMomenta.set(Top);
119 
120  // build up the anti top branch
124  else if (key() == TtFullLeptonicEvent::kGenMatch)
126  addFourMomenta.set(WMinus);
127  TopBar.addDaughter(WMinus, TtFullLepDaughter::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 }
std::unique_ptr< reco::LeafCandidate > recNu
candidates needed for the genmatch hypothesis
std::unique_ptr< reco::ShallowClonePtrCandidate > leptonBar_
static const std::string WMinus
static const std::string Nu
static const std::string WPlus
static const std::string B
static const std::string Top
static const std::string Top
static const std::string TopBar
def move
Definition: eostools.py:511
static const std::string WMinus
static const std::string LepBar
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
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_
std::unique_ptr< reco::LeafCandidate > recNuBar
static const std::string BBar
std::unique_ptr< reco::ShallowClonePtrCandidate > lepton_
int key() const
return key
void set(reco::Candidate &c) const
set up a candidate
std::unique_ptr< reco::ShallowClonePtrCandidate > b_
static const std::string NuBar
static const std::string Lep
std::unique_ptr< reco::ShallowClonePtrCandidate > bBar_
bool TtFullLepHypothesis::isValid ( const int &  idx,
const edm::Handle< std::vector< pat::Jet > > &  jets 
)
inlineprotected

check if index is in valid range of selected jets

Definition at line 56 of file TtFullLepHypothesis.h.

References fwrapper::jets.

Referenced by ntupleDataFormat._Object::_checkIsValid(), TtFullLepHypGenMatch::buildHypo(), and core.AutoHandle.AutoHandle::ReallyLoad().

56  {
57  return (0 <= idx && idx < (int)jets->size());
58  };
int TtFullLepHypothesis::key ( ) const
inlineprotected

return key

Definition at line 52 of file TtFullLepHypothesis.h.

References key_.

Referenced by hypo(), and produce().

52 { return key_; };
int key_
hypothesis key (to be set by the buildKey function)
template<typename C >
std::unique_ptr< reco::ShallowClonePtrCandidate > TtFullLepHypothesis::makeCandidate ( const edm::Handle< C > &  handle,
const int &  idx 
)
protected

use one object in a collection to set a ShallowClonePtrCandidate

Definition at line 109 of file TtFullLepHypothesis.h.

References patZpeak::handle.

Referenced by TtFullLepHypKinSolution::buildHypo(), and TtFullLepHypGenMatch::buildHypo().

110  {
111  typedef typename C::value_type O;
112  edm::Ptr<O> ptr = edm::Ptr<O>(handle, idx);
113  return std::make_unique<reco::ShallowClonePtrCandidate>(ptr, ptr->charge(), ptr->p4(), ptr->vertex());
114 }
tuple handle
Definition: patZpeak.py:25
std::unique_ptr< reco::ShallowClonePtrCandidate > TtFullLepHypothesis::makeCandidate ( const edm::Handle< std::vector< pat::Jet > > &  handle,
const int &  idx,
const std::string &  correctionLevel 
)
protected

use one object in a jet collection to set a ShallowClonePtrCandidate with proper jet corrections

Definition at line 143 of file TtFullLepHypothesis.cc.

References patZpeak::handle, and jetCorrectionLevel_.

144  {
146  return std::make_unique<reco::ShallowClonePtrCandidate>(
147  ptr, ptr->charge(), ptr->correctedJet(jetCorrectionLevel_, "bottom").p4(), ptr->vertex());
148 }
tuple handle
Definition: patZpeak.py:25
std::string jetCorrectionLevel_
void TtFullLepHypothesis::produce ( edm::Event evt,
const edm::EventSetup setup 
)
overrideprotected

produce the event hypothesis as CompositeCandidate and Key

Definition at line 27 of file TtFullLepHypothesis.cc.

References buildHypo(), buildKey(), elecsToken_, edm::Event::getByToken(), getMatch_, hypo(), mps_fire::i, fwrapper::jets, jetsToken_, key(), match(), matchToken_, metsToken_, eostools::move(), musToken_, edm::Event::put(), resetCandidates(), and trackerHitRTTI::vector.

27  {
29  evt.getByToken(elecsToken_, elecs);
30 
32  evt.getByToken(musToken_, mus);
33 
35  evt.getByToken(jetsToken_, jets);
36 
38  evt.getByToken(metsToken_, mets);
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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
virtual void buildKey()=0
build the event hypothesis key
vector< PseudoJet > jets
def move
Definition: eostools.py:511
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
void resetCandidates()
reset candidate pointers before hypo build process
reco::CompositeCandidate hypo()
return event hypothesis
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_
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
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
edm::EDGetTokenT< std::vector< pat::Muon > > musToken_
void TtFullLepHypothesis::resetCandidates ( )
protected

reset candidate pointers before hypo build process

Definition at line 78 of file TtFullLepHypothesis.cc.

References b_, bBar_, lepton_, leptonBar_, neutrino_, and neutrinoBar_.

Referenced by produce().

78  {
79  lepton_.reset();
80  leptonBar_.reset();
81  b_.reset();
82  bBar_.reset();
83  neutrino_.reset();
84  neutrinoBar_.reset();
85  //met_ = 0;
86 }
std::unique_ptr< reco::ShallowClonePtrCandidate > leptonBar_
std::unique_ptr< reco::ShallowClonePtrCandidate > neutrino_
std::unique_ptr< reco::ShallowClonePtrCandidate > neutrinoBar_
std::unique_ptr< reco::ShallowClonePtrCandidate > lepton_
std::unique_ptr< reco::ShallowClonePtrCandidate > b_
std::unique_ptr< reco::ShallowClonePtrCandidate > bBar_

Member Data Documentation

std::unique_ptr<reco::ShallowClonePtrCandidate> TtFullLepHypothesis::b_
protected
std::unique_ptr<reco::ShallowClonePtrCandidate> TtFullLepHypothesis::bBar_
protected
edm::EDGetTokenT<std::vector<pat::Electron> > TtFullLepHypothesis::elecsToken_
protected

Definition at line 82 of file TtFullLepHypothesis.h.

Referenced by produce().

bool TtFullLepHypothesis::getMatch_
protected

internal check whether the match information exists or not, if false a blind dummy match vector will be used internally

Definition at line 79 of file TtFullLepHypothesis.h.

Referenced by produce(), and TtFullLepHypothesis().

std::string TtFullLepHypothesis::jetCorrectionLevel_
protected

specify the desired jet correction level (the default should be L3Absolute-'abs')

Definition at line 88 of file TtFullLepHypothesis.h.

Referenced by TtFullLepHypKinSolution::buildHypo(), TtFullLepHypGenMatch::buildHypo(), makeCandidate(), and TtFullLepHypothesis().

edm::EDGetTokenT<std::vector<pat::Jet> > TtFullLepHypothesis::jetsToken_
protected

Definition at line 84 of file TtFullLepHypothesis.h.

Referenced by produce().

int TtFullLepHypothesis::key_
protected

hypothesis key (to be set by the buildKey function)

Definition at line 90 of file TtFullLepHypothesis.h.

Referenced by TtFullLepHypKinSolution::buildKey(), TtFullLepHypGenMatch::buildKey(), and key().

std::unique_ptr<reco::ShallowClonePtrCandidate> TtFullLepHypothesis::lepton_
protected

candidates for internal use for the creation of the hypothesis candidate

Definition at line 93 of file TtFullLepHypothesis.h.

Referenced by TtFullLepHypKinSolution::buildHypo(), TtFullLepHypGenMatch::buildHypo(), hypo(), and resetCandidates().

std::unique_ptr<reco::ShallowClonePtrCandidate> TtFullLepHypothesis::leptonBar_
protected
edm::EDGetTokenT<std::vector<std::vector<int> > > TtFullLepHypothesis::matchToken_
protected

input label for all necessary collections

Definition at line 81 of file TtFullLepHypothesis.h.

Referenced by produce(), and TtFullLepHypothesis().

edm::EDGetTokenT<std::vector<pat::MET> > TtFullLepHypothesis::metsToken_
protected

Definition at line 85 of file TtFullLepHypothesis.h.

Referenced by produce().

edm::EDGetTokenT<std::vector<pat::Muon> > TtFullLepHypothesis::musToken_
protected

Definition at line 83 of file TtFullLepHypothesis.h.

Referenced by produce().

std::unique_ptr<reco::ShallowClonePtrCandidate> TtFullLepHypothesis::neutrino_
protected

Definition at line 97 of file TtFullLepHypothesis.h.

Referenced by TtFullLepHypKinSolution::buildHypo(), hypo(), and resetCandidates().

std::unique_ptr<reco::ShallowClonePtrCandidate> TtFullLepHypothesis::neutrinoBar_
protected

Definition at line 98 of file TtFullLepHypothesis.h.

Referenced by TtFullLepHypKinSolution::buildHypo(), hypo(), and resetCandidates().

std::unique_ptr<reco::LeafCandidate> TtFullLepHypothesis::recNu
protected

candidates needed for the genmatch hypothesis

Definition at line 102 of file TtFullLepHypothesis.h.

Referenced by TtFullLepHypGenMatch::buildMatchingNeutrinos(), and hypo().

std::unique_ptr<reco::LeafCandidate> TtFullLepHypothesis::recNuBar
protected

Definition at line 103 of file TtFullLepHypothesis.h.

Referenced by TtFullLepHypGenMatch::buildMatchingNeutrinos(), and hypo().