18 b_(0), bBar_(0), lightQ_(0), lightQBar_(0), lightP_(0), lightPBar_(0),
19 udscResolutions_(0), bResolutions_(0),
20 jetEnergyResolutionScaleFactors_(0), jetEnergyResolutionEtaBinning_(0),
27 std::vector<TtFullHadKinFitter::Constraint>
30 std::vector<TtFullHadKinFitter::Constraint> cConstraints;
31 cConstraints.resize(constraints.size());
32 for(
unsigned int i=0;
i<constraints.size();++
i)
41 const std::vector<unsigned int>&
constraints,
double mW,
double mTop,
42 const std::vector<edm::ParameterSet>* udscResolutions,
43 const std::vector<edm::ParameterSet>* bResolutions,
44 const std::vector<double>* jetEnergyResolutionScaleFactors,
45 const std::vector<double>* jetEnergyResolutionEtaBinning):
47 b_(0), bBar_(0), lightQ_(0), lightQBar_(0), lightP_(0), lightPBar_(0),
48 udscResolutions_(udscResolutions), bResolutions_(bResolutions),
49 jetEnergyResolutionScaleFactors_(jetEnergyResolutionScaleFactors),
50 jetEnergyResolutionEtaBinning_(jetEnergyResolutionEtaBinning),
51 jetParam_((
Param)jetParam), constraints_(intToConstraint(constraints))
58 const std::vector<Constraint>&
constraints,
double mW,
double mTop,
59 const std::vector<edm::ParameterSet>* udscResolutions,
60 const std::vector<edm::ParameterSet>* bResolutions,
61 const std::vector<double>* jetEnergyResolutionScaleFactors,
62 const std::vector<double>* jetEnergyResolutionEtaBinning):
64 b_(0), bBar_(0), lightQ_(0), lightQBar_(0), lightP_(0), lightPBar_(0),
65 udscResolutions_(udscResolutions), bResolutions_(bResolutions),
66 jetEnergyResolutionScaleFactors_(jetEnergyResolutionScaleFactors),
67 jetEnergyResolutionEtaBinning_(jetEnergyResolutionEtaBinning),
68 jetParam_(jetParam), constraints_(constraints)
83 for(std::map<Constraint, TFitConstraintM*>::iterator it =
massConstr_.begin(); it !=
massConstr_.end(); ++it)
91 std::stringstream constr;
94 case kWPlusMass : constr <<
" * W+-mass (" <<
mW_ <<
" GeV) \n";
break;
95 case kWMinusMass : constr <<
" * W--mass (" << mW_ <<
" GeV) \n";
break;
96 case kTopMass : constr <<
" * t-mass (" <<
mTop_ <<
" GeV) \n";
break;
97 case kTopBarMass : constr <<
" * tBar-mass (" << mTop_ <<
" GeV) \n";
break;
103 <<
"+++++++++++ TtFullHadKinFitter Setup ++++++++++++ \n"
104 <<
" Parametrization: \n"
106 <<
" Constraints: \n"
108 <<
" Max(No iterations): " <<
maxNrIter_ <<
"\n"
110 <<
" Max(F) : " <<
maxF_ <<
"\n"
111 <<
"+++++++++++++++++++++++++++++++++++++++++++++++++ \n";
118 TMatrixD empty3x3(3,3);
119 TMatrixD empty4x4(4,4);
214 const TLorentzVector p4B( b.
px(), b.
py(), b.
pz(), b.
energy() );
215 const TLorentzVector p4BBar( bBar.
px(), bBar.
py(), bBar.
pz(), bBar.
energy() );
216 const TLorentzVector p4LightQ( lightQ.
px(), lightQ.
py(), lightQ.
pz(), lightQ.
energy() );
217 const TLorentzVector p4LightQBar( lightQBar.
px(), lightQBar.
py(), lightQBar.
pz(), lightQBar.
energy() );
218 const TLorentzVector p4LightP( lightP.
px(), lightP.
py(), lightP.
pz(), lightP.
energy() );
219 const TLorentzVector p4LightPBar( lightPBar.
px(), lightPBar.
py(), lightPBar.
pz(), lightPBar.
energy() );
269 std::vector<pat::Jet>
jets;
301 bTagAlgo_(
"trackCountingHighPurBJetTags"),
302 minBTagValueBJet_(3.41),
303 maxBTagValueNonBJet_(3.41),
306 jetEnergyResolutionScaleFactors_(0),
307 jetEnergyResolutionEtaBinning_(0),
308 jetCorrectionLevel_(
"L3Absolute"),
317 useOnlyMatch_(
false),
318 match_(std::vector<int>(0)),
328 const std::vector<edm::ParameterSet>& udscResolutions,
const std::vector<edm::ParameterSet>& bResolutions,
329 const std::vector<double>& jetEnergyResolutionScaleFactors,
const std::vector<double>& jetEnergyResolutionEtaBinning,
330 std::string jetCorrectionLevel,
int maxNJets,
int maxNComb,
331 unsigned int maxNrIter,
double maxDeltaS,
double maxF,
unsigned int jetParam,
const std::vector<unsigned>&
constraints,
double mW,
double mTop) :
332 useBTagging_(useBTagging),
335 minBTagValueBJet_(minBTagValueBJet),
336 maxBTagValueNonBJet_(maxBTagValueNonBJet),
341 jetCorrectionLevel_(jetCorrectionLevel),
351 useOnlyMatch_(
false),
368 if( !useBTagging_ ) {
380 else if( bTags_ == 1 ){
381 if( bJetCounter == 1 &&
390 else if( bJetCounter > 1 &&
400 else if( bTags_ == 0 ){
401 if( bJetCounter == 0){
404 else if( bJetCounter == 1 &&
413 else if( bJetCounter > 1 &&
423 else if( bTags_ > 2 ){
425 <<
"Wrong number of bTags (" << bTags_ <<
" bTags not supported)!\n";
436 if(jetCorrectionLevel_.empty())
438 <<
"Unconfigured jetCorrectionLevel. Please use an appropriate, non-empty string.\n";
441 if( !(quarkType==
"wMix" ||
443 quarkType==
"charm" ||
444 quarkType==
"bottom") )
446 << quarkType <<
" is unknown as a quarkType for the jetCorrectionLevel.\n";
448 float jecFactor = 1.;
449 if(quarkType==
"wMix") jecFactor = 0.75 * jet.
jecFactor(jetCorrectionLevel_,
"uds") + 0.25 * jet.
jecFactor(jetCorrectionLevel_,
"charm");
450 else jecFactor = jet.
jecFactor(jetCorrectionLevel_, quarkType);
457 std::list<TtFullHadKinFitter::KinFitResult>
460 std::list<TtFullHadKinFitter::KinFitResult> fitResults;
468 if( jets.size()<
nPartons || invalidMatch_ ) {
470 std::vector<int> invalidCombi;
471 for(
unsigned int i = 0;
i <
nPartons; ++
i) invalidCombi.push_back( -1 );
481 result.
B = fitter->fittedB();
482 result.
BBar = fitter->fittedBBar();
483 result.
LightQ = fitter->fittedLightQ();
484 result.
LightQBar= fitter->fittedLightQBar();
485 result.
LightP = fitter->fittedLightP();
486 result.
LightPBar= fitter->fittedLightPBar();
489 fitResults.push_back( result );
498 std::vector<int> jetIndices;
500 for(
unsigned int idx=0;
idx<jets.size(); ++
idx){
501 if(maxNJets_>=(
int)
nPartons && maxNJets_==(int)
idx)
break;
502 jetIndices.push_back(
idx);
506 std::vector<int> combi;
508 useOnlyMatch_?combi.push_back(match_[
idx]):combi.push_back(idx);
512 unsigned int bJetCounter = 0;
513 for(std::vector<pat::Jet>::const_iterator
jet = jets.begin();
jet < jets.end(); ++
jet){
514 if(
jet->bDiscriminator(bTagAlgo_) >= minBTagValueBJet_) ++bJetCounter;
518 for(
int cnt=0; cnt<TMath::Factorial(combi.size()); ++cnt){
524 useOnlyMatch_) && doBTagging(jets, bJetCounter, combi) ) {
526 std::vector<pat::Jet> jetCombi;
527 jetCombi.resize(nPartons);
536 int status = fitter->fit(jetCombi);
542 result.
Chi2 = fitter->fitS();
543 result.
Prob = fitter->fitProb();
544 result.
B = fitter->fittedB();
545 result.
BBar = fitter->fittedBBar();
546 result.
LightQ = fitter->fittedLightQ();
547 result.
LightQBar= fitter->fittedLightQBar();
548 result.
LightP = fitter->fittedLightP();
549 result.
LightPBar= fitter->fittedLightPBar();
552 fitResults.push_back( result );
560 std::next_permutation( combi.begin(), combi.end() );
578 if( (
unsigned)fitResults.size() < 1 ) {
589 result.
B = fitter->fittedB();
590 result.
BBar = fitter->fittedBBar();
591 result.
LightQ = fitter->fittedLightQ();
592 result.
LightQBar= fitter->fittedLightQBar();
593 result.
LightP = fitter->fittedLightP();
594 result.
LightPBar= fitter->fittedLightPBar();
596 std::vector<int> invalidCombi(nPartons, -1);
599 fitResults.push_back( result );
608 switch(configParameter){
614 <<
"Chosen jet parametrization is not supported: " << configParameter <<
"\n";
624 switch(configParameter){
632 <<
"Chosen fit constraint is not supported: " << configParameter <<
"\n";
638 std::vector<TtFullHadKinFitter::Constraint>
641 std::vector<TtFullHadKinFitter::Constraint>
result;
642 for(
unsigned i=0;
i<configParameters.size(); ++
i){
643 result.push_back(constraint(configParameters[
i]));
TAbsFitParticle * lightQ_
double maxF_
maximal deviation for contstraints
float jecFactor(const std::string &level, const std::string &flavor="none", const std::string &set="") const
const std::vector< double > * jetEnergyResolutionEtaBinning_
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
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)
virtual void setP4(const LorentzVector &p4)
set 4-momentum
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)
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_
virtual double energy() const
energy
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)
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
virtual double px() const
x coordinate of momentum vector
~KinFit()
default destructor
XYZPointD XYZPoint
point in space with cartesian internal representation
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
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
virtual double pz() const
z coordinate of momentum vector
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
volatile std::atomic< bool > shutdown_flag false
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
pat::Jet getCalHadbbar() const
double mTop_
top mass value used for constraints
KinFit()
default constructor
virtual double py() const
y coordinate of momentum vector
TAbsFitParticle * lightPBar_
double maxF_
maximal allowed distance from constraints