CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
TtSemiLepKinFitProducer< LeptonCollection > Class Template Reference

#include <TtSemiLepKinFitProducer.h>

Inheritance diagram for TtSemiLepKinFitProducer< LeptonCollection >:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  KinFitResult
 

Public Member Functions

 TtSemiLepKinFitProducer (const edm::ParameterSet &)
 
 ~TtSemiLepKinFitProducer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector
< edm::ProductResolverIndex >
const & 
indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector
< edm::ProductResolverIndex >
const & 
putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector
< ProductResolverIndexAndSkipBit >
const & 
itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

TtSemiLepKinFitter::Constraint constraint (unsigned)
 
std::vector
< TtSemiLepKinFitter::Constraint
constraints (std::vector< unsigned > &)
 
bool doBTagging (bool &useBTag_, edm::Handle< std::vector< pat::Jet >> &jets, std::vector< int > &combi, std::string &bTagAlgo_, double &minBTagValueBJets_, double &maxBTagValueNonBJets_)
 
TtSemiLepKinFitter::Param param (unsigned)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::vector< edm::ParameterSetbResolutions_
 
std::string bTagAlgo_
 input tag for b-tagging algorithm More...
 
std::vector< unsigned > constraints_
 constrains More...
 
TtSemiLepKinFitterfitter
 
std::vector< double > jetEnergyResolutionEtaBinning_
 
std::vector< double > jetEnergyResolutionScaleFactors_
 scale factors for jet energy resolution More...
 
unsigned int jetParam_
 
edm::EDGetTokenT< std::vector
< pat::Jet > > 
jetsToken_
 
unsigned int lepParam_
 
std::vector< edm::ParameterSetlepResolutions_
 
edm::EDGetTokenT
< LeptonCollection > 
lepsToken_
 
edm::EDGetTokenT< std::vector
< std::vector< int > > > 
matchToken_
 
double maxBTagValueNonBJet_
 max value of bTag for a non-b-jet More...
 
double maxDeltaS_
 maximal chi2 equivalent More...
 
double maxF_
 maximal deviation for contstraints More...
 
int maxNComb_
 maximal number of combinations to be written to the event More...
 
int maxNJets_
 maximal number of jets (-1 possible to indicate 'all') More...
 
unsigned int maxNrIter_
 maximal number of iterations to be performed for the fit More...
 
unsigned int metParam_
 
std::vector< edm::ParameterSetmetResolutions_
 
edm::EDGetTokenT< std::vector
< pat::MET > > 
metsToken_
 
double minBTagValueBJet_
 min value of bTag for a b-jet More...
 
double mTop_
 
double mW_
 
std::vector< edm::ParameterSetudscResolutions_
 config-file-based object resolutions More...
 
bool useBTag_
 switch to tell whether to use b-tagging or not More...
 
bool useOnlyMatch_
 switch to use only a combination given by another hypothesis More...
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

template<typename LeptonCollection>
class TtSemiLepKinFitProducer< LeptonCollection >

Definition at line 13 of file TtSemiLepKinFitProducer.h.

Constructor & Destructor Documentation

template<typename LeptonCollection >
TtSemiLepKinFitProducer< LeptonCollection >::TtSemiLepKinFitProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 96 of file TtSemiLepKinFitProducer.h.

References TtSemiLepKinFitProducer< LeptonCollection >::bResolutions_, TtSemiLepKinFitProducer< LeptonCollection >::constraints(), TtSemiLepKinFitProducer< LeptonCollection >::constraints_, Exception, edm::ParameterSet::exists(), TtSemiLepKinFitProducer< LeptonCollection >::fitter, edm::ParameterSet::getParameter(), TtSemiLepKinFitProducer< LeptonCollection >::jetEnergyResolutionEtaBinning_, TtSemiLepKinFitProducer< LeptonCollection >::jetEnergyResolutionScaleFactors_, TtSemiLepKinFitProducer< LeptonCollection >::jetParam_, TtSemiLepKinFitProducer< LeptonCollection >::lepParam_, TtSemiLepKinFitProducer< LeptonCollection >::lepResolutions_, TtSemiLepKinFitProducer< LeptonCollection >::maxDeltaS_, TtSemiLepKinFitProducer< LeptonCollection >::maxF_, TtSemiLepKinFitProducer< LeptonCollection >::maxNrIter_, TtSemiLepKinFitProducer< LeptonCollection >::metParam_, TtSemiLepKinFitProducer< LeptonCollection >::metResolutions_, TtSemiLepKinFitProducer< LeptonCollection >::mTop_, TtSemiLepKinFitProducer< LeptonCollection >::mW_, TtSemiLepKinFitProducer< LeptonCollection >::param(), and TtSemiLepKinFitProducer< LeptonCollection >::udscResolutions_.

97  : jetsToken_(consumes<std::vector<pat::Jet>>(cfg.getParameter<edm::InputTag>("jets"))),
98  lepsToken_(consumes<LeptonCollection>(cfg.getParameter<edm::InputTag>("leps"))),
99  metsToken_(consumes<std::vector<pat::MET>>(cfg.getParameter<edm::InputTag>("mets"))),
100  matchToken_(mayConsume<std::vector<std::vector<int>>>(cfg.getParameter<edm::InputTag>("match"))),
101  useOnlyMatch_(cfg.getParameter<bool>("useOnlyMatch")),
102  bTagAlgo_(cfg.getParameter<std::string>("bTagAlgo")),
103  minBTagValueBJet_(cfg.getParameter<double>("minBDiscBJets")),
104  maxBTagValueNonBJet_(cfg.getParameter<double>("maxBDiscLightJets")),
105  useBTag_(cfg.getParameter<bool>("useBTagging")),
106  maxNJets_(cfg.getParameter<int>("maxNJets")),
107  maxNComb_(cfg.getParameter<int>("maxNComb")),
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")),
114  constraints_(cfg.getParameter<std::vector<unsigned>>("constraints")),
115  mW_(cfg.getParameter<double>("mW")),
116  mTop_(cfg.getParameter<double>("mTop")),
117  jetEnergyResolutionScaleFactors_(cfg.getParameter<std::vector<double>>("jetEnergyResolutionScaleFactors")),
118  jetEnergyResolutionEtaBinning_(cfg.getParameter<std::vector<double>>("jetEnergyResolutionEtaBinning")),
119  udscResolutions_(0),
120  bResolutions_(0),
121  lepResolutions_(0),
122  metResolutions_(0) {
123  if (cfg.exists("udscResolutions") && cfg.exists("bResolutions") && cfg.exists("lepResolutions") &&
124  cfg.exists("metResolutions")) {
125  udscResolutions_ = cfg.getParameter<std::vector<edm::ParameterSet>>("udscResolutions");
126  bResolutions_ = cfg.getParameter<std::vector<edm::ParameterSet>>("bResolutions");
127  lepResolutions_ = cfg.getParameter<std::vector<edm::ParameterSet>>("lepResolutions");
128  metResolutions_ = cfg.getParameter<std::vector<edm::ParameterSet>>("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";
133  }
134 
136  param(lepParam_),
137  param(metParam_),
138  maxNrIter_,
139  maxDeltaS_,
140  maxF_,
142  mW_,
143  mTop_,
145  &bResolutions_,
150 
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");
157 
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");
162 
163  produces<int>("NumberOfConsideredJets");
164 }
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_
double minBTagValueBJet_
min value of bTag for a b-jet
std::vector< TtSemiLepKinFitter::Constraint > constraints(std::vector< unsigned > &)
bool exists(std::string const &parameterName) const
checks if a parameter exists
int maxNJets_
maximal number of jets (-1 possible to indicate &#39;all&#39;)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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
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_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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)
double maxDeltaS_
maximal chi2 equivalent
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
std::vector< edm::ParameterSet > lepResolutions_
template<typename LeptonCollection >
TtSemiLepKinFitProducer< LeptonCollection >::~TtSemiLepKinFitProducer ( )
override

Definition at line 167 of file TtSemiLepKinFitProducer.h.

167  {
168  delete fitter;
169 }

Member Function Documentation

template<typename LeptonCollection >
TtSemiLepKinFitter::Constraint TtSemiLepKinFitProducer< LeptonCollection >::constraint ( unsigned  val)
private

Definition at line 431 of file TtSemiLepKinFitProducer.h.

References Exception, TtSemiLepKinFitter::kEqualTopMasses, TtSemiLepKinFitter::kNeutrinoMass, TtSemiLepKinFitter::kSumPt, TtSemiLepKinFitter::kTopHadMass, TtSemiLepKinFitter::kTopLepMass, TtSemiLepKinFitter::kWHadMass, TtSemiLepKinFitter::kWLepMass, and mps_fire::result.

431  {
433  switch (val) {
436  break;
439  break;
442  break;
445  break;
448  break;
451  break;
454  break;
455  default:
456  throw cms::Exception("Configuration") << "Chosen fit constraint is not supported: " << val << "\n";
457  break;
458  }
459  return result;
460 }
tuple result
Definition: mps_fire.py:311
Constraint
supported constraints
template<typename LeptonCollection >
std::vector< TtSemiLepKinFitter::Constraint > TtSemiLepKinFitProducer< LeptonCollection >::constraints ( std::vector< unsigned > &  val)
private

Definition at line 463 of file TtSemiLepKinFitProducer.h.

References HLT_FULL_cff::constraint, mps_fire::i, and mps_fire::result.

Referenced by TtSemiLepKinFitProducer< LeptonCollection >::TtSemiLepKinFitProducer().

464  {
465  std::vector<TtSemiLepKinFitter::Constraint> result;
466  for (unsigned i = 0; i < val.size(); ++i) {
467  result.push_back(constraint(val[i]));
468  }
469  return result;
470 }
tuple result
Definition: mps_fire.py:311
TtSemiLepKinFitter::Constraint constraint(unsigned)
template<typename LeptonCollection >
bool TtSemiLepKinFitProducer< LeptonCollection >::doBTagging ( bool &  useBTag_,
edm::Handle< std::vector< pat::Jet >> &  jets,
std::vector< int > &  combi,
std::string &  bTagAlgo_,
double &  minBTagValueBJets_,
double &  maxBTagValueNonBJets_ 
)
private

Definition at line 172 of file TtSemiLepKinFitProducer.h.

References TtSemiLepEvtPartons::HadB, fwrapper::jets, TtSemiLepEvtPartons::LepB, TtSemiLepEvtPartons::LightQ, and TtSemiLepEvtPartons::LightQBar.

177  {
178  if (!useBTag_) {
179  return true;
180  }
181  if (useBTag_ && (*jets)[combi[TtSemiLepEvtPartons::HadB]].bDiscriminator(bTagAlgo_) >= minBTagValueBJet_ &&
182  (*jets)[combi[TtSemiLepEvtPartons::LepB]].bDiscriminator(bTagAlgo_) >= minBTagValueBJet_ &&
183  (*jets)[combi[TtSemiLepEvtPartons::LightQ]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
184  (*jets)[combi[TtSemiLepEvtPartons::LightQBar]].bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_) {
185  return true;
186  } else {
187  return false;
188  }
189 }
double maxBTagValueNonBJet_
max value of bTag for a non-b-jet
std::string bTagAlgo_
input tag for b-tagging algorithm
double minBTagValueBJet_
min value of bTag for a b-jet
bool useBTag_
switch to tell whether to use b-tagging or not
template<typename LeptonCollection >
TtSemiLepKinFitter::Param TtSemiLepKinFitProducer< LeptonCollection >::param ( unsigned  val)
private

Definition at line 411 of file TtSemiLepKinFitProducer.h.

References Exception, TopKinFitter::kEMom, TopKinFitter::kEtEtaPhi, TopKinFitter::kEtThetaPhi, and mps_fire::result.

Referenced by TtSemiLepKinFitProducer< LeptonCollection >::TtSemiLepKinFitProducer().

411  {
413  switch (val) {
415  result = TtSemiLepKinFitter::kEMom;
416  break;
419  break;
422  break;
423  default:
424  throw cms::Exception("Configuration") << "Chosen jet parametrization is not supported: " << val << "\n";
425  break;
426  }
427  return result;
428 }
Param
supported parameterizations
Definition: TopKinFitter.h:20
tuple result
Definition: mps_fire.py:311
template<typename LeptonCollection >
void TtSemiLepKinFitProducer< LeptonCollection >::produce ( edm::Event evt,
const edm::EventSetup setup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 192 of file TtSemiLepKinFitProducer.h.

References TtSemiLepKinFitProducer< LeptonCollection >::KinFitResult::Chi2, edm::Event::getByToken(), TtSemiLepEvtPartons::HadB, TtSemiLepKinFitProducer< LeptonCollection >::KinFitResult::HadB, TtSemiLepKinFitProducer< LeptonCollection >::KinFitResult::HadP, TtSemiLepKinFitProducer< LeptonCollection >::KinFitResult::HadQ, mps_fire::i, TtSemiLepKinFitProducer< LeptonCollection >::KinFitResult::JetCombi, fwrapper::jets, TtSemiLepEvtPartons::LepB, TtSemiLepKinFitProducer< LeptonCollection >::KinFitResult::LepB, TtSemiLepKinFitProducer< LeptonCollection >::KinFitResult::LepL, TtSemiLepKinFitProducer< LeptonCollection >::KinFitResult::LepN, TtSemiLepEvtPartons::LightQ, TtSemiLepEvtPartons::LightQBar, match(), eostools::move(), stdcomb::next_combination(), nPartons, TtSemiLepKinFitProducer< LeptonCollection >::KinFitResult::Prob, edm::Event::put(), mps_fire::result, TtSemiLepKinFitProducer< LeptonCollection >::KinFitResult::Status, mps_update::status, and trackerHitRTTI::vector.

192  {
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>);
199 
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>);
204 
205  std::unique_ptr<int> pJetsConsidered(new int);
206 
208  evt.getByToken(jetsToken_, jets);
209 
211  evt.getByToken(metsToken_, mets);
212 
214  evt.getByToken(lepsToken_, leps);
215 
216  const unsigned int nPartons = 4;
217 
218  std::vector<int> match;
219  bool invalidMatch = false;
220  if (useOnlyMatch_) {
221  *pJetsConsidered = nPartons;
223  evt.getByToken(matchToken_, matchHandle);
224  match = *(matchHandle->begin());
225  // check if match is valid
226  if (match.size() != nPartons)
227  invalidMatch = true;
228  else {
229  for (unsigned int idx = 0; idx < match.size(); ++idx) {
230  if (match[idx] < 0 || match[idx] >= (int)jets->size()) {
231  invalidMatch = true;
232  break;
233  }
234  }
235  }
236  }
237 
238  // -----------------------------------------------------
239  // skip events with no appropriate lepton candidate in
240  // or empty MET or less jets than partons or invalid match
241  // -----------------------------------------------------
242 
243  if (leps->empty() || mets->empty() || jets->size() < nPartons || invalidMatch) {
244  // the kinFit getters return empty objects here
245  pPartonsHadP->push_back(fitter->fittedHadP());
246  pPartonsHadQ->push_back(fitter->fittedHadQ());
247  pPartonsHadB->push_back(fitter->fittedHadB());
248  pPartonsLepB->push_back(fitter->fittedLepB());
249  pLeptons->push_back(fitter->fittedLepton());
250  pNeutrinos->push_back(fitter->fittedNeutrino());
251  // indices referring to the jet combination
252  std::vector<int> invalidCombi;
253  for (unsigned int i = 0; i < nPartons; ++i)
254  invalidCombi.push_back(-1);
255  pCombi->push_back(invalidCombi);
256  // chi2
257  pChi2->push_back(-1.);
258  // chi2 probability
259  pProb->push_back(-1.);
260  // status of the fitter
261  pStatus->push_back(-1);
262  // number of jets
263  *pJetsConsidered = jets->size();
264  // feed out all products
265  evt.put(std::move(pCombi));
266  evt.put(std::move(pPartonsHadP), "PartonsHadP");
267  evt.put(std::move(pPartonsHadQ), "PartonsHadQ");
268  evt.put(std::move(pPartonsHadB), "PartonsHadB");
269  evt.put(std::move(pPartonsLepB), "PartonsLepB");
270  evt.put(std::move(pLeptons), "Leptons");
271  evt.put(std::move(pNeutrinos), "Neutrinos");
272  evt.put(std::move(pChi2), "Chi2");
273  evt.put(std::move(pProb), "Prob");
274  evt.put(std::move(pStatus), "Status");
275  evt.put(std::move(pJetsConsidered), "NumberOfConsideredJets");
276  return;
277  }
278 
279  // -----------------------------------------------------
280  // analyze different jet combinations using the KinFitter
281  // (or only a given jet combination if useOnlyMatch=true)
282  // -----------------------------------------------------
283 
284  std::vector<int> jetIndices;
285  if (!useOnlyMatch_) {
286  for (unsigned int i = 0; i < jets->size(); ++i) {
287  if (maxNJets_ >= (int)nPartons && maxNJets_ == (int)i) {
288  *pJetsConsidered = i;
289  break;
290  }
291  jetIndices.push_back(i);
292  }
293  }
294 
295  std::vector<int> combi;
296  for (unsigned int i = 0; i < nPartons; ++i) {
297  if (useOnlyMatch_)
298  combi.push_back(match[i]);
299  else
300  combi.push_back(i);
301  }
302 
303  std::list<KinFitResult> FitResultList;
304 
305  do {
306  for (int cnt = 0; cnt < TMath::Factorial(combi.size()); ++cnt) {
307  // take into account indistinguishability of the two jets from the hadr. W decay,
308  // reduces combinatorics by a factor of 2
311  std::vector<pat::Jet> jetCombi;
312  jetCombi.resize(nPartons);
313  jetCombi[TtSemiLepEvtPartons::LightQ] = (*jets)[combi[TtSemiLepEvtPartons::LightQ]];
315  jetCombi[TtSemiLepEvtPartons::HadB] = (*jets)[combi[TtSemiLepEvtPartons::HadB]];
316  jetCombi[TtSemiLepEvtPartons::LepB] = (*jets)[combi[TtSemiLepEvtPartons::LepB]];
317 
318  // do the kinematic fit
319  const int status = fitter->fit(jetCombi, (*leps)[0], (*mets)[0]);
320 
321  if (status == 0) { // only take into account converged fits
322  KinFitResult result;
323  result.Status = status;
324  result.Chi2 = fitter->fitS();
325  result.Prob = fitter->fitProb();
326  result.HadB = fitter->fittedHadB();
327  result.HadP = fitter->fittedHadP();
328  result.HadQ = fitter->fittedHadQ();
329  result.LepB = fitter->fittedLepB();
330  result.LepL = fitter->fittedLepton();
331  result.LepN = fitter->fittedNeutrino();
332  result.JetCombi = combi;
333 
334  FitResultList.push_back(result);
335  }
336  }
337  if (useOnlyMatch_)
338  break; // don't go through combinatorics if useOnlyMatch was chosen
339  next_permutation(combi.begin(), combi.end());
340  }
341  if (useOnlyMatch_)
342  break; // don't go through combinatorics if useOnlyMatch was chosen
343  } while (stdcomb::next_combination(jetIndices.begin(), jetIndices.end(), combi.begin(), combi.end()));
344 
345  // sort results w.r.t. chi2 values
346  FitResultList.sort();
347 
348  // -----------------------------------------------------
349  // feed out result
350  // starting with the JetComb having the smallest chi2
351  // -----------------------------------------------------
352 
353  if ((unsigned)FitResultList.size() < 1) { // in case no fit results were stored in the list (all fits aborted)
354  pPartonsHadP->push_back(fitter->fittedHadP());
355  pPartonsHadQ->push_back(fitter->fittedHadQ());
356  pPartonsHadB->push_back(fitter->fittedHadB());
357  pPartonsLepB->push_back(fitter->fittedLepB());
358  pLeptons->push_back(fitter->fittedLepton());
359  pNeutrinos->push_back(fitter->fittedNeutrino());
360  // indices referring to the jet combination
361  std::vector<int> invalidCombi;
362  for (unsigned int i = 0; i < nPartons; ++i)
363  invalidCombi.push_back(-1);
364  pCombi->push_back(invalidCombi);
365  // chi2
366  pChi2->push_back(-1.);
367  // chi2 probability
368  pProb->push_back(-1.);
369  // status of the fitter
370  pStatus->push_back(-1);
371  } else {
372  unsigned int iComb = 0;
373  for (typename std::list<KinFitResult>::const_iterator result = FitResultList.begin(); result != FitResultList.end();
374  ++result) {
375  if (maxNComb_ >= 1 && iComb == (unsigned int)maxNComb_)
376  break;
377  iComb++;
378  // partons
379  pPartonsHadP->push_back(result->HadP);
380  pPartonsHadQ->push_back(result->HadQ);
381  pPartonsHadB->push_back(result->HadB);
382  pPartonsLepB->push_back(result->LepB);
383  // lepton
384  pLeptons->push_back(result->LepL);
385  // neutrino
386  pNeutrinos->push_back(result->LepN);
387  // indices referring to the jet combination
388  pCombi->push_back(result->JetCombi);
389  // chi2
390  pChi2->push_back(result->Chi2);
391  // chi2 probability
392  pProb->push_back(result->Prob);
393  // status of the fitter
394  pStatus->push_back(result->Status);
395  }
396  }
397  evt.put(std::move(pCombi));
398  evt.put(std::move(pPartonsHadP), "PartonsHadP");
399  evt.put(std::move(pPartonsHadQ), "PartonsHadQ");
400  evt.put(std::move(pPartonsHadB), "PartonsHadB");
401  evt.put(std::move(pPartonsLepB), "PartonsLepB");
402  evt.put(std::move(pLeptons), "Leptons");
403  evt.put(std::move(pNeutrinos), "Neutrinos");
404  evt.put(std::move(pChi2), "Chi2");
405  evt.put(std::move(pProb), "Prob");
406  evt.put(std::move(pStatus), "Status");
407  evt.put(std::move(pJetsConsidered), "NumberOfConsideredJets");
408 }
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.
Definition: Event.h:133
double minBTagValueBJet_
min value of bTag for a b-jet
const pat::Particle fittedNeutrino() const
return neutrino candidate
const pat::Particle fittedLepB() const
return leptonic b quark candidate
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
list status
Definition: mps_update.py:107
double fitProb() const
return fit probability
Definition: TopKinFitter.h:37
int maxNJets_
maximal number of jets (-1 possible to indicate &#39;all&#39;)
tuple result
Definition: mps_fire.py:311
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
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
vector< PseudoJet > jets
def move
Definition: eostools.py:511
const pat::Particle fittedHadB() const
return hadronic b quark candidate
int maxNComb_
maximal number of combinations to be written to the event
edm::EDGetTokenT< LeptonCollection > lepsToken_
const pat::Particle fittedHadQ() const
return hadronic light quark candidate
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)
Definition: TopKinFitter.h:33
bool useBTag_
switch to tell whether to use b-tagging or not
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
Definition: combination.h:19

Member Data Documentation

template<typename LeptonCollection >
std::vector<edm::ParameterSet> TtSemiLepKinFitProducer< LeptonCollection >::bResolutions_
private
template<typename LeptonCollection >
std::string TtSemiLepKinFitProducer< LeptonCollection >::bTagAlgo_
private

input tag for b-tagging algorithm

Definition at line 44 of file TtSemiLepKinFitProducer.h.

template<typename LeptonCollection >
std::vector<unsigned> TtSemiLepKinFitProducer< LeptonCollection >::constraints_
private
template<typename LeptonCollection >
TtSemiLepKinFitter* TtSemiLepKinFitProducer< LeptonCollection >::fitter
private
template<typename LeptonCollection >
std::vector<double> TtSemiLepKinFitProducer< LeptonCollection >::jetEnergyResolutionEtaBinning_
private
template<typename LeptonCollection >
std::vector<double> TtSemiLepKinFitProducer< LeptonCollection >::jetEnergyResolutionScaleFactors_
private

scale factors for jet energy resolution

Definition at line 70 of file TtSemiLepKinFitProducer.h.

Referenced by TtSemiLepKinFitProducer< LeptonCollection >::TtSemiLepKinFitProducer().

template<typename LeptonCollection >
unsigned int TtSemiLepKinFitProducer< LeptonCollection >::jetParam_
private
template<typename LeptonCollection >
edm::EDGetTokenT<std::vector<pat::Jet> > TtSemiLepKinFitProducer< LeptonCollection >::jetsToken_
private

Definition at line 36 of file TtSemiLepKinFitProducer.h.

template<typename LeptonCollection >
unsigned int TtSemiLepKinFitProducer< LeptonCollection >::lepParam_
private
template<typename LeptonCollection >
std::vector<edm::ParameterSet> TtSemiLepKinFitProducer< LeptonCollection >::lepResolutions_
private
template<typename LeptonCollection >
edm::EDGetTokenT<LeptonCollection> TtSemiLepKinFitProducer< LeptonCollection >::lepsToken_
private

Definition at line 37 of file TtSemiLepKinFitProducer.h.

template<typename LeptonCollection >
edm::EDGetTokenT<std::vector<std::vector<int> > > TtSemiLepKinFitProducer< LeptonCollection >::matchToken_
private

Definition at line 40 of file TtSemiLepKinFitProducer.h.

template<typename LeptonCollection >
double TtSemiLepKinFitProducer< LeptonCollection >::maxBTagValueNonBJet_
private

max value of bTag for a non-b-jet

Definition at line 48 of file TtSemiLepKinFitProducer.h.

template<typename LeptonCollection >
double TtSemiLepKinFitProducer< LeptonCollection >::maxDeltaS_
private

maximal chi2 equivalent

Definition at line 59 of file TtSemiLepKinFitProducer.h.

Referenced by TtSemiLepKinFitProducer< LeptonCollection >::TtSemiLepKinFitProducer().

template<typename LeptonCollection >
double TtSemiLepKinFitProducer< LeptonCollection >::maxF_
private

maximal deviation for contstraints

Definition at line 61 of file TtSemiLepKinFitProducer.h.

Referenced by TtSemiLepKinFitProducer< LeptonCollection >::TtSemiLepKinFitProducer().

template<typename LeptonCollection >
int TtSemiLepKinFitProducer< LeptonCollection >::maxNComb_
private

maximal number of combinations to be written to the event

Definition at line 54 of file TtSemiLepKinFitProducer.h.

template<typename LeptonCollection >
int TtSemiLepKinFitProducer< LeptonCollection >::maxNJets_
private

maximal number of jets (-1 possible to indicate 'all')

Definition at line 52 of file TtSemiLepKinFitProducer.h.

template<typename LeptonCollection >
unsigned int TtSemiLepKinFitProducer< LeptonCollection >::maxNrIter_
private

maximal number of iterations to be performed for the fit

Definition at line 57 of file TtSemiLepKinFitProducer.h.

Referenced by TtSemiLepKinFitProducer< LeptonCollection >::TtSemiLepKinFitProducer().

template<typename LeptonCollection >
unsigned int TtSemiLepKinFitProducer< LeptonCollection >::metParam_
private
template<typename LeptonCollection >
std::vector<edm::ParameterSet> TtSemiLepKinFitProducer< LeptonCollection >::metResolutions_
private
template<typename LeptonCollection >
edm::EDGetTokenT<std::vector<pat::MET> > TtSemiLepKinFitProducer< LeptonCollection >::metsToken_
private

Definition at line 38 of file TtSemiLepKinFitProducer.h.

template<typename LeptonCollection >
double TtSemiLepKinFitProducer< LeptonCollection >::minBTagValueBJet_
private

min value of bTag for a b-jet

Definition at line 46 of file TtSemiLepKinFitProducer.h.

template<typename LeptonCollection >
double TtSemiLepKinFitProducer< LeptonCollection >::mTop_
private
template<typename LeptonCollection >
double TtSemiLepKinFitProducer< LeptonCollection >::mW_
private
template<typename LeptonCollection >
std::vector<edm::ParameterSet> TtSemiLepKinFitProducer< LeptonCollection >::udscResolutions_
private

config-file-based object resolutions

Definition at line 73 of file TtSemiLepKinFitProducer.h.

Referenced by TtSemiLepKinFitProducer< LeptonCollection >::TtSemiLepKinFitProducer().

template<typename LeptonCollection >
bool TtSemiLepKinFitProducer< LeptonCollection >::useBTag_
private

switch to tell whether to use b-tagging or not

Definition at line 50 of file TtSemiLepKinFitProducer.h.

template<typename LeptonCollection >
bool TtSemiLepKinFitProducer< LeptonCollection >::useOnlyMatch_
private

switch to use only a combination given by another hypothesis

Definition at line 42 of file TtSemiLepKinFitProducer.h.