CMS 3D CMS Logo

Public Member Functions | Private Member Functions

TtSemiLepHypGenMatch Class Reference

#include <TtSemiLepHypGenMatch.h>

Inheritance diagram for TtSemiLepHypGenMatch:
TtSemiLepHypothesis edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 TtSemiLepHypGenMatch (const edm::ParameterSet &)
 ~TtSemiLepHypGenMatch ()

Private Member Functions

virtual 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)
 build event hypothesis from the reco objects of a semi-leptonic event
virtual void buildKey ()
 build the event hypothesis key
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

Detailed Description

Definition at line 7 of file TtSemiLepHypGenMatch.h.


Constructor & Destructor Documentation

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

Definition at line 6 of file TtSemiLepHypGenMatch.cc.

                                                                    :
  TtSemiLepHypothesis( cfg )
{ }
TtSemiLepHypGenMatch::~TtSemiLepHypGenMatch ( )

Definition at line 10 of file TtSemiLepHypGenMatch.cc.

{ }

Member Function Documentation

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 
) [private, virtual]

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

Implements TtSemiLepHypothesis.

Definition at line 13 of file TtSemiLepHypGenMatch.cc.

References abs, findMatchingLepton(), TtGenEvtProducer_cfi::genEvt, edm::Event::getByLabel(), TtSemiLepEvtPartons::HadB, TtSemiLepHypothesis::hadronicB_, TtSemiLepHypothesis::isValid(), TtSemiLepHypothesis::jetCorrectionLevel(), fwrapper::jets, TtSemiLepEvtPartons::LepB, TtSemiLepHypothesis::lepton_, TtSemiLepHypothesis::leptonicB_, TtSemiLepEvtPartons::LightQ, TtSemiLepHypothesis::lightQ_, TtSemiLepEvtPartons::LightQBar, TtSemiLepHypothesis::lightQBar_, TtSemiLepHypothesis::neutrino_, TtSemiLepHypothesis::neutrinoSolutionType_, TtSemiLepHypothesis::setCandidate(), and TtSemiLepHypothesis::setNeutrino().

{
  // -----------------------------------------------------
  // get genEvent (to distinguish between uds and c quarks
  // and for the lepton matching)
  // -----------------------------------------------------
  edm::Handle<TtGenEvent> genEvt;
  evt.getByLabel("genEvt", genEvt);  

  // -----------------------------------------------------
  // add jets
  // -----------------------------------------------------
  for(unsigned idx=0; idx<match.size(); ++idx){
    if( isValid(match[idx], jets) ){
      switch(idx){
      case TtSemiLepEvtPartons::LightQ:
        if( std::abs(genEvt->hadronicDecayQuark()->pdgId())==4 )
          setCandidate(jets, match[idx], lightQ_, jetCorrectionLevel("cQuark"));
        else
          setCandidate(jets, match[idx], lightQ_, jetCorrectionLevel("udsQuark"));
        break;
      case TtSemiLepEvtPartons::LightQBar:
        if( std::abs(genEvt->hadronicDecayQuarkBar()->pdgId())==4 )
          setCandidate(jets, match[idx], lightQBar_, jetCorrectionLevel("cQuark"));
        else
          setCandidate(jets, match[idx], lightQBar_, jetCorrectionLevel("udsQuark"));
        break;
      case TtSemiLepEvtPartons::HadB:
        setCandidate(jets, match[idx], hadronicB_, jetCorrectionLevel("bQuark")); break;
      case TtSemiLepEvtPartons::LepB: 
        setCandidate(jets, match[idx], leptonicB_, jetCorrectionLevel("bQuark")); break;
      }
    }
  }
 
  // -----------------------------------------------------
  // add lepton
  // -----------------------------------------------------
  int iLepton = findMatchingLepton(genEvt, leps);
  if( iLepton<0 )
    return;
  setCandidate(leps, iLepton, lepton_);
  match.push_back( iLepton );

  // -----------------------------------------------------
  // add neutrino
  // -----------------------------------------------------
  if( mets->empty() )
    return;
  if(neutrinoSolutionType_ == -1)
    setCandidate(mets, 0, neutrino_);
  else
    setNeutrino(mets, leps, iLepton, neutrinoSolutionType_);
}
virtual void TtSemiLepHypGenMatch::buildKey ( ) [inline, private, virtual]

build the event hypothesis key

Implements TtSemiLepHypothesis.

Definition at line 17 of file TtSemiLepHypGenMatch.h.

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

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 74 of file TtSemiLepHypGenMatch.cc.

References deltaR(), i, and TtSemiLepHypothesis::leptonType().

Referenced by buildHypo().

{
  int genIdx=-1;

  // jump out with -1 when the collection is empty
  if( leps->empty() ) return genIdx;
  
  if( genEvt->isTtBar() && genEvt->isSemiLeptonic( leptonType( &(leps->front()) ) ) && genEvt->singleLepton() ){
    double minDR=-1;
    for(unsigned i=0; i<leps->size(); ++i){
      double dR = deltaR(genEvt->singleLepton()->eta(), genEvt->singleLepton()->phi(), (*leps)[i].eta(), (*leps)[i].phi());
      if(minDR<0 || dR<minDR){
        minDR=dR;
        genIdx=i;
      }
    }
  }
  return genIdx;
}