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 TtSemiLepHypKinFit TtSemiLepHypMaxSumPtWMass TtSemiLepHypMVADisc TtSemiLepHypWMassDeltaTopMass TtSemiLepHypWMassMaxSumPt

List of all members.

Public Member Functions

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

Protected Member Functions

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
 return key
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
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
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 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 9 of file TtSemiLepHypothesis.cc.

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

                                                                  :
  jets_(cfg.getParameter<edm::InputTag>("jets")),
  leps_(cfg.getParameter<edm::InputTag>("leps")),
  mets_(cfg.getParameter<edm::InputTag>("mets")),
  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("jetCorrectionLevel") ) {
    jetCorrectionLevel_ = cfg.getParameter<std::string>("jetCorrectionLevel");
  }
  produces<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > >();
  produces<int>("Key");
  produces<int>("NumberOfRealNeutrinoSolutions");
}
TtSemiLepHypothesis::~TtSemiLepHypothesis ( )

default destructor

Definition at line 31 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

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]

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

Implemented in TtSemiLepHypGenMatch, TtSemiLepHypGeom, TtSemiLepHypKinFit, TtSemiLepHypMaxSumPtWMass, TtSemiLepHypMVADisc, TtSemiLepHypWMassDeltaTopMass, and TtSemiLepHypWMassMaxSumPt.

Referenced by produce().

virtual void TtSemiLepHypothesis::buildKey ( ) [protected, pure virtual]
reco::CompositeCandidate TtSemiLepHypothesis::hypo ( ) [protected]

return event hypothesis

Definition at line 111 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]
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 163 of file TtSemiLepHypothesis.cc.

References jetCorrectionLevel_, and testEve_cfg::level.

Referenced by TtSemiLepHypGenMatch::buildHypo(), TtSemiLepHypGeom::buildHypo(), TtSemiLepHypWMassMaxSumPt::buildHypo(), TtSemiLepHypWMassDeltaTopMass::buildHypo(), and TtSemiLepHypMaxSumPtWMass::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]

return key

Definition at line 55 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 148 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 43 of file TtSemiLepHypothesis.cc.

References buildHypo(), buildKey(), edm::Event::getByLabel(), getMatch_, hypo(), i, analyzePatCleaning_cfg::jets, jets_, key(), leps_, match(), match_, mets_, 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);

  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);

  // 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");
}
void TtSemiLepHypothesis::resetCandidates ( ) [protected]

reset candidate pointers before hypo build process

Definition at line 98 of file TtSemiLepHypothesis.cc.

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

Referenced by produce().

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 109 of file TtSemiLepHypothesis.h.

References patZpeak::handle.

Referenced by TtSemiLepHypGenMatch::buildHypo(), TtSemiLepHypGeom::buildHypo(), TtSemiLepHypWMassMaxSumPt::buildHypo(), TtSemiLepHypKinFit::buildHypo(), TtSemiLepHypWMassDeltaTopMass::buildHypo(), TtSemiLepHypMaxSumPtWMass::buildHypo(), and TtSemiLepHypMVADisc::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::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 197 of file TtSemiLepHypothesis.cc.

References patZpeak::handle, and ExpressReco_HICollisions_FallBack::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() );
}
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 214 of file TtSemiLepHypothesis.cc.

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

Referenced by TtSemiLepHypGenMatch::buildHypo(), TtSemiLepHypGeom::buildHypo(), TtSemiLepHypWMassMaxSumPt::buildHypo(), TtSemiLepHypWMassDeltaTopMass::buildHypo(), and TtSemiLepHypMaxSumPtWMass::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 81 of file TtSemiLepHypothesis.h.

Referenced by produce(), and TtSemiLepHypothesis().

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

Definition at line 89 of file TtSemiLepHypothesis.h.

Referenced by jetCorrectionLevel(), and TtSemiLepHypothesis().

input label for all necessary collections

Definition at line 83 of file TtSemiLepHypothesis.h.

Referenced by produce().

int TtSemiLepHypothesis::key_ [protected]

Definition at line 84 of file TtSemiLepHypothesis.h.

Referenced by produce().

Definition at line 86 of file TtSemiLepHypothesis.h.

Referenced by produce(), and TtSemiLepHypothesis().

Definition at line 85 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 94 of file TtSemiLepHypothesis.h.

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