CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes

TtFullLepHypothesis Class Reference

#include <TtFullLepHypothesis.h>

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

List of all members.

Public Member Functions

 TtFullLepHypothesis (const edm::ParameterSet &)
 default constructor
 ~TtFullLepHypothesis ()
 default destructor

Protected 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)=0
 build event hypothesis from the reco objects of a semi-leptonic event
virtual void buildKey ()=0
 build the event hypothesis key
reco::CompositeCandidate hypo ()
 return event hypothesis
bool isValid (const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
 check if index is in valid range of selected jets
int key () const
 return key
virtual void produce (edm::Event &, const edm::EventSetup &)
 produce the event hypothesis as CompositeCandidate and Key
void resetCandidates ()
 reset candidate pointers before hypo build process
template<typename C >
void setCandidate (const edm::Handle< C > &handle, const int &idx, reco::ShallowClonePtrCandidate *&clone)
 use one object in a collection to set a ShallowClonePtrCandidate
void setCandidate (const edm::Handle< std::vector< pat::Jet > > &handle, const int &idx, reco::ShallowClonePtrCandidate *&clone, const std::string &correctionLevel)
 use one object in a jet collection to set a ShallowClonePtrCandidate with proper jet corrections

Protected Attributes

reco::ShallowClonePtrCandidateb_
reco::ShallowClonePtrCandidatebBar_
edm::InputTag elecs_
bool getMatch_
std::string jetCorrectionLevel_
edm::InputTag jets_
int key_
 hypothesis key (to be set by the buildKey function)
reco::ShallowClonePtrCandidatelepton_
reco::ShallowClonePtrCandidateleptonBar_
edm::InputTag match_
 input label for all necessary collections
edm::InputTag mets_
edm::InputTag mus_
reco::ShallowClonePtrCandidateneutrino_
reco::ShallowClonePtrCandidateneutrinoBar_
reco::LeafCandidaterecNu
 candidates needed for the genmatch hypothesis
reco::LeafCandidaterecNuBar

Detailed Description

Definition at line 34 of file TtFullLepHypothesis.h.


Constructor & Destructor Documentation

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

default constructor

Definition at line 5 of file TtFullLepHypothesis.cc.

References edm::ParameterSet::exists(), getMatch_, edm::ParameterSet::getParameter(), jetCorrectionLevel_, and match_.

                                                                  :
  elecs_(cfg.getParameter<edm::InputTag>("electrons")),
  mus_  (cfg.getParameter<edm::InputTag>("muons")),
  jets_ (cfg.getParameter<edm::InputTag>("jets")),
  mets_ (cfg.getParameter<edm::InputTag>("mets")),

  lepton_(0), leptonBar_(0), b_(0), 
  bBar_(0), neutrino_(0), neutrinoBar_(0)
{  
  getMatch_ = false;
  if( cfg.exists("match") ) {
    getMatch_ = true;
    match_ = cfg.getParameter<edm::InputTag>("match");
  }
  // if no other correction is given apply L3 (abs) correction
  jetCorrectionLevel_ = "abs";
  if( cfg.exists("jetCorrectionLevel") ) {
    jetCorrectionLevel_ = cfg.getParameter<std::string>("jetCorrectionLevel");
  }
  else{ // if no other correction is given apply L3 (abs) correction
    jetCorrectionLevel_ = "abs";
  }
  produces<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > >();
  produces<int>("Key");
}
TtFullLepHypothesis::~TtFullLepHypothesis ( )

default destructor

Definition at line 32 of file TtFullLepHypothesis.cc.

References b_, bBar_, lepton_, leptonBar_, neutrino_, and neutrinoBar_.

{
  if( lepton_      ) delete lepton_;
  if( leptonBar_   ) delete leptonBar_;
  if( b_           ) delete b_;
  if( bBar_        ) delete bBar_;
  if( neutrino_    ) delete neutrino_;
  if( neutrinoBar_ ) delete neutrinoBar_;
  //if( met_         ) delete met_;
}

Member Function Documentation

virtual void TtFullLepHypothesis::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 
) [protected, pure virtual]

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

Implemented in TtFullLepHypGenMatch, and TtFullLepHypKinSolution.

Referenced by produce().

virtual void TtFullLepHypothesis::buildKey ( ) [protected, pure virtual]

build the event hypothesis key

Implemented in TtFullLepHypGenMatch, and TtFullLepHypKinSolution.

Referenced by produce().

reco::CompositeCandidate TtFullLepHypothesis::hypo ( ) [protected]

return event hypothesis

Definition at line 111 of file TtFullLepHypothesis.cc.

References reco::CompositeCandidate::addDaughter(), TtFullLepDaughter::B, b_, TtFullLepDaughter::BBar, bBar_, key(), TtEvent::kGenMatch, TtEvent::kKinSolution, TtFullLepDaughter::Lep, TtFullLepDaughter::LepBar, lepton_, leptonBar_, neutrino_, neutrinoBar_, TtFullLepDaughter::Nu, TtFullLepDaughter::NuBar, recNu, recNuBar, AddFourMomenta::set(), TtFullLepDaughter::Top, TtFullHadDaughter::Top, TtFullHadDaughter::TopBar, TtFullLepDaughter::TopBar, TtFullLepDaughter::WMinus, TtFullHadDaughter::WMinus, TtFullHadDaughter::WPlus, and TtFullLepDaughter::WPlus.

Referenced by produce().

{ 
  // check for sanity of the hypothesis  
  if( !lepton_ || !leptonBar_ || !b_ || !bBar_ ){
    return reco::CompositeCandidate();
  } 
       
  if( key()==TtFullLeptonicEvent::kGenMatch && (!recNu || !recNuBar) ){
    edm::LogWarning("TtFullHypothesis") << "no neutrinos for gen match" << std::endl; 
    return reco::CompositeCandidate();
  }  
  if( key()==TtFullLeptonicEvent::kKinSolution && (!neutrino_ || !neutrinoBar_) ){
    edm::LogWarning("TtFullHypothesis") << "no neutrinos for kin solution" << std::endl;  
    return reco::CompositeCandidate();    
  }
          
  // setup transient references
  reco::CompositeCandidate hyp, Top, WPlus, TopBar, WMinus;

  AddFourMomenta addFourMomenta; 
     
  // build up the top branch
  WPlus.addDaughter(*leptonBar_, TtFullLepDaughter::LepBar);
  if(key()==TtFullLeptonicEvent::kKinSolution)
    WPlus.addDaughter(*neutrino_, TtFullLepDaughter::Nu);  
  else if(key()==TtFullLeptonicEvent::kGenMatch)
    WPlus.addDaughter(*recNu, TtFullLepDaughter::Nu);     
  addFourMomenta.set(WPlus);
  Top.addDaughter(WPlus, TtFullLepDaughter::WPlus);
  Top.addDaughter(*b_,TtFullLepDaughter::B);
  addFourMomenta.set(Top);   
   
  // build up the anti top branch
  WMinus.addDaughter(*lepton_, TtFullLepDaughter::Lep); 
  if(key()==TtFullLeptonicEvent::kKinSolution)
    WMinus.addDaughter(*neutrinoBar_, TtFullLepDaughter::NuBar);  
  else if(key()==TtFullLeptonicEvent::kGenMatch)  
    WMinus.addDaughter(*recNuBar, TtFullLepDaughter::NuBar);   
  addFourMomenta.set(WMinus);
  TopBar.addDaughter(WMinus, TtFullLepDaughter::WMinus);
  TopBar.addDaughter(*bBar_, TtFullLepDaughter::BBar);
  addFourMomenta.set(TopBar);   

  // build ttbar hypothesis
  hyp.addDaughter(Top, TtFullLepDaughter::Top);
  hyp.addDaughter(TopBar, TtFullLepDaughter::TopBar);
  addFourMomenta.set( hyp );
     
  // the four momentum of the met is not added to the hypothesis
  // because it is allready included through the neutrinos     
  //hyp.addDaughter(*met_, TtFullLepDaughter::Met);
  return hyp;
}
bool TtFullLepHypothesis::isValid ( const int &  idx,
const edm::Handle< std::vector< pat::Jet > > &  jets 
) [inline, protected]

check if index is in valid range of selected jets

Definition at line 57 of file TtFullLepHypothesis.h.

References analyzePatCleaning_cfg::jets.

Referenced by TtFullLepHypGenMatch::buildHypo().

{ return (0<=idx && idx<(int)jets->size()); };
int TtFullLepHypothesis::key ( ) const [inline, protected]

return key

Definition at line 53 of file TtFullLepHypothesis.h.

References key_.

Referenced by hypo(), and produce().

{ return key_; };
void TtFullLepHypothesis::produce ( edm::Event evt,
const edm::EventSetup setup 
) [protected, virtual]

produce the event hypothesis as CompositeCandidate and Key

Implements edm::EDProducer.

Definition at line 45 of file TtFullLepHypothesis.cc.

References buildHypo(), buildKey(), elecs_, edm::Event::getByLabel(), getMatch_, hypo(), i, analyzePatCleaning_cfg::jets, jets_, key(), match(), match_, mets_, mus_, edm::Event::put(), and resetCandidates().

{
  edm::Handle<std::vector<pat::Electron> > elecs;
  evt.getByLabel(elecs_, elecs);
  
  edm::Handle<std::vector<pat::Muon> > mus;
  evt.getByLabel(mus_, mus);  

  edm::Handle<std::vector<pat::Jet> > jets;
  evt.getByLabel(jets_, jets);

  edm::Handle<std::vector<pat::MET> > mets;
  evt.getByLabel(mets_, mets);

  std::vector<std::vector<int> > matchVec;
  if( getMatch_ ) {
    edm::Handle<std::vector<std::vector<int> > > matchHandle;
    evt.getByLabel(match_, matchHandle);;  
    matchVec = *matchHandle;
  }
  else {
    std::vector<int> dummyMatch;
    for(unsigned int i = 0; i < 4; ++i) 
      dummyMatch.push_back( -1 );
    matchVec.push_back( dummyMatch );
  }

  // declare auto_ptr for products
  std::auto_ptr<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > >
    pOut( new std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > );
  std::auto_ptr<int> pKey(new int);
  
  // build and feed out key
  buildKey();  
  *pKey=key();
  evt.put(pKey, "Key");

  // go through given vector of jet combinations
  unsigned int idMatch = 0;  
  typedef std::vector<std::vector<int> >::iterator MatchVecIterator;
  for(MatchVecIterator match = matchVec.begin(); match != matchVec.end(); ++match) {        
    // reset pointers
    resetCandidates();
    // build hypothesis
    buildHypo(evt, elecs, mus, jets, mets, *match, idMatch++);        
    pOut->push_back( std::make_pair(hypo(), *match) );    
  }
  // feed out hyps and matches
  evt.put(pOut);
}
void TtFullLepHypothesis::resetCandidates ( ) [protected]

reset candidate pointers before hypo build process

Definition at line 98 of file TtFullLepHypothesis.cc.

References b_, bBar_, lepton_, leptonBar_, neutrino_, and neutrinoBar_.

Referenced by produce().

{
  lepton_     = 0;
  leptonBar_  = 0;
  b_          = 0;
  bBar_       = 0;
  neutrino_   = 0;
  neutrinoBar_= 0;
  //met_        = 0;
}
template<typename C >
void TtFullLepHypothesis::setCandidate ( const edm::Handle< C > &  handle,
const int &  idx,
reco::ShallowClonePtrCandidate *&  clone 
) [protected]

use one object in a collection to set a ShallowClonePtrCandidate

Definition at line 109 of file TtFullLepHypothesis.h.

References patZpeak::handle.

Referenced by TtFullLepHypKinSolution::buildHypo(), and TtFullLepHypGenMatch::buildHypo().

                                                                                                                  {
  typedef typename C::value_type O;
  edm::Ptr<O> ptr = edm::Ptr<O>(handle, idx);
  clone = new reco::ShallowClonePtrCandidate( ptr, ptr->charge(), ptr->p4(), ptr->vertex() );
}
void TtFullLepHypothesis::setCandidate ( const edm::Handle< std::vector< pat::Jet > > &  handle,
const int &  idx,
reco::ShallowClonePtrCandidate *&  clone,
const std::string &  correctionLevel 
) [protected]

use one object in a jet collection to set a ShallowClonePtrCandidate with proper jet corrections

Definition at line 167 of file TtFullLepHypothesis.cc.

References patZpeak::handle, and jetCorrectionLevel_.

{
  edm::Ptr<pat::Jet> ptr = edm::Ptr<pat::Jet>(handle, idx);
  clone = new reco::ShallowClonePtrCandidate( ptr, ptr->charge(), ptr->correctedJet(jetCorrectionLevel_, "bottom").p4(), ptr->vertex() );
}

Member Data Documentation

Definition at line 81 of file TtFullLepHypothesis.h.

Referenced by produce().

internal check whether the match information exists or not, if false a blind dummy match vector will be used internally

Definition at line 78 of file TtFullLepHypothesis.h.

Referenced by produce(), and TtFullLepHypothesis().

specify the desired jet correction level (the default should be L3Absolute-'abs')

Definition at line 87 of file TtFullLepHypothesis.h.

Referenced by TtFullLepHypKinSolution::buildHypo(), TtFullLepHypGenMatch::buildHypo(), setCandidate(), and TtFullLepHypothesis().

Definition at line 83 of file TtFullLepHypothesis.h.

Referenced by produce().

int TtFullLepHypothesis::key_ [protected]

hypothesis key (to be set by the buildKey function)

Definition at line 89 of file TtFullLepHypothesis.h.

Referenced by TtFullLepHypGenMatch::buildKey(), TtFullLepHypKinSolution::buildKey(), and key().

candidates for internal use for the creation of the hypothesis candidate

Definition at line 92 of file TtFullLepHypothesis.h.

Referenced by TtFullLepHypKinSolution::buildHypo(), TtFullLepHypGenMatch::buildHypo(), hypo(), resetCandidates(), and ~TtFullLepHypothesis().

input label for all necessary collections

Definition at line 80 of file TtFullLepHypothesis.h.

Referenced by produce(), and TtFullLepHypothesis().

Definition at line 84 of file TtFullLepHypothesis.h.

Referenced by produce().

Definition at line 82 of file TtFullLepHypothesis.h.

Referenced by produce().

candidates needed for the genmatch hypothesis

Definition at line 101 of file TtFullLepHypothesis.h.

Referenced by TtFullLepHypGenMatch::buildMatchingNeutrinos(), and hypo().

Definition at line 102 of file TtFullLepHypothesis.h.

Referenced by TtFullLepHypGenMatch::buildMatchingNeutrinos(), and hypo().