1 #ifndef TtSemiLepKinFitProducer_h 2 #define TtSemiLepKinFitProducer_h 12 template <
typename LeptonCollection>
27 std::vector<TtSemiLepKinFitter::Constraint>
constraints(std::vector<unsigned>&);
31 std::vector<int>& combi,
33 double& minBTagValueBJets_,
34 double& maxBTagValueNonBJets_);
95 template <
typename LeptonCollection>
108 maxNrIter_(cfg.getParameter<unsigned>(
"maxNrIter")),
109 maxDeltaS_(cfg.getParameter<double>(
"maxDeltaS")),
110 maxF_(cfg.getParameter<double>(
"maxF")),
111 jetParam_(cfg.getParameter<unsigned>(
"jetParametrisation")),
112 lepParam_(cfg.getParameter<unsigned>(
"lepParametrisation")),
113 metParam_(cfg.getParameter<unsigned>(
"metParametrisation")),
115 mW_(cfg.getParameter<double>(
"mW")),
116 mTop_(cfg.getParameter<double>(
"mTop")),
123 if (cfg.
exists(
"udscResolutions") && cfg.
exists(
"bResolutions") && cfg.
exists(
"lepResolutions") &&
124 cfg.
exists(
"metResolutions")) {
129 }
else if (cfg.
exists(
"udscResolutions") || cfg.
exists(
"bResolutions") || cfg.
exists(
"lepResolutions") ||
130 cfg.
exists(
"metResolutions")) {
131 throw cms::Exception(
"Configuration") <<
"Parameters 'udscResolutions', 'bResolutions', 'lepResolutions', " 132 "'metResolutions' should be used together.\n";
151 produces<std::vector<pat::Particle>>(
"PartonsHadP");
152 produces<std::vector<pat::Particle>>(
"PartonsHadQ");
153 produces<std::vector<pat::Particle>>(
"PartonsHadB");
154 produces<std::vector<pat::Particle>>(
"PartonsLepB");
155 produces<std::vector<pat::Particle>>(
"Leptons");
156 produces<std::vector<pat::Particle>>(
"Neutrinos");
158 produces<std::vector<std::vector<int>>>();
159 produces<std::vector<double>>(
"Chi2");
160 produces<std::vector<double>>(
"Prob");
161 produces<std::vector<int>>(
"Status");
163 produces<int>(
"NumberOfConsideredJets");
166 template <
typename LeptonCollection>
171 template <
typename LeptonCollection>
174 std::vector<int>& combi,
191 template <
typename LeptonCollection>
193 std::unique_ptr<std::vector<pat::Particle>> pPartonsHadP(
new std::vector<pat::Particle>);
194 std::unique_ptr<std::vector<pat::Particle>> pPartonsHadQ(
new std::vector<pat::Particle>);
195 std::unique_ptr<std::vector<pat::Particle>> pPartonsHadB(
new std::vector<pat::Particle>);
196 std::unique_ptr<std::vector<pat::Particle>> pPartonsLepB(
new std::vector<pat::Particle>);
197 std::unique_ptr<std::vector<pat::Particle>> pLeptons(
new std::vector<pat::Particle>);
198 std::unique_ptr<std::vector<pat::Particle>> pNeutrinos(
new std::vector<pat::Particle>);
200 std::unique_ptr<std::vector<std::vector<int>>> pCombi(
new std::vector<std::vector<int>>);
201 std::unique_ptr<std::vector<double>> pChi2(
new std::vector<double>);
202 std::unique_ptr<std::vector<double>> pProb(
new std::vector<double>);
203 std::unique_ptr<std::vector<int>> pStatus(
new std::vector<int>);
205 std::unique_ptr<int> pJetsConsidered(
new int);
218 std::vector<int>
match;
219 bool invalidMatch =
false;
224 match = *(matchHandle->begin());
229 for (
unsigned int idx = 0;
idx < match.size(); ++
idx) {
230 if (match[
idx] < 0 || match[
idx] >= (
int)jets->size()) {
243 if (leps->empty() || mets->empty() || jets->size() < nPartons || invalidMatch) {
252 std::vector<int> invalidCombi;
254 invalidCombi.push_back(-1);
255 pCombi->push_back(invalidCombi);
257 pChi2->push_back(-1.);
259 pProb->push_back(-1.);
261 pStatus->push_back(-1);
263 *pJetsConsidered = jets->size();
275 evt.
put(
std::move(pJetsConsidered),
"NumberOfConsideredJets");
284 std::vector<int> jetIndices;
286 for (
unsigned int i = 0;
i < jets->size(); ++
i) {
288 *pJetsConsidered =
i;
291 jetIndices.push_back(
i);
295 std::vector<int> combi;
298 combi.push_back(match[
i]);
303 std::list<KinFitResult> FitResultList;
306 for (
int cnt = 0; cnt < TMath::Factorial(combi.size()); ++cnt) {
311 std::vector<pat::Jet> jetCombi;
312 jetCombi.resize(nPartons);
334 FitResultList.push_back(result);
339 next_permutation(combi.begin(), combi.end());
346 FitResultList.sort();
353 if ((
unsigned)FitResultList.size() < 1) {
361 std::vector<int> invalidCombi;
363 invalidCombi.push_back(-1);
364 pCombi->push_back(invalidCombi);
366 pChi2->push_back(-1.);
368 pProb->push_back(-1.);
370 pStatus->push_back(-1);
372 unsigned int iComb = 0;
373 for (
typename std::list<KinFitResult>::const_iterator
result = FitResultList.begin();
result != FitResultList.end();
379 pPartonsHadP->push_back(
result->HadP);
380 pPartonsHadQ->push_back(
result->HadQ);
381 pPartonsHadB->push_back(
result->HadB);
382 pPartonsLepB->push_back(
result->LepB);
384 pLeptons->push_back(
result->LepL);
386 pNeutrinos->push_back(
result->LepN);
388 pCombi->push_back(
result->JetCombi);
390 pChi2->push_back(
result->Chi2);
392 pProb->push_back(
result->Prob);
394 pStatus->push_back(
result->Status);
407 evt.
put(
std::move(pJetsConsidered),
"NumberOfConsideredJets");
410 template <
typename LeptonCollection>
424 throw cms::Exception(
"Configuration") <<
"Chosen jet parametrization is not supported: " << val <<
"\n";
430 template <
typename LeptonCollection>
456 throw cms::Exception(
"Configuration") <<
"Chosen fit constraint is not supported: " << val <<
"\n";
462 template <
typename LeptonCollection>
464 std::vector<unsigned>&
val) {
465 std::vector<TtSemiLepKinFitter::Constraint>
result;
466 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
~TtSemiLepKinFitProducer() override
double fitProb() const
return fit probability
int maxNJets_
maximal number of jets (-1 possible to indicate 'all')
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
bool doBTagging(bool &useBTag_, edm::Handle< std::vector< pat::Jet >> &jets, std::vector< int > &combi, std::string &bTagAlgo_, double &minBTagValueBJets_, double &maxBTagValueNonBJets_)
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
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.
void produce(edm::Event &, const edm::EventSetup &) override
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