CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes | Private Member Functions
TtSemiLepHypGenMatch Class Reference
Inheritance diagram for TtSemiLepHypGenMatch:
TtSemiLepHypothesis edm::stream::EDProducer<>

Public Member Functions

 TtSemiLepHypGenMatch (const edm::ParameterSet &)
 
- Public Member Functions inherited from TtSemiLepHypothesis
 TtSemiLepHypothesis (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 Attributes

edm::EDGetTokenT< TtGenEventgenEvtToken_
 
- Protected Attributes inherited from TtSemiLepHypothesis
bool getMatch_
 
std::unique_ptr< reco::ShallowClonePtrCandidatehadronicB_
 
std::string jetCorrectionLevel_
 
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
 input label for all necessary collections More...
 
int key_
 hypothesis key (to be set by the buildKey function) More...
 
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
 
std::unique_ptr< reco::ShallowClonePtrCandidatelepton_
 
std::unique_ptr< reco::ShallowClonePtrCandidateleptonicB_
 
std::unique_ptr< reco::ShallowClonePtrCandidatelightQ_
 
std::unique_ptr< reco::ShallowClonePtrCandidatelightQBar_
 
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
 
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
 
std::unique_ptr< reco::ShallowClonePtrCandidateneutrino_
 
int neutrinoSolutionType_
 algorithm used to calculate neutrino solutions (see cfi for further details) More...
 
edm::EDGetTokenT< int > nJetsConsideredToken_
 
int numberOfRealNeutrinoSolutions_
 

Private Member Functions

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 More...
 
void buildKey () override
 build the event hypothesis key More...
 
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; return -1 if this fails More...
 

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
 
- Protected Member Functions inherited from TtSemiLepHypothesis
void buildHypo (const edm::Handle< edm::View< reco::RecoCandidate > > &leps, const edm::Handle< std::vector< pat::MET > > &mets, const edm::Handle< std::vector< pat::Jet > > &jets, std::vector< int > &jetPartonAssociation)
 minimalistic build function for simple hypotheses 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...
 
std::string jetCorrectionLevel (const std::string &quarkType)
 helper function to construct the proper correction level string for corresponding quarkType More...
 
int key () const
 
WDecay::LeptonType leptonType (const reco::RecoCandidate *cand)
 determine lepton type of reco candidate and return a corresponding WDecay::LeptonType; the type is kNone if it is whether a muon nor an electron More...
 
template<typename C >
std::unique_ptr< reco::ShallowClonePtrCandidatemakeCandidate (const edm::Handle< C > &handle, const int &idx)
 use one object in a collection to set a ShallowClonePtrCandidate More...
 
std::unique_ptr< reco::ShallowClonePtrCandidatemakeCandidate (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...
 
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 More...
 

Detailed Description

Definition at line 6 of file TtSemiLepHypGenMatch.cc.

Constructor & Destructor Documentation

◆ TtSemiLepHypGenMatch()

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

Definition at line 27 of file TtSemiLepHypGenMatch.cc.

28  : TtSemiLepHypothesis(cfg), genEvtToken_(consumes<TtGenEvent>(edm::InputTag("genEvt"))) {}
TtSemiLepHypothesis(const edm::ParameterSet &)
default constructor
edm::EDGetTokenT< TtGenEvent > genEvtToken_

Member Function Documentation

◆ buildHypo()

void TtSemiLepHypGenMatch::buildHypo ( edm::Event evt,
const edm::Handle< edm::View< reco::RecoCandidate > > &  leps,
const edm::Handle< std::vector< pat::MET > > &  mets,
const edm::Handle< std::vector< pat::Jet > > &  jets,
std::vector< int > &  match,
const unsigned int  iComb 
)
overrideprivatevirtual

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

Implements TtSemiLepHypothesis.

Definition at line 30 of file TtSemiLepHypGenMatch.cc.

References funct::abs(), findMatchingLepton(), TtGenEvtProducer_cfi::genEvt, genEvtToken_, edm::Event::getByToken(), TtSemiLepEvtPartons::HadB, TtSemiLepHypothesis::hadronicB_, heavyIonCSV_trainingSettings::idx, TtSemiLepHypothesis::isValid(), TtSemiLepHypothesis::jetCorrectionLevel(), PDWG_EXODelayedJetMET_cff::jets, TtSemiLepEvtPartons::LepB, TtSemiLepHitFitProducer_Electrons_cfi::leps, TtSemiLepHypothesis::lepton_, TtSemiLepHypothesis::leptonicB_, TtSemiLepEvtPartons::LightQ, TtSemiLepHypothesis::lightQ_, TtSemiLepEvtPartons::LightQBar, TtSemiLepHypothesis::lightQBar_, TtSemiLepHypothesis::makeCandidate(), match(), singleTopDQM_cfi::mets, TtSemiLepHypothesis::neutrino_, TtSemiLepHypothesis::neutrinoSolutionType_, and TtSemiLepHypothesis::setNeutrino().

35  {
36  // -----------------------------------------------------
37  // get genEvent (to distinguish between uds and c quarks
38  // and for the lepton matching)
39  // -----------------------------------------------------
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)
52  else
54  break;
56  if (std::abs(genEvt->hadronicDecayQuarkBar()->pdgId()) == 4)
58  else
60  break;
63  break;
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)
87  else
89 }
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:528
std::unique_ptr< reco::ShallowClonePtrCandidate > leptonicB_
std::unique_ptr< reco::ShallowClonePtrCandidate > lepton_
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_
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 ...

◆ buildKey()

void TtSemiLepHypGenMatch::buildKey ( )
inlineoverrideprivatevirtual

build the event hypothesis key

Implements TtSemiLepHypothesis.

Definition at line 12 of file TtSemiLepHypGenMatch.cc.

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

int key_
hypothesis key (to be set by the buildKey function)

◆ findMatchingLepton()

int TtSemiLepHypGenMatch::findMatchingLepton ( const edm::Handle< TtGenEvent > &  genEvt,
const edm::Handle< edm::View< reco::RecoCandidate > > &  leps 
)
private

find index of the candidate nearest to the singleLepton of the generator event in the collection; return -1 if this fails

Definition at line 92 of file TtSemiLepHypGenMatch.cc.

References PbPb_ZMuSkimMuonDPG_cff::deltaR, HGC3DClusterGenMatchSelector_cfi::dR, TtGenEvtProducer_cfi::genEvt, mps_fire::i, TtSemiLepHitFitProducer_Electrons_cfi::leps, TtSemiLepHypothesis::leptonType(), and HLT_2024v10_cff::minDR.

Referenced by buildHypo().

93  {
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 }
WDecay::LeptonType leptonType(const reco::RecoCandidate *cand)
determine lepton type of reco candidate and return a corresponding WDecay::LeptonType; the type is kN...

Member Data Documentation

◆ genEvtToken_

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

Definition at line 24 of file TtSemiLepHypGenMatch.cc.

Referenced by buildHypo().