CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

TtSemiLepKinFitter Class Reference

#include <TtSemiLepKinFitter.h>

Inheritance diagram for TtSemiLepKinFitter:
TopKinFitter

List of all members.

Public Types

enum  Constraint {
  kWHadMass = 1, kWLepMass, kTopHadMass, kTopLepMass,
  kNeutrinoMass, kEqualTopMasses
}
 

supported constraints

More...

Public Member Functions

TtSemiEvtSolution addKinFitInfo (TtSemiEvtSolution *asol)
 add kin fit information to the old event solution (in for legacy reasons)
template<class LeptonType >
int fit (const std::vector< pat::Jet > &jets, const pat::Lepton< LeptonType > &leps, const pat::MET &met)
 kinematic fit interface
const pat::Particle fittedHadB () const
const pat::Particle fittedHadP () const
const pat::Particle fittedHadQ () const
const pat::Particle fittedLepB () const
const pat::Particle fittedLepton () const
const pat::Particle fittedNeutrino () const
 TtSemiLepKinFitter ()
 default constructor
 TtSemiLepKinFitter (Param jetParam, Param lepParam, Param metParam, int maxNrIter, double maxDeltaS, double maxF, std::vector< Constraint > constraints, double mW=80.4, double mTop=173.)
 constructor initialized with built-in types and class enum's custom parameters
 ~TtSemiLepKinFitter ()
 default destructor

Private Member Functions

void printSetup () const
 print fitter setup
void setupConstraints ()
 initialize constraints
void setupFitter ()
 setup fitter
void setupJets ()
 initialize jet inputs
void setupLeptons ()
 initialize lepton inputs

Private Attributes

std::vector< ConstraintconstrList_
 vector of constraints to be used
pat::Particle fittedHadB_
pat::Particle fittedHadP_
pat::Particle fittedHadQ_
pat::Particle fittedLepB_
pat::Particle fittedLepton_
pat::Particle fittedNeutrino_
TAbsFitParticlehadB_
TAbsFitParticlehadP_
TAbsFitParticlehadQ_
Param jetParam_
 jet parametrization
TAbsFitParticlelepB_
Param lepParam_
 lepton parametrization
TAbsFitParticlelepton_
std::map< Constraint,
TFitConstraintM * > 
massConstr_
Param metParam_
 met parametrization
TAbsFitParticleneutrino_

Detailed Description

Definition at line 26 of file TtSemiLepKinFitter.h.


Member Enumeration Documentation

supported constraints

Enumerator:
kWHadMass 
kWLepMass 
kTopHadMass 
kTopLepMass 
kNeutrinoMass 
kEqualTopMasses 

Definition at line 31 of file TtSemiLepKinFitter.h.


Constructor & Destructor Documentation

TtSemiLepKinFitter::TtSemiLepKinFitter ( ) [explicit]

default constructor

default configuration is: Parametrization kEMom, Max iterations = 200, deltaS<= 5e-5, maxF<= 1e-4, no constraints

Definition at line 15 of file TtSemiLepKinFitter.cc.

References setupFitter().

TtSemiLepKinFitter::TtSemiLepKinFitter ( Param  jetParam,
Param  lepParam,
Param  metParam,
int  maxNrIter,
double  maxDeltaS,
double  maxF,
std::vector< Constraint constraints,
double  mW = 80.4,
double  mTop = 173. 
) [explicit]

constructor initialized with built-in types and class enum's custom parameters

Definition at line 23 of file TtSemiLepKinFitter.cc.

References setupFitter().

                                                                                                 :
  TopKinFitter(maxNrIter, maxDeltaS, maxF, mW, mTop),
  hadB_(0), hadP_(0), hadQ_(0), lepB_(0), lepton_(0), neutrino_(0),
  jetParam_(jetParam), lepParam_(lepParam), metParam_(metParam), constrList_(constraints)
{
  setupFitter();
}
TtSemiLepKinFitter::~TtSemiLepKinFitter ( )

default destructor

Definition at line 33 of file TtSemiLepKinFitter.cc.

References hadB_, hadP_, hadQ_, lepB_, lepton_, massConstr_, and neutrino_.

{
  delete hadB_; 
  delete hadP_; 
  delete hadQ_;
  delete lepB_; 
  delete lepton_; 
  delete neutrino_;
  for(std::map<Constraint, TFitConstraintM*>::iterator it = massConstr_.begin(); it != massConstr_.end(); ++it)
    delete it->second;
}

Member Function Documentation

TtSemiEvtSolution TtSemiLepKinFitter::addKinFitInfo ( TtSemiEvtSolution asol)

add kin fit information to the old event solution (in for legacy reasons)

Definition at line 225 of file TtSemiLepKinFitter.cc.

References fit(), TopKinFitter::fitProb(), fittedHadB(), fittedHadP(), fittedHadQ(), fittedLepB(), fittedLepton(), fittedNeutrino(), TopKinFitter::fitter_, TtSemiEvtSolution::getCalHadb(), TtSemiEvtSolution::getCalHadp(), TtSemiEvtSolution::getCalHadq(), TtSemiEvtSolution::getCalLepb(), TtSemiEvtSolution::getCalLepe(), TtSemiEvtSolution::getCalLepm(), TtSemiEvtSolution::getCalLepn(), TtSemiEvtSolution::getDecay(), TKinFitter::getStatus(), TtSemiLepDaughter::HadB, analyzePatCleaning_cfg::jets, TtSemiLepDaughter::LepB, TtFullHadDaughter::LightQ, TtFullHadDaughter::LightQBar, TtSemiEvtSolution::setFitHadb(), TtSemiEvtSolution::setFitHadp(), TtSemiEvtSolution::setFitHadq(), TtSemiEvtSolution::setFitLepb(), TtSemiEvtSolution::setFitLepl(), TtSemiEvtSolution::setFitLepn(), and TtSemiEvtSolution::setProbChi2().

Referenced by TtSemiEvtSolutionMaker::produce().

{

  TtSemiEvtSolution fitsol(*asol);

  std::vector<pat::Jet> jets;
  jets.resize(4);
  jets[TtSemiLepEvtPartons::LightQ   ] = fitsol.getCalHadp();
  jets[TtSemiLepEvtPartons::LightQBar] = fitsol.getCalHadq();
  jets[TtSemiLepEvtPartons::HadB     ] = fitsol.getCalHadb();
  jets[TtSemiLepEvtPartons::LepB     ] = fitsol.getCalLepb();

  // perform the fit, either using the electron or the muon
  if(fitsol.getDecay() == "electron") fit( jets, fitsol.getCalLepe(), fitsol.getCalLepn() );
  if(fitsol.getDecay() == "muon")     fit( jets, fitsol.getCalLepm(), fitsol.getCalLepn() );
  
  // add fitted information to the solution
  if (fitter_->getStatus() == 0) {
    // fill the fitted particles
    fitsol.setFitHadb( fittedHadB() );
    fitsol.setFitHadp( fittedHadP() );
    fitsol.setFitHadq( fittedHadQ() );
    fitsol.setFitLepb( fittedLepB() );
    fitsol.setFitLepl( fittedLepton() );
    fitsol.setFitLepn( fittedNeutrino() );
    // store the fit's chi2 probability
    fitsol.setProbChi2( fitProb() );
  }
  return fitsol;
}
template<class LeptonType >
int TtSemiLepKinFitter::fit ( const std::vector< pat::Jet > &  jets,
const pat::Lepton< LeptonType > &  leps,
const pat::MET met 
)

kinematic fit interface

Definition at line 155 of file TtSemiLepKinFitter.cc.

References edm::errors::Configuration, reco::LeafCandidate::energy(), reco::LeafCandidate::et(), TKinFitter::fit(), fittedHadB_, fittedHadP_, fittedHadQ_, fittedLepB_, fittedLepton_, fittedNeutrino_, TopKinFitter::fitter_, TAbsFitParticle::getCurr4Vec(), TKinFitter::getStatus(), TtSemiLepDaughter::HadB, hadB_, hadP_, hadQ_, jetParam_, TtSemiLepDaughter::LepB, lepB_, lepParam_, lepton_, TtFullHadDaughter::LightQ, TtFullHadDaughter::LightQBar, metParam_, neutrino_, reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), TAbsFitParticle::setCovMatrix(), TAbsFitParticle::setIni4Vec(), and CovarianceMatrix::setupMatrix().

Referenced by addKinFitInfo().

{
  if( jets.size()<4 )
    throw edm::Exception( edm::errors::Configuration, "Cannot run the TtSemiLepKinFitter with less than 4 jets" );

  // get jets in right order
  pat::Jet hadP = jets[TtSemiLepEvtPartons::LightQ   ];
  pat::Jet hadQ = jets[TtSemiLepEvtPartons::LightQBar];
  pat::Jet hadB = jets[TtSemiLepEvtPartons::HadB     ];
  pat::Jet lepB = jets[TtSemiLepEvtPartons::LepB     ];
 
  // initialize particles
  TLorentzVector p4HadP( hadP.px(), hadP.py(), hadP.pz(), hadP.energy() );
  TLorentzVector p4HadQ( hadQ.px(), hadQ.py(), hadQ.pz(), hadQ.energy() );
  TLorentzVector p4HadB( hadB.px(), hadB.py(), hadB.pz(), hadB.energy() );
  TLorentzVector p4LepB( lepB.px(), lepB.py(), lepB.pz(), lepB.energy() );
  TLorentzVector p4Lepton  ( lepton.px(), lepton.py(), lepton.pz(), lepton.energy() );
  TLorentzVector p4Neutrino( neutrino.px(), neutrino.py(), 0, neutrino.et() );

  // initialize covariance matrices
  CovarianceMatrix covM;
  TMatrixD m1 = covM.setupMatrix(hadP,     jetParam_);
  TMatrixD m2 = covM.setupMatrix(hadQ,     jetParam_);
  TMatrixD m3 = covM.setupMatrix(hadB,     jetParam_, "bjets");
  TMatrixD m4 = covM.setupMatrix(lepB,     jetParam_, "bjets");
  TMatrixD m5 = covM.setupMatrix(lepton,   lepParam_);
  TMatrixD m6 = covM.setupMatrix(neutrino, metParam_);

  // set the kinematics of the objects to be fitted
  hadP_->setIni4Vec( &p4HadP );
  hadQ_->setIni4Vec( &p4HadQ );
  hadB_->setIni4Vec( &p4HadB );
  lepB_->setIni4Vec( &p4LepB );
  lepton_->setIni4Vec( &p4Lepton );
  neutrino_->setIni4Vec( &p4Neutrino );

  hadP_->setCovMatrix( &m1 );
  hadQ_->setCovMatrix( &m2 );
  hadB_->setCovMatrix( &m3 );
  lepB_->setCovMatrix( &m4 );
  lepton_->setCovMatrix( &m5 );
  neutrino_->setCovMatrix( &m6 );

  // now do the fit
  fitter_->fit();

  // read back the resulting particles if the fit converged
  if(fitter_->getStatus()==0){
    // read back jet kinematics
    fittedHadP_= pat::Particle(reco::LeafCandidate(0, math::XYZTLorentzVector(hadP_->getCurr4Vec()->X(),
                               hadP_->getCurr4Vec()->Y(), hadP_->getCurr4Vec()->Z(), hadP_->getCurr4Vec()->E()), math::XYZPoint()));
    fittedHadQ_= pat::Particle(reco::LeafCandidate(0, math::XYZTLorentzVector(hadQ_->getCurr4Vec()->X(),
                               hadQ_->getCurr4Vec()->Y(), hadQ_->getCurr4Vec()->Z(), hadQ_->getCurr4Vec()->E()), math::XYZPoint()));
    fittedHadB_= pat::Particle(reco::LeafCandidate(0, math::XYZTLorentzVector(hadB_->getCurr4Vec()->X(),
                               hadB_->getCurr4Vec()->Y(), hadB_->getCurr4Vec()->Z(), hadB_->getCurr4Vec()->E()), math::XYZPoint()));
    fittedLepB_= pat::Particle(reco::LeafCandidate(0, math::XYZTLorentzVector(lepB_->getCurr4Vec()->X(),
                               lepB_->getCurr4Vec()->Y(), lepB_->getCurr4Vec()->Z(), lepB_->getCurr4Vec()->E()), math::XYZPoint()));

    // read back lepton kinematics
    fittedLepton_= pat::Particle(reco::LeafCandidate(0, math::XYZTLorentzVector(lepton_->getCurr4Vec()->X(),
                                 lepton_->getCurr4Vec()->Y(), lepton_->getCurr4Vec()->Z(), lepton_->getCurr4Vec()->E()), math::XYZPoint()));

    // read back the MET kinematics
    fittedNeutrino_= pat::Particle(reco::LeafCandidate(0, math::XYZTLorentzVector(neutrino_->getCurr4Vec()->X(),
                                   neutrino_->getCurr4Vec()->Y(), neutrino_->getCurr4Vec()->Z(), neutrino_->getCurr4Vec()->E()), math::XYZPoint()));

  }
  return fitter_->getStatus();
}
const pat::Particle TtSemiLepKinFitter::fittedHadB ( ) const [inline]

Definition at line 45 of file TtSemiLepKinFitter.h.

References fittedHadB_, TopKinFitter::fitter_, and TKinFitter::getStatus().

Referenced by addKinFitInfo().

{ return (fitter_->getStatus()==0 ? fittedHadB_ : pat::Particle()); };
const pat::Particle TtSemiLepKinFitter::fittedHadP ( ) const [inline]

Definition at line 47 of file TtSemiLepKinFitter.h.

References fittedHadP_, TopKinFitter::fitter_, and TKinFitter::getStatus().

Referenced by addKinFitInfo().

{ return (fitter_->getStatus()==0 ? fittedHadP_ : pat::Particle()); };
const pat::Particle TtSemiLepKinFitter::fittedHadQ ( ) const [inline]

Definition at line 49 of file TtSemiLepKinFitter.h.

References fittedHadQ_, TopKinFitter::fitter_, and TKinFitter::getStatus().

Referenced by addKinFitInfo().

{ return (fitter_->getStatus()==0 ? fittedHadQ_ : pat::Particle()); };
const pat::Particle TtSemiLepKinFitter::fittedLepB ( ) const [inline]

Definition at line 51 of file TtSemiLepKinFitter.h.

References fittedLepB_, TopKinFitter::fitter_, and TKinFitter::getStatus().

Referenced by addKinFitInfo().

{ return (fitter_->getStatus()==0 ? fittedLepB_ : pat::Particle()); };
const pat::Particle TtSemiLepKinFitter::fittedLepton ( ) const [inline]

Definition at line 53 of file TtSemiLepKinFitter.h.

References fittedLepton_, TopKinFitter::fitter_, and TKinFitter::getStatus().

Referenced by addKinFitInfo().

{ return (fitter_->getStatus()==0 ? fittedLepton_ : pat::Particle()); };
const pat::Particle TtSemiLepKinFitter::fittedNeutrino ( ) const [inline]

Definition at line 55 of file TtSemiLepKinFitter.h.

References fittedNeutrino_, TopKinFitter::fitter_, and TKinFitter::getStatus().

Referenced by addKinFitInfo().

{ return (fitter_->getStatus()==0 ? fittedNeutrino_ : pat::Particle()); };
void TtSemiLepKinFitter::printSetup ( ) const [private]

print fitter setup

Definition at line 45 of file TtSemiLepKinFitter.cc.

References constrList_, i, jetParam_, kEqualTopMasses, kNeutrinoMass, kTopHadMass, kTopLepMass, kWHadMass, kWLepMass, lepParam_, TopKinFitter::maxDeltaS_, TopKinFitter::maxF_, TopKinFitter::maxNrIter_, metParam_, TopKinFitter::mTop_, TopKinFitter::mW_, and TopKinFitter::param().

Referenced by setupFitter().

{
  std::stringstream constr;
  for(unsigned int i=0; i<constrList_.size(); ++i){
    switch(constrList_[i]){
    case kWHadMass       : constr << "    * hadronic W-mass (" << mW_   << " GeV) \n"; break;
    case kWLepMass       : constr << "    * leptonic W-mass (" << mW_   << " GeV) \n"; break;
    case kTopHadMass     : constr << "    * hadronic t-mass (" << mTop_ << " GeV) \n"; break;
    case kTopLepMass     : constr << "    * leptonic t-mass (" << mTop_ << " GeV) \n"; break;
    case kNeutrinoMass   : constr << "    * neutrino   mass (0 GeV) \n"; break;
    case kEqualTopMasses : constr << "    * equal    t-masses \n"; break;
    }
  }
  edm::LogVerbatim( "TtSemiLepKinFitter" ) 
    << "\n"
    << "+++++++++++ TtSemiLepKinFitter Setup ++++++++++++ \n"
    << "  Parametrization:                                \n" 
    << "   * jet : " << param(jetParam_) << "\n"
    << "   * lep : " << param(lepParam_) << "\n"
    << "   * met : " << param(metParam_) << "\n"
    << "  Constraints:                                    \n"
    <<    constr.str()
    << "  Max(No iterations): " << maxNrIter_ << "\n"
    << "  Max(deltaS)       : " << maxDeltaS_ << "\n"
    << "  Max(F)            : " << maxF_      << "\n"
    << "+++++++++++++++++++++++++++++++++++++++++++++++++ \n";
}
void TtSemiLepKinFitter::setupConstraints ( ) [private]

initialize constraints

Definition at line 114 of file TtSemiLepKinFitter.cc.

References hadB_, hadP_, hadQ_, kEqualTopMasses, kNeutrinoMass, kTopHadMass, kTopLepMass, kWHadMass, kWLepMass, lepB_, lepton_, massConstr_, TopKinFitter::mTop_, TopKinFitter::mW_, and neutrino_.

Referenced by setupFitter().

{
  massConstr_[kWHadMass      ] = new TFitConstraintM("WMassHad",      "WMassHad",      0, 0, mW_  );
  massConstr_[kWLepMass      ] = new TFitConstraintM("WMassLep",      "WMassLep",      0, 0, mW_  );
  massConstr_[kTopHadMass    ] = new TFitConstraintM("TopMassHad",    "TopMassHad",    0, 0, mTop_);
  massConstr_[kTopLepMass    ] = new TFitConstraintM("TopMassLep",    "TopMassLep",    0, 0, mTop_);
  massConstr_[kNeutrinoMass  ] = new TFitConstraintM("NeutrinoMass",  "NeutrinoMass",  0, 0,    0.);
  massConstr_[kEqualTopMasses] = new TFitConstraintM("EqualTopMasses","EqualTopMasses",0, 0,    0.);

  massConstr_[kWHadMass      ]->addParticles1(hadP_,   hadQ_    );
  massConstr_[kWLepMass      ]->addParticles1(lepton_, neutrino_);
  massConstr_[kTopHadMass    ]->addParticles1(hadP_, hadQ_, hadB_);
  massConstr_[kTopLepMass    ]->addParticles1(lepton_, neutrino_, lepB_);
  massConstr_[kNeutrinoMass  ]->addParticle1 (neutrino_);
  massConstr_[kEqualTopMasses]->addParticles1(hadP_, hadQ_, hadB_);
  massConstr_[kEqualTopMasses]->addParticles2(lepton_, neutrino_, lepB_);
}
void TtSemiLepKinFitter::setupFitter ( ) [private]
void TtSemiLepKinFitter::setupJets ( ) [private]

initialize jet inputs

Definition at line 73 of file TtSemiLepKinFitter.cc.

References hadB_, hadP_, hadQ_, jetParam_, TopKinFitter::kEMom, TopKinFitter::kEtEtaPhi, TopKinFitter::kEtThetaPhi, and lepB_.

Referenced by setupFitter().

{
  TMatrixD empty3x3(3,3); 
  TMatrixD empty4x4(4,4);
  switch(jetParam_){ // setup jets according to parameterization
  case kEMom :
    hadB_= new TFitParticleEMomDev   ("Jet1", "Jet1", 0, &empty4x4);
    hadP_= new TFitParticleEMomDev   ("Jet2", "Jet2", 0, &empty4x4);
    hadQ_= new TFitParticleEMomDev   ("Jet3", "Jet3", 0, &empty4x4);
    lepB_= new TFitParticleEMomDev   ("Jet4", "Jet4", 0, &empty4x4);
    break;
  case kEtEtaPhi :
    hadB_= new TFitParticleEtEtaPhi  ("Jet1", "Jet1", 0, &empty3x3);
    hadP_= new TFitParticleEtEtaPhi  ("Jet2", "Jet2", 0, &empty3x3);
    hadQ_= new TFitParticleEtEtaPhi  ("Jet3", "Jet3", 0, &empty3x3);
    lepB_= new TFitParticleEtEtaPhi  ("Jet4", "Jet4", 0, &empty3x3);
    break;
  case kEtThetaPhi :
    hadB_= new TFitParticleEtThetaPhi("Jet1", "Jet1", 0, &empty3x3);
    hadP_= new TFitParticleEtThetaPhi("Jet2", "Jet2", 0, &empty3x3);
    hadQ_= new TFitParticleEtThetaPhi("Jet3", "Jet3", 0, &empty3x3);
    lepB_= new TFitParticleEtThetaPhi("Jet4", "Jet4", 0, &empty3x3);
    break;
  }
}
void TtSemiLepKinFitter::setupLeptons ( ) [private]

initialize lepton inputs

Definition at line 99 of file TtSemiLepKinFitter.cc.

References TopKinFitter::kEMom, TopKinFitter::kEtEtaPhi, TopKinFitter::kEtThetaPhi, lepParam_, lepton_, metParam_, and neutrino_.

Referenced by setupFitter().

{
  TMatrixD empty3x3(3,3); 
  switch(lepParam_){ // setup lepton according to parameterization
  case kEMom       : lepton_  = new TFitParticleEScaledMomDev("Lepton",   "Lepton",   0, &empty3x3); break;
  case kEtEtaPhi   : lepton_  = new TFitParticleEtEtaPhi     ("Lepton",   "Lepton",   0, &empty3x3); break;
  case kEtThetaPhi : lepton_  = new TFitParticleEtThetaPhi   ("Lepton",   "Lepton",   0, &empty3x3); break;
  }
  switch(metParam_){ // setup neutrino according to parameterization
  case kEMom       : neutrino_= new TFitParticleEScaledMomDev("Neutrino", "Neutrino", 0, &empty3x3); break;
  case kEtEtaPhi   : neutrino_= new TFitParticleEtEtaPhi     ("Neutrino", "Neutrino", 0, &empty3x3); break;
  case kEtThetaPhi : neutrino_= new TFitParticleEtThetaPhi   ("Neutrino", "Neutrino", 0, &empty3x3); break;
  }
}

Member Data Documentation

vector of constraints to be used

Definition at line 95 of file TtSemiLepKinFitter.h.

Referenced by printSetup(), and setupFitter().

Definition at line 82 of file TtSemiLepKinFitter.h.

Referenced by fit(), and fittedHadB().

Definition at line 83 of file TtSemiLepKinFitter.h.

Referenced by fit(), and fittedHadP().

Definition at line 84 of file TtSemiLepKinFitter.h.

Referenced by fit(), and fittedHadQ().

Definition at line 85 of file TtSemiLepKinFitter.h.

Referenced by fit(), and fittedLepB().

Definition at line 86 of file TtSemiLepKinFitter.h.

Referenced by fit(), and fittedLepton().

Definition at line 87 of file TtSemiLepKinFitter.h.

Referenced by fit(), and fittedNeutrino().

jet parametrization

Definition at line 89 of file TtSemiLepKinFitter.h.

Referenced by fit(), printSetup(), and setupJets().

lepton parametrization

Definition at line 91 of file TtSemiLepKinFitter.h.

Referenced by fit(), printSetup(), and setupLeptons().

Definition at line 80 of file TtSemiLepKinFitter.h.

Referenced by setupConstraints(), setupFitter(), and ~TtSemiLepKinFitter().

met parametrization

Definition at line 93 of file TtSemiLepKinFitter.h.

Referenced by fit(), printSetup(), and setupLeptons().