CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes | Private Member Functions
TtFullLepHypGenMatch Class Reference

#include <TtFullLepHypGenMatch.h>

Inheritance diagram for TtFullLepHypGenMatch:
TtFullLepHypothesis edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 TtFullLepHypGenMatch (const edm::ParameterSet &)
 
 ~TtFullLepHypGenMatch () override
 
- Public Member Functions inherited from TtFullLepHypothesis
 TtFullLepHypothesis (const edm::ParameterSet &)
 default constructor More...
 
 ~TtFullLepHypothesis () override
 default destructor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Attributes

edm::EDGetTokenT< TtGenEventgenEvtToken_
 
- Protected Attributes inherited from TtFullLepHypothesis
reco::ShallowClonePtrCandidateb_
 
reco::ShallowClonePtrCandidatebBar_
 
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...
 
reco::ShallowClonePtrCandidatelepton_
 
reco::ShallowClonePtrCandidateleptonBar_
 
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_
 
reco::ShallowClonePtrCandidateneutrino_
 
reco::ShallowClonePtrCandidateneutrinoBar_
 
reco::LeafCandidaterecNu
 candidates needed for the genmatch hypothesis More...
 
reco::LeafCandidaterecNuBar
 

Private Member Functions

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) override
 build event hypothesis from the reco objects of a semi-leptonic event More...
 
void buildKey () override
 build the event hypothesis key More...
 
void buildMatchingNeutrinos (edm::Event &, const edm::Handle< std::vector< pat::MET > > &)
 
template<typename O >
int findMatchingLepton (const reco::GenParticle *, const edm::Handle< std::vector< O > > &)
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from TtFullLepHypothesis
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...
 
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...
 
template<typename C >
void setCandidate (const edm::Handle< C > &handle, const int &idx, reco::ShallowClonePtrCandidate *&clone)
 use one object in a collection to set a ShallowClonePtrCandidate More...
 
void setCandidate (const edm::Handle< std::vector< pat::Jet > > &handle, const int &idx, reco::ShallowClonePtrCandidate *&clone, const std::string &correctionLevel)
 use one object in a jet collection to set a ShallowClonePtrCandidate with proper jet corrections More...
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 7 of file TtFullLepHypGenMatch.h.

Constructor & Destructor Documentation

◆ TtFullLepHypGenMatch()

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

Definition at line 5 of file TtFullLepHypGenMatch.cc.

6  : TtFullLepHypothesis(cfg), genEvtToken_(consumes<TtGenEvent>(edm::InputTag("genEvt"))) {}

◆ ~TtFullLepHypGenMatch()

TtFullLepHypGenMatch::~TtFullLepHypGenMatch ( )
override

Definition at line 8 of file TtFullLepHypGenMatch.cc.

8 {}

Member Function Documentation

◆ buildHypo()

void TtFullLepHypGenMatch::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 
)
overrideprivatevirtual

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

Implements TtFullLepHypothesis.

Definition at line 10 of file TtFullLepHypGenMatch.cc.

16  {
17  // -----------------------------------------------------
18  // add jets
19  // -----------------------------------------------------
20  for (unsigned idx = 0; idx < match.size(); ++idx) {
21  if (isValid(match[idx], jets)) {
22  switch (idx) {
25  break;
28  break;
29  }
30  }
31  }
32 
33  // -----------------------------------------------------
34  // add leptons
35  // -----------------------------------------------------
36  // get genEvent
39 
40  // push back fake indices if no leptons in genevent
41  if (!genEvt->isFullLeptonic() || !genEvt->lepton() || !genEvt->leptonBar()) {
42  match.push_back(-1);
43  match.push_back(-1);
44  match.push_back(-1);
45  match.push_back(-1);
46  } else if (genEvt->isFullLeptonic(WDecay::kElec, WDecay::kElec) && elecs->size() >= 2) {
47  //search indices for electrons
48  int iLepBar = findMatchingLepton(genEvt->leptonBar(), elecs);
49  setCandidate(elecs, iLepBar, leptonBar_);
50  match.push_back(iLepBar);
51  int iLep = findMatchingLepton(genEvt->lepton(), elecs);
52  setCandidate(elecs, iLep, lepton_);
53  match.push_back(iLep);
54 
55  // fake indices for muons
56  match.push_back(-1);
57  match.push_back(-1);
58  } else if (genEvt->isFullLeptonic(WDecay::kElec, WDecay::kMuon) && !elecs->empty() && !mus->empty()) {
59  if (genEvt->leptonBar()->isElectron()) {
60  // push back index for e+
61  int iLepBar = findMatchingLepton(genEvt->leptonBar(), elecs);
62  setCandidate(elecs, iLepBar, leptonBar_);
63  match.push_back(iLepBar);
64  // push back fake indices for e- and mu+
65  match.push_back(-1);
66  match.push_back(-1);
67  // push back index for mu-
68  int iLep = findMatchingLepton(genEvt->lepton(), mus);
69  setCandidate(mus, iLep, lepton_);
70  match.push_back(iLep);
71  } else {
72  // push back fake index for e+
73  match.push_back(-1);
74  // push back index for e-
75  int iLepBar = findMatchingLepton(genEvt->leptonBar(), mus);
76  setCandidate(mus, iLepBar, leptonBar_);
77  match.push_back(iLepBar);
78  // push back index for mu+
79  int iLep = findMatchingLepton(genEvt->lepton(), elecs);
80  setCandidate(elecs, iLep, lepton_);
81  match.push_back(iLep);
82  // push back fake index for mu-
83  match.push_back(-1);
84  }
85  } else if (genEvt->isFullLeptonic(WDecay::kMuon, WDecay::kMuon) && mus->size() >= 2) {
86  // fake indices for electrons
87  match.push_back(-1);
88  match.push_back(-1);
89 
90  //search indices for electrons
91  int iLepBar = findMatchingLepton(genEvt->leptonBar(), mus);
92  setCandidate(mus, iLepBar, leptonBar_);
93  match.push_back(iLepBar);
94  int iLep = findMatchingLepton(genEvt->lepton(), mus);
95  setCandidate(mus, iLep, lepton_);
96  match.push_back(iLep);
97  } else { //this 'else' should happen if at least one genlepton is a tau
98  match.push_back(-1);
99  match.push_back(-1);
100  match.push_back(-1);
101  match.push_back(-1);
102  }
103 
104  // -----------------------------------------------------
105  // add met and neutrinos
106  // -----------------------------------------------------
107  if (!mets->empty()) {
108  //setCandidate(mets, 0, met_);
110  }
111 }

References TtFullLepEvtPartons::B, TtFullLepHypothesis::b_, TtFullLepEvtPartons::BBar, TtFullLepHypothesis::bBar_, buildMatchingNeutrinos(), singleTopDQM_cfi::elecs, findMatchingLepton(), TtGenEvtProducer_cfi::genEvt, genEvtToken_, edm::Event::getByToken(), training_settings::idx, TtFullLepHypothesis::isValid(), TtFullLepHypothesis::jetCorrectionLevel_, singleTopDQM_cfi::jets, WDecay::kElec, WDecay::kMuon, TtFullLepHypothesis::lepton_, TtFullLepHypothesis::leptonBar_, match(), singleTopDQM_cfi::mets, and TtFullLepHypothesis::setCandidate().

◆ buildKey()

void TtFullLepHypGenMatch::buildKey ( )
inlineoverrideprivatevirtual

build the event hypothesis key

Implements TtFullLepHypothesis.

Definition at line 14 of file TtFullLepHypGenMatch.h.

References TtFullLepHypothesis::key_, and TtEvent::kGenMatch.

◆ buildMatchingNeutrinos()

void TtFullLepHypGenMatch::buildMatchingNeutrinos ( edm::Event evt,
const edm::Handle< std::vector< pat::MET > > &  mets 
)
private

Definition at line 128 of file TtFullLepHypGenMatch.cc.

128  {
129  // get genEvent
132 
133  if (genEvt->isTtBar() && genEvt->isFullLeptonic() && genEvt->neutrino() && genEvt->neutrinoBar()) {
134  double momXNu = genEvt->neutrino()->px();
135  double momYNu = genEvt->neutrino()->py();
136  double momXNuBar = genEvt->neutrinoBar()->px();
137  double momYNuBar = genEvt->neutrinoBar()->py();
138 
139  double momXMet = mets->at(0).px();
140  double momYMet = mets->at(0).py();
141 
142  double momXNeutrino = 0.5 * (momXNu - momXNuBar + momXMet);
143  double momYNeutrino = 0.5 * (momYNu - momYNuBar + momYMet);
144  double momXNeutrinoBar = momXMet - momXNeutrino;
145  double momYNeutrinoBar = momYMet - momYNeutrino;
146 
147  math::XYZTLorentzVector recNuFM(
148  momXNeutrino, momYNeutrino, 0, sqrt(momXNeutrino * momXNeutrino + momYNeutrino * momYNeutrino));
149  recNu = new reco::LeafCandidate(0, recNuFM);
150 
151  math::XYZTLorentzVector recNuBarFM(momXNeutrinoBar,
152  momYNeutrinoBar,
153  0,
154  sqrt(momXNeutrinoBar * momXNeutrinoBar + momYNeutrinoBar * momYNeutrinoBar));
155  recNuBar = new reco::LeafCandidate(0, recNuBarFM);
156  }
157 }

References TtGenEvtProducer_cfi::genEvt, genEvtToken_, edm::Event::getByToken(), singleTopDQM_cfi::mets, TtFullLepHypothesis::recNu, TtFullLepHypothesis::recNuBar, and mathSSE::sqrt().

Referenced by buildHypo().

◆ findMatchingLepton()

template<typename O >
int TtFullLepHypGenMatch::findMatchingLepton ( const reco::GenParticle genLep,
const edm::Handle< std::vector< O > > &  leps 
)
private

Definition at line 114 of file TtFullLepHypGenMatch.cc.

115  {
116  int idx = -1;
117  double minDR = -1;
118  for (unsigned i = 0; i < leps->size(); ++i) {
119  double dR = deltaR(genLep->eta(), genLep->phi(), (*leps)[i].eta(), (*leps)[i].phi());
120  if (minDR < 0 || dR < minDR) {
121  minDR = dR;
122  idx = i;
123  }
124  }
125  return idx;
126 }

References PbPb_ZMuSkimMuonDPG_cff::deltaR, HGC3DClusterGenMatchSelector_cfi::dR, reco::LeafCandidate::eta(), mps_fire::i, training_settings::idx, TtSemiLepHitFitProducer_Electrons_cfi::leps, PDWG_EXOHSCP_cff::minDR, and reco::LeafCandidate::phi().

Referenced by buildHypo().

Member Data Documentation

◆ genEvtToken_

edm::EDGetTokenT<TtGenEvent> TtFullLepHypGenMatch::genEvtToken_
protected

Definition at line 29 of file TtFullLepHypGenMatch.h.

Referenced by buildHypo(), and buildMatchingNeutrinos().

mps_fire.i
i
Definition: mps_fire.py:355
TtFullLepEvtPartons::BBar
Definition: TtFullLepEvtPartons.h:25
TtFullLepHypothesis::isValid
bool isValid(const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
check if index is in valid range of selected jets
Definition: TtFullLepHypothesis.h:59
TtFullLepHypothesis::setCandidate
void setCandidate(const edm::Handle< C > &handle, const int &idx, reco::ShallowClonePtrCandidate *&clone)
use one object in a collection to set a ShallowClonePtrCandidate
Definition: TtFullLepHypothesis.h:112
TtFullLepHypothesis::b_
reco::ShallowClonePtrCandidate * b_
Definition: TtFullLepHypothesis.h:98
TtFullLepHypGenMatch::buildMatchingNeutrinos
void buildMatchingNeutrinos(edm::Event &, const edm::Handle< std::vector< pat::MET > > &)
Definition: TtFullLepHypGenMatch.cc:128
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
singleTopDQM_cfi.mets
mets
Definition: singleTopDQM_cfi.py:43
edm::Handle
Definition: AssociativeIterator.h:50
training_settings.idx
idx
Definition: training_settings.py:16
TtSemiLepHitFitProducer_Electrons_cfi.leps
leps
Definition: TtSemiLepHitFitProducer_Electrons_cfi.py:5
TtFullLepHypGenMatch::findMatchingLepton
int findMatchingLepton(const reco::GenParticle *, const edm::Handle< std::vector< O > > &)
Definition: TtFullLepHypGenMatch.cc:114
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
singleTopDQM_cfi.elecs
elecs
Definition: singleTopDQM_cfi.py:41
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
PDWG_EXOHSCP_cff.minDR
minDR
Definition: PDWG_EXOHSCP_cff.py:109
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
TtFullLepHypothesis::recNuBar
reco::LeafCandidate * recNuBar
Definition: TtFullLepHypothesis.h:106
TtFullLepHypothesis::lepton_
reco::ShallowClonePtrCandidate * lepton_
Definition: TtFullLepHypothesis.h:96
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
looper.cfg
cfg
Definition: looper.py:297
TtEvent::kGenMatch
Definition: TtEvent.h:34
TtFullLepEvtPartons::B
Definition: TtFullLepEvtPartons.h:25
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition: LeafCandidate.h:148
TtFullLepHypothesis::TtFullLepHypothesis
TtFullLepHypothesis(const edm::ParameterSet &)
default constructor
Definition: TtFullLepHypothesis.cc:5
WDecay::kMuon
Definition: TopGenEvent.h:27
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
TtFullLepHypothesis::recNu
reco::LeafCandidate * recNu
candidates needed for the genmatch hypothesis
Definition: TtFullLepHypothesis.h:105
TtFullLepHypGenMatch::genEvtToken_
edm::EDGetTokenT< TtGenEvent > genEvtToken_
Definition: TtFullLepHypGenMatch.h:29
TtFullLepHypothesis::jetCorrectionLevel_
std::string jetCorrectionLevel_
Definition: TtFullLepHypothesis.h:91
TtFullLepHypothesis::leptonBar_
reco::ShallowClonePtrCandidate * leptonBar_
Definition: TtFullLepHypothesis.h:97
reco::LeafCandidate
Definition: LeafCandidate.h:16
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
WDecay::kElec
Definition: TopGenEvent.h:27
TtFullLepHypothesis::bBar_
reco::ShallowClonePtrCandidate * bBar_
Definition: TtFullLepHypothesis.h:99
edm::InputTag
Definition: InputTag.h:15
TtFullLepHypothesis::key_
int key_
hypothesis key (to be set by the buildKey function)
Definition: TtFullLepHypothesis.h:93
TtGenEvtProducer_cfi.genEvt
genEvt
Definition: TtGenEvtProducer_cfi.py:7