CMS 3D CMS Logo

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

#include <TtSemiLepJetCombWMassMaxSumPt.h>

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

Public Member Functions

 TtSemiLepJetCombWMassMaxSumPt (const edm::ParameterSet &)
 
 ~TtSemiLepJetCombWMassMaxSumPt () 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

void beginJob () override
 
void endJob () override
 
bool isValid (const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
 
void produce (edm::Event &evt, const edm::EventSetup &setup) override
 

Private Attributes

std::string bTagAlgorithm_
 
edm::EDGetTokenT< std::vector
< pat::Jet > > 
jetsToken_
 
edm::EDGetTokenT< edm::View
< reco::RecoCandidate > > 
lepsToken_
 
double maxBDiscLightJets_
 
int maxNJets_
 
double minBDiscBJets_
 
bool useBTagging_
 
double wMass_
 

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

Definition at line 10 of file TtSemiLepJetCombWMassMaxSumPt.h.

Constructor & Destructor Documentation

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

Definition at line 5 of file TtSemiLepJetCombWMassMaxSumPt.cc.

References Exception, and maxNJets_.

6  : jetsToken_(consumes<std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("jets"))),
8  maxNJets_(cfg.getParameter<int>("maxNJets")),
9  wMass_(cfg.getParameter<double>("wMass")),
10  useBTagging_(cfg.getParameter<bool>("useBTagging")),
11  bTagAlgorithm_(cfg.getParameter<std::string>("bTagAlgorithm")),
12  minBDiscBJets_(cfg.getParameter<double>("minBDiscBJets")),
13  maxBDiscLightJets_(cfg.getParameter<double>("maxBDiscLightJets")) {
14  if (maxNJets_ < 4 && maxNJets_ != -1)
15  throw cms::Exception("WrongConfig") << "Parameter maxNJets can not be set to " << maxNJets_ << ". \n"
16  << "It has to be larger than 4 or can be set to -1 to take all jets.";
17 
18  produces<std::vector<std::vector<int> > >();
19  produces<int>("NumberOfConsideredJets");
20 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
TtSemiLepJetCombWMassMaxSumPt::~TtSemiLepJetCombWMassMaxSumPt ( )
override

Definition at line 22 of file TtSemiLepJetCombWMassMaxSumPt.cc.

22 {}

Member Function Documentation

void TtSemiLepJetCombWMassMaxSumPt::beginJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 16 of file TtSemiLepJetCombWMassMaxSumPt.h.

16 {};
void TtSemiLepJetCombWMassMaxSumPt::endJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 18 of file TtSemiLepJetCombWMassMaxSumPt.h.

18 {};
bool TtSemiLepJetCombWMassMaxSumPt::isValid ( const int &  idx,
const edm::Handle< std::vector< pat::Jet > > &  jets 
)
inlineprivate

Definition at line 20 of file TtSemiLepJetCombWMassMaxSumPt.h.

References fwrapper::jets.

Referenced by ntupleDataFormat._Object::_checkIsValid(), produce(), and core.AutoHandle.AutoHandle::ReallyLoad().

20  {
21  return (0 <= idx && idx < (int)jets->size());
22  };
void TtSemiLepJetCombWMassMaxSumPt::produce ( edm::Event evt,
const edm::EventSetup setup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 24 of file TtSemiLepJetCombWMassMaxSumPt.cc.

References bTagAlgorithm_, edm::Event::getByToken(), TtSemiLepEvtPartons::HadB, mps_fire::i, isValid(), fwrapper::jets, jetsToken_, TtSemiLepEvtPartons::LepB, lepsToken_, TtSemiLepEvtPartons::LightQ, TtSemiLepEvtPartons::LightQBar, match(), maxBDiscLightJets_, maxNJets_, minBDiscBJets_, eostools::move(), edm::Event::put(), useBTagging_, trackerHitRTTI::vector, and wMass_.

24  {
25  std::unique_ptr<std::vector<std::vector<int> > > pOut(new std::vector<std::vector<int> >);
26  std::unique_ptr<int> pJetsConsidered(new int);
27 
28  std::vector<int> match;
29  for (unsigned int i = 0; i < 4; ++i)
30  match.push_back(-1);
31 
32  // get jets
34  evt.getByToken(jetsToken_, jets);
35 
36  // get leptons
38  evt.getByToken(lepsToken_, leps);
39 
40  // skip events without lepton candidate or less than 4 jets or no MET
41  if (leps->empty() || jets->size() < 4) {
42  pOut->push_back(match);
43  evt.put(std::move(pOut));
44  *pJetsConsidered = jets->size();
45  evt.put(std::move(pJetsConsidered), "NumberOfConsideredJets");
46  return;
47  }
48 
49  unsigned maxNJets = maxNJets_;
50  if (maxNJets_ == -1 || (int)jets->size() < maxNJets_)
51  maxNJets = jets->size();
52  *pJetsConsidered = maxNJets;
53  evt.put(std::move(pJetsConsidered), "NumberOfConsideredJets");
54 
55  std::vector<bool> isBJet;
56  std::vector<bool> isLJet;
57  int cntBJets = 0;
58  if (useBTagging_) {
59  for (unsigned int idx = 0; idx < maxNJets; ++idx) {
60  isBJet.push_back(((*jets)[idx].bDiscriminator(bTagAlgorithm_) > minBDiscBJets_));
61  isLJet.push_back(((*jets)[idx].bDiscriminator(bTagAlgorithm_) < maxBDiscLightJets_));
62  if ((*jets)[idx].bDiscriminator(bTagAlgorithm_) > minBDiscBJets_)
63  cntBJets++;
64  }
65  }
66 
67  // -----------------------------------------------------
68  // associate those jets that get closest to the W mass
69  // with their invariant mass to the hadronic W boson
70  // -----------------------------------------------------
71  double wDist = -1.;
72  std::vector<int> closestToWMassIndices;
73  closestToWMassIndices.push_back(-1);
74  closestToWMassIndices.push_back(-1);
75  for (unsigned idx = 0; idx < maxNJets; ++idx) {
76  if (useBTagging_ && (!isLJet[idx] || (cntBJets <= 2 && isBJet[idx])))
77  continue;
78  for (unsigned jdx = (idx + 1); jdx < maxNJets; ++jdx) {
79  if (useBTagging_ &&
80  (!isLJet[jdx] || (cntBJets <= 2 && isBJet[jdx]) || (cntBJets == 3 && isBJet[idx] && isBJet[jdx])))
81  continue;
82  reco::Particle::LorentzVector sum = (*jets)[idx].p4() + (*jets)[jdx].p4();
83  if (wDist < 0. || wDist > fabs(sum.mass() - wMass_)) {
84  wDist = fabs(sum.mass() - wMass_);
85  closestToWMassIndices.clear();
86  closestToWMassIndices.push_back(idx);
87  closestToWMassIndices.push_back(jdx);
88  }
89  }
90  }
91 
92  // -----------------------------------------------------
93  // associate those jets with maximum pt of the vectorial
94  // sum to the hadronic decay chain
95  // -----------------------------------------------------
96  double maxPt = -1.;
97  int hadB = -1;
98  if (isValid(closestToWMassIndices[0], jets) && isValid(closestToWMassIndices[1], jets)) {
99  for (unsigned idx = 0; idx < maxNJets; ++idx) {
100  if (useBTagging_ && !isBJet[idx])
101  continue;
102  // make sure it's not used up already from the hadronic W
103  if ((int)idx != closestToWMassIndices[0] && (int)idx != closestToWMassIndices[1]) {
105  (*jets)[closestToWMassIndices[0]].p4() + (*jets)[closestToWMassIndices[1]].p4() + (*jets)[idx].p4();
106  if (maxPt < 0. || maxPt < sum.pt()) {
107  maxPt = sum.pt();
108  hadB = idx;
109  }
110  }
111  }
112  }
113 
114  // -----------------------------------------------------
115  // associate the remaining jet with maximum pt of the
116  // vectorial sum with the leading lepton with the
117  // leptonic b quark
118  // -----------------------------------------------------
119  maxPt = -1.;
120  int lepB = -1;
121  for (unsigned idx = 0; idx < maxNJets; ++idx) {
122  if (useBTagging_ && !isBJet[idx])
123  continue;
124  // make sure it's not used up already from the hadronic decay chain
125  if ((int)idx != closestToWMassIndices[0] && (int)idx != closestToWMassIndices[1] && (int)idx != hadB) {
126  reco::Particle::LorentzVector sum = (*jets)[idx].p4() + (*leps)[0].p4();
127  if (maxPt < 0. || maxPt < sum.pt()) {
128  maxPt = sum.pt();
129  lepB = idx;
130  }
131  }
132  }
133 
134  match[TtSemiLepEvtPartons::LightQ] = closestToWMassIndices[0];
135  match[TtSemiLepEvtPartons::LightQBar] = closestToWMassIndices[1];
136  match[TtSemiLepEvtPartons::HadB] = hadB;
137  match[TtSemiLepEvtPartons::LepB] = lepB;
138 
139  pOut->push_back(match);
140  evt.put(std::move(pOut));
141 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool isValid(const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
vector< PseudoJet > jets
def move
Definition: eostools.py:511
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21

Member Data Documentation

std::string TtSemiLepJetCombWMassMaxSumPt::bTagAlgorithm_
private

Definition at line 29 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce().

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

Definition at line 22 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce().

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

Definition at line 25 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce().

double TtSemiLepJetCombWMassMaxSumPt::maxBDiscLightJets_
private

Definition at line 31 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce().

int TtSemiLepJetCombWMassMaxSumPt::maxNJets_
private

Definition at line 26 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce(), and TtSemiLepJetCombWMassMaxSumPt().

double TtSemiLepJetCombWMassMaxSumPt::minBDiscBJets_
private

Definition at line 30 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce().

bool TtSemiLepJetCombWMassMaxSumPt::useBTagging_
private

Definition at line 28 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce().

double TtSemiLepJetCombWMassMaxSumPt::wMass_
private

Definition at line 27 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce().