CMS 3D CMS Logo

TtFullHadKinFitter.cc
Go to the documentation of this file.
7 
10 
12 
13 static const unsigned int nPartons = 6;
14 
17  : TopKinFitter(),
18  b_(nullptr),
19  bBar_(nullptr),
20  lightQ_(nullptr),
21  lightQBar_(nullptr),
22  lightP_(nullptr),
23  lightPBar_(nullptr),
24  udscResolutions_(nullptr),
25  bResolutions_(nullptr),
26  jetEnergyResolutionScaleFactors_(nullptr),
27  jetEnergyResolutionEtaBinning_(nullptr),
28  jetParam_(kEMom) {
29  setupFitter();
30 }
31 
33 std::vector<TtFullHadKinFitter::Constraint> TtFullHadKinFitter::intToConstraint(
34  const std::vector<unsigned int>& constraints) {
35  std::vector<TtFullHadKinFitter::Constraint> cConstraints;
36  cConstraints.resize(constraints.size());
37  for (unsigned int i = 0; i < constraints.size(); ++i) {
38  cConstraints[i] = (Constraint)constraints[i];
39  }
40  return cConstraints;
41 }
42 
45  int maxNrIter,
46  double maxDeltaS,
47  double maxF,
48  const std::vector<unsigned int>& constraints,
49  double mW,
50  double mTop,
51  const std::vector<edm::ParameterSet>* udscResolutions,
52  const std::vector<edm::ParameterSet>* bResolutions,
53  const std::vector<double>* jetEnergyResolutionScaleFactors,
54  const std::vector<double>* jetEnergyResolutionEtaBinning)
56  b_(nullptr),
57  bBar_(nullptr),
58  lightQ_(nullptr),
59  lightQBar_(nullptr),
60  lightP_(nullptr),
61  lightPBar_(nullptr),
62  udscResolutions_(udscResolutions),
63  bResolutions_(bResolutions),
64  jetEnergyResolutionScaleFactors_(jetEnergyResolutionScaleFactors),
65  jetEnergyResolutionEtaBinning_(jetEnergyResolutionEtaBinning),
66  jetParam_((Param)jetParam),
67  constraints_(intToConstraint(constraints)) {
68  setupFitter();
69 }
70 
73  int maxNrIter,
74  double maxDeltaS,
75  double maxF,
76  const std::vector<Constraint>& constraints,
77  double mW,
78  double mTop,
79  const std::vector<edm::ParameterSet>* udscResolutions,
80  const std::vector<edm::ParameterSet>* bResolutions,
81  const std::vector<double>* jetEnergyResolutionScaleFactors,
82  const std::vector<double>* jetEnergyResolutionEtaBinning)
84  b_(nullptr),
85  bBar_(nullptr),
86  lightQ_(nullptr),
87  lightQBar_(nullptr),
88  lightP_(nullptr),
89  lightPBar_(nullptr),
90  udscResolutions_(udscResolutions),
91  bResolutions_(bResolutions),
92  jetEnergyResolutionScaleFactors_(jetEnergyResolutionScaleFactors),
93  jetEnergyResolutionEtaBinning_(jetEnergyResolutionEtaBinning),
94  jetParam_(jetParam),
95  constraints_(constraints) {
96  setupFitter();
97 }
98 
101  delete b_;
102  delete bBar_;
103  delete lightQ_;
104  delete lightQBar_;
105  delete lightP_;
106  delete lightPBar_;
107  delete covM_;
108  for (std::map<Constraint, TFitConstraintM*>::iterator it = massConstr_.begin(); it != massConstr_.end(); ++it)
109  delete it->second;
110 }
111 
114  std::stringstream constr;
115  for (unsigned int i = 0; i < constraints_.size(); ++i) {
116  switch (constraints_[i]) {
117  case kWPlusMass:
118  constr << " * W+-mass (" << mW_ << " GeV) \n";
119  break;
120  case kWMinusMass:
121  constr << " * W--mass (" << mW_ << " GeV) \n";
122  break;
123  case kTopMass:
124  constr << " * t-mass (" << mTop_ << " GeV) \n";
125  break;
126  case kTopBarMass:
127  constr << " * tBar-mass (" << mTop_ << " GeV) \n";
128  break;
129  case kEqualTopMasses:
130  constr << " * equal t-masses \n";
131  break;
132  }
133  }
134  edm::LogVerbatim("TtFullHadKinFitter") << "\n"
135  << "+++++++++++ TtFullHadKinFitter Setup ++++++++++++ \n"
136  << " Parametrization: \n"
137  << " * jet : " << param(jetParam_) << "\n"
138  << " Constraints: \n"
139  << constr.str() << " Max(No iterations): " << maxNrIter_ << "\n"
140  << " Max(deltaS) : " << maxDeltaS_ << "\n"
141  << " Max(F) : " << maxF_ << "\n"
142  << "+++++++++++++++++++++++++++++++++++++++++++++++++ \n";
143 }
144 
147  TMatrixD empty3x3(3, 3);
148  TMatrixD empty4x4(4, 4);
149  switch (jetParam_) { // setup jets according to parameterization
150  case kEMom:
151  b_ = new TFitParticleEMomDev("Jet1", "Jet1", nullptr, &empty4x4);
152  bBar_ = new TFitParticleEMomDev("Jet2", "Jet2", nullptr, &empty4x4);
153  lightQ_ = new TFitParticleEMomDev("Jet3", "Jet3", nullptr, &empty4x4);
154  lightQBar_ = new TFitParticleEMomDev("Jet4", "Jet4", nullptr, &empty4x4);
155  lightP_ = new TFitParticleEMomDev("Jet5", "Jet5", nullptr, &empty4x4);
156  lightPBar_ = new TFitParticleEMomDev("Jet6", "Jet6", nullptr, &empty4x4);
157  break;
158  case kEtEtaPhi:
159  b_ = new TFitParticleEtEtaPhi("Jet1", "Jet1", nullptr, &empty3x3);
160  bBar_ = new TFitParticleEtEtaPhi("Jet2", "Jet2", nullptr, &empty3x3);
161  lightQ_ = new TFitParticleEtEtaPhi("Jet3", "Jet3", nullptr, &empty3x3);
162  lightQBar_ = new TFitParticleEtEtaPhi("Jet4", "Jet4", nullptr, &empty3x3);
163  lightP_ = new TFitParticleEtEtaPhi("Jet5", "Jet5", nullptr, &empty3x3);
164  lightPBar_ = new TFitParticleEtEtaPhi("Jet6", "Jet6", nullptr, &empty3x3);
165  break;
166  case kEtThetaPhi:
167  b_ = new TFitParticleEtThetaPhi("Jet1", "Jet1", nullptr, &empty3x3);
168  bBar_ = new TFitParticleEtThetaPhi("Jet2", "Jet2", nullptr, &empty3x3);
169  lightQ_ = new TFitParticleEtThetaPhi("Jet3", "Jet3", nullptr, &empty3x3);
170  lightQBar_ = new TFitParticleEtThetaPhi("Jet4", "Jet4", nullptr, &empty3x3);
171  lightP_ = new TFitParticleEtThetaPhi("Jet5", "Jet5", nullptr, &empty3x3);
172  lightPBar_ = new TFitParticleEtThetaPhi("Jet6", "Jet6", nullptr, &empty3x3);
173  break;
174  }
175 }
176 
179  massConstr_[kWPlusMass] = new TFitConstraintM("WPlusMass", "WPlusMass", nullptr, nullptr, mW_);
180  massConstr_[kWMinusMass] = new TFitConstraintM("WMinusMass", "WMinusMass", nullptr, nullptr, mW_);
181  massConstr_[kTopMass] = new TFitConstraintM("TopMass", "TopMass", nullptr, nullptr, mTop_);
182  massConstr_[kTopBarMass] = new TFitConstraintM("TopBarMass", "TopBarMass", nullptr, nullptr, mTop_);
183  massConstr_[kEqualTopMasses] = new TFitConstraintM("EqualTopMasses", "EqualTopMasses", nullptr, nullptr, 0);
184 
185  massConstr_[kWPlusMass]->addParticles1(lightQ_, lightQBar_);
186  massConstr_[kWMinusMass]->addParticles1(lightP_, lightPBar_);
187  massConstr_[kTopMass]->addParticles1(b_, lightQ_, lightQBar_);
188  massConstr_[kTopBarMass]->addParticles1(bBar_, lightP_, lightPBar_);
189  massConstr_[kEqualTopMasses]->addParticles1(b_, lightQ_, lightQBar_);
191 }
192 
195  printSetup();
196  setupJets();
198 
199  // add measured particles
206 
207  // add constraints
208  for (unsigned int i = 0; i < constraints_.size(); i++) {
210  }
211 
212  // initialize helper class used to bring the resolutions into covariance matrices
213  if (!udscResolutions_->empty() && !bResolutions_->empty())
214  covM_ = new CovarianceMatrix(
216  else
217  covM_ = new CovarianceMatrix();
218 }
219 
221 int TtFullHadKinFitter::fit(const std::vector<pat::Jet>& jets) {
222  if (jets.size() < 6) {
223  throw edm::Exception(edm::errors::Configuration, "Cannot run the TtFullHadKinFitter with less than 6 jets");
224  }
225 
226  // get jets in right order
228  const pat::Jet& bBar = jets[TtFullHadEvtPartons::BBar];
229  const pat::Jet& lightQ = jets[TtFullHadEvtPartons::LightQ];
230  const pat::Jet& lightQBar = jets[TtFullHadEvtPartons::LightQBar];
231  const pat::Jet& lightP = jets[TtFullHadEvtPartons::LightP];
232  const pat::Jet& lightPBar = jets[TtFullHadEvtPartons::LightPBar];
233 
234  // initialize particles
235  const TLorentzVector p4B(b.px(), b.py(), b.pz(), b.energy());
236  const TLorentzVector p4BBar(bBar.px(), bBar.py(), bBar.pz(), bBar.energy());
237  const TLorentzVector p4LightQ(lightQ.px(), lightQ.py(), lightQ.pz(), lightQ.energy());
238  const TLorentzVector p4LightQBar(lightQBar.px(), lightQBar.py(), lightQBar.pz(), lightQBar.energy());
239  const TLorentzVector p4LightP(lightP.px(), lightP.py(), lightP.pz(), lightP.energy());
240  const TLorentzVector p4LightPBar(lightPBar.px(), lightPBar.py(), lightPBar.pz(), lightPBar.energy());
241 
242  // initialize covariance matrices
243  TMatrixD m1 = covM_->setupMatrix(lightQ, jetParam_);
244  TMatrixD m2 = covM_->setupMatrix(lightQBar, jetParam_);
245  TMatrixD m3 = covM_->setupMatrix(b, jetParam_, "bjets");
246  TMatrixD m4 = covM_->setupMatrix(lightP, jetParam_);
247  TMatrixD m5 = covM_->setupMatrix(lightPBar, jetParam_);
248  TMatrixD m6 = covM_->setupMatrix(bBar, jetParam_, "bjets");
249 
250  // set the kinematics of the objects to be fitted
251  b_->setIni4Vec(&p4B);
252  bBar_->setIni4Vec(&p4BBar);
253  lightQ_->setIni4Vec(&p4LightQ);
254  lightQBar_->setIni4Vec(&p4LightQBar);
255  lightP_->setIni4Vec(&p4LightP);
256  lightPBar_->setIni4Vec(&p4LightPBar);
257 
258  // initialize covariance matrices
259  lightQ_->setCovMatrix(&m1);
260  lightQBar_->setCovMatrix(&m2);
261  b_->setCovMatrix(&m3);
262  lightP_->setCovMatrix(&m4);
263  lightPBar_->setCovMatrix(&m5);
264  bBar_->setCovMatrix(&m6);
265 
266  // perform the fit!
267  fitter_->fit();
268 
269  // add fitted information to the solution
270  if (fitter_->getStatus() == 0) {
271  // read back jet kinematics
273  0,
275  b_->getCurr4Vec()->X(), b_->getCurr4Vec()->Y(), b_->getCurr4Vec()->Z(), b_->getCurr4Vec()->E()),
276  math::XYZPoint()));
279  lightQ_->getCurr4Vec()->Y(),
280  lightQ_->getCurr4Vec()->Z(),
281  lightQ_->getCurr4Vec()->E()),
282  math::XYZPoint()));
285  lightQBar_->getCurr4Vec()->Y(),
286  lightQBar_->getCurr4Vec()->Z(),
287  lightQBar_->getCurr4Vec()->E()),
288  math::XYZPoint()));
289 
291  0,
293  bBar_->getCurr4Vec()->X(), bBar_->getCurr4Vec()->Y(), bBar_->getCurr4Vec()->Z(), bBar_->getCurr4Vec()->E()),
294  math::XYZPoint()));
297  lightP_->getCurr4Vec()->Y(),
298  lightP_->getCurr4Vec()->Z(),
299  lightP_->getCurr4Vec()->E()),
300  math::XYZPoint()));
303  lightPBar_->getCurr4Vec()->Y(),
304  lightPBar_->getCurr4Vec()->Z(),
305  lightPBar_->getCurr4Vec()->E()),
306  math::XYZPoint()));
307  }
308  return fitter_->getStatus();
309 }
310 
313  TtHadEvtSolution fitsol(*asol);
314 
315  std::vector<pat::Jet> jets;
316  jets.resize(6);
323 
324  fit(jets);
325 
326  // add fitted information to the solution
327  if (fitter_->getStatus() == 0) {
328  // finally fill the fitted particles
329  fitsol.setFitHadb(fittedB_);
330  fitsol.setFitHadp(fittedLightQ_);
332  fitsol.setFitHadk(fittedLightP_);
334  fitsol.setFitHadbbar(fittedBBar_);
335 
336  // store the fit's chi2 probability
337  fitsol.setProbChi2(fitProb());
338  }
339  return fitsol;
340 }
341 
344  : useBTagging_(true),
345  bTags_(2),
346  bTagAlgo_("trackCountingHighPurBJetTags"),
347  minBTagValueBJet_(3.41),
348  maxBTagValueNonBJet_(3.41),
349  udscResolutions_(std::vector<edm::ParameterSet>(0)),
350  bResolutions_(std::vector<edm::ParameterSet>(0)),
351  jetEnergyResolutionScaleFactors_(0),
352  jetEnergyResolutionEtaBinning_(0),
353  jetCorrectionLevel_("L3Absolute"),
354  maxNJets_(-1),
355  maxNComb_(1),
356  maxNrIter_(500),
357  maxDeltaS_(5e-5),
358  maxF_(0.0001),
359  jetParam_(1),
360  mW_(80.4),
361  mTop_(173.),
362  useOnlyMatch_(false),
363  match_(std::vector<int>(0)),
364  invalidMatch_(false) {
365  constraints_.push_back(1);
366  constraints_.push_back(2);
367  constraints_.push_back(5);
368 }
369 
372  unsigned int bTags,
374  double minBTagValueBJet,
375  double maxBTagValueNonBJet,
376  const std::vector<edm::ParameterSet>& udscResolutions,
377  const std::vector<edm::ParameterSet>& bResolutions,
378  const std::vector<double>& jetEnergyResolutionScaleFactors,
379  const std::vector<double>& jetEnergyResolutionEtaBinning,
381  int maxNJets,
382  int maxNComb,
383  unsigned int maxNrIter,
384  double maxDeltaS,
385  double maxF,
386  unsigned int jetParam,
387  const std::vector<unsigned>& constraints,
388  double mW,
389  double mTop)
390  : useBTagging_(useBTagging),
391  bTags_(bTags),
392  bTagAlgo_(bTagAlgo),
393  minBTagValueBJet_(minBTagValueBJet),
394  maxBTagValueNonBJet_(maxBTagValueNonBJet),
399  jetCorrectionLevel_(jetCorrectionLevel),
400  maxNJets_(maxNJets),
401  maxNComb_(maxNComb),
404  maxF_(maxF),
405  jetParam_(jetParam),
407  mW_(mW),
408  mTop_(mTop),
409  useOnlyMatch_(false),
410  invalidMatch_(false) {
411  // define kinematic fit interface
413  maxNrIter_,
414  maxDeltaS_,
415  maxF_,
417  mW_,
418  mTop_,
420  &bResolutions_,
423 }
424 
427 
428 bool TtFullHadKinFitter::KinFit::doBTagging(const std::vector<pat::Jet>& jets,
429  const unsigned int& bJetCounter,
430  std::vector<int>& combi) {
431  if (!useBTagging_) {
432  return true;
433  }
434  if (bTags_ == 2 && jets[combi[TtFullHadEvtPartons::B]].bDiscriminator(bTagAlgo_) >= minBTagValueBJet_ &&
435  jets[combi[TtFullHadEvtPartons::BBar]].bDiscriminator(bTagAlgo_) >= minBTagValueBJet_ &&
436  jets[combi[TtFullHadEvtPartons::LightQ]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
437  jets[combi[TtFullHadEvtPartons::LightQBar]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
438  jets[combi[TtFullHadEvtPartons::LightP]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
439  jets[combi[TtFullHadEvtPartons::LightPBar]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_) {
440  return true;
441  } else if (bTags_ == 1) {
442  if (bJetCounter == 1 &&
443  (jets[combi[TtFullHadEvtPartons::B]].bDiscriminator(bTagAlgo_) >= minBTagValueBJet_ ||
444  jets[combi[TtFullHadEvtPartons::BBar]].bDiscriminator(bTagAlgo_) >= minBTagValueBJet_) &&
445  jets[combi[TtFullHadEvtPartons::LightQ]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
446  jets[combi[TtFullHadEvtPartons::LightQBar]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
447  jets[combi[TtFullHadEvtPartons::LightP]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
448  jets[combi[TtFullHadEvtPartons::LightPBar]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_) {
449  return true;
450  } else if (bJetCounter > 1 && jets[combi[TtFullHadEvtPartons::B]].bDiscriminator(bTagAlgo_) >= minBTagValueBJet_ &&
451  jets[combi[TtFullHadEvtPartons::BBar]].bDiscriminator(bTagAlgo_) >= minBTagValueBJet_ &&
452  jets[combi[TtFullHadEvtPartons::LightQ]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
453  jets[combi[TtFullHadEvtPartons::LightQBar]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
454  jets[combi[TtFullHadEvtPartons::LightP]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
455  jets[combi[TtFullHadEvtPartons::LightPBar]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_) {
456  return true;
457  }
458  } else if (bTags_ == 0) {
459  if (bJetCounter == 0) {
460  return true;
461  } else if (bJetCounter == 1 &&
462  (jets[combi[TtFullHadEvtPartons::B]].bDiscriminator(bTagAlgo_) >= minBTagValueBJet_ ||
463  jets[combi[TtFullHadEvtPartons::BBar]].bDiscriminator(bTagAlgo_) >= minBTagValueBJet_) &&
464  jets[combi[TtFullHadEvtPartons::LightQ]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
465  jets[combi[TtFullHadEvtPartons::LightQBar]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
466  jets[combi[TtFullHadEvtPartons::LightP]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
467  jets[combi[TtFullHadEvtPartons::LightPBar]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_) {
468  return true;
469  } else if (bJetCounter > 1 && jets[combi[TtFullHadEvtPartons::B]].bDiscriminator(bTagAlgo_) >= minBTagValueBJet_ &&
470  jets[combi[TtFullHadEvtPartons::BBar]].bDiscriminator(bTagAlgo_) >= minBTagValueBJet_ &&
471  jets[combi[TtFullHadEvtPartons::LightQ]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
472  jets[combi[TtFullHadEvtPartons::LightQBar]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
473  jets[combi[TtFullHadEvtPartons::LightP]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
474  jets[combi[TtFullHadEvtPartons::LightPBar]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_) {
475  return true;
476  }
477  } else if (bTags_ > 2) {
478  throw cms::Exception("Configuration") << "Wrong number of bTags (" << bTags_ << " bTags not supported)!\n";
479  return true;
480  }
481  return false;
482 }
483 
486  // jetCorrectionLevel was not configured
487  if (jetCorrectionLevel_.empty())
488  throw cms::Exception("Configuration")
489  << "Unconfigured jetCorrectionLevel. Please use an appropriate, non-empty string.\n";
490 
491  // quarkType is unknown
492  if (!(quarkType == "wMix" || quarkType == "uds" || quarkType == "charm" || quarkType == "bottom"))
493  throw cms::Exception("Configuration") << quarkType << " is unknown as a quarkType for the jetCorrectionLevel.\n";
494 
495  float jecFactor = 1.;
496  if (quarkType == "wMix")
497  jecFactor = 0.75 * jet.jecFactor(jetCorrectionLevel_, "uds") + 0.25 * jet.jecFactor(jetCorrectionLevel_, "charm");
498  else
499  jecFactor = jet.jecFactor(jetCorrectionLevel_, quarkType);
500 
501  pat::Jet ret = jet;
502  ret.setP4(ret.p4() * jecFactor);
503  return ret;
504 }
505 
506 std::list<TtFullHadKinFitter::KinFitResult> TtFullHadKinFitter::KinFit::fit(const std::vector<pat::Jet>& jets) {
507  std::list<TtFullHadKinFitter::KinFitResult> fitResults;
508 
515  if (jets.size() < nPartons || invalidMatch_) {
516  // indices referring to the jet combination
517  std::vector<int> invalidCombi;
518  for (unsigned int i = 0; i < nPartons; ++i)
519  invalidCombi.push_back(-1);
520 
522  // status of the fitter
523  result.Status = -1;
524  // chi2
525  result.Chi2 = -1.;
526  // chi2 probability
527  result.Prob = -1.;
528  // the kinFit getters return empty objects here
529  result.B = fitter->fittedB();
530  result.BBar = fitter->fittedBBar();
531  result.LightQ = fitter->fittedLightQ();
532  result.LightQBar = fitter->fittedLightQBar();
533  result.LightP = fitter->fittedLightP();
534  result.LightPBar = fitter->fittedLightPBar();
535  result.JetCombi = invalidCombi;
536  // push back fit result
537  fitResults.push_back(result);
538  return fitResults;
539  }
540 
546  std::vector<int> jetIndices;
547  if (!useOnlyMatch_) {
548  for (unsigned int idx = 0; idx < jets.size(); ++idx) {
549  if (maxNJets_ >= (int)nPartons && maxNJets_ == (int)idx)
550  break;
551  jetIndices.push_back(idx);
552  }
553  }
554 
555  std::vector<int> combi;
556  for (unsigned int idx = 0; idx < nPartons; ++idx) {
557  useOnlyMatch_ ? combi.push_back(match_[idx]) : combi.push_back(idx);
558  }
559 
560  unsigned int bJetCounter = 0;
561  for (std::vector<pat::Jet>::const_iterator jet = jets.begin(); jet < jets.end(); ++jet) {
562  if (jet->bDiscriminator(bTagAlgo_) >= minBTagValueBJet_)
563  ++bJetCounter;
564  }
565 
566  do {
567  for (int cnt = 0; cnt < TMath::Factorial(combi.size()); ++cnt) {
568  // take into account indistinguishability of the two jets from the two W decays,
569  // and the two decay branches, this reduces the combinatorics by a factor of 2*2*2
573  useOnlyMatch_) &&
574  doBTagging(jets, bJetCounter, combi)) {
575  std::vector<pat::Jet> jetCombi;
576  jetCombi.resize(nPartons);
577  jetCombi[TtFullHadEvtPartons::LightQ] = corJet(jets[combi[TtFullHadEvtPartons::LightQ]], "wMix");
578  jetCombi[TtFullHadEvtPartons::LightQBar] = corJet(jets[combi[TtFullHadEvtPartons::LightQBar]], "wMix");
579  jetCombi[TtFullHadEvtPartons::B] = corJet(jets[combi[TtFullHadEvtPartons::B]], "bottom");
580  jetCombi[TtFullHadEvtPartons::BBar] = corJet(jets[combi[TtFullHadEvtPartons::BBar]], "bottom");
581  jetCombi[TtFullHadEvtPartons::LightP] = corJet(jets[combi[TtFullHadEvtPartons::LightP]], "wMix");
582  jetCombi[TtFullHadEvtPartons::LightPBar] = corJet(jets[combi[TtFullHadEvtPartons::LightPBar]], "wMix");
583 
584  // do the kinematic fit
585  int status = fitter->fit(jetCombi);
586 
587  if (status == 0) {
588  // fill struct KinFitResults if converged
590  result.Status = status;
591  result.Chi2 = fitter->fitS();
592  result.Prob = fitter->fitProb();
593  result.B = fitter->fittedB();
594  result.BBar = fitter->fittedBBar();
595  result.LightQ = fitter->fittedLightQ();
596  result.LightQBar = fitter->fittedLightQBar();
597  result.LightP = fitter->fittedLightP();
598  result.LightPBar = fitter->fittedLightPBar();
599  result.JetCombi = combi;
600  // push back fit result
601  fitResults.push_back(result);
602  }
603  }
604  // don't go through combinatorics if useOnlyMatch was chosen
605  if (useOnlyMatch_) {
606  break;
607  }
608  // next permutation
609  std::next_permutation(combi.begin(), combi.end());
610  }
611  // don't go through combinatorics if useOnlyMatch was chosen
612  if (useOnlyMatch_) {
613  break;
614  }
615  } while (stdcomb::next_combination(jetIndices.begin(), jetIndices.end(), combi.begin(), combi.end()));
616 
617  // sort results w.r.t. chi2 values
618  fitResults.sort();
619 
625  if ((unsigned)fitResults.size() < 1) {
626  // in case no fit results were stored in the list (i.e. when all fits were aborted)
627 
629  // status of the fitter
630  result.Status = -1;
631  // chi2
632  result.Chi2 = -1.;
633  // chi2 probability
634  result.Prob = -1.;
635  // the kinFit getters return empty objects here
636  result.B = fitter->fittedB();
637  result.BBar = fitter->fittedBBar();
638  result.LightQ = fitter->fittedLightQ();
639  result.LightQBar = fitter->fittedLightQBar();
640  result.LightP = fitter->fittedLightP();
641  result.LightPBar = fitter->fittedLightPBar();
642  // indices referring to the jet combination
643  std::vector<int> invalidCombi(nPartons, -1);
644  result.JetCombi = invalidCombi;
645  // push back fit result
646  fitResults.push_back(result);
647  }
648  return fitResults;
649 }
650 
653  switch (configParameter) {
656  break;
659  break;
662  break;
663  default:
664  throw cms::Exception("Configuration")
665  << "Chosen jet parametrization is not supported: " << configParameter << "\n";
666  break;
667  }
668  return result;
669 }
670 
673  switch (configParameter) {
676  break;
679  break;
682  break;
685  break;
688  break;
689  default:
690  throw cms::Exception("Configuration") << "Chosen fit constraint is not supported: " << configParameter << "\n";
691  break;
692  }
693  return result;
694 }
695 
696 std::vector<TtFullHadKinFitter::Constraint> TtFullHadKinFitter::KinFit::constraints(
697  const std::vector<unsigned>& configParameters) {
698  std::vector<TtFullHadKinFitter::Constraint> result;
699  for (unsigned i = 0; i < configParameters.size(); ++i) {
700  result.push_back(constraint(configParameters[i]));
701  }
702  return result;
703 }
TtFullHadKinFitter::jetParam_
Param jetParam_
jet parametrization
Definition: TtFullHadKinFitter.h:121
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:373
TopKinFitter::kEtEtaPhi
Definition: TopKinFitter.h:20
TtFullHadKinFitter::fit
int fit(const std::vector< pat::Jet > &jets)
kinematic fit interface
Definition: TtFullHadKinFitter.cc:221
TtFullHadKinFitter::KinFit::maxDeltaS_
double maxDeltaS_
maximal chi2 equivalent
Definition: TtFullHadKinFitter.h:265
TFitParticleEMomDev
Definition: TFitParticleEMomDev.h:10
TtFullHadKinFitter::fittedLightQ_
pat::Particle fittedLightQ_
Definition: TtFullHadKinFitter.h:116
mps_fire.i
i
Definition: mps_fire.py:428
TtHadEvtSolution::setFitHadbbar
void setFitHadbbar(const pat::Particle &aFitHadbbar)
Definition: TtHadEvtSolution.h:229
MessageLogger.h
TopKinFitter::fitter_
TKinFitter * fitter_
kinematic fitter
Definition: TopKinFitter.h:47
funct::false
false
Definition: Factorize.h:29
TtFullHadKinFitter::KinFitResult
struct for fit results
Definition: TtFullHadKinFitter.h:130
TtFullHadKinFitter::addKinFitInfo
TtHadEvtSolution addKinFitInfo(TtHadEvtSolution *asol)
add kin fit information to the old event solution (in for legacy reasons)
Definition: TtFullHadKinFitter.cc:312
HLT_FULL_cff.constraint
constraint
Definition: HLT_FULL_cff.py:51992
TtFullHadKinFitter::covM_
CovarianceMatrix * covM_
get object resolutions and put them into a matrix
Definition: TtFullHadKinFitter.h:126
TopKinFitter::maxNrIter_
int maxNrIter_
maximal allowed number of iterations to be used for the fit
Definition: TopKinFitter.h:49
TtFullHadKinFitter::setupFitter
void setupFitter()
setup fitter
Definition: TtFullHadKinFitter.cc:194
TtFullHadKinFitter.h
TtFullHadKinFitProducer_cfi.udscResolutions
udscResolutions
Definition: TtFullHadKinFitProducer_cfi.py:83
StEvtSolProducer_cfi.maxNrIter
maxNrIter
Definition: StEvtSolProducer_cfi.py:24
mps_update.status
status
Definition: mps_update.py:69
TtFullHadKinFitter::kTopMass
Definition: TtFullHadKinFitter.h:32
TtFullHadEvtPartons::LightQ
Definition: TtFullHadEvtPartons.h:25
TtFullHadKinFitter::lightQBar_
TAbsFitParticle * lightQBar_
Definition: TtFullHadKinFitter.h:102
edm
HLT enums.
Definition: AlignableModifier.h:19
TtFullHadKinFitter::KinFit::jetEnergyResolutionEtaBinning_
std::vector< double > jetEnergyResolutionEtaBinning_
Definition: TtFullHadKinFitter.h:255
TtFullHadKinFitter::b_
TAbsFitParticle * b_
input particles
Definition: TtFullHadKinFitter.h:99
TFitConstraintM
Definition: TFitConstraintM.h:11
TtFullHadKinFitter::KinFit::jetParam_
unsigned int jetParam_
numbering of different possible jet parametrizations
Definition: TtFullHadKinFitter.h:269
TFitParticleEScaledMomDev.h
TFitParticleEtThetaPhi.h
TtFullHadKinFitter::kWMinusMass
Definition: TtFullHadKinFitter.h:32
TtFullHadKinFitProducer_cfi.maxBTagValueNonBJet
maxBTagValueNonBJet
Definition: TtFullHadKinFitProducer_cfi.py:39
TtHadEvtSolution::setFitHadk
void setFitHadk(const pat::Particle &aFitHadk)
Definition: TtHadEvtSolution.h:221
TopKinFitter::param
std::string param(const Param &param) const
convert Param to human readable form
Definition: TopKinFitter.cc:18
TtFullHadEvtPartons::LightP
Definition: TtFullHadEvtPartons.h:25
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
TFitConstraintM.h
TtFullHadKinFitter::KinFit::mTop_
double mTop_
top mass value used for constraints
Definition: TtFullHadKinFitter.h:275
TtFullHadKinFitter::KinFit::doBTagging
bool doBTagging(const std::vector< pat::Jet > &jets, const unsigned int &bJetCounter, std::vector< int > &combi)
Definition: TtFullHadKinFitter.cc:428
TtHadEvtSolution::getCalHadb
pat::Jet getCalHadb() const
Definition: TtHadEvtSolution.h:105
TtFullHadKinFitter::kEqualTopMasses
Definition: TtFullHadKinFitter.h:32
TtFullHadKinFitter::setupJets
void setupJets()
initialize jet inputs
Definition: TtFullHadKinFitter.cc:146
TtFullHadKinFitter::KinFit::constraint
TtFullHadKinFitter::Constraint constraint(unsigned int configParameter)
Definition: TtFullHadKinFitter.cc:671
TopKinFitter::kEMom
Definition: TopKinFitter.h:20
TopKinFitter::fitProb
double fitProb() const
return fit probability
Definition: TopKinFitter.h:37
TtHadEvtSolution::getCalHadk
pat::Jet getCalHadk() const
Definition: TtHadEvtSolution.h:110
TtFullHadKinFitter::KinFit::mW_
double mW_
W mass value used for constraints.
Definition: TtFullHadKinFitter.h:273
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
TtFullHadKinFitter::constraints_
std::vector< Constraint > constraints_
vector of constraints to be used
Definition: TtFullHadKinFitter.h:123
TtFullHadKinFitter::KinFit::fit
std::list< TtFullHadKinFitter::KinFitResult > fit(const std::vector< pat::Jet > &jets)
do the fitting and return fit result
Definition: TtFullHadKinFitter.cc:506
CovarianceMatrix
math::Error< 5 >::type CovarianceMatrix
Definition: SeedToTrackProducer.h:48
TtFullHadKinFitter::KinFit::bResolutions_
std::vector< edm::ParameterSet > bResolutions_
Definition: TtFullHadKinFitter.h:252
TopKinFitter::mW_
double mW_
W mass value used for constraints.
Definition: TopKinFitter.h:55
pat::Jet
Analysis-level calorimeter jet class.
Definition: Jet.h:77
TtFullHadKinFitter::KinFit::jetEnergyResolutionScaleFactors_
std::vector< double > jetEnergyResolutionScaleFactors_
scale factors for the jet energy resolution
Definition: TtFullHadKinFitter.h:254
TtFullHadKinFitProducer_cfi.minBTagValueBJet
minBTagValueBJet
Definition: TtFullHadKinFitProducer_cfi.py:38
TKinFitter::fit
Int_t fit()
Definition: TKinFitter.cc:318
TtHadEvtSolution::setFitHadq
void setFitHadq(const pat::Particle &aFitHadq)
Definition: TtHadEvtSolution.h:213
TtFullHadKinFitter::massConstr_
std::map< Constraint, TFitConstraintM * > massConstr_
supported constraints
Definition: TtFullHadKinFitter.h:112
TtFullHadKinFitter::KinFit::fitter
TtFullHadKinFitter * fitter
kinematic fit interface
Definition: TtFullHadKinFitter.h:284
TtFullHadKinFitter::kTopBarMass
Definition: TtFullHadKinFitter.h:32
reco::LeafCandidate::py
double py() const final
y coordinate of momentum vector
Definition: LeafCandidate.h:142
TtFullHadKinFitter::KinFit::maxF_
double maxF_
maximal deviation for contstraints
Definition: TtFullHadKinFitter.h:267
TtFullHadKinFitter::udscResolutions_
const std::vector< edm::ParameterSet > * udscResolutions_
resolutions
Definition: TtFullHadKinFitter.h:106
TtFullHadKinFitter::printSetup
void printSetup() const
print fitter setup
Definition: TtFullHadKinFitter.cc:113
TtHadEvtSolution::getCalHadbbar
pat::Jet getCalHadbbar() const
Definition: TtHadEvtSolution.h:106
TtSemiLepHitFitProducer_Electrons_cfi.mTop
mTop
Definition: TtSemiLepHitFitProducer_Electrons_cfi.py:36
TtFullHadKinFitter::KinFit::maxNrIter_
unsigned int maxNrIter_
maximal number of iterations to be performed for the fit
Definition: TtFullHadKinFitter.h:263
TtSemiLepHitFitProducer_Electrons_cfi.jetCorrectionLevel
jetCorrectionLevel
Definition: TtSemiLepHitFitProducer_Electrons_cfi.py:43
TtFullHadKinFitter::Constraint
Constraint
supported constraints
Definition: TtFullHadKinFitter.h:32
TtHadEvtSolution::getCalHadq
pat::Jet getCalHadq() const
Definition: TtHadEvtSolution.h:108
TtFullHadKinFitter::lightPBar_
TAbsFitParticle * lightPBar_
Definition: TtFullHadKinFitter.h:104
TopKinFitter::maxDeltaS_
double maxDeltaS_
maximal allowed chi2 (not normalized to degrees of freedom)
Definition: TopKinFitter.h:51
b
double b
Definition: hdecay.h:118
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TtFullHadKinFitter::KinFit::corJet
pat::Jet corJet(const pat::Jet &jet, const std::string &quarkType)
helper function to construct the proper corrected jet for its corresponding quarkType
Definition: TtFullHadKinFitter.cc:485
TtHadEvtSolution::setFitHadj
void setFitHadj(const pat::Particle &aFitHadj)
Definition: TtHadEvtSolution.h:217
TtFullHadKinFitter::fittedB_
pat::Particle fittedB_
output particles
Definition: TtFullHadKinFitter.h:114
TtFullHadKinFitter::bBar_
TAbsFitParticle * bBar_
Definition: TtFullHadKinFitter.h:100
funct::true
true
Definition: Factorize.h:173
TAbsFitParticle::getCurr4Vec
const TLorentzVector * getCurr4Vec()
Definition: TAbsFitParticle.h:31
TtSemiLepHitFitProducer_Electrons_cfi.mW
mW
Definition: TtSemiLepHitFitProducer_Electrons_cfi.py:35
TKinFitter::getStatus
Int_t getStatus()
Definition: TKinFitter.h:51
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
TtFullHadKinFitter::kWPlusMass
Definition: TtFullHadKinFitter.h:32
TtFullHadKinFitter::jetEnergyResolutionScaleFactors_
const std::vector< double > * jetEnergyResolutionScaleFactors_
scale factors for the jet energy resolution
Definition: TtFullHadKinFitter.h:109
TtFullHadEvtPartons::LightPBar
Definition: TtFullHadEvtPartons.h:25
ParameterSet
Definition: Functions.h:16
TAbsFitParticle::setCovMatrix
virtual void setCovMatrix(const TMatrixD *theCovMatrix)
Definition: TAbsFitParticle.cc:98
TtFullHadEvtPartons::LightQBar
Definition: TtFullHadEvtPartons.h:25
TtFullHadKinFitter::jetEnergyResolutionEtaBinning_
const std::vector< double > * jetEnergyResolutionEtaBinning_
Definition: TtFullHadKinFitter.h:110
TopKinFitter
Definition: TopKinFitter.h:17
TtFullHadKinFitter::bResolutions_
const std::vector< edm::ParameterSet > * bResolutions_
Definition: TtFullHadKinFitter.h:107
TtFullHadKinFitter::KinFit::KinFit
KinFit()
default constructor
Definition: TtFullHadKinFitter.cc:343
TtFullHadKinFitter::KinFit::constraints
std::vector< TtFullHadKinFitter::Constraint > constraints(const std::vector< unsigned int > &configParameters)
Definition: TtFullHadKinFitter.cc:696
createfilelist.int
int
Definition: createfilelist.py:10
TtFullHadKinFitProducer_cfi.bTags
bTags
Definition: TtFullHadKinFitProducer_cfi.py:40
SUSYDQMAnalyzer_cfi.maxNJets
maxNJets
Definition: SUSYDQMAnalyzer_cfi.py:13
TtFullHadKinFitter::KinFit::constraints_
std::vector< unsigned > constraints_
numbering of different possible kinematic constraints
Definition: TtFullHadKinFitter.h:271
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
TtFullHadKinFitter::lightQ_
TAbsFitParticle * lightQ_
Definition: TtFullHadKinFitter.h:101
TtFullHadKinFitter::fittedLightPBar_
pat::Particle fittedLightPBar_
Definition: TtFullHadKinFitter.h:119
TtFullHadKinFitter::fittedLightP_
pat::Particle fittedLightP_
Definition: TtFullHadKinFitter.h:118
TtHadEvtSolution::setFitHadp
void setFitHadp(const pat::Particle &aFitHadp)
Definition: TtHadEvtSolution.h:209
TtFullHadKinFitProducer_cfi.jetEnergyResolutionEtaBinning
jetEnergyResolutionEtaBinning
Definition: TtFullHadKinFitProducer_cfi.py:95
TopKinFitter::kEtThetaPhi
Definition: TopKinFitter.h:20
nPartons
static const unsigned int nPartons
Definition: TtFullHadKinFitter.cc:13
TtFullHadKinFitProducer_cfi.jetEnergyResolutionScaleFactors
jetEnergyResolutionScaleFactors
Definition: TtFullHadKinFitProducer_cfi.py:94
createBeamHaloJobs.constraints
string constraints
Definition: createBeamHaloJobs.py:229
TtSemiLepHitFitProducer_Electrons_cfi.maxNComb
maxNComb
Definition: TtSemiLepHitFitProducer_Electrons_cfi.py:21
StEvtSolProducer_cfi.maxDeltaS
maxDeltaS
Definition: StEvtSolProducer_cfi.py:25
TopKinFitter::mTop_
double mTop_
top mass value used for constraints
Definition: TopKinFitter.h:57
TtFullHadKinFitter::KinFit::~KinFit
~KinFit()
default destructor
Definition: TtFullHadKinFitter.cc:426
TKinFitter::addConstraint
void addConstraint(TAbsFitConstraint *constraint)
Definition: TKinFitter.cc:292
std
Definition: JetResolutionObject.h:76
stdcomb::next_combination
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
Definition: combination.h:19
TFitParticleEMomDev.h
TtFullHadKinFitter::intToConstraint
std::vector< TtFullHadKinFitter::Constraint > intToConstraint(const std::vector< unsigned int > &constraints)
used to convert vector of int's to vector of constraints (just used in TtFullHadKinFitter(int,...
Definition: TtFullHadKinFitter.cc:33
TtSemiLepHitFitProducer_Electrons_cfi.useBTagging
useBTagging
Definition: TtSemiLepHitFitProducer_Electrons_cfi.py:29
TopKinFitter::maxF_
double maxF_
maximal allowed distance from constraints
Definition: TopKinFitter.h:53
TtFullHadEvtPartons::BBar
Definition: TtFullHadEvtPartons.h:25
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
TtFullHadKinFitter::setupConstraints
void setupConstraints()
initialize constraints
Definition: TtFullHadKinFitter.cc:178
metsig::jet
Definition: SignAlgoResolutions.h:47
TtFullHadKinFitter::TtFullHadKinFitter
TtFullHadKinFitter()
default constructor
Definition: TtFullHadKinFitter.cc:16
Exception
Definition: hltDiff.cc:246
TtFullHadKinFitProducer_cfi.bResolutions
bResolutions
Definition: TtFullHadKinFitProducer_cfi.py:84
TFitParticleEtEtaPhi
Definition: TFitParticleEtEtaPhi.h:8
TKinFitter::addMeasParticle
void addMeasParticle(TAbsFitParticle *particle)
Definition: TKinFitter.cc:194
TtHadEvtSolution::getCalHadp
pat::Jet getCalHadp() const
Definition: TtHadEvtSolution.h:107
TtFullHadKinFitter::lightP_
TAbsFitParticle * lightP_
Definition: TtFullHadKinFitter.h:103
TtHadEvtSolution::setFitHadb
void setFitHadb(const pat::Particle &aFitHadb)
Definition: TtHadEvtSolution.h:225
TAbsFitParticle.h
TtFullHadKinFitter::fittedLightQBar_
pat::Particle fittedLightQBar_
Definition: TtFullHadKinFitter.h:117
reco::LeafCandidate::energy
double energy() const final
energy
Definition: LeafCandidate.h:125
TtFullHadEvtPartons.h
TtHadEvtSolution::getCalHadj
pat::Jet getCalHadj() const
Definition: TtHadEvtSolution.h:109
TtHadEvtSolution::setProbChi2
void setProbChi2(double c)
Definition: TtHadEvtSolution.h:257
CovarianceMatrix::setupMatrix
TMatrixD setupMatrix(const pat::PATObject< T > &object, const TopKinFitter::Param param, const std::string &resolutionProvider="")
return covariance matrix for a PAT object
Definition: CovarianceMatrix.h:87
reco::LeafCandidate
Definition: LeafCandidate.h:16
mps_fire.result
result
Definition: mps_fire.py:311
cms::Exception
Definition: Exception.h:70
TFitParticleEtThetaPhi
Definition: TFitParticleEtThetaPhi.h:8
TtFullHadKinFitter::~TtFullHadKinFitter
~TtFullHadKinFitter()
default destructor
Definition: TtFullHadKinFitter.cc:100
TopKinFitter::Param
Param
supported parameterizations
Definition: TopKinFitter.h:20
TtHadEvtSolution
Definition: TtHadEvtSolution.h:21
TtFullHadEvtPartons::B
Definition: TtFullHadEvtPartons.h:25
TFitParticleEtEtaPhi.h
TtFullHadKinFitter::KinFit::param
TtFullHadKinFitter::Param param(unsigned int configParameter)
Definition: TtFullHadKinFitter.cc:651
TAbsFitParticle::setIni4Vec
virtual void setIni4Vec(const TLorentzVector *pini)=0
StEvtSolProducer_cfi.maxF
maxF
Definition: StEvtSolProducer_cfi.py:26
reco::LeafCandidate::px
double px() const final
x coordinate of momentum vector
Definition: LeafCandidate.h:140
reco::LeafCandidate::pz
double pz() const final
z coordinate of momentum vector
Definition: LeafCandidate.h:144
edm::errors::Configuration
Definition: EDMException.h:36
pat::Particle
Analysis-level particle class.
Definition: Particle.h:30
TtSemiLepHitFitProducer_Electrons_cfi.bTagAlgo
bTagAlgo
Definition: TtSemiLepHitFitProducer_Electrons_cfi.py:26
TtFullHadKinFitter::fittedBBar_
pat::Particle fittedBBar_
Definition: TtFullHadKinFitter.h:115
TtFullHadKinFitter::KinFit::udscResolutions_
std::vector< edm::ParameterSet > udscResolutions_
store the resolutions for the jets
Definition: TtFullHadKinFitter.h:252
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37