CMS 3D CMS Logo

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

Public Member Functions

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

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

Detailed Description

Definition at line 7 of file TtFullLepHypGenMatch.cc.

Constructor & Destructor Documentation

◆ TtFullLepHypGenMatch()

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

Definition at line 31 of file TtFullLepHypGenMatch.cc.

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

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 34 of file TtFullLepHypGenMatch.cc.

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

40  {
41  // -----------------------------------------------------
42  // add jets
43  // -----------------------------------------------------
44  for (unsigned idx = 0; idx < match.size(); ++idx) {
45  if (isValid(match[idx], jets)) {
46  switch (idx) {
49  break;
52  break;
53  }
54  }
55  }
56 
57  // -----------------------------------------------------
58  // add leptons
59  // -----------------------------------------------------
60  // get genEvent
63 
64  // push back fake indices if no leptons in genevent
65  if (!genEvt->isFullLeptonic() || !genEvt->lepton() || !genEvt->leptonBar()) {
66  match.push_back(-1);
67  match.push_back(-1);
68  match.push_back(-1);
69  match.push_back(-1);
70  } else if (genEvt->isFullLeptonic(WDecay::kElec, WDecay::kElec) && elecs->size() >= 2) {
71  //search indices for electrons
72  int iLepBar = findMatchingLepton(genEvt->leptonBar(), elecs);
73  leptonBar_ = makeCandidate(elecs, iLepBar);
74  match.push_back(iLepBar);
75  int iLep = findMatchingLepton(genEvt->lepton(), elecs);
76  lepton_ = makeCandidate(elecs, iLep);
77  match.push_back(iLep);
78 
79  // fake indices for muons
80  match.push_back(-1);
81  match.push_back(-1);
82  } else if (genEvt->isFullLeptonic(WDecay::kElec, WDecay::kMuon) && !elecs->empty() && !mus->empty()) {
83  if (genEvt->leptonBar()->isElectron()) {
84  // push back index for e+
85  int iLepBar = findMatchingLepton(genEvt->leptonBar(), elecs);
86  leptonBar_ = makeCandidate(elecs, iLepBar);
87  match.push_back(iLepBar);
88  // push back fake indices for e- and mu+
89  match.push_back(-1);
90  match.push_back(-1);
91  // push back index for mu-
92  int iLep = findMatchingLepton(genEvt->lepton(), mus);
93  lepton_ = makeCandidate(mus, iLep);
94  match.push_back(iLep);
95  } else {
96  // push back fake index for e+
97  match.push_back(-1);
98  // push back index for e-
99  int iLepBar = findMatchingLepton(genEvt->leptonBar(), mus);
100  leptonBar_ = makeCandidate(mus, iLepBar);
101  match.push_back(iLepBar);
102  // push back index for mu+
103  int iLep = findMatchingLepton(genEvt->lepton(), elecs);
104  lepton_ = makeCandidate(elecs, iLep);
105  match.push_back(iLep);
106  // push back fake index for mu-
107  match.push_back(-1);
108  }
109  } else if (genEvt->isFullLeptonic(WDecay::kMuon, WDecay::kMuon) && mus->size() >= 2) {
110  // fake indices for electrons
111  match.push_back(-1);
112  match.push_back(-1);
113 
114  //search indices for electrons
115  int iLepBar = findMatchingLepton(genEvt->leptonBar(), mus);
116  leptonBar_ = makeCandidate(mus, iLepBar);
117  match.push_back(iLepBar);
118  int iLep = findMatchingLepton(genEvt->lepton(), mus);
119  lepton_ = makeCandidate(mus, iLep);
120  match.push_back(iLep);
121  } else { //this 'else' should happen if at least one genlepton is a tau
122  match.push_back(-1);
123  match.push_back(-1);
124  match.push_back(-1);
125  match.push_back(-1);
126  }
127 
128  // -----------------------------------------------------
129  // add met and neutrinos
130  // -----------------------------------------------------
131  if (!mets->empty()) {
132  //met_ = makeCandidate(mets, 0);
134  }
135 }
std::unique_ptr< reco::ShallowClonePtrCandidate > leptonBar_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:540
void buildMatchingNeutrinos(edm::Event &, const edm::Handle< std::vector< pat::MET > > &)
edm::EDGetTokenT< TtGenEvent > genEvtToken_
int findMatchingLepton(const reco::GenParticle *, const edm::Handle< std::vector< O > > &)
std::string jetCorrectionLevel_
std::unique_ptr< reco::ShallowClonePtrCandidate > lepton_
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
bool isValid(const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
check if index is in valid range of selected jets
std::unique_ptr< reco::ShallowClonePtrCandidate > bBar_

◆ buildKey()

void TtFullLepHypGenMatch::buildKey ( )
inlineoverrideprivatevirtual

build the event hypothesis key

Implements TtFullLepHypothesis.

Definition at line 13 of file TtFullLepHypGenMatch.cc.

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

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

◆ buildMatchingNeutrinos()

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

Definition at line 152 of file TtFullLepHypGenMatch.cc.

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

Referenced by buildHypo().

152  {
153  // get genEvent
156 
157  if (genEvt->isTtBar() && genEvt->isFullLeptonic() && genEvt->neutrino() && genEvt->neutrinoBar()) {
158  double momXNu = genEvt->neutrino()->px();
159  double momYNu = genEvt->neutrino()->py();
160  double momXNuBar = genEvt->neutrinoBar()->px();
161  double momYNuBar = genEvt->neutrinoBar()->py();
162 
163  double momXMet = mets->at(0).px();
164  double momYMet = mets->at(0).py();
165 
166  double momXNeutrino = 0.5 * (momXNu - momXNuBar + momXMet);
167  double momYNeutrino = 0.5 * (momYNu - momYNuBar + momYMet);
168  double momXNeutrinoBar = momXMet - momXNeutrino;
169  double momYNeutrinoBar = momYMet - momYNeutrino;
170 
171  math::XYZTLorentzVector recNuFM(
172  momXNeutrino, momYNeutrino, 0, sqrt(momXNeutrino * momXNeutrino + momYNeutrino * momYNeutrino));
173  recNu = std::make_unique<reco::LeafCandidate>(0, recNuFM);
174 
175  math::XYZTLorentzVector recNuBarFM(momXNeutrinoBar,
176  momYNeutrinoBar,
177  0,
178  sqrt(momXNeutrinoBar * momXNeutrinoBar + momYNeutrinoBar * momYNeutrinoBar));
179  recNuBar = std::make_unique<reco::LeafCandidate>(0, recNuBarFM);
180  }
181 }
std::unique_ptr< reco::LeafCandidate > recNu
candidates needed for the genmatch hypothesis
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:540
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
T sqrt(T t)
Definition: SSEVec.h:19
edm::EDGetTokenT< TtGenEvent > genEvtToken_
std::unique_ptr< reco::LeafCandidate > recNuBar

◆ findMatchingLepton()

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

Definition at line 138 of file TtFullLepHypGenMatch.cc.

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

Referenced by buildHypo().

139  {
140  int idx = -1;
141  double minDR = -1;
142  for (unsigned i = 0; i < leps->size(); ++i) {
143  double dR = deltaR(genLep->eta(), genLep->phi(), (*leps)[i].eta(), (*leps)[i].phi());
144  if (minDR < 0 || dR < minDR) {
145  minDR = dR;
146  idx = i;
147  }
148  }
149  return idx;
150 }
double phi() const final
momentum azimuthal angle
double eta() const final
momentum pseudorapidity

Member Data Documentation

◆ genEvtToken_

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

Definition at line 28 of file TtFullLepHypGenMatch.cc.

Referenced by buildHypo(), and buildMatchingNeutrinos().