CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes

TtSemiLepHypothesis Class Reference

#include <TtSemiLepHypothesis.h>

Inheritance diagram for TtSemiLepHypothesis:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper TtSemiLepHypGenMatch TtSemiLepHypGeom TtSemiLepHypHitFit TtSemiLepHypKinFit TtSemiLepHypMaxSumPtWMass TtSemiLepHypMVADisc TtSemiLepHypWMassDeltaTopMass TtSemiLepHypWMassMaxSumPt

List of all members.

Public Member Functions

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

Protected Member Functions

void buildHypo (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 > &jetPartonAssociation)
 minimalistic build function for simple hypotheses
virtual void buildHypo (edm::Event &event, const edm::Handle< edm::View< reco::RecoCandidate > > &lepton, const edm::Handle< std::vector< pat::MET > > &neutrino, const edm::Handle< std::vector< pat::Jet > > &jets, std::vector< int > &jetPartonAssociation, 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
std::string jetCorrectionLevel (const std::string &quarkType)
 helper function to construct the proper correction level string for corresponding quarkType
int key () const
WDecay::LeptonType leptonType (const reco::RecoCandidate *cand)
 determine lepton type of reco candidate and return a corresponding WDecay::LeptonType; the type is kNone if it is whether a muon nor an electron
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
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
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 setNeutrino (const edm::Handle< std::vector< pat::MET > > &met, const edm::Handle< edm::View< reco::RecoCandidate > > &leps, const int &idx, const int &type)
 set neutrino, using mW = 80.4 to calculate the neutrino pz

Protected Attributes

bool getMatch_
reco::ShallowClonePtrCandidatehadronicB_
std::string jetCorrectionLevel_
edm::InputTag jets_
 input label for all necessary collections
int key_
 hypothesis key (to be set by the buildKey function)
edm::InputTag leps_
reco::ShallowClonePtrCandidatelepton_
reco::ShallowClonePtrCandidateleptonicB_
reco::ShallowClonePtrCandidatelightQ_
reco::ShallowClonePtrCandidatelightQBar_
edm::InputTag match_
edm::InputTag mets_
reco::ShallowClonePtrCandidateneutrino_
int neutrinoSolutionType_
 algorithm used to calculate neutrino solutions (see cfi for further details)
edm::InputTag nJetsConsidered_
int numberOfRealNeutrinoSolutions_

Detailed Description

Definition at line 31 of file TtSemiLepHypothesis.h.


Constructor & Destructor Documentation

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

default constructor

Definition at line 10 of file TtSemiLepHypothesis.cc.

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

                                                                  :
  jets_(cfg.getParameter<edm::InputTag>("jets")),
  leps_(cfg.getParameter<edm::InputTag>("leps")),
  mets_(cfg.getParameter<edm::InputTag>("mets")),
  nJetsConsidered_(cfg.getParameter<edm::InputTag>("nJetsConsidered")),
  numberOfRealNeutrinoSolutions_(-1),
  lightQ_(0), lightQBar_(0), hadronicB_(0), 
  leptonicB_(0), neutrino_(0), lepton_(0)
{
  getMatch_ = false;
  if( cfg.exists("match") ) {
    getMatch_ = true;
    match_ = cfg.getParameter<edm::InputTag>("match");
  }
  if( cfg.exists("neutrinoSolutionType") )
    neutrinoSolutionType_ = cfg.getParameter<int>("neutrinoSolutionType");
  else
    neutrinoSolutionType_ = -1;
  if( cfg.exists("jetCorrectionLevel") ) {
    jetCorrectionLevel_ = cfg.getParameter<std::string>("jetCorrectionLevel");
  }
  produces<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > >();
  produces<int>("Key");
  produces<int>("NumberOfRealNeutrinoSolutions");
  produces<int>("NumberOfConsideredJets");
}
TtSemiLepHypothesis::~TtSemiLepHypothesis ( )

default destructor

Definition at line 38 of file TtSemiLepHypothesis.cc.

References hadronicB_, lepton_, leptonicB_, lightQ_, lightQBar_, and neutrino_.

{
  if( lightQ_    ) delete lightQ_;
  if( lightQBar_ ) delete lightQBar_;
  if( hadronicB_ ) delete hadronicB_;
  if( leptonicB_ ) delete leptonicB_;
  if( neutrino_  ) delete neutrino_;
  if( lepton_    ) delete lepton_;
}

Member Function Documentation

void TtSemiLepHypothesis::buildHypo ( 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 > &  jetPartonAssociation 
) [protected]

minimalistic build function for simple hypotheses

return key minimalistic build function for simple hypotheses

Definition at line 249 of file TtSemiLepHypothesis.cc.

References TtSemiLepEvtPartons::HadB, hadronicB_, isValid(), jetCorrectionLevel(), fwrapper::jets, TtSemiLepEvtPartons::LepB, lepton_, leptonicB_, TtSemiLepEvtPartons::LightQ, lightQ_, TtSemiLepEvtPartons::LightQBar, lightQBar_, neutrino_, neutrinoSolutionType_, setCandidate(), and setNeutrino().

Referenced by produce().

{
  // -----------------------------------------------------
  // add jets
  // -----------------------------------------------------
  for(unsigned idx=0; idx<match.size(); ++idx){
    if( isValid(match[idx], jets) ){
      switch(idx){
      case TtSemiLepEvtPartons::LightQ:
        setCandidate(jets, match[idx], lightQ_,    jetCorrectionLevel("wQuarkMix")); break;
      case TtSemiLepEvtPartons::LightQBar:
        setCandidate(jets, match[idx], lightQBar_, jetCorrectionLevel("wQuarkMix")); 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
  // -----------------------------------------------------
  if( leps->empty() )
    return;
  setCandidate(leps, 0, lepton_);
  match.push_back( 0 );
  
  // -----------------------------------------------------
  // add neutrino
  // -----------------------------------------------------
  if( mets->empty() )
    return;
  if(neutrinoSolutionType_ == -1)
    setCandidate(mets, 0, neutrino_);
  else
    setNeutrino(mets, leps, 0, neutrinoSolutionType_);
}
virtual void TtSemiLepHypothesis::buildHypo ( edm::Event event,
const edm::Handle< edm::View< reco::RecoCandidate > > &  lepton,
const edm::Handle< std::vector< pat::MET > > &  neutrino,
const edm::Handle< std::vector< pat::Jet > > &  jets,
std::vector< int > &  jetPartonAssociation,
const unsigned int  iComb 
) [protected, pure virtual]
virtual void TtSemiLepHypothesis::buildKey ( ) [protected, pure virtual]
reco::CompositeCandidate TtSemiLepHypothesis::hypo ( ) [protected]

return event hypothesis

Definition at line 126 of file TtSemiLepHypothesis.cc.

References reco::CompositeCandidate::addDaughter(), TtSemiLepDaughter::HadB, TtSemiLepDaughter::HadP, TtSemiLepDaughter::HadQ, hadronicB_, TtSemiLepDaughter::HadTop, TtSemiLepDaughter::HadW, TtSemiLepDaughter::Lep, TtSemiLepDaughter::LepB, lepton_, leptonicB_, TtSemiLepDaughter::LepTop, TtSemiLepDaughter::LepW, lightQ_, lightQBar_, neutrino_, TtSemiLepDaughter::Nu, and AddFourMomenta::set().

Referenced by produce().

{
  // check for sanity of the hypothesis
  if( !lightQ_ || !lightQBar_ || !hadronicB_ || 
      !leptonicB_ || !neutrino_ || !lepton_ )
    return reco::CompositeCandidate();
  
  // setup transient references
  reco::CompositeCandidate hyp, hadTop, hadW, lepTop, lepW;

  AddFourMomenta addFourMomenta;  
  // build up the top branch that decays leptonically
  lepW  .addDaughter(*lepton_,   TtSemiLepDaughter::Lep    );
  lepW  .addDaughter(*neutrino_, TtSemiLepDaughter::Nu     );
  addFourMomenta.set( lepW );
  lepTop.addDaughter( lepW,      TtSemiLepDaughter::LepW   );
  lepTop.addDaughter(*leptonicB_,TtSemiLepDaughter::LepB   );
  addFourMomenta.set( lepTop );
  
  // build up the top branch that decays hadronically
  hadW  .addDaughter(*lightQ_,   TtSemiLepDaughter::HadP   );
  hadW  .addDaughter(*lightQBar_,TtSemiLepDaughter::HadQ   );
  addFourMomenta.set( hadW );
  hadTop.addDaughter( hadW,      TtSemiLepDaughter::HadW   );
  hadTop.addDaughter(*hadronicB_,TtSemiLepDaughter::HadB   );
  addFourMomenta.set( hadTop );

  // build ttbar hypotheses
  hyp.addDaughter( lepTop,       TtSemiLepDaughter::LepTop );
  hyp.addDaughter( hadTop,       TtSemiLepDaughter::HadTop );
  addFourMomenta.set( hyp );

  return hyp;
}
bool TtSemiLepHypothesis::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 64 of file TtSemiLepHypothesis.h.

References fwrapper::jets.

Referenced by TtSemiLepHypGenMatch::buildHypo(), and buildHypo().

{ return (0<=idx && idx<(int)jets->size()); };
std::string TtSemiLepHypothesis::jetCorrectionLevel ( const std::string &  quarkType) [protected]

helper function to construct the proper correction level string for corresponding quarkType

helper function to construct the proper correction level string for corresponding quarkType, for unknown quarkTypes an empty string is returned

Definition at line 178 of file TtSemiLepHypothesis.cc.

References jetCorrectionLevel_, and testEve_cfg::level.

Referenced by TtSemiLepHypGenMatch::buildHypo(), and buildHypo().

{
  // jetCorrectionLevel was not configured
  if(jetCorrectionLevel_.empty())
    throw cms::Exception("Configuration")
      << "Unconfigured jetCorrectionLevel. Please use an appropriate, non-empty string.\n";

  // quarkType is unknown
  if( !(quarkType=="wQuarkMix" ||
        quarkType=="udsQuark" ||
        quarkType=="cQuark" ||
        quarkType=="bQuark") )
    throw cms::Exception("Configuration")
      << quarkType << " is unknown as a quarkType for the jetCorrectionLevel.\n";

  // combine correction level; start with a ':' even if 
  // there is no flavor tag to be added, as it is needed
  // by setCandidate to disentangle the correction tag 
  // from a potential flavor tag, which can be empty
  std::string level=jetCorrectionLevel_+":";
  if( level=="L5Flavor:" || level=="L6UE:" || level=="L7Parton:" ){
    if(quarkType=="wQuarkMix"){level+="wMix";}
    if(quarkType=="udsQuark" ){level+="uds";}
    if(quarkType=="cQuark"   ){level+="charm";}
    if(quarkType=="bQuark"   ){level+="bottom";}
  }
  else{
    level+="none";
  }
  return level;
}
int TtSemiLepHypothesis::key ( ) const [inline, protected]

Definition at line 60 of file TtSemiLepHypothesis.h.

References key_.

Referenced by produce().

{ return key_; };
WDecay::LeptonType TtSemiLepHypothesis::leptonType ( const reco::RecoCandidate cand) [protected]

determine lepton type of reco candidate and return a corresponding WDecay::LeptonType; the type is kNone if it is whether a muon nor an electron

Definition at line 163 of file TtSemiLepHypothesis.cc.

References WDecay::kElec, WDecay::kMuon, and WDecay::kNone.

Referenced by TtSemiLepHypGenMatch::findMatchingLepton(), and setNeutrino().

{
  // check whetherwe are dealing with a reco muon or a reco electron
  WDecay::LeptonType type = WDecay::kNone;
  if( dynamic_cast<const reco::Muon*>(cand) ){
    type = WDecay::kMuon;
  } 
  else if( dynamic_cast<const reco::GsfElectron*>(cand) ){
    type = WDecay::kElec;
  }
  return type;
}
void TtSemiLepHypothesis::produce ( edm::Event evt,
const edm::EventSetup setup 
) [protected, virtual]

produce the event hypothesis as CompositeCandidate and Key

Implements edm::EDProducer.

Definition at line 50 of file TtSemiLepHypothesis.cc.

References buildHypo(), buildKey(), edm::Event::getByLabel(), getMatch_, hypo(), i, fwrapper::jets, jets_, key(), leps_, match(), match_, mets_, nJetsConsidered_, numberOfRealNeutrinoSolutions_, edm::Event::put(), and resetCandidates().

{
  edm::Handle<std::vector<pat::Jet> > jets;
  evt.getByLabel(jets_, jets);
  
  edm::Handle<edm::View<reco::RecoCandidate> > leps;
  evt.getByLabel(leps_, leps);

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

  edm::Handle<int> nJetsConsidered;
  evt.getByLabel(nJetsConsidered_, nJetsConsidered);

  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);
  std::auto_ptr<int> pNeutrinoSolutions(new int);
  std::auto_ptr<int> pJetsConsidered(new int);

  // 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, leps, mets, jets, *match, idMatch++);
    pOut->push_back( std::make_pair(hypo(), *match) );
  }
  // feed out hyps and matches
  evt.put(pOut);

  // build and feed out key
  buildKey();
  *pKey=key();
  evt.put(pKey, "Key");

  // feed out number of real neutrino solutions
  *pNeutrinoSolutions=numberOfRealNeutrinoSolutions_;
  evt.put(pNeutrinoSolutions, "NumberOfRealNeutrinoSolutions");

  // feed out number of considered jets
  *pJetsConsidered=*nJetsConsidered;
  evt.put(pJetsConsidered, "NumberOfConsideredJets");
}
void TtSemiLepHypothesis::resetCandidates ( ) [protected]

reset candidate pointers before hypo build process

Definition at line 113 of file TtSemiLepHypothesis.cc.

References hadronicB_, lepton_, leptonicB_, lightQ_, lightQBar_, neutrino_, and numberOfRealNeutrinoSolutions_.

Referenced by produce().

void TtSemiLepHypothesis::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 212 of file TtSemiLepHypothesis.cc.

References patZpeak::handle, and launcher::step.

{
  edm::Ptr<pat::Jet> ptr = edm::Ptr<pat::Jet>(handle, idx);
  // disentangle the correction from the potential flavor tag 
  // by the separating ':'; the flavor tag can be empty though
  std::string step   = correctionLevel.substr(0,correctionLevel.find(":"));
  std::string flavor = correctionLevel.substr(1+correctionLevel.find(":"));
  float corrFactor = 1.;
  if(flavor=="wMix")
    corrFactor = 0.75*ptr->jecFactor(step, "uds") + 0.25*ptr->jecFactor(step, "charm");
  else
    corrFactor = ptr->jecFactor(step, flavor);
  clone = new reco::ShallowClonePtrCandidate( ptr, ptr->charge(), ptr->p4()*corrFactor, ptr->vertex() );
}
template<typename C >
void TtSemiLepHypothesis::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 117 of file TtSemiLepHypothesis.h.

References patZpeak::handle.

Referenced by TtSemiLepHypGenMatch::buildHypo(), TtSemiLepHypHitFit::buildHypo(), TtSemiLepHypKinFit::buildHypo(), and 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 TtSemiLepHypothesis::setNeutrino ( const edm::Handle< std::vector< pat::MET > > &  met,
const edm::Handle< edm::View< reco::RecoCandidate > > &  leps,
const int &  idx,
const int &  type 
) [protected]

set neutrino, using mW = 80.4 to calculate the neutrino pz

Definition at line 229 of file TtSemiLepHypothesis.cc.

References Exception, WDecay::kElec, WDecay::kMuon, leptonType(), CaloMET_cfi::met, neutrino_, numberOfRealNeutrinoSolutions_, p4, and mathSSE::sqrt().

Referenced by TtSemiLepHypGenMatch::buildHypo(), and buildHypo().

{
  edm::Ptr<pat::MET> ptr = edm::Ptr<pat::MET>(met, 0);
  MEzCalculator mez;
  mez.SetMET( *(met->begin()) );
  if( leptonType( &(leps->front()) ) == WDecay::kMuon )
    mez.SetLepton( (*leps)[idx], true );
  else if( leptonType( &(leps->front()) ) == WDecay::kElec )
    mez.SetLepton( (*leps)[idx], false );
  else
    throw cms::Exception("UnimplementedFeature") << "Type of lepton given together with MET for solving neutrino kinematics is neither muon nor electron.\n";
  double pz = mez.Calculate(type);
  numberOfRealNeutrinoSolutions_ = mez.IsComplex() ? 0 : 2;
  const math::XYZTLorentzVector p4( ptr->px(), ptr->py(), pz, sqrt(ptr->px()*ptr->px() + ptr->py()*ptr->py() + pz*pz) );
  neutrino_ = new reco::ShallowClonePtrCandidate( ptr, ptr->charge(), p4, ptr->vertex() );
}

Member Data Documentation

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

Definition at line 86 of file TtSemiLepHypothesis.h.

Referenced by produce(), and TtSemiLepHypothesis().

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

Definition at line 95 of file TtSemiLepHypothesis.h.

Referenced by jetCorrectionLevel(), and TtSemiLepHypothesis().

input label for all necessary collections

Definition at line 88 of file TtSemiLepHypothesis.h.

Referenced by produce().

int TtSemiLepHypothesis::key_ [protected]

Definition at line 89 of file TtSemiLepHypothesis.h.

Referenced by produce().

candidates for internal use for the creation of the hypothesis candidate

Definition at line 105 of file TtSemiLepHypothesis.h.

Referenced by TtSemiLepHypGenMatch::buildHypo(), TtSemiLepHypHitFit::buildHypo(), TtSemiLepHypKinFit::buildHypo(), buildHypo(), hypo(), resetCandidates(), and ~TtSemiLepHypothesis().

Definition at line 91 of file TtSemiLepHypothesis.h.

Referenced by produce(), and TtSemiLepHypothesis().

Definition at line 90 of file TtSemiLepHypothesis.h.

Referenced by produce().

algorithm used to calculate neutrino solutions (see cfi for further details)

Definition at line 99 of file TtSemiLepHypothesis.h.

Referenced by TtSemiLepHypGenMatch::buildHypo(), buildHypo(), and TtSemiLepHypothesis().

Definition at line 92 of file TtSemiLepHypothesis.h.

Referenced by produce().

number of real neutrino solutions: -1 if not determined, 0 if only complex, 2 if two real solutions

Definition at line 102 of file TtSemiLepHypothesis.h.

Referenced by produce(), resetCandidates(), and setNeutrino().