CMS 3D CMS Logo

TtSemiLepHypGenMatch.cc

Go to the documentation of this file.
00001 #include "DataFormats/Math/interface/deltaR.h"
00002 #include "AnalysisDataFormats/TopObjects/interface/TtGenEvent.h"
00003 #include "TopQuarkAnalysis/TopJetCombination/plugins/TtSemiLepHypGenMatch.h"
00004 
00005 
00006 TtSemiLepHypGenMatch::TtSemiLepHypGenMatch(const edm::ParameterSet& cfg):
00007   TtSemiLepHypothesis( cfg ) { }
00008 
00009 TtSemiLepHypGenMatch::~TtSemiLepHypGenMatch() { }
00010 
00011 void
00012 TtSemiLepHypGenMatch::buildHypo(edm::Event& evt,
00013                                 const edm::Handle<edm::View<reco::RecoCandidate> >& leps, 
00014                                 const edm::Handle<std::vector<pat::MET> >& mets, 
00015                                 const edm::Handle<std::vector<pat::Jet> >& jets, 
00016                                 std::vector<int>& match, const unsigned int iComb)
00017 {
00018   // -----------------------------------------------------
00019   // add jets
00020   // -----------------------------------------------------
00021   for(unsigned idx=0; idx<match.size(); ++idx){
00022     if( isValid(match[idx], jets) ){
00023       switch(idx){
00024       case TtSemiLepEvtPartons::LightQ:
00025         setCandidate(jets, match[idx], lightQ_); break;
00026       case TtSemiLepEvtPartons::LightQBar:
00027         setCandidate(jets, match[idx], lightQBar_); break;
00028       case TtSemiLepEvtPartons::HadB:
00029         setCandidate(jets, match[idx], hadronicB_); break;
00030       case TtSemiLepEvtPartons::LepB: 
00031         setCandidate(jets, match[idx], leptonicB_); break;
00032       }
00033     }
00034   }
00035 
00036   // -----------------------------------------------------
00037   // add lepton
00038   // -----------------------------------------------------
00039   if( !leps->empty() ){
00040     int iLepton = findMatchingLepton(evt,leps);
00041     if( iLepton>=0 )
00042       setCandidate(leps, iLepton, lepton_);
00043     match.push_back( iLepton );
00044   }
00045   else match.push_back( -1 );
00046 
00047   // -----------------------------------------------------
00048   // add neutrino
00049   // -----------------------------------------------------
00050   if( !mets->empty() )
00051     setCandidate(mets, 0, neutrino_);
00052 }
00053 
00054 int
00055 TtSemiLepHypGenMatch::findMatchingLepton(edm::Event& evt, const edm::Handle<edm::View<reco::RecoCandidate> >& leps)
00056 {
00057   int genIdx=-1;
00058 
00059   // set genEvent
00060   edm::Handle<TtGenEvent> genEvt;
00061   evt.getByLabel("genEvt", genEvt);  
00062   
00063   if( genEvt->isTtBar() && genEvt->isSemiLeptonic() && genEvt->singleLepton() ){
00064     double minDR=-1;
00065     for(unsigned i=0; i<leps->size(); ++i){
00066       double dR = deltaR(genEvt->singleLepton()->eta(), genEvt->singleLepton()->phi(), (*leps)[i].eta(), (*leps)[i].phi());
00067       if(minDR<0 || dR<minDR){
00068         minDR=dR;
00069         genIdx=i;
00070       }
00071     }
00072   }
00073   return genIdx;
00074 }

Generated on Tue Jun 9 17:48:13 2009 for CMSSW by  doxygen 1.5.4