CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TtSemiLepJetCombMVAComputer Class Reference

#include <TtSemiLepJetCombMVAComputer.h>

Inheritance diagram for TtSemiLepJetCombMVAComputer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 TtSemiLepJetCombMVAComputer (const edm::ParameterSet &)
 
 ~TtSemiLepJetCombMVAComputer () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginJob () override
 
void endJob () override
 
void produce (edm::Event &evt, const edm::EventSetup &setup) override
 

Private Attributes

edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
 
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
 
int maxNComb_
 
int maxNJets_
 
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
 
PhysicsTools::MVAComputerCache mvaComputer
 

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
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 21 of file TtSemiLepJetCombMVAComputer.h.

Constructor & Destructor Documentation

◆ TtSemiLepJetCombMVAComputer()

TtSemiLepJetCombMVAComputer::TtSemiLepJetCombMVAComputer ( const edm::ParameterSet cfg)
explicit

Definition at line 5 of file TtSemiLepJetCombMVAComputer.cc.

7  jetsToken_(consumes<std::vector<pat::Jet>>(cfg.getParameter<edm::InputTag>("jets"))),
8  metsToken_(consumes<std::vector<pat::MET>>(cfg.getParameter<edm::InputTag>("mets"))),
9  maxNJets_(cfg.getParameter<int>("maxNJets")),
10  maxNComb_(cfg.getParameter<int>("maxNComb")) {
11  produces<std::vector<std::vector<int>>>();
12  produces<std::vector<double>>("Discriminators");
13  produces<std::string>("Method");
14  produces<int>("NumberOfConsideredJets");
15 }

◆ ~TtSemiLepJetCombMVAComputer()

TtSemiLepJetCombMVAComputer::~TtSemiLepJetCombMVAComputer ( )
override

Definition at line 17 of file TtSemiLepJetCombMVAComputer.cc.

17 {}

Member Function Documentation

◆ beginJob()

void TtSemiLepJetCombMVAComputer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 123 of file TtSemiLepJetCombMVAComputer.cc.

123 {}

◆ endJob()

void TtSemiLepJetCombMVAComputer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 125 of file TtSemiLepJetCombMVAComputer.cc.

125 {}

◆ produce()

void TtSemiLepJetCombMVAComputer::produce ( edm::Event evt,
const edm::EventSetup setup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 19 of file TtSemiLepJetCombMVAComputer.cc.

19  {
20  std::unique_ptr<std::vector<std::vector<int>>> pOut(new std::vector<std::vector<int>>);
21  std::unique_ptr<std::vector<double>> pOutDisc(new std::vector<double>);
22  std::unique_ptr<std::string> pOutMeth(new std::string);
23  std::unique_ptr<int> pJetsConsidered(new int);
24 
25  mvaComputer.update<TtSemiLepJetCombMVARcd>(setup, "ttSemiLepJetCombMVA");
26 
27  // read name of the processor that provides the MVA discriminator
28  // (to be used as meta information)
30  setup.get<TtSemiLepJetCombMVARcd>().get(calibContainer);
31  std::vector<PhysicsTools::Calibration::VarProcessor*> processors =
32  (calibContainer->find("ttSemiLepJetCombMVA")).getProcessors();
33  *pOutMeth = (processors[processors.size() - 3])->getInstanceName();
34  evt.put(std::move(pOutMeth), "Method");
35 
36  // get lepton, jets and mets
39 
42 
45 
46  const unsigned int nPartons = 4;
47 
48  // skip events with no appropriate lepton candidate,
49  // empty METs vector or less jets than partons
50  if (leptons->empty() || mets->empty() || jets->size() < nPartons) {
51  std::vector<int> invalidCombi;
52  for (unsigned int i = 0; i < nPartons; ++i)
53  invalidCombi.push_back(-1);
54  pOut->push_back(invalidCombi);
55  evt.put(std::move(pOut));
56  pOutDisc->push_back(0.);
57  evt.put(std::move(pOutDisc), "Discriminators");
58  *pJetsConsidered = jets->size();
59  evt.put(std::move(pJetsConsidered), "NumberOfConsideredJets");
60  return;
61  }
62 
63  const math::XYZTLorentzVector lepton = leptons->begin()->p4();
64 
65  const pat::MET* met = &(*mets)[0];
66 
67  // analyze jet combinations
68  std::vector<int> jetIndices;
69  for (unsigned int i = 0; i < jets->size(); ++i) {
70  if (maxNJets_ >= (int)nPartons && maxNJets_ == (int)i) {
71  *pJetsConsidered = i;
72  break;
73  }
74  jetIndices.push_back(i);
75  }
76 
77  std::vector<int> combi;
78  for (unsigned int i = 0; i < nPartons; ++i)
79  combi.push_back(i);
80 
81  typedef std::pair<double, std::vector<int>> discCombPair;
82  std::list<discCombPair> discCombList;
83 
84  do {
85  for (int cnt = 0; cnt < TMath::Factorial(combi.size()); ++cnt) {
86  // take into account indistinguishability of the two jets from the hadr. W decay,
87  // reduces combinatorics by a factor of 2
89  TtSemiLepJetComb jetComb(*jets, combi, lepton, *met);
90 
91  // feed MVA input variables into a ValueList
94 
95  // get discriminator from the MVAComputer
96  double discrim = mvaComputer->eval(values);
97 
98  discCombList.push_back(std::make_pair(discrim, combi));
99  }
100  next_permutation(combi.begin(), combi.end());
101  }
102  } while (stdcomb::next_combination(jetIndices.begin(), jetIndices.end(), combi.begin(), combi.end()));
103 
104  // sort results w.r.t. discriminator values
105  discCombList.sort();
106 
107  // write result into the event
108  // (starting with the JetComb having the highest discriminator value -> reverse iterator)
109  unsigned int iDiscComb = 0;
110  typedef std::list<discCombPair>::reverse_iterator discCombIterator;
111  for (discCombIterator discCombPair = discCombList.rbegin(); discCombPair != discCombList.rend(); ++discCombPair) {
112  if (maxNComb_ >= 1 && iDiscComb == (unsigned int)maxNComb_)
113  break;
114  pOut->push_back(discCombPair->second);
115  pOutDisc->push_back(discCombPair->first);
116  iDiscComb++;
117  }
118  evt.put(std::move(pOut));
119  evt.put(std::move(pOutDisc), "Discriminators");
120  evt.put(std::move(pJetsConsidered), "NumberOfConsideredJets");
121 }

References PhysicsTools::MVAComputer::eval(), evaluateTtSemiLepJetComb(), get, edm::Event::getByToken(), mps_fire::i, createfilelist::int, singleTopDQM_cfi::jets, jetsToken_, lepsToken_, HLT_FULL_cff::leptons, TtSemiLepEvtPartons::LightQ, TtSemiLepEvtPartons::LightQBar, maxNComb_, maxNJets_, BTaggingMonitor_cfi::met, singleTopDQM_cfi::mets, metsToken_, eostools::move(), mvaComputer, stdcomb::next_combination(), nPartons, edm::Event::put(), singleTopDQM_cfi::setup, AlCaHLTBitMon_QueryRunRegistry::string, PhysicsTools::MVAComputerCache::update(), contentValuesCheck::values, and trackerHitRTTI::vector.

Member Data Documentation

◆ jetsToken_

edm::EDGetTokenT<std::vector<pat::Jet> > TtSemiLepJetCombMVAComputer::jetsToken_
private

Definition at line 32 of file TtSemiLepJetCombMVAComputer.h.

Referenced by produce().

◆ lepsToken_

edm::EDGetTokenT<edm::View<reco::RecoCandidate> > TtSemiLepJetCombMVAComputer::lepsToken_
private

Definition at line 31 of file TtSemiLepJetCombMVAComputer.h.

Referenced by produce().

◆ maxNComb_

int TtSemiLepJetCombMVAComputer::maxNComb_
private

Definition at line 36 of file TtSemiLepJetCombMVAComputer.h.

Referenced by produce().

◆ maxNJets_

int TtSemiLepJetCombMVAComputer::maxNJets_
private

Definition at line 35 of file TtSemiLepJetCombMVAComputer.h.

Referenced by produce().

◆ metsToken_

edm::EDGetTokenT<std::vector<pat::MET> > TtSemiLepJetCombMVAComputer::metsToken_
private

Definition at line 33 of file TtSemiLepJetCombMVAComputer.h.

Referenced by produce().

◆ mvaComputer

PhysicsTools::MVAComputerCache TtSemiLepJetCombMVAComputer::mvaComputer
private

Definition at line 38 of file TtSemiLepJetCombMVAComputer.h.

Referenced by produce().

PhysicsTools::MVAComputer::eval
double eval(Iterator_t first, Iterator_t last) const
evaluate variables given by a range of iterators given by first and last
mps_fire.i
i
Definition: mps_fire.py:428
TtSemiLepJetCombMVAComputer::lepsToken_
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
Definition: TtSemiLepJetCombMVAComputer.h:31
TtSemiLepEvtPartons::LightQBar
Definition: TtSemiLepEvtPartons.h:25
TtSemiLepJetCombMVAComputer::jetsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
Definition: TtSemiLepJetCombMVAComputer.h:32
HLT_FULL_cff.leptons
leptons
Definition: HLT_FULL_cff.py:26281
TtSemiLepJetCombMVARcd
Definition: TtSemiLepJetCombMVAComputer.h:18
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
singleTopDQM_cfi.mets
mets
Definition: singleTopDQM_cfi.py:43
edm::Handle
Definition: AssociativeIterator.h:50
PhysicsTools::Variable::ValueList
Helper class that can contain an list of identifier-value pairs.
Definition: Variable.h:77
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
TtSemiLepJetCombMVAComputer::mvaComputer
PhysicsTools::MVAComputerCache mvaComputer
Definition: TtSemiLepJetCombMVAComputer.h:38
BTaggingMonitor_cfi.met
met
Definition: BTaggingMonitor_cfi.py:84
TtSemiLepJetComb
Common calculator class to keep multivariate analysis variables for jet combinations in semi-leptonic...
Definition: TtSemiLepJetComb.h:48
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
edm::ESHandle
Definition: DTSurvey.h:22
evaluateTtSemiLepJetComb
void evaluateTtSemiLepJetComb(PhysicsTools::Variable::ValueList &values, const TtSemiLepJetComb &jetComb)
Definition: TtSemiLepJetCombEval.h:13
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:535
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View
Definition: CaloClusterFwd.h:14
TtSemiLepJetCombMVAComputer::metsToken_
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
Definition: TtSemiLepJetCombMVAComputer.h:33
nPartons
static const unsigned int nPartons
Definition: TtFullHadKinFitProducer.cc:3
TtSemiLepEvtPartons::LightQ
Definition: TtSemiLepEvtPartons.h:25
createfilelist.int
int
Definition: createfilelist.py:10
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
pat::MET
Analysis-level MET class.
Definition: MET.h:40
get
#define get
looper.cfg
cfg
Definition: looper.py:297
eostools.move
def move(src, dest)
Definition: eostools.py:511
stdcomb::next_combination
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
Definition: combination.h:19
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
PhysicsTools::MVAComputerCache::update
bool update(const Calibration::MVAComputer *computer)
Definition: MVAComputerCache.cc:15
TtSemiLepJetCombMVAComputer::maxNComb_
int maxNComb_
Definition: TtSemiLepJetCombMVAComputer.h:36
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:155
TtSemiLepJetCombMVAComputer::maxNJets_
int maxNJets_
Definition: TtSemiLepJetCombMVAComputer.h:35
edm::InputTag
Definition: InputTag.h:15