CMS 3D CMS Logo

Public Member Functions | Private Member Functions

TtFullLepHypGenMatch Class Reference

#include <TtFullLepHypGenMatch.h>

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

List of all members.

Public Member Functions

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

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

Detailed Description

Definition at line 7 of file TtFullLepHypGenMatch.h.


Constructor & Destructor Documentation

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

Definition at line 5 of file TtFullLepHypGenMatch.cc.

                                                                    :
  TtFullLepHypothesis( cfg ) 
{  
}
TtFullLepHypGenMatch::~TtFullLepHypGenMatch ( )

Definition at line 10 of file TtFullLepHypGenMatch.cc.

{ }

Member Function Documentation

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

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

Implements TtFullLepHypothesis.

Definition at line 13 of file TtFullLepHypGenMatch.cc.

References TtFullLepEvtPartons::B, TtFullLepHypothesis::b_, TtFullLepEvtPartons::BBar, TtFullLepHypothesis::bBar_, buildMatchingNeutrinos(), findMatchingLepton(), TtGenEvtProducer_cfi::genEvt, edm::Event::getByLabel(), UserOptions_cff::idx, TtFullLepHypothesis::isValid(), TtFullLepHypothesis::jetCorrectionLevel_, analyzePatCleaning_cfg::jets, WDecay::kElec, WDecay::kMuon, TtFullLepHypothesis::lepton_, TtFullLepHypothesis::leptonBar_, and TtFullLepHypothesis::setCandidate().

{
  // -----------------------------------------------------
  // add jets
  // -----------------------------------------------------
  for(unsigned idx=0; idx<match.size(); ++idx){
    if( isValid(match[idx], jets) ){
      switch(idx){
      case TtFullLepEvtPartons::B:
        setCandidate(jets, match[idx], b_   , jetCorrectionLevel_); break;
      case TtFullLepEvtPartons::BBar:
        setCandidate(jets, match[idx], bBar_, jetCorrectionLevel_); break;      
      }
    }
  }

  // -----------------------------------------------------
  // add leptons
  // -----------------------------------------------------
  // get genEvent
  edm::Handle<TtGenEvent> genEvt;
  evt.getByLabel("genEvt", genEvt);
  
  // push back fake indices if no leptons in genevent
  if( !genEvt->isFullLeptonic() || !genEvt->lepton() || !genEvt->leptonBar() ){
    match.push_back( -1 );
    match.push_back( -1 );
    match.push_back( -1 );
    match.push_back( -1 );          
  }  
  else if(genEvt->isFullLeptonic(WDecay::kElec, WDecay::kElec) && elecs->size()>=2){    
    //search indices for electrons
    int iLepBar = findMatchingLepton(genEvt->leptonBar(), elecs);
    setCandidate(elecs, iLepBar, leptonBar_);
    match.push_back( iLepBar );
    int iLep = findMatchingLepton(genEvt->lepton(), elecs);
    setCandidate(elecs, iLep, lepton_);
    match.push_back( iLep );
    
    // fake indices for muons  
    match.push_back( -1 );
    match.push_back( -1 );         
  }
  else if(genEvt->isFullLeptonic(WDecay::kElec, WDecay::kMuon) && !elecs->empty() && !mus->empty() ){
    if(genEvt->leptonBar()->isElectron()){       
      // push back index for e+
      int iLepBar = findMatchingLepton(genEvt->leptonBar(), elecs);
      setCandidate(elecs, iLepBar, leptonBar_);
      match.push_back( iLepBar );
      // push back fake indices for e- and mu+
      match.push_back( -1 );
      match.push_back( -1 ); 
      // push back index for mu-     
      int iLep = findMatchingLepton(genEvt->lepton(), mus);
      setCandidate(mus, iLep, lepton_);
      match.push_back( iLep );              
    }
    else{       
      // push back fake index for e+    
      match.push_back( -1 );  
      // push back index for e-  
      int iLepBar = findMatchingLepton(genEvt->leptonBar(), mus);
      setCandidate(mus, iLepBar, leptonBar_);
      match.push_back( iLepBar ); 
      // push back index for mu+
      int iLep = findMatchingLepton(genEvt->lepton(), elecs);
      setCandidate(elecs, iLep, lepton_);
      match.push_back( iLep );
      // push back fake index for mu-     
      match.push_back( -1 );              
    }
  }  
  else if(genEvt->isFullLeptonic(WDecay::kMuon, WDecay::kMuon) &&  mus->size()>=2 ){     
    // fake indices for electrons
    match.push_back( -1 );
    match.push_back( -1 );  
    
    //search indices for electrons
    int iLepBar = findMatchingLepton(genEvt->leptonBar(), mus);
    setCandidate(mus, iLepBar, leptonBar_);
    match.push_back( iLepBar );
    int iLep = findMatchingLepton(genEvt->lepton(), mus);
    setCandidate(mus, iLep, lepton_);
    match.push_back( iLep );    
  }
  else{ //this 'else' should happen if at least one genlepton is a tau
    match.push_back( -1 );
    match.push_back( -1 );
    match.push_back( -1 );
    match.push_back( -1 );   
  }

  // -----------------------------------------------------
  // add met and neutrinos
  // -----------------------------------------------------  
  if( !mets->empty() ){
    //setCandidate(mets, 0, met_);
    buildMatchingNeutrinos(evt, mets);  
  }    
}
virtual void TtFullLepHypGenMatch::buildKey ( ) [inline, private, virtual]

