1 #ifndef TtSemiLepKinFitProducer_h 2 #define TtSemiLepKinFitProducer_h 12 template <
typename LeptonCollection>
29 std::vector<TtSemiLepKinFitter::Constraint>
constraints(std::vector<unsigned>&);
93 template<
typename LeptonCollection>
103 useBTag_ (cfg.getParameter<bool> (
"useBTagging" )),
106 maxNrIter_ (cfg.getParameter<unsigned> (
"maxNrIter" )),
107 maxDeltaS_ (cfg.getParameter<double> (
"maxDeltaS" )),
108 maxF_ (cfg.getParameter<double> (
"maxF" )),
109 jetParam_ (cfg.getParameter<unsigned> (
"jetParametrisation" )),
110 lepParam_ (cfg.getParameter<unsigned> (
"lepParametrisation" )),
111 metParam_ (cfg.getParameter<unsigned> (
"metParametrisation" )),
112 constraints_ (cfg.getParameter<
std::vector<unsigned> >(
"constraints")),
113 mW_ (cfg.getParameter<double> (
"mW" )),
114 mTop_ (cfg.getParameter<double> (
"mTop" )),
119 if(cfg.
exists(
"udscResolutions") && cfg.
exists(
"bResolutions") && cfg.
exists(
"lepResolutions") && cfg.
exists(
"metResolutions")){
125 else if(cfg.
exists(
"udscResolutions") || cfg.
exists(
"bResolutions") || cfg.
exists(
"lepResolutions") || cfg.
exists(
"metResolutions") ){
126 throw cms::Exception(
"Configuration") <<
"Parameters 'udscResolutions', 'bResolutions', 'lepResolutions', 'metResolutions' should be used together.\n";
133 produces< std::vector<pat::Particle> >(
"PartonsHadP");
134 produces< std::vector<pat::Particle> >(
"PartonsHadQ");
135 produces< std::vector<pat::Particle> >(
"PartonsHadB");
136 produces< std::vector<pat::Particle> >(
"PartonsLepB");
137 produces< std::vector<pat::Particle> >(
"Leptons");
138 produces< std::vector<pat::Particle> >(
"Neutrinos");
140 produces< std::vector<std::vector<int> > >();
141 produces< std::vector<double> >(
"Chi2");
142 produces< std::vector<double> >(
"Prob");
143 produces< std::vector<int> >(
"Status");
145 produces<int>(
"NumberOfConsideredJets");
148 template<
typename LeptonCollection>
154 template<
typename LeptonCollection>
173 template<
typename LeptonCollection>
176 std::unique_ptr< std::vector<pat::Particle> > pPartonsHadP(
new std::vector<pat::Particle> );
177 std::unique_ptr< std::vector<pat::Particle> > pPartonsHadQ(
new std::vector<pat::Particle> );
178 std::unique_ptr< std::vector<pat::Particle> > pPartonsHadB(
new std::vector<pat::Particle> );
179 std::unique_ptr< std::vector<pat::Particle> > pPartonsLepB(
new std::vector<pat::Particle> );
180 std::unique_ptr< std::vector<pat::Particle> > pLeptons (
new std::vector<pat::Particle> );
181 std::unique_ptr< std::vector<pat::Particle> > pNeutrinos (
new std::vector<pat::Particle> );
183 std::unique_ptr< std::vector<std::vector<int> > > pCombi (
new std::vector<std::vector<int> > );
184 std::unique_ptr< std::vector<double> > pChi2 (
new std::vector<double> );
185 std::unique_ptr< std::vector<double> > pProb (
new std::vector<double> );
186 std::unique_ptr< std::vector<int> > pStatus(
new std::vector<int> );
188 std::unique_ptr<int> pJetsConsidered(
new int);
201 std::vector<int>
match;
202 bool invalidMatch =
false;
207 match = *(matchHandle->begin());
209 if(match.size()!=
nPartons) invalidMatch=
true;
211 for(
unsigned int idx=0;
idx<match.size(); ++
idx) {
212 if(match[
idx]<0 || match[
idx]>=(
int)jets->size()) {
225 if( leps->empty() || mets->empty() || jets->size()<nPartons || invalidMatch ) {
234 std::vector<int> invalidCombi;
236 invalidCombi.push_back( -1 );
237 pCombi->push_back( invalidCombi );
239 pChi2->push_back( -1. );
241 pProb->push_back( -1. );
243 pStatus->push_back( -1 );
245 *pJetsConsidered = jets->size();
257 evt.
put(
std::move(pJetsConsidered),
"NumberOfConsideredJets");
266 std::vector<int> jetIndices;
268 for(
unsigned int i=0;
i<jets->size(); ++
i){
270 *pJetsConsidered =
i;
273 jetIndices.push_back(
i);
277 std::vector<int> combi;
280 else combi.push_back(i);
283 std::list<KinFitResult> FitResultList;
286 for(
int cnt = 0; cnt < TMath::Factorial( combi.size() ); ++cnt){
292 std::vector<pat::Jet> jetCombi;
293 jetCombi.resize(nPartons);
315 FitResultList.push_back(result);
320 next_permutation( combi.begin(), combi.end() );
327 FitResultList.sort();
334 if( (
unsigned)FitResultList.size() < 1 ) {
342 std::vector<int> invalidCombi;
344 invalidCombi.push_back( -1 );
345 pCombi->push_back( invalidCombi );
347 pChi2->push_back( -1. );
349 pProb->push_back( -1. );
351 pStatus->push_back( -1 );
354 unsigned int iComb = 0;
355 for(
typename std::list<KinFitResult>::const_iterator
result = FitResultList.begin();
result != FitResultList.end(); ++
result) {
359 pPartonsHadP->push_back(
result->HadP );
360 pPartonsHadQ->push_back(
result->HadQ );
361 pPartonsHadB->push_back(
result->HadB );
362 pPartonsLepB->push_back(
result->LepB );
364 pLeptons->push_back(
result->LepL );
366 pNeutrinos->push_back(
result->LepN );
368 pCombi->push_back(
result->JetCombi );
370 pChi2->push_back(
result->Chi2 );
372 pProb->push_back(
result->Prob );
374 pStatus->push_back(
result->Status );
387 evt.
put(
std::move(pJetsConsidered),
"NumberOfConsideredJets");
390 template<
typename LeptonCollection>
400 <<
"Chosen jet parametrization is not supported: " << val <<
"\n";
406 template<
typename LeptonCollection>
420 <<
"Chosen fit constraint is not supported: " << val <<
"\n";
426 template<
typename LeptonCollection>
429 std::vector<TtSemiLepKinFitter::Constraint>
result;
430 for(
unsigned i=0;
i<val.size(); ++
i){
std::vector< edm::ParameterSet > bResolutions_
std::vector< double > jetEnergyResolutionScaleFactors_
scale factors for jet energy resolution
T getParameter(std::string const &) const
double maxBTagValueNonBJet_
max value of bTag for a non-b-jet
const pat::Particle fittedHadP() const
return hadronic light quark candidate
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
std::string bTagAlgo_
input tag for b-tagging algorithm
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
static const unsigned int nPartons
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
double minBTagValueBJet_
min value of bTag for a b-jet
Param
supported parameterizations
std::vector< int > JetCombi
const pat::Particle fittedNeutrino() const
return neutrino candidate
const pat::Particle fittedLepB() const
return leptonic b quark candidate
std::vector< TtSemiLepKinFitter::Constraint > constraints(std::vector< unsigned > &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
def setup(process, global_tag, zero_tesla=False)
virtual void produce(edm::Event &, const edm::EventSetup &)
double fitProb() const
return fit probability
int maxNJets_
maximal number of jets (-1 possible to indicate 'all')
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int fit(const std::vector< pat::Jet > &jets, const pat::Lepton< LeptonType > &leps, const pat::MET &met)
kinematic fit interface for PAT objects
std::vector< double > jetEnergyResolutionEtaBinning_
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
TtSemiLepKinFitter * fitter
std::vector< unsigned > constraints_
constrains
unsigned int maxNrIter_
maximal number of iterations to be performed for the fit
bool operator<(const KinFitResult &rhs)
const pat::Particle fittedHadB() const
return hadronic b quark candidate
std::vector< edm::ParameterSet > udscResolutions_
config-file-based object resolutions
bool doBTagging(bool &useBTag_, edm::Handle< std::vector< pat::Jet > > &jets, std::vector< int > &combi, std::string &bTagAlgo_, double &minBTagValueBJets_, double &maxBTagValueNonBJets_)
int maxNComb_
maximal number of combinations to be written to the event
double maxF_
maximal deviation for contstraints
edm::EDGetTokenT< LeptonCollection > lepsToken_
std::vector< edm::ParameterSet > metResolutions_
Analysis-level particle class.
~TtSemiLepKinFitProducer()
const pat::Particle fittedHadQ() const
return hadronic light quark candidate
TtSemiLepKinFitter::Constraint constraint(unsigned)
const pat::Particle fittedLepton() const
return lepton candidate
bool useOnlyMatch_
switch to use only a combination given by another hypothesis
double fitS() const
return chi2 of fit (not normalized to degrees of freedom)
bool useBTag_
switch to tell whether to use b-tagging or not
TtSemiLepKinFitter::Param param(unsigned)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
TtSemiLepKinFitProducer(const edm::ParameterSet &)
double maxDeltaS_
maximal chi2 equivalent
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
std::vector< edm::ParameterSet > lepResolutions_
Constraint
supported constraints