CMS 3D CMS Logo

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

#include <TtSemiLepJetCombMaxSumPtWMass.h>

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

Public Member Functions

 TtSemiLepJetCombMaxSumPtWMass (const edm::ParameterSet &)
 
 ~TtSemiLepJetCombMaxSumPtWMass () 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
 
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::vector< ModuleDescription const * > &modules, 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
 
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 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>
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)
 
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 9 of file TtSemiLepJetCombMaxSumPtWMass.h.

Constructor & Destructor Documentation

◆ TtSemiLepJetCombMaxSumPtWMass()

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

Definition at line 7 of file TtSemiLepJetCombMaxSumPtWMass.cc.

8  : jetsToken_(consumes<std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("jets"))),
10  maxNJets_(cfg.getParameter<int>("maxNJets")),
11  wMass_(cfg.getParameter<double>("wMass")),
12  useBTagging_(cfg.getParameter<bool>("useBTagging")),
13  bTagAlgorithm_(cfg.getParameter<std::string>("bTagAlgorithm")),
14  minBDiscBJets_(cfg.getParameter<double>("minBDiscBJets")),
15  maxBDiscLightJets_(cfg.getParameter<double>("maxBDiscLightJets")) {
16  if (maxNJets_ < 4 && maxNJets_ != -1)
17  throw cms::Exception("WrongConfig") << "Parameter maxNJets can not be set to " << maxNJets_ << ". \n"
18  << "It has to be larger than 4 or can be set to -1 to take all jets.";
19 
20  produces<std::vector<std::vector<int> > >();
21  produces<int>("NumberOfConsideredJets");
22 }

References Exception, and maxNJets_.

◆ ~TtSemiLepJetCombMaxSumPtWMass()

TtSemiLepJetCombMaxSumPtWMass::~TtSemiLepJetCombMaxSumPtWMass ( )
override

Definition at line 24 of file TtSemiLepJetCombMaxSumPtWMass.cc.

24 {}

Member Function Documentation

◆ beginJob()

void TtSemiLepJetCombMaxSumPtWMass::beginJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 15 of file TtSemiLepJetCombMaxSumPtWMass.h.

15 {};

◆ endJob()

void TtSemiLepJetCombMaxSumPtWMass::endJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 17 of file TtSemiLepJetCombMaxSumPtWMass.h.

17 {};

◆ isValid()

bool TtSemiLepJetCombMaxSumPtWMass::isValid ( const int &  idx,
const edm::Handle< std::vector< pat::Jet > > &  jets 
)
inlineprivate

Definition at line 19 of file TtSemiLepJetCombMaxSumPtWMass.h.

19  {
20  return (0 <= idx && idx < (int)jets->size());
21  };

References training_settings::idx, and singleTopDQM_cfi::jets.

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

◆ produce()

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

Implements edm::EDProducer.

Definition at line 26 of file TtSemiLepJetCombMaxSumPtWMass.cc.

26  {
27  std::unique_ptr<std::vector<std::vector<int> > > pOut(new std::vector<std::vector<int> >);
28  std::unique_ptr<int> pJetsConsidered(new int);
29 
30  std::vector<int> match;
31  for (unsigned int i = 0; i < 4; ++i)
32  match.push_back(-1);
33 
34  // get jets
37 
38  // get leptons
41 
42  // skip events without lepton candidate or less than 4 jets or no MET
43  if (leps->empty() || jets->size() < 4) {
44  pOut->push_back(match);
45  evt.put(std::move(pOut));
46  *pJetsConsidered = jets->size();
47  evt.put(std::move(pJetsConsidered), "NumberOfConsideredJets");
48  return;
49  }
50 
51  unsigned maxNJets = maxNJets_;
52  if (maxNJets_ == -1 || (int)jets->size() < maxNJets_)
53  maxNJets = jets->size();
54  *pJetsConsidered = maxNJets;
55  evt.put(std::move(pJetsConsidered), "NumberOfConsideredJets");
56 
57  std::vector<bool> isBJet;
58  std::vector<bool> isLJet;
59  int cntBJets = 0;
60  if (useBTagging_) {
61  for (unsigned int idx = 0; idx < maxNJets; ++idx) {
62  isBJet.push_back(((*jets)[idx].bDiscriminator(bTagAlgorithm_) > minBDiscBJets_));
63  isLJet.push_back(((*jets)[idx].bDiscriminator(bTagAlgorithm_) < maxBDiscLightJets_));
64  if ((*jets)[idx].bDiscriminator(bTagAlgorithm_) > minBDiscBJets_)
65  cntBJets++;
66  }
67  }
68 
69  // -----------------------------------------------------
70  // associate those jets with maximum pt of the vectorial
71  // sum to the hadronic decay chain
72  // -----------------------------------------------------
73  double maxPt = -1.;
74  std::vector<int> maxPtIndices;
75  maxPtIndices.push_back(-1);
76  maxPtIndices.push_back(-1);
77  maxPtIndices.push_back(-1);
78  for (unsigned idx = 0; idx < maxNJets; ++idx) {
79  if (useBTagging_ && (!isLJet[idx] || (cntBJets <= 2 && isBJet[idx])))
80  continue;
81  for (unsigned jdx = (idx + 1); jdx < maxNJets; ++jdx) {
82  if (jdx == idx || (useBTagging_ && (!isLJet[jdx] || (cntBJets <= 2 && isBJet[jdx]) ||
83  (cntBJets == 3 && isBJet[idx] && isBJet[jdx]))))
84  continue;
85  for (unsigned kdx = 0; kdx < maxNJets; ++kdx) {
86  if (kdx == idx || kdx == jdx || (useBTagging_ && !isBJet[kdx]))
87  continue;
88  reco::Particle::LorentzVector sum = (*jets)[idx].p4() + (*jets)[jdx].p4() + (*jets)[kdx].p4();
89  if (maxPt < 0. || maxPt < sum.pt()) {
90  maxPt = sum.pt();
91  maxPtIndices.clear();
92  maxPtIndices.push_back(idx);
93  maxPtIndices.push_back(jdx);
94  maxPtIndices.push_back(kdx);
95  }
96  }
97  }
98  }
99 
100  // -----------------------------------------------------
101  // associate those jets that get closest to the W mass
102  // with their invariant mass to the W boson
103  // -----------------------------------------------------
104  double wDist = -1.;
105  std::vector<int> closestToWMassIndices;
106  closestToWMassIndices.push_back(-1);
107  closestToWMassIndices.push_back(-1);
108  if (isValid(maxPtIndices[0], jets) && isValid(maxPtIndices[1], jets) && isValid(maxPtIndices[2], jets)) {
109  for (unsigned idx = 0; idx < maxPtIndices.size(); ++idx) {
110  for (unsigned jdx = 0; jdx < maxPtIndices.size(); ++jdx) {
111  if (jdx == idx || maxPtIndices[idx] > maxPtIndices[jdx] ||
112  (useBTagging_ &&
113  (!isLJet[maxPtIndices[idx]] || !isLJet[maxPtIndices[jdx]] ||
114  (cntBJets <= 2 && isBJet[maxPtIndices[idx]]) || (cntBJets <= 2 && isBJet[maxPtIndices[jdx]]) ||
115  (cntBJets == 3 && isBJet[maxPtIndices[idx]] && isBJet[maxPtIndices[jdx]]))))
116  continue;
117  reco::Particle::LorentzVector sum = (*jets)[maxPtIndices[idx]].p4() + (*jets)[maxPtIndices[jdx]].p4();
118  if (wDist < 0. || wDist > fabs(sum.mass() - wMass_)) {
119  wDist = fabs(sum.mass() - wMass_);
120  closestToWMassIndices.clear();
121  closestToWMassIndices.push_back(maxPtIndices[idx]);
122  closestToWMassIndices.push_back(maxPtIndices[jdx]);
123  }
124  }
125  }
126  }
127  int hadB = -1;
128  for (unsigned idx = 0; idx < maxPtIndices.size(); ++idx) {
129  // if this idx is not yet contained in the list of W mass candidates...
130  if (std::find(closestToWMassIndices.begin(), closestToWMassIndices.end(), maxPtIndices[idx]) ==
131  closestToWMassIndices.end()) {
132  hadB = maxPtIndices[idx];
133  break; // there should be no other cadidates!
134  }
135  }
136 
137  // -----------------------------------------------------
138  // associate the remaining jet with maximum pt of the
139  // vectorial sum with the leading lepton with the
140  // leptonic decay chain
141  // -----------------------------------------------------
142  maxPt = -1.;
143  int lepB = -1;
144  for (unsigned idx = 0; idx < maxNJets; ++idx) {
145  if (useBTagging_ && !isBJet[idx])
146  continue;
147  // make sure it's not used up already from the hadronic decay chain
148  if (std::find(maxPtIndices.begin(), maxPtIndices.end(), idx) == maxPtIndices.end()) {
149  reco::Particle::LorentzVector sum = (*jets)[idx].p4() + (*leps)[0].p4();
150  if (maxPt < 0. || maxPt < sum.pt()) {
151  maxPt = sum.pt();
152  lepB = idx;
153  }
154  }
155  }
156 
157  match[TtSemiLepEvtPartons::LightQ] = closestToWMassIndices[0];
158  match[TtSemiLepEvtPartons::LightQBar] = closestToWMassIndices[1];
161 
162  pOut->push_back(match);
163  evt.put(std::move(pOut));
164 }

References bTagAlgorithm_, spr::find(), edm::Event::getByToken(), TtSemiLepEvtPartons::HadB, mps_fire::i, training_settings::idx, isValid(), singleTopDQM_cfi::jets, jetsToken_, TtSemiLepEvtPartons::LepB, TtSemiLepHitFitProducer_Electrons_cfi::leps, lepsToken_, TtSemiLepEvtPartons::LightQ, TtSemiLepEvtPartons::LightQBar, match(), maxBDiscLightJets_, SUSYDQMAnalyzer_cfi::maxNJets, maxNJets_, MuonErrorMatrixAnalyzer_cfi::maxPt, minBDiscBJets_, eostools::move(), edm::Event::put(), useBTagging_, and wMass_.

Member Data Documentation

◆ bTagAlgorithm_

std::string TtSemiLepJetCombMaxSumPtWMass::bTagAlgorithm_
private

Definition at line 28 of file TtSemiLepJetCombMaxSumPtWMass.h.

Referenced by produce().

◆ jetsToken_

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

Definition at line 21 of file TtSemiLepJetCombMaxSumPtWMass.h.

Referenced by produce().

◆ lepsToken_

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

Definition at line 24 of file TtSemiLepJetCombMaxSumPtWMass.h.

Referenced by produce().

◆ maxBDiscLightJets_

double TtSemiLepJetCombMaxSumPtWMass::maxBDiscLightJets_
private

Definition at line 30 of file TtSemiLepJetCombMaxSumPtWMass.h.

Referenced by produce().

◆ maxNJets_

int TtSemiLepJetCombMaxSumPtWMass::maxNJets_
private

Definition at line 25 of file TtSemiLepJetCombMaxSumPtWMass.h.

Referenced by produce(), and TtSemiLepJetCombMaxSumPtWMass().

◆ minBDiscBJets_

double TtSemiLepJetCombMaxSumPtWMass::minBDiscBJets_
private

Definition at line 29 of file TtSemiLepJetCombMaxSumPtWMass.h.

Referenced by produce().

◆ useBTagging_

bool TtSemiLepJetCombMaxSumPtWMass::useBTagging_
private

Definition at line 27 of file TtSemiLepJetCombMaxSumPtWMass.h.

Referenced by produce().

◆ wMass_

double TtSemiLepJetCombMaxSumPtWMass::wMass_
private

Definition at line 26 of file TtSemiLepJetCombMaxSumPtWMass.h.

Referenced by produce().

mps_fire.i
i
Definition: mps_fire.py:355
TtSemiLepEvtPartons::LightQBar
Definition: TtSemiLepEvtPartons.h:25
TtSemiLepJetCombMaxSumPtWMass::isValid
bool isValid(const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
Definition: TtSemiLepJetCombMaxSumPtWMass.h:19
TtSemiLepEvtPartons::LepB
Definition: TtSemiLepEvtPartons.h:25
TtSemiLepJetCombMaxSumPtWMass::bTagAlgorithm_
std::string bTagAlgorithm_
Definition: TtSemiLepJetCombMaxSumPtWMass.h:28
TtSemiLepJetCombMaxSumPtWMass::jetsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
Definition: TtSemiLepJetCombMaxSumPtWMass.h:21
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle
Definition: AssociativeIterator.h:50
training_settings.idx
idx
Definition: training_settings.py:16
reco::Particle::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
TtSemiLepJetCombMaxSumPtWMass::minBDiscBJets_
double minBDiscBJets_
Definition: TtSemiLepJetCombMaxSumPtWMass.h:29
TtSemiLepHitFitProducer_Electrons_cfi.leps
leps
Definition: TtSemiLepHitFitProducer_Electrons_cfi.py:5
MuonErrorMatrixAnalyzer_cfi.maxPt
maxPt
Definition: MuonErrorMatrixAnalyzer_cfi.py:19
TtSemiLepJetCombMaxSumPtWMass::lepsToken_
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
Definition: TtSemiLepJetCombMaxSumPtWMass.h:24
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TtSemiLepJetCombMaxSumPtWMass::maxNJets_
int maxNJets_
Definition: TtSemiLepJetCombMaxSumPtWMass.h:25
edm::View
Definition: CaloClusterFwd.h:14
TtSemiLepJetCombMaxSumPtWMass::wMass_
double wMass_
Definition: TtSemiLepJetCombMaxSumPtWMass.h:26
TtSemiLepEvtPartons::HadB
Definition: TtSemiLepEvtPartons.h:25
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
TtSemiLepEvtPartons::LightQ
Definition: TtSemiLepEvtPartons.h:25
SUSYDQMAnalyzer_cfi.maxNJets
maxNJets
Definition: SUSYDQMAnalyzer_cfi.py:13
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
looper.cfg
cfg
Definition: looper.py:297
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:246
TtSemiLepJetCombMaxSumPtWMass::maxBDiscLightJets_
double maxBDiscLightJets_
Definition: TtSemiLepJetCombMaxSumPtWMass.h:30
TtSemiLepJetCombMaxSumPtWMass::useBTagging_
bool useBTagging_
Definition: TtSemiLepJetCombMaxSumPtWMass.h:27
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:126
edm::InputTag
Definition: InputTag.h:15