24 udscResolutions_(nullptr),
25 bResolutions_(nullptr),
26 jetEnergyResolutionScaleFactors_(nullptr),
27 jetEnergyResolutionEtaBinning_(nullptr),
35 std::vector<TtFullHadKinFitter::Constraint> cConstraints;
36 cConstraints.resize(constraints.size());
37 for (
unsigned int i = 0;
i < constraints.size(); ++
i) {
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)
62 udscResolutions_(udscResolutions),
63 bResolutions_(bResolutions),
64 jetEnergyResolutionScaleFactors_(jetEnergyResolutionScaleFactors),
65 jetEnergyResolutionEtaBinning_(jetEnergyResolutionEtaBinning),
66 jetParam_((
Param)jetParam),
67 constraints_(intToConstraint(constraints)) {
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)
90 udscResolutions_(udscResolutions),
91 bResolutions_(bResolutions),
92 jetEnergyResolutionScaleFactors_(jetEnergyResolutionScaleFactors),
93 jetEnergyResolutionEtaBinning_(jetEnergyResolutionEtaBinning),
95 constraints_(constraints) {
108 for (std::map<Constraint, TFitConstraintM*>::iterator it =
massConstr_.begin(); it !=
massConstr_.end(); ++it)
114 std::stringstream constr;
118 constr <<
" * W+-mass (" <<
mW_ <<
" GeV) \n";
121 constr <<
" * W--mass (" << mW_ <<
" GeV) \n";
124 constr <<
" * t-mass (" <<
mTop_ <<
" GeV) \n";
127 constr <<
" * tBar-mass (" << mTop_ <<
" GeV) \n";
130 constr <<
" * equal t-masses \n";
135 <<
"+++++++++++ TtFullHadKinFitter Setup ++++++++++++ \n"
136 <<
" Parametrization: \n"
138 <<
" Constraints: \n"
139 << constr.str() <<
" Max(No iterations): " <<
maxNrIter_ <<
"\n"
141 <<
" Max(F) : " <<
maxF_ <<
"\n"
142 <<
"+++++++++++++++++++++++++++++++++++++++++++++++++ \n";
147 TMatrixD empty3x3(3, 3);
148 TMatrixD empty4x4(4, 4);
222 if (jets.size() < 6) {
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());
315 std::vector<pat::Jet>
jets;
344 : useBTagging_(
true),
346 bTagAlgo_(
"trackCountingHighPurBJetTags"),
347 minBTagValueBJet_(3.41),
348 maxBTagValueNonBJet_(3.41),
351 jetEnergyResolutionScaleFactors_(0),
352 jetEnergyResolutionEtaBinning_(0),
353 jetCorrectionLevel_(
"L3Absolute"),
362 useOnlyMatch_(
false),
363 match_(std::
vector<int>(0)),
364 invalidMatch_(
false) {
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,
383 unsigned int maxNrIter,
386 unsigned int jetParam,
390 : useBTagging_(useBTagging),
393 minBTagValueBJet_(minBTagValueBJet),
394 maxBTagValueNonBJet_(maxBTagValueNonBJet),
399 jetCorrectionLevel_(jetCorrectionLevel),
409 useOnlyMatch_(
false),
410 invalidMatch_(
false) {
429 const unsigned int& bJetCounter,
430 std::vector<int>& combi) {
441 }
else if (bTags_ == 1) {
442 if (bJetCounter == 1 &&
450 }
else if (bJetCounter > 1 && jets[combi[
TtFullHadEvtPartons::B]].bDiscriminator(bTagAlgo_) >= minBTagValueBJet_ &&
458 }
else if (bTags_ == 0) {
459 if (bJetCounter == 0) {
461 }
else if (bJetCounter == 1 &&
469 }
else if (bJetCounter > 1 && jets[combi[
TtFullHadEvtPartons::B]].bDiscriminator(bTagAlgo_) >= minBTagValueBJet_ &&
477 }
else if (bTags_ > 2) {
478 throw cms::Exception(
"Configuration") <<
"Wrong number of bTags (" << bTags_ <<
" bTags not supported)!\n";
487 if (jetCorrectionLevel_.empty())
489 <<
"Unconfigured jetCorrectionLevel. Please use an appropriate, non-empty string.\n";
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";
495 float jecFactor = 1.;
496 if (quarkType ==
"wMix")
497 jecFactor = 0.75 * jet.
jecFactor(jetCorrectionLevel_,
"uds") + 0.25 * jet.
jecFactor(jetCorrectionLevel_,
"charm");
499 jecFactor = jet.
jecFactor(jetCorrectionLevel_, quarkType);
502 ret.
setP4(ret.
p4() * jecFactor);
507 std::list<TtFullHadKinFitter::KinFitResult> fitResults;
515 if (jets.size() <
nPartons || invalidMatch_) {
517 std::vector<int> invalidCombi;
519 invalidCombi.push_back(-1);
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();
537 fitResults.push_back(result);
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)
551 jetIndices.push_back(idx);
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);
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_)
567 for (
int cnt = 0; cnt < TMath::Factorial(combi.size()); ++cnt) {
574 doBTagging(jets, bJetCounter, combi)) {
575 std::vector<pat::Jet> jetCombi;
576 jetCombi.resize(nPartons);
585 int status = fitter->fit(jetCombi);
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();
601 fitResults.push_back(result);
609 std::next_permutation(combi.begin(), combi.end());
625 if ((
unsigned)fitResults.size() < 1) {
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();
643 std::vector<int> invalidCombi(nPartons, -1);
646 fitResults.push_back(result);
653 switch (configParameter) {
665 <<
"Chosen jet parametrization is not supported: " << configParameter <<
"\n";
673 switch (configParameter) {
690 throw cms::Exception(
"Configuration") <<
"Chosen fit constraint is not supported: " << configParameter <<
"\n";
697 const std::vector<unsigned>& configParameters) {
698 std::vector<TtFullHadKinFitter::Constraint>
result;
699 for (
unsigned i = 0;
i < configParameters.size(); ++
i) {
TAbsFitParticle * lightQ_
Log< level::Info, true > LogVerbatim
double maxF_
maximal deviation for contstraints
const std::vector< double > * jetEnergyResolutionEtaBinning_
tuple ret
prodAgent to be discontinued
double maxDeltaS_
maximal chi2 equivalent
TtFullHadKinFitter::Param param(unsigned int configParameter)
pat::Jet getCalHadj() const
void setFitHadj(const pat::Particle &aFitHadj)
CovarianceMatrix * covM_
get object resolutions and put them into a matrix
Param
supported parameterizations
void setupConstraints()
initialize constraints
double pz() const final
z coordinate of momentum vector
TtHadEvtSolution addKinFitInfo(TtHadEvtSolution *asol)
add kin fit information to the old event solution (in for legacy reasons)
TAbsFitParticle * lightP_
TtFullHadKinFitter::Constraint constraint(unsigned int configParameter)
virtual void setIni4Vec(const TLorentzVector *pini)=0
void setFitHadb(const pat::Particle &aFitHadb)
pat::Jet getCalHadq() const
pat::Particle fittedLightPBar_
std::string param(const Param ¶m) const
convert Param to human readable form
pat::Jet getCalHadp() const
void setFitHadp(const pat::Particle &aFitHadp)
pat::Particle fittedB_
output particles
TMatrixD setupMatrix(const pat::PATObject< T > &object, const TopKinFitter::Param param, const std::string &resolutionProvider="")
return covariance matrix for a PAT object
int fit(const std::vector< pat::Jet > &jets)
kinematic fit interface
void printSetup() const
print fitter setup
TtFullHadKinFitter * fitter
kinematic fit interface
double mW_
W mass value used for constraints.
std::vector< unsigned > constraints_
numbering of different possible kinematic constraints
math::Error< 5 >::type CovarianceMatrix
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)
const LorentzVector & p4() const final
four-momentum Lorentz vector
std::vector< double > jetEnergyResolutionScaleFactors_
scale factors for the jet energy resolution
std::vector< edm::ParameterSet > udscResolutions_
store the resolutions for the jets
double fitProb() const
return fit probability
std::vector< edm::ParameterSet > bResolutions_
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_
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
const std::vector< edm::ParameterSet > * bResolutions_
void addConstraint(TAbsFitConstraint *constraint)
TAbsFitParticle * b_
input particles
pat::Jet getCalHadb() const
virtual void setCovMatrix(const TMatrixD *theCovMatrix)
pat::Jet getCalHadk() const
double mW_
W mass value used for constraints.
void addMeasParticle(TAbsFitParticle *particle)
double py() const final
y coordinate of momentum vector
std::map< Constraint, TFitConstraintM * > massConstr_
supported constraints
std::vector< TtFullHadKinFitter::Constraint > constraints(const std::vector< unsigned int > &configParameters)
pat::Particle fittedLightP_
TAbsFitParticle * lightQBar_
pat::Particle fittedBBar_
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
std::vector< int > JetCombi
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
const TLorentzVector * getCurr4Vec()
unsigned int jetParam_
numbering of different possible jet parametrizations
void setFitHadq(const pat::Particle &aFitHadq)
TtFullHadKinFitter()
default constructor
void setupJets()
initialize jet inputs
TKinFitter * fitter_
kinematic fitter
float jecFactor(const std::string &level, const std::string &flavor="none", const std::string &set="") const
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
pat::Jet getCalHadbbar() const
double mTop_
top mass value used for constraints
void setP4(const LorentzVector &p4) final
set 4-momentum
KinFit()
default constructor
TAbsFitParticle * lightPBar_
double maxF_
maximal allowed distance from constraints
double energy() const final
energy