9 template <
typename LeptonCollection>
23 std::vector<TtSemiLepKinFitter::Constraint>
constraints(std::vector<unsigned>&);
27 const std::vector<int>& combi,
29 double& minBTagValueBJets_,
30 double& maxBTagValueNonBJets_);
74 std::unique_ptr<TtSemiLepKinFitter>
fitter;
91 template <
typename LeptonCollection>
94 lepsToken_(consumes<LeptonCollection>(
cfg.getParameter<
edm::
InputTag>(
"leps"))),
97 useOnlyMatch_(
cfg.getParameter<
bool>(
"useOnlyMatch")),
99 minBTagValueBJet_(
cfg.getParameter<double>(
"minBDiscBJets")),
100 maxBTagValueNonBJet_(
cfg.getParameter<double>(
"maxBDiscLightJets")),
101 useBTag_(
cfg.getParameter<
bool>(
"useBTagging")),
102 maxNJets_(
cfg.getParameter<
int>(
"maxNJets")),
103 maxNComb_(
cfg.getParameter<
int>(
"maxNComb")),
104 maxNrIter_(
cfg.getParameter<unsigned>(
"maxNrIter")),
105 maxDeltaS_(
cfg.getParameter<double>(
"maxDeltaS")),
106 maxF_(
cfg.getParameter<double>(
"maxF")),
107 jetParam_(
cfg.getParameter<unsigned>(
"jetParametrisation")),
108 lepParam_(
cfg.getParameter<unsigned>(
"lepParametrisation")),
109 metParam_(
cfg.getParameter<unsigned>(
"metParametrisation")),
110 constraints_(
cfg.getParameter<
std::
vector<unsigned>>(
"constraints")),
111 mW_(
cfg.getParameter<double>(
"mW")),
112 mTop_(
cfg.getParameter<double>(
"mTop")),
113 jetEnergyResolutionScaleFactors_(
cfg.getParameter<
std::
vector<double>>(
"jetEnergyResolutionScaleFactors")),
114 jetEnergyResolutionEtaBinning_(
cfg.getParameter<
std::
vector<double>>(
"jetEnergyResolutionEtaBinning")),
119 if (
cfg.exists(
"udscResolutions") &&
cfg.exists(
"bResolutions") &&
cfg.exists(
"lepResolutions") &&
120 cfg.exists(
"metResolutions")) {
122 bResolutions_ =
cfg.getParameter<std::vector<edm::ParameterSet>>(
"bResolutions");
125 }
else if (
cfg.exists(
"udscResolutions") ||
cfg.exists(
"bResolutions") ||
cfg.exists(
"lepResolutions") ||
126 cfg.exists(
"metResolutions")) {
127 throw cms::Exception(
"Configuration") <<
"Parameters 'udscResolutions', 'bResolutions', 'lepResolutions', " 128 "'metResolutions' should be used together.\n";
147 produces<std::vector<pat::Particle>>(
"PartonsHadP");
148 produces<std::vector<pat::Particle>>(
"PartonsHadQ");
149 produces<std::vector<pat::Particle>>(
"PartonsHadB");
150 produces<std::vector<pat::Particle>>(
"PartonsLepB");
151 produces<std::vector<pat::Particle>>(
"Leptons");
152 produces<std::vector<pat::Particle>>(
"Neutrinos");
154 produces<std::vector<std::vector<int>>>();
155 produces<std::vector<double>>(
"Chi2");
156 produces<std::vector<double>>(
"Prob");
157 produces<std::vector<int>>(
"Status");
159 produces<int>(
"NumberOfConsideredJets");
162 template <
typename LeptonCollection>
165 const std::vector<int>& combi,
167 double& minBTagValueBJet_,
168 double& maxBTagValueNonBJet_) {
182 template <
typename LeptonCollection>
184 std::unique_ptr<std::vector<pat::Particle>> pPartonsHadP(
new std::vector<pat::Particle>);
185 std::unique_ptr<std::vector<pat::Particle>> pPartonsHadQ(
new std::vector<pat::Particle>);
186 std::unique_ptr<std::vector<pat::Particle>> pPartonsHadB(
new std::vector<pat::Particle>);
187 std::unique_ptr<std::vector<pat::Particle>> pPartonsLepB(
new std::vector<pat::Particle>);
188 std::unique_ptr<std::vector<pat::Particle>> pLeptons(
new std::vector<pat::Particle>);
189 std::unique_ptr<std::vector<pat::Particle>> pNeutrinos(
new std::vector<pat::Particle>);
191 std::unique_ptr<std::vector<std::vector<int>>> pCombi(
new std::vector<std::vector<int>>);
192 std::unique_ptr<std::vector<double>> pChi2(
new std::vector<double>);
193 std::unique_ptr<std::vector<double>> pProb(
new std::vector<double>);
194 std::unique_ptr<std::vector<int>> pStatus(
new std::vector<int>);
196 std::unique_ptr<int> pJetsConsidered(
new int);
206 std::vector<int>
match;
207 bool invalidMatch =
false;
211 match = *(matchHandle->begin());
232 pPartonsHadP->push_back(fitter->fittedHadP());
233 pPartonsHadQ->push_back(fitter->fittedHadQ());
234 pPartonsHadB->push_back(fitter->fittedHadB());
235 pPartonsLepB->push_back(fitter->fittedLepB());
236 pLeptons->push_back(fitter->fittedLepton());
237 pNeutrinos->push_back(fitter->fittedNeutrino());
239 std::vector<int> invalidCombi;
241 invalidCombi.push_back(-1);
242 pCombi->push_back(invalidCombi);
244 pChi2->push_back(-1.);
246 pProb->push_back(-1.);
248 pStatus->push_back(-1);
250 *pJetsConsidered =
jets->size();
262 evt.
put(
std::move(pJetsConsidered),
"NumberOfConsideredJets");
271 std::vector<int> jetIndices;
272 if (!useOnlyMatch_) {
273 for (
unsigned int i = 0;
i <
jets->size(); ++
i) {
274 if (maxNJets_ >= (
int)
nPartons && maxNJets_ == (
int)
i) {
275 *pJetsConsidered =
i;
278 jetIndices.push_back(
i);
282 std::vector<int> combi;
285 combi.push_back(
match[
i]);
290 std::list<KinFitResult> FitResultList;
293 for (
int cnt = 0; cnt < TMath::Factorial(combi.size()); ++cnt) {
297 doBTagging(useBTag_,
jets, combi, bTagAlgo_, minBTagValueBJet_, maxBTagValueNonBJet_)) {
298 std::vector<pat::Jet> jetCombi;
311 result.Chi2 = fitter->fitS();
312 result.Prob = fitter->fitProb();
313 result.HadB = fitter->fittedHadB();
314 result.HadP = fitter->fittedHadP();
315 result.HadQ = fitter->fittedHadQ();
316 result.LepB = fitter->fittedLepB();
317 result.LepL = fitter->fittedLepton();
318 result.LepN = fitter->fittedNeutrino();
321 FitResultList.push_back(
result);
326 next_permutation(combi.begin(), combi.end());
333 FitResultList.sort();
340 if ((
unsigned)FitResultList.size() < 1) {
341 pPartonsHadP->push_back(fitter->fittedHadP());
342 pPartonsHadQ->push_back(fitter->fittedHadQ());
343 pPartonsHadB->push_back(fitter->fittedHadB());
344 pPartonsLepB->push_back(fitter->fittedLepB());
345 pLeptons->push_back(fitter->fittedLepton());
346 pNeutrinos->push_back(fitter->fittedNeutrino());
348 std::vector<int> invalidCombi;
350 invalidCombi.push_back(-1);
351 pCombi->push_back(invalidCombi);
353 pChi2->push_back(-1.);
355 pProb->push_back(-1.);
357 pStatus->push_back(-1);
359 unsigned int iComb = 0;
360 for (
typename std::list<KinFitResult>::const_iterator
result = FitResultList.begin();
result != FitResultList.end();
362 if (maxNComb_ >= 1 && iComb == (
unsigned int)maxNComb_)
366 pPartonsHadP->push_back(
result->HadP);
367 pPartonsHadQ->push_back(
result->HadQ);
368 pPartonsHadB->push_back(
result->HadB);
369 pPartonsLepB->push_back(
result->LepB);
371 pLeptons->push_back(
result->LepL);
373 pNeutrinos->push_back(
result->LepN);
375 pCombi->push_back(
result->JetCombi);
377 pChi2->push_back(
result->Chi2);
379 pProb->push_back(
result->Prob);
381 pStatus->push_back(
result->Status);
394 evt.
put(
std::move(pJetsConsidered),
"NumberOfConsideredJets");
397 template <
typename LeptonCollection>
411 throw cms::Exception(
"Configuration") <<
"Chosen jet parametrization is not supported: " <<
val <<
"\n";
417 template <
typename LeptonCollection>
443 throw cms::Exception(
"Configuration") <<
"Chosen fit constraint is not supported: " <<
val <<
"\n";
449 template <
typename LeptonCollection>
451 std::vector<unsigned>&
val) {
452 std::vector<TtSemiLepKinFitter::Constraint>
result;
453 for (
unsigned i = 0;
i <
val.size(); ++
i) {
std::vector< edm::ParameterSet > bResolutions_
std::vector< double > jetEnergyResolutionScaleFactors_
scale factors for jet energy resolution
double maxBTagValueNonBJet_
max value of bTag for a non-b-jet
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
std::vector< TtSemiLepKinFitter::Constraint > constraints(std::vector< unsigned > &)
bool doBTagging(bool &useBTag_, const edm::Handle< std::vector< pat::Jet >> &jets, const std::vector< int > &combi, std::string &bTagAlgo_, double &minBTagValueBJets_, double &maxBTagValueNonBJets_)
int maxNJets_
maximal number of jets (-1 possible to indicate 'all')
std::unique_ptr< TtSemiLepKinFitter > fitter
std::vector< double > jetEnergyResolutionEtaBinning_
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
std::vector< unsigned > constraints_
constrains
unsigned int maxNrIter_
maximal number of iterations to be performed for the fit
bool operator<(const KinFitResult &rhs)
#define DEFINE_FWK_MODULE(type)
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
TtSemiLepKinFitter::Constraint constraint(unsigned)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
bool useOnlyMatch_
switch to use only a combination given by another hypothesis
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)
std::vector< edm::ParameterSet > lepResolutions_
Constraint
supported constraints