CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TtSemiLepKinFitter.cc
Go to the documentation of this file.
7 
11 
13 
16  TopKinFitter(),
17  hadB_(0), hadP_(0), hadQ_(0), lepB_(0), lepton_(0), neutrino_(0),
18  jetParam_(kEMom), lepParam_(kEMom), metParam_(kEMom)
19 {
20  setupFitter();
21 }
22 
24  int maxNrIter, double maxDeltaS, double maxF,
25  std::vector<Constraint> constraints, double mW, double mTop):
26  TopKinFitter(maxNrIter, maxDeltaS, maxF, mW, mTop),
27  hadB_(0), hadP_(0), hadQ_(0), lepB_(0), lepton_(0), neutrino_(0),
28  jetParam_(jetParam), lepParam_(lepParam), metParam_(metParam), constrList_(constraints)
29 {
30  setupFitter();
31 }
32 
34 {
35  delete hadB_;
36  delete hadP_;
37  delete hadQ_;
38  delete lepB_;
39  delete lepton_;
40  delete neutrino_;
41  for(std::map<Constraint, TFitConstraintM*>::iterator it = massConstr_.begin(); it != massConstr_.end(); ++it)
42  delete it->second;
43 }
44 
46 {
47  std::stringstream constr;
48  for(unsigned int i=0; i<constrList_.size(); ++i){
49  switch(constrList_[i]){
50  case kWHadMass : constr << " * hadronic W-mass (" << mW_ << " GeV) \n"; break;
51  case kWLepMass : constr << " * leptonic W-mass (" << mW_ << " GeV) \n"; break;
52  case kTopHadMass : constr << " * hadronic t-mass (" << mTop_ << " GeV) \n"; break;
53  case kTopLepMass : constr << " * leptonic t-mass (" << mTop_ << " GeV) \n"; break;
54  case kNeutrinoMass : constr << " * neutrino mass (0 GeV) \n"; break;
55  case kEqualTopMasses : constr << " * equal t-masses \n"; break;
56  }
57  }
58  edm::LogVerbatim( "TtSemiLepKinFitter" )
59  << "\n"
60  << "+++++++++++ TtSemiLepKinFitter Setup ++++++++++++ \n"
61  << " Parametrization: \n"
62  << " * jet : " << param(jetParam_) << "\n"
63  << " * lep : " << param(lepParam_) << "\n"
64  << " * met : " << param(metParam_) << "\n"
65  << " Constraints: \n"
66  << constr.str()
67  << " Max(No iterations): " << maxNrIter_ << "\n"
68  << " Max(deltaS) : " << maxDeltaS_ << "\n"
69  << " Max(F) : " << maxF_ << "\n"
70  << "+++++++++++++++++++++++++++++++++++++++++++++++++ \n";
71 }
72 
74 {
75  TMatrixD empty3x3(3,3);
76  TMatrixD empty4x4(4,4);
77  switch(jetParam_){ // setup jets according to parameterization
78  case kEMom :
79  hadB_= new TFitParticleEMomDev ("Jet1", "Jet1", 0, &empty4x4);
80  hadP_= new TFitParticleEMomDev ("Jet2", "Jet2", 0, &empty4x4);
81  hadQ_= new TFitParticleEMomDev ("Jet3", "Jet3", 0, &empty4x4);
82  lepB_= new TFitParticleEMomDev ("Jet4", "Jet4", 0, &empty4x4);
83  break;
84  case kEtEtaPhi :
85  hadB_= new TFitParticleEtEtaPhi ("Jet1", "Jet1", 0, &empty3x3);
86  hadP_= new TFitParticleEtEtaPhi ("Jet2", "Jet2", 0, &empty3x3);
87  hadQ_= new TFitParticleEtEtaPhi ("Jet3", "Jet3", 0, &empty3x3);
88  lepB_= new TFitParticleEtEtaPhi ("Jet4", "Jet4", 0, &empty3x3);
89  break;
90  case kEtThetaPhi :
91  hadB_= new TFitParticleEtThetaPhi("Jet1", "Jet1", 0, &empty3x3);
92  hadP_= new TFitParticleEtThetaPhi("Jet2", "Jet2", 0, &empty3x3);
93  hadQ_= new TFitParticleEtThetaPhi("Jet3", "Jet3", 0, &empty3x3);
94  lepB_= new TFitParticleEtThetaPhi("Jet4", "Jet4", 0, &empty3x3);
95  break;
96  }
97 }
98 
100 {
101  TMatrixD empty3x3(3,3);
102  switch(lepParam_){ // setup lepton according to parameterization
103  case kEMom : lepton_ = new TFitParticleEScaledMomDev("Lepton", "Lepton", 0, &empty3x3); break;
104  case kEtEtaPhi : lepton_ = new TFitParticleEtEtaPhi ("Lepton", "Lepton", 0, &empty3x3); break;
105  case kEtThetaPhi : lepton_ = new TFitParticleEtThetaPhi ("Lepton", "Lepton", 0, &empty3x3); break;
106  }
107  switch(metParam_){ // setup neutrino according to parameterization
108  case kEMom : neutrino_= new TFitParticleEScaledMomDev("Neutrino", "Neutrino", 0, &empty3x3); break;
109  case kEtEtaPhi : neutrino_= new TFitParticleEtEtaPhi ("Neutrino", "Neutrino", 0, &empty3x3); break;
110  case kEtThetaPhi : neutrino_= new TFitParticleEtThetaPhi ("Neutrino", "Neutrino", 0, &empty3x3); break;
111  }
112 }
113 
115 {
116  massConstr_[kWHadMass ] = new TFitConstraintM("WMassHad", "WMassHad", 0, 0, mW_ );
117  massConstr_[kWLepMass ] = new TFitConstraintM("WMassLep", "WMassLep", 0, 0, mW_ );
118  massConstr_[kTopHadMass ] = new TFitConstraintM("TopMassHad", "TopMassHad", 0, 0, mTop_);
119  massConstr_[kTopLepMass ] = new TFitConstraintM("TopMassLep", "TopMassLep", 0, 0, mTop_);
120  massConstr_[kNeutrinoMass ] = new TFitConstraintM("NeutrinoMass", "NeutrinoMass", 0, 0, 0.);
121  massConstr_[kEqualTopMasses] = new TFitConstraintM("EqualTopMasses","EqualTopMasses",0, 0, 0.);
122 
123  massConstr_[kWHadMass ]->addParticles1(hadP_, hadQ_ );
124  massConstr_[kWLepMass ]->addParticles1(lepton_, neutrino_);
125  massConstr_[kTopHadMass ]->addParticles1(hadP_, hadQ_, hadB_);
126  massConstr_[kTopLepMass ]->addParticles1(lepton_, neutrino_, lepB_);
127  massConstr_[kNeutrinoMass ]->addParticle1 (neutrino_);
128  massConstr_[kEqualTopMasses]->addParticles1(hadP_, hadQ_, hadB_);
130 }
131 
133 {
134  printSetup();
135 
136  setupJets();
137  setupLeptons();
139 
140  // add measured particles
147 
148  // add constraints
149  for(unsigned int i=0; i<constrList_.size(); i++){
151  }
152 }
153 
154 template <class LeptonType>
155 int TtSemiLepKinFitter::fit(const std::vector<pat::Jet>& jets, const pat::Lepton<LeptonType>& lepton, const pat::MET& neutrino)
156 {
157  if( jets.size()<4 )
158  throw edm::Exception( edm::errors::Configuration, "Cannot run the TtSemiLepKinFitter with less than 4 jets" );
159 
160  // get jets in right order
163  pat::Jet hadB = jets[TtSemiLepEvtPartons::HadB ];
164  pat::Jet lepB = jets[TtSemiLepEvtPartons::LepB ];
165 
166  // initialize particles
167  TLorentzVector p4HadP( hadP.px(), hadP.py(), hadP.pz(), hadP.energy() );
168  TLorentzVector p4HadQ( hadQ.px(), hadQ.py(), hadQ.pz(), hadQ.energy() );
169  TLorentzVector p4HadB( hadB.px(), hadB.py(), hadB.pz(), hadB.energy() );
170  TLorentzVector p4LepB( lepB.px(), lepB.py(), lepB.pz(), lepB.energy() );
171  TLorentzVector p4Lepton ( lepton.px(), lepton.py(), lepton.pz(), lepton.energy() );
172  TLorentzVector p4Neutrino( neutrino.px(), neutrino.py(), 0, neutrino.et() );
173 
174  // initialize covariance matrices
175  CovarianceMatrix covM;
176  TMatrixD m1 = covM.setupMatrix(hadP, jetParam_);
177  TMatrixD m2 = covM.setupMatrix(hadQ, jetParam_);
178  TMatrixD m3 = covM.setupMatrix(hadB, jetParam_, "bjets");
179  TMatrixD m4 = covM.setupMatrix(lepB, jetParam_, "bjets");
180  TMatrixD m5 = covM.setupMatrix(lepton, lepParam_);
181  TMatrixD m6 = covM.setupMatrix(neutrino, metParam_);
182 
183  // set the kinematics of the objects to be fitted
184  hadP_->setIni4Vec( &p4HadP );
185  hadQ_->setIni4Vec( &p4HadQ );
186  hadB_->setIni4Vec( &p4HadB );
187  lepB_->setIni4Vec( &p4LepB );
188  lepton_->setIni4Vec( &p4Lepton );
189  neutrino_->setIni4Vec( &p4Neutrino );
190 
191  hadP_->setCovMatrix( &m1 );
192  hadQ_->setCovMatrix( &m2 );
193  hadB_->setCovMatrix( &m3 );
194  lepB_->setCovMatrix( &m4 );
195  lepton_->setCovMatrix( &m5 );
196  neutrino_->setCovMatrix( &m6 );
197 
198  // now do the fit
199  fitter_->fit();
200 
201  // read back the resulting particles if the fit converged
202  if(fitter_->getStatus()==0){
203  // read back jet kinematics
205  hadP_->getCurr4Vec()->Y(), hadP_->getCurr4Vec()->Z(), hadP_->getCurr4Vec()->E()), math::XYZPoint()));
207  hadQ_->getCurr4Vec()->Y(), hadQ_->getCurr4Vec()->Z(), hadQ_->getCurr4Vec()->E()), math::XYZPoint()));
209  hadB_->getCurr4Vec()->Y(), hadB_->getCurr4Vec()->Z(), hadB_->getCurr4Vec()->E()), math::XYZPoint()));
211  lepB_->getCurr4Vec()->Y(), lepB_->getCurr4Vec()->Z(), lepB_->getCurr4Vec()->E()), math::XYZPoint()));
212 
213  // read back lepton kinematics
215  lepton_->getCurr4Vec()->Y(), lepton_->getCurr4Vec()->Z(), lepton_->getCurr4Vec()->E()), math::XYZPoint()));
216 
217  // read back the MET kinematics
220 
221  }
222  return fitter_->getStatus();
223 }
224 
226 {
227 
228  TtSemiEvtSolution fitsol(*asol);
229 
230  std::vector<pat::Jet> jets;
231  jets.resize(4);
232  jets[TtSemiLepEvtPartons::LightQ ] = fitsol.getCalHadp();
234  jets[TtSemiLepEvtPartons::HadB ] = fitsol.getCalHadb();
235  jets[TtSemiLepEvtPartons::LepB ] = fitsol.getCalLepb();
236 
237  // perform the fit, either using the electron or the muon
238  if(fitsol.getDecay() == "electron") fit( jets, fitsol.getCalLepe(), fitsol.getCalLepn() );
239  if(fitsol.getDecay() == "muon") fit( jets, fitsol.getCalLepm(), fitsol.getCalLepn() );
240 
241  // add fitted information to the solution
242  if (fitter_->getStatus() == 0) {
243  // fill the fitted particles
244  fitsol.setFitHadb( fittedHadB() );
245  fitsol.setFitHadp( fittedHadP() );
246  fitsol.setFitHadq( fittedHadQ() );
247  fitsol.setFitLepb( fittedLepB() );
248  fitsol.setFitLepl( fittedLepton() );
249  fitsol.setFitLepn( fittedNeutrino() );
250  // store the fit's chi2 probability
251  fitsol.setProbChi2( fitProb() );
252  }
253  return fitsol;
254 }
Analysis-level MET class.
Definition: MET.h:42
void setFitHadq(const pat::Particle &aFitHadq)
const pat::Particle fittedHadP() const
int i
Definition: DBlmapReader.cc:9
void setFitHadb(const pat::Particle &aFitHadb)
TAbsFitParticle * hadB_
Param
supported parameterizations
Definition: TopKinFitter.h:22
TAbsFitParticle * neutrino_
Int_t fit()
Definition: TKinFitter.cc:309
virtual double et() const
transverse energy
const pat::Particle fittedNeutrino() const
const pat::Particle fittedLepB() const
TAbsFitParticle * hadQ_
pat::Jet getCalHadq() const
virtual void setIni4Vec(const TLorentzVector *pini)=0
std::string param(const Param &param) const
convert Param to human readable form
Definition: TopKinFitter.cc:23
pat::MET getCalLepn() const
TMatrixD setupMatrix(const pat::PATObject< ObjectType > &object, TopKinFitter::Param param, std::string resolutionProvider)
std::string getDecay() const
int maxNrIter_
maximal allowed number of iterations to be used for the fit
Definition: TopKinFitter.h:46
pat::Particle fittedHadP_
double fitProb() const
return fit probability
Definition: TopKinFitter.h:36
pat::Particle fittedLepB_
Param lepParam_
lepton parametrization
pat::Particle fittedHadB_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
pat::Electron getCalLepe() const
virtual double energy() const
energy
TAbsFitParticle * lepton_
int fit(const std::vector< pat::Jet > &jets, const pat::Lepton< LeptonType > &leps, const pat::MET &met)
kinematic fit interface
void setupJets()
initialize jet inputs
void printSetup() const
print fitter setup
void setFitLepb(const pat::Particle &aFitLepb)
pat::Particle fittedLepton_
void addConstraint(TAbsFitConstraint *constraint)
Definition: TKinFitter.cc:281
TAbsFitParticle * hadP_
void setFitHadp(const pat::Particle &aFitHadp)
Analysis-level lepton class.
Definition: Lepton.h:32
Int_t getStatus()
Definition: TKinFitter.h:40
virtual void setCovMatrix(const TMatrixD *theCovMatrix)
Param jetParam_
jet parametrization
const pat::Particle fittedHadB() const
double mW_
W mass value used for constraints.
Definition: TopKinFitter.h:52
void addMeasParticle(TAbsFitParticle *particle)
Definition: TKinFitter.cc:209
TtSemiLepKinFitter()
default constructor
std::map< Constraint, TFitConstraintM * > massConstr_
Param metParam_
met parametrization
pat::Particle fittedHadQ_
pat::Muon getCalLepm() const
double maxDeltaS_
maximal allowed chi2 (not normalized to degrees of freedom)
Definition: TopKinFitter.h:48
pat::Jet getCalHadb() const
TtSemiEvtSolution addKinFitInfo(TtSemiEvtSolution *asol)
add kin fit information to the old event solution (in for legacy reasons)
~TtSemiLepKinFitter()
default destructor
void setupConstraints()
initialize constraints
std::vector< Constraint > constrList_
vector of constraints to be used
void setupLeptons()
initialize lepton inputs
virtual double px() const
x coordinate of momentum vector
void setFitLepn(const pat::Particle &aFitLepn)
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
Analysis-level particle class.
Definition: Particle.h:34
Analysis-level calorimeter jet class.
Definition: Jet.h:67
const pat::Particle fittedHadQ() const
virtual double pz() const
z coordinate of momentum vector
const TLorentzVector * getCurr4Vec()
const pat::Particle fittedLepton() const
void setProbChi2(double c)
pat::Jet getCalLepb() const
void setupFitter()
setup fitter
pat::Particle fittedNeutrino_
TKinFitter * fitter_
Definition: TopKinFitter.h:44
void setFitLepl(const pat::Particle &aFitLepl)
double mTop_
top mass value used for constraints
Definition: TopKinFitter.h:54
virtual double py() const
y coordinate of momentum vector
TAbsFitParticle * lepB_
double maxF_
maximal allowed distance from constraints
Definition: TopKinFitter.h:50
pat::Jet getCalHadp() const