build the event hypothesis key

Implements TtFullLepHypothesis.

Definition at line 17 of file TtFullLepHypGenMatch.h.

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

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

Definition at line 137 of file TtFullLepHypGenMatch.cc.

References TtGenEvtProducer_cfi::genEvt, edm::Event::getByLabel(), TtFullLepHypothesis::recNu, TtFullLepHypothesis::recNuBar, and mathSSE::sqrt().

Referenced by buildHypo().

{
  // get genEvent
  edm::Handle<TtGenEvent> genEvt;
  evt.getByLabel("genEvt", genEvt);
  
  if( genEvt->isTtBar() && genEvt->isFullLeptonic() && genEvt->neutrino() && genEvt->neutrinoBar() ){
    double momXNu    = genEvt->neutrino()   ->px();
    double momYNu    = genEvt->neutrino()   ->py(); 
    double momXNuBar = genEvt->neutrinoBar()->px();
    double momYNuBar = genEvt->neutrinoBar()->py();
        
    double momXMet = mets->at(0).px();
    double momYMet = mets->at(0).py();

    double momXNeutrino = 0.5*(momXNu - momXNuBar + momXMet);
    double momYNeutrino = 0.5*(momYNu - momYNuBar + momYMet);   
    double momXNeutrinoBar = momXMet - momXNeutrino;
    double momYNeutrinoBar = momYMet - momYNeutrino; 
  
    math::XYZTLorentzVector recNuFM(momXNeutrino,momYNeutrino,0,sqrt(momXNeutrino * momXNeutrino + momYNeutrino * momYNeutrino));    
    recNu = new reco::LeafCandidate(0,recNuFM);
    
    math::XYZTLorentzVector recNuBarFM(momXNeutrinoBar,momYNeutrinoBar,0,sqrt(momXNeutrinoBar * momXNeutrinoBar + momYNeutrinoBar * momYNeutrinoBar));
    recNuBar = new reco::LeafCandidate(0,recNuBarFM);                 
  }
}
template<typename O >
int TtFullLepHypGenMatch::findMatchingLepton ( const reco::GenParticle genLep,
const edm::Handle< std::vector< O > > &  leps 
) [private]

Definition at line 122 of file TtFullLepHypGenMatch.cc.

References deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, reco::LeafCandidate::eta(), i, UserOptions_cff::idx, and reco::LeafCandidate::phi().

Referenced by buildHypo().

{
  int idx=-1;   
  double minDR = -1;
  for(unsigned i=0; i<leps->size(); ++i){
    double dR = deltaR(genLep->eta(), genLep->phi(), (*leps)[i].eta(), (*leps)[i].phi());
    if(minDR<0 || dR<minDR){
      minDR=dR;
      idx=i;
    }     
  }
  return idx;
}