CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

TtEvtBuilder< C > Class Template Reference

Template class to fill the TtEvent structure. More...

#include <TopQuarkAnalysis/TopEventProducers/interface/TtEvtBuilder.h>

Inheritance diagram for TtEvtBuilder< C >:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

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

Private Member Functions

virtual void fillSpecific (C &, const edm::Event &)
 fill data members that are decay-channel specific
template<>
void fillSpecific (TtSemiLeptonicEvent &ttEvent, const edm::Event &evt)
template<>
void fillSpecific (TtFullLeptonicEvent &ttEvent, const edm::Event &evt)
template<>
void fillSpecific (TtFullHadronicEvent &ttEvent, const edm::Event &evt)
virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

int decayChnTop1_
int decayChnTop2_
edm::InputTag disc_
edm::InputTag fitChi2_
edm::InputTag fitProb_
edm::InputTag genEvt_
 TtGenEvent.
edm::ParameterSet genMatch_
edm::ParameterSet hitFit_
edm::InputTag hitFitChi2_
edm::InputTag hitFitMT_
edm::InputTag hitFitProb_
edm::InputTag hitFitSigMT_
std::vector< edm::InputTaghyps_
 vector of hypothesis class names
edm::ParameterSet kinFit_
edm::ParameterSet kinSolution_
edm::InputTag meth_
edm::ParameterSet mvaDisc_
edm::InputTag solWeight_
edm::InputTag sumDR_
edm::InputTag sumPt_
int verbosity_
 vebosity level
edm::InputTag wrongCharge_

Detailed Description

template<typename C>
class TtEvtBuilder< C >

Template class to fill the TtEvent structure.

Template class to fill the TtEvent structure for:

TtSemiLeptonicEvent TtFullLeptonicEvent TtFullHadronicEvent

event hypothesis, genEvent and extra information (if available) are read from the event and contracted into the TtEvent

Definition at line 29 of file TtEvtBuilder.h.


Constructor & Destructor Documentation

template<typename C >
TtEvtBuilder< C >::TtEvtBuilder ( const edm::ParameterSet cfg) [explicit]

default constructor

Definition at line 89 of file TtEvtBuilder.h.

References TtEvtBuilder< C >::disc_, edm::ParameterSet::exists(), TtEvtBuilder< C >::fitChi2_, TtEvtBuilder< C >::fitProb_, TtEvtBuilder< C >::genMatch_, edm::ParameterSet::getParameter(), TtEvtBuilder< C >::hitFit_, TtEvtBuilder< C >::hitFitChi2_, TtEvtBuilder< C >::hitFitMT_, TtEvtBuilder< C >::hitFitProb_, TtEvtBuilder< C >::hitFitSigMT_, TtEvtBuilder< C >::kinFit_, TtEvtBuilder< C >::kinSolution_, TtEvtBuilder< C >::meth_, TtEvtBuilder< C >::mvaDisc_, TtEvtBuilder< C >::solWeight_, TtEvtBuilder< C >::sumDR_, TtEvtBuilder< C >::sumPt_, and TtEvtBuilder< C >::wrongCharge_.

                                                        :
  verbosity_   (cfg.getParameter<int>                        ("verbosity"    )),
  hyps_        (cfg.getParameter<std::vector<edm::InputTag> >("hypotheses"   )),
  genEvt_      (cfg.getParameter<edm::InputTag>              ("genEvent"     )),
  decayChnTop1_(cfg.getParameter<int>                        ("decayChannel1")),
  decayChnTop2_(cfg.getParameter<int>                        ("decayChannel2"))
{
  // parameter subsets for kKinFit
  if( cfg.exists("kinFit") ) {
    kinFit_  = cfg.getParameter<edm::ParameterSet>("kinFit");
    fitChi2_ = kinFit_.getParameter<edm::InputTag>("chi2");
    fitProb_ = kinFit_.getParameter<edm::InputTag>("prob");
  }
  // parameter subsets for kHitFit
  if( cfg.exists("hitFit") ) {
    hitFit_  = cfg.getParameter<edm::ParameterSet>("hitFit");
    hitFitChi2_ = hitFit_.getParameter<edm::InputTag>("chi2");
    hitFitProb_ = hitFit_.getParameter<edm::InputTag>("prob");
    hitFitMT_ = hitFit_.getParameter<edm::InputTag>("mt");
    hitFitSigMT_ = hitFit_.getParameter<edm::InputTag>("sigmt");
  }
  // parameter subsets for kKinSolution
  if( cfg.exists("kinSolution") ) {
    kinSolution_  = cfg.getParameter<edm::ParameterSet>("kinSolution");
    solWeight_    = kinSolution_.getParameter<edm::InputTag>("solWeight");
    wrongCharge_  = kinSolution_.getParameter<edm::InputTag>("wrongCharge");
  }  
  // parameter subsets for kGenMatch
  if( cfg.exists("genMatch") ) {
    genMatch_ = cfg.getParameter<edm::ParameterSet>("genMatch");
    sumPt_    = genMatch_.getParameter<edm::InputTag>("sumPt");
    sumDR_    = genMatch_.getParameter<edm::InputTag>("sumDR");
  }
  // parameter subsets for kMvaDisc
  if( cfg.exists("mvaDisc") ) {
    mvaDisc_ = cfg.getParameter<edm::ParameterSet>("mvaDisc");
    meth_    = mvaDisc_.getParameter<edm::InputTag>("meth");
    disc_    = mvaDisc_.getParameter<edm::InputTag>("disc");
  }
  // produces a TtEventEvent for:
  //  * TtSemiLeptonicEvent 
  //  * TtFullLeptonicEvent
  //  * TtFullHadronicEvent
  // from hypotheses and associated extra information
  produces<C>();
}
template<typename C >
TtEvtBuilder< C >::~TtEvtBuilder ( ) [inline]

default destructor

Definition at line 36 of file TtEvtBuilder.h.

{};

Member Function Documentation

template<typename C >
virtual void TtEvtBuilder< C >::fillSpecific ( C &  ,
const edm::Event  
) [private, virtual]

fill data members that are decay-channel specific

template<>
void TtEvtBuilder< TtSemiLeptonicEvent >::fillSpecific ( TtSemiLeptonicEvent ttEvent,
const edm::Event evt 
) [private]

Definition at line 253 of file TtEvtBuilder.h.

References edm::Event::getByLabel(), h, combine::key, TtEvent::setNumberOfConsideredJets(), and TtSemiLeptonicEvent::setNumberOfRealNeutrinoSolutions().

{

  typedef std::vector<edm::InputTag>::const_iterator EventHypo;
  for(EventHypo h=hyps_.begin(); h!=hyps_.end(); ++h){
    edm::Handle<int> key; 
    evt.getByLabel(h->label(), "Key", key);

    // set number of real neutrino solutions for all hypotheses
    edm::Handle<int> numberOfRealNeutrinoSolutions;
    evt.getByLabel(h->label(), "NumberOfRealNeutrinoSolutions", numberOfRealNeutrinoSolutions);
    ttEvent.setNumberOfRealNeutrinoSolutions((TtEvent::HypoClassKey&)*key, *numberOfRealNeutrinoSolutions);

    // set number of considered jets for all hypotheses
    edm::Handle<int> numberOfConsideredJets;
    evt.getByLabel(h->label(), "NumberOfConsideredJets", numberOfConsideredJets);
    ttEvent.setNumberOfConsideredJets((TtEvent::HypoClassKey&)*key, *numberOfConsideredJets);
  }

}
template<>
void TtEvtBuilder< TtFullLeptonicEvent >::fillSpecific ( TtFullLeptonicEvent ttEvent,
const edm::Event evt 
) [private]

Definition at line 236 of file TtEvtBuilder.h.

References edm::Event::getByLabel(), TtEvent::isHypoAvailable(), TtEvent::kKinSolution, TtFullLeptonicEvent::setSolWeight(), and TtFullLeptonicEvent::setWrongCharge().

{

  // set kKinSolution extras  
  if( ttEvent.isHypoAvailable(TtEvent::kKinSolution) ) {
    edm::Handle<std::vector<double> > solWeight;
    evt.getByLabel(solWeight_, solWeight);
    ttEvent.setSolWeight( *solWeight );
    
    edm::Handle<bool> wrongCharge;
    evt.getByLabel(wrongCharge_, wrongCharge);
    ttEvent.setWrongCharge( *wrongCharge );   
  }

}
template<>
void TtEvtBuilder< TtFullHadronicEvent >::fillSpecific ( TtFullHadronicEvent ttEvent,
const edm::Event evt 
) [private]

Definition at line 231 of file TtEvtBuilder.h.

{
}
template<typename C >
void TtEvtBuilder< C >::produce ( edm::Event evt,
const edm::EventSetup setup 
) [private, virtual]

produce function (this one is not even accessible for derived classes)

Implements edm::EDProducer.

Definition at line 138 of file TtEvtBuilder.h.

References funct::C, fitChi2(), TtGenEvtProducer_cfi::genEvt, edm::Event::getByLabel(), h, combine::key, TtEvent::kGenMatch, TtEvent::kHitFit, TtEvent::kKinFit, TtEvent::kMVADisc, and edm::Event::put().

{
  C ttEvent;

  // set leptonic decay channels
  ttEvent.setLepDecays( WDecay::LeptonType(decayChnTop1_), WDecay::LeptonType(decayChnTop2_) );

  // set genEvent (if available)
  edm::Handle<TtGenEvent> genEvt;
  if( evt.getByLabel(genEvt_, genEvt) )
    ttEvent.setGenEvent(genEvt);

  // add event hypotheses for all given 
  // hypothesis classes to the TtEvent
  typedef std::vector<edm::InputTag>::const_iterator EventHypo;
  for(EventHypo h=hyps_.begin(); h!=hyps_.end(); ++h){
    edm::Handle<int> key; 
    evt.getByLabel(h->label(), "Key", key);

    edm::Handle<std::vector<TtEvent::HypoCombPair> > hypMatchVec; 
    evt.getByLabel(*h, hypMatchVec);

    typedef std::vector<TtEvent::HypoCombPair>::const_iterator HypMatch;
    for(HypMatch hm=hypMatchVec->begin(); hm != hypMatchVec->end(); ++hm){
      ttEvent.addEventHypo((TtEvent::HypoClassKey&)*key, *hm);
    }
  }

  // set kKinFit extras
  if( ttEvent.isHypoAvailable(TtEvent::kKinFit) ) {
    edm::Handle<std::vector<double> > fitChi2;
    evt.getByLabel(fitChi2_, fitChi2);
    ttEvent.setFitChi2( *fitChi2 );
    
    edm::Handle<std::vector<double> > fitProb;
    evt.getByLabel(fitProb_, fitProb);
    ttEvent.setFitProb( *fitProb );
  }

  // set kHitFit extras
  if( ttEvent.isHypoAvailable(TtEvent::kHitFit) ) {
    edm::Handle<std::vector<double> > hitFitChi2;
    evt.getByLabel(hitFitChi2_, hitFitChi2);
    ttEvent.setHitFitChi2( *hitFitChi2 );
    
    edm::Handle<std::vector<double> > hitFitProb;
    evt.getByLabel(hitFitProb_, hitFitProb);
    ttEvent.setHitFitProb( *hitFitProb );
    
    edm::Handle<std::vector<double> > hitFitMT;
    evt.getByLabel(hitFitMT_, hitFitMT);
    ttEvent.setHitFitMT( *hitFitMT );
    
    edm::Handle<std::vector<double> > hitFitSigMT;
    evt.getByLabel(hitFitSigMT_, hitFitSigMT);
    ttEvent.setHitFitSigMT( *hitFitSigMT );
  }

  // set kGenMatch extras
  if( ttEvent.isHypoAvailable(TtEvent::kGenMatch) ) {
    edm::Handle<std::vector<double> > sumPt;
    evt.getByLabel(sumPt_, sumPt);
    ttEvent.setGenMatchSumPt( *sumPt );

    edm::Handle<std::vector<double> > sumDR;
    evt.getByLabel(sumDR_, sumDR);
    ttEvent.setGenMatchSumDR( *sumDR );
  }

  // set kMvaDisc extras
  if( ttEvent.isHypoAvailable(TtEvent::kMVADisc) ) {
    edm::Handle<std::string> meth;
    evt.getByLabel(meth_, meth);
    ttEvent.setMvaMethod( *meth );

    edm::Handle<std::vector<double> > disc;
    evt.getByLabel(disc_, disc);
    ttEvent.setMvaDiscriminators( *disc );
  }

  // fill data members that are decay-channel specific
  fillSpecific(ttEvent, evt);

  // print summary via MessageLogger if verbosity_>0
  ttEvent.print(verbosity_);

  // write object into the edm::Event
  std::auto_ptr<C> pOut(new C);
  *pOut=ttEvent;
  evt.put(pOut);
}

Member Data Documentation

template<typename C >
int TtEvtBuilder< C >::decayChnTop1_ [private]

decay channels of the two top decay branches; to be filled according to WDecay::LeptonTypes in TtGenEvent

Definition at line 56 of file TtEvtBuilder.h.

template<typename C >
int TtEvtBuilder< C >::decayChnTop2_ [private]

Definition at line 57 of file TtEvtBuilder.h.

template<typename C >
edm::InputTag TtEvtBuilder< C >::disc_ [private]

Definition at line 85 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
edm::InputTag TtEvtBuilder< C >::fitChi2_ [private]

Definition at line 62 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
edm::InputTag TtEvtBuilder< C >::fitProb_ [private]

Definition at line 63 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
edm::InputTag TtEvtBuilder< C >::genEvt_ [private]

TtGenEvent.

Definition at line 53 of file TtEvtBuilder.h.

template<typename C >
edm::ParameterSet TtEvtBuilder< C >::genMatch_ [private]

input parameters for the kGenMatch hypothesis class extras

Definition at line 78 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
edm::ParameterSet TtEvtBuilder< C >::hitFit_ [private]

input parameters for the kHitFit hypothesis class extras

Definition at line 66 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
edm::InputTag TtEvtBuilder< C >::hitFitChi2_ [private]

Definition at line 67 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
edm::InputTag TtEvtBuilder< C >::hitFitMT_ [private]

Definition at line 69 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
edm::InputTag TtEvtBuilder< C >::hitFitProb_ [private]

Definition at line 68 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
edm::InputTag TtEvtBuilder< C >::hitFitSigMT_ [private]

Definition at line 70 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
std::vector<edm::InputTag> TtEvtBuilder< C >::hyps_ [private]

vector of hypothesis class names

Definition at line 51 of file TtEvtBuilder.h.

template<typename C >
edm::ParameterSet TtEvtBuilder< C >::kinFit_ [private]

input parameters for the kKinFit hypothesis class extras

Definition at line 61 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
edm::ParameterSet TtEvtBuilder< C >::kinSolution_ [private]

input parameters for the kKinSolution hypothesis class extras

Definition at line 73 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
edm::InputTag TtEvtBuilder< C >::meth_ [private]

Definition at line 84 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
edm::ParameterSet TtEvtBuilder< C >::mvaDisc_ [private]

input parameters for the kMVADisc hypothesis class extras

Definition at line 83 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
edm::InputTag TtEvtBuilder< C >::solWeight_ [private]

Definition at line 74 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
edm::InputTag TtEvtBuilder< C >::sumDR_ [private]

Definition at line 80 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
edm::InputTag TtEvtBuilder< C >::sumPt_ [private]

Definition at line 79 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().

template<typename C >
int TtEvtBuilder< C >::verbosity_ [private]

vebosity level

Definition at line 49 of file TtEvtBuilder.h.

template<typename C >
edm::InputTag TtEvtBuilder< C >::wrongCharge_ [private]

Definition at line 75 of file TtEvtBuilder.h.

Referenced by TtEvtBuilder< C >::TtEvtBuilder().