21 std::vector<TtFullHadKinFitter::Constraint> cConstraints;
46 jetParam_((
Param)jetParam),
78 std::stringstream constr;
82 constr <<
" * W+-mass (" <<
mW_ <<
" GeV) \n";
85 constr <<
" * W--mass (" <<
mW_ <<
" GeV) \n";
88 constr <<
" * t-mass (" <<
mTop_ <<
" GeV) \n";
91 constr <<
" * tBar-mass (" <<
mTop_ <<
" GeV) \n";
94 constr <<
" * equal t-masses \n";
99 <<
"+++++++++++ TtFullHadKinFitter Setup ++++++++++++ \n" 100 <<
" Parametrization: \n" 102 <<
" Constraints: \n" 103 << constr.str() <<
" Max(No iterations): " <<
maxNrIter_ <<
"\n" 105 <<
" Max(F) : " <<
maxF_ <<
"\n" 106 <<
"+++++++++++++++++++++++++++++++++++++++++++++++++ \n";
111 TMatrixD empty3x3(3, 3);
112 TMatrixD empty4x4(4, 4);
115 b_ = std::make_unique<TFitParticleEMomDev>(
"Jet1",
"Jet1",
nullptr, &empty4x4);
116 bBar_ = std::make_unique<TFitParticleEMomDev>(
"Jet2",
"Jet2",
nullptr, &empty4x4);
117 lightQ_ = std::make_unique<TFitParticleEMomDev>(
"Jet3",
"Jet3",
nullptr, &empty4x4);
118 lightQBar_ = std::make_unique<TFitParticleEMomDev>(
"Jet4",
"Jet4",
nullptr, &empty4x4);
119 lightP_ = std::make_unique<TFitParticleEMomDev>(
"Jet5",
"Jet5",
nullptr, &empty4x4);
120 lightPBar_ = std::make_unique<TFitParticleEMomDev>(
"Jet6",
"Jet6",
nullptr, &empty4x4);
123 b_ = std::make_unique<TFitParticleEtEtaPhi>(
"Jet1",
"Jet1",
nullptr, &empty3x3);
124 bBar_ = std::make_unique<TFitParticleEtEtaPhi>(
"Jet2",
"Jet2",
nullptr, &empty3x3);
125 lightQ_ = std::make_unique<TFitParticleEtEtaPhi>(
"Jet3",
"Jet3",
nullptr, &empty3x3);
126 lightQBar_ = std::make_unique<TFitParticleEtEtaPhi>(
"Jet4",
"Jet4",
nullptr, &empty3x3);
127 lightP_ = std::make_unique<TFitParticleEtEtaPhi>(
"Jet5",
"Jet5",
nullptr, &empty3x3);
128 lightPBar_ = std::make_unique<TFitParticleEtEtaPhi>(
"Jet6",
"Jet6",
nullptr, &empty3x3);
131 b_ = std::make_unique<TFitParticleEtThetaPhi>(
"Jet1",
"Jet1",
nullptr, &empty3x3);
132 bBar_ = std::make_unique<TFitParticleEtThetaPhi>(
"Jet2",
"Jet2",
nullptr, &empty3x3);
133 lightQ_ = std::make_unique<TFitParticleEtThetaPhi>(
"Jet3",
"Jet3",
nullptr, &empty3x3);
134 lightQBar_ = std::make_unique<TFitParticleEtThetaPhi>(
"Jet4",
"Jet4",
nullptr, &empty3x3);
135 lightP_ = std::make_unique<TFitParticleEtThetaPhi>(
"Jet5",
"Jet5",
nullptr, &empty3x3);
136 lightPBar_ = std::make_unique<TFitParticleEtThetaPhi>(
"Jet6",
"Jet6",
nullptr, &empty3x3);
148 std::make_unique<TFitConstraintM>(
"EqualTopMasses",
"EqualTopMasses",
nullptr,
nullptr, 0);
179 covM_ = std::make_unique<CovarianceMatrix>(
182 covM_ = std::make_unique<CovarianceMatrix>();
187 if (
jets.size() < 6) {
200 const TLorentzVector p4B(
b.px(),
b.py(),
b.pz(),
b.energy());
201 const TLorentzVector p4BBar(bBar.
px(), bBar.
py(), bBar.
pz(), bBar.
energy());
202 const TLorentzVector p4LightQ(lightQ.
px(), lightQ.
py(), lightQ.
pz(), lightQ.
energy());
203 const TLorentzVector p4LightQBar(lightQBar.
px(), lightQBar.
py(), lightQBar.
pz(), lightQBar.
energy());
204 const TLorentzVector p4LightP(lightP.
px(), lightP.
py(), lightP.
pz(), lightP.
energy());
205 const TLorentzVector p4LightPBar(lightPBar.
px(), lightPBar.
py(), lightPBar.
pz(), lightPBar.
energy());
216 b_->setIni4Vec(&p4B);
217 bBar_->setIni4Vec(&p4BBar);
218 lightQ_->setIni4Vec(&p4LightQ);
220 lightP_->setIni4Vec(&p4LightP);
226 b_->setCovMatrix(&m3);
229 bBar_->setCovMatrix(&m6);
235 if (
fitter_->getStatus() == 0) {
240 b_->getCurr4Vec()->X(),
b_->getCurr4Vec()->Y(),
b_->getCurr4Vec()->Z(),
b_->getCurr4Vec()->E()),
258 bBar_->getCurr4Vec()->X(),
bBar_->getCurr4Vec()->Y(),
bBar_->getCurr4Vec()->Z(),
bBar_->getCurr4Vec()->E()),
280 std::vector<pat::Jet>
jets;
292 if (
fitter_->getStatus() == 0) {
309 : useBTagging_(
true),
311 bTagAlgo_(
"trackCountingHighPurBJetTags"),
312 minBTagValueBJet_(3.41),
313 maxBTagValueNonBJet_(3.41),
316 jetEnergyResolutionScaleFactors_(0),
317 jetEnergyResolutionEtaBinning_(0),
318 jetCorrectionLevel_(
"L3Absolute"),
327 useOnlyMatch_(
false),
329 invalidMatch_(
false) {
351 unsigned int jetParam,
374 useOnlyMatch_(
false),
375 invalidMatch_(
false) {
394 const unsigned int& bJetCounter,
395 std::vector<int>& combi) {
406 }
else if (bTags_ == 1) {
407 if (bJetCounter == 1 &&
423 }
else if (bTags_ == 0) {
424 if (bJetCounter == 0) {
426 }
else if (bJetCounter == 1 &&
442 }
else if (bTags_ > 2) {
443 throw cms::Exception(
"Configuration") <<
"Wrong number of bTags (" << bTags_ <<
" bTags not supported)!\n";
452 if (jetCorrectionLevel_.empty())
454 <<
"Unconfigured jetCorrectionLevel. Please use an appropriate, non-empty string.\n";
457 if (!(quarkType ==
"wMix" || quarkType ==
"uds" || quarkType ==
"charm" || quarkType ==
"bottom"))
458 throw cms::Exception(
"Configuration") << quarkType <<
" is unknown as a quarkType for the jetCorrectionLevel.\n";
460 float jecFactor = 1.;
461 if (quarkType ==
"wMix")
462 jecFactor = 0.75 *
jet.jecFactor(jetCorrectionLevel_,
"uds") + 0.25 *
jet.jecFactor(jetCorrectionLevel_,
"charm");
464 jecFactor =
jet.jecFactor(jetCorrectionLevel_, quarkType);
467 ret.setP4(
ret.p4() * jecFactor);
472 std::list<TtFullHadKinFitter::KinFitResult> fitResults;
482 std::vector<int> invalidCombi;
484 invalidCombi.push_back(-1);
494 result.B = fitter->fittedB();
495 result.BBar = fitter->fittedBBar();
496 result.LightQ = fitter->fittedLightQ();
497 result.LightQBar = fitter->fittedLightQBar();
498 result.LightP = fitter->fittedLightP();
499 result.LightPBar = fitter->fittedLightPBar();
500 result.JetCombi = invalidCombi;
502 fitResults.push_back(
result);
511 std::vector<int> jetIndices;
512 if (!useOnlyMatch_) {
516 jetIndices.push_back(
idx);
520 std::vector<int> combi;
522 useOnlyMatch_ ? combi.push_back(match_[
idx]) : combi.push_back(
idx);
525 unsigned int bJetCounter = 0;
526 for (std::vector<pat::Jet>::const_iterator
jet =
jets.begin();
jet <
jets.end(); ++
jet) {
527 if (
jet->bDiscriminator(bTagAlgo_) >= minBTagValueBJet_)
532 for (
int cnt = 0; cnt < TMath::Factorial(combi.size()); ++cnt) {
539 doBTagging(
jets, bJetCounter, combi)) {
540 std::vector<pat::Jet> jetCombi;
550 int status = fitter->fit(jetCombi);
556 result.Chi2 = fitter->fitS();
557 result.Prob = fitter->fitProb();
558 result.B = fitter->fittedB();
559 result.BBar = fitter->fittedBBar();
560 result.LightQ = fitter->fittedLightQ();
561 result.LightQBar = fitter->fittedLightQBar();
562 result.LightP = fitter->fittedLightP();
563 result.LightPBar = fitter->fittedLightPBar();
566 fitResults.push_back(
result);
574 std::next_permutation(combi.begin(), combi.end());
590 if ((
unsigned)fitResults.size() < 1) {
601 result.B = fitter->fittedB();
602 result.BBar = fitter->fittedBBar();
603 result.LightQ = fitter->fittedLightQ();
604 result.LightQBar = fitter->fittedLightQBar();
605 result.LightP = fitter->fittedLightP();
606 result.LightPBar = fitter->fittedLightPBar();
608 std::vector<int> invalidCombi(
nPartons, -1);
609 result.JetCombi = invalidCombi;
611 fitResults.push_back(
result);
618 switch (configParameter) {
630 <<
"Chosen jet parametrization is not supported: " << configParameter <<
"\n";
638 switch (configParameter) {
655 throw cms::Exception(
"Configuration") <<
"Chosen fit constraint is not supported: " << configParameter <<
"\n";
662 const std::vector<unsigned>& configParameters) {
663 std::vector<TtFullHadKinFitter::Constraint>
result;
664 for (
unsigned i = 0;
i < configParameters.size(); ++
i) {
std::string param(const Param ¶m) const
convert Param to human readable form
Log< level::Info, true > LogVerbatim
double maxF_
maximal deviation for contstraints
const std::vector< double > * jetEnergyResolutionEtaBinning_
double maxDeltaS_
maximal chi2 equivalent
TtFullHadKinFitter::Param param(unsigned int configParameter)
void setFitHadj(const pat::Particle &aFitHadj)
Param
supported parameterizations
void setupConstraints()
initialize constraints
double pz() const final
z coordinate of momentum vector
pat::Jet getCalHadq() const
TtHadEvtSolution addKinFitInfo(TtHadEvtSolution *asol)
add kin fit information to the old event solution (in for legacy reasons)
std::unique_ptr< TAbsFitParticle > lightPBar_
ret
prodAgent to be discontinued
TtFullHadKinFitter::Constraint constraint(unsigned int configParameter)
void printSetup() const
print fitter setup
void setFitHadb(const pat::Particle &aFitHadb)
std::unique_ptr< TKinFitter > fitter_
kinematic fitter
pat::Particle fittedLightPBar_
void setFitHadp(const pat::Particle &aFitHadp)
pat::Particle fittedB_
output particles
jetEnergyResolutionScaleFactors
int fit(const std::vector< pat::Jet > &jets)
kinematic fit interface
double mW_
W mass value used for constraints.
std::vector< unsigned > constraints_
numbering of different possible kinematic constraints
pat::Particle fittedLightQBar_
const std::vector< double > * jetEnergyResolutionScaleFactors_
scale factors for the jet energy resolution
std::list< TtFullHadKinFitter::KinFitResult > fit(const std::vector< pat::Jet > &jets)
do the fitting and return fit result
int maxNrIter_
maximal allowed number of iterations to be used for the fit
void setProbChi2(double c)
std::vector< double > jetEnergyResolutionScaleFactors_
scale factors for the jet energy resolution
pat::Jet getCalHadj() const
std::vector< edm::ParameterSet > udscResolutions_
store the resolutions for the jets
std::vector< edm::ParameterSet > bResolutions_
std::map< Constraint, std::unique_ptr< TFitConstraintM > > massConstr_
supported constraints
pat::Jet getCalHadp() const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
bool doBTagging(const std::vector< pat::Jet > &jets, const unsigned int &bJetCounter, std::vector< int > &combi)
pat::Jet corJet(const pat::Jet &jet, const std::string &quarkType)
helper function to construct the proper corrected jet for its corresponding quarkType ...
std::vector< double > jetEnergyResolutionEtaBinning_
std::unique_ptr< TAbsFitParticle > lightP_
double px() const final
x coordinate of momentum vector
Constraint
supported constraints
unsigned int maxNrIter_
maximal number of iterations to be performed for the fit
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, int, double, double, std::vector<unsigned int>))
~TtFullHadKinFitter()
default destructor
double fitProb() const
return fit probability
const std::vector< edm::ParameterSet > * bResolutions_
jetEnergyResolutionEtaBinning
double mW_
W mass value used for constraints.
double py() const final
y coordinate of momentum vector
std::vector< TtFullHadKinFitter::Constraint > constraints(const std::vector< unsigned int > &configParameters)
pat::Particle fittedLightP_
pat::Particle fittedBBar_
std::unique_ptr< TAbsFitParticle > b_
input particles
double maxDeltaS_
maximal allowed chi2 (not normalized to degrees of freedom)
double mTop_
top mass value used for constraints
std::vector< Constraint > constraints_
vector of constraints to be used
Param jetParam_
jet parametrization
pat::Particle fittedLightQ_
void setupFitter()
setup fitter
~KinFit()
default destructor
XYZPointD XYZPoint
point in space with cartesian internal representation
Analysis-level particle class.
void setFitHadbbar(const pat::Particle &aFitHadbbar)
const std::vector< edm::ParameterSet > * udscResolutions_
resolutions
Analysis-level calorimeter jet class.
void setFitHadk(const pat::Particle &aFitHadk)
static const unsigned int nPartons
unsigned int jetParam_
numbering of different possible jet parametrizations
pat::Jet getCalHadb() const
void setFitHadq(const pat::Particle &aFitHadq)
TtFullHadKinFitter()
default constructor
std::unique_ptr< CovarianceMatrix > covM_
get object resolutions and put them into a matrix
void setupJets()
initialize jet inputs
std::unique_ptr< TAbsFitParticle > lightQBar_
std::unique_ptr< TtFullHadKinFitter > fitter
kinematic fit interface
std::unique_ptr< TAbsFitParticle > lightQ_
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
double mTop_
top mass value used for constraints
pat::Jet getCalHadk() const
pat::Jet getCalHadbbar() const
KinFit()
default constructor
double maxF_
maximal allowed distance from constraints
std::unique_ptr< TAbsFitParticle > bBar_
double energy() const final
energy