CMS 3D CMS Logo

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

#include <TtSemiLepJetCombGeom.h>

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

Public Member Functions

 TtSemiLepJetCombGeom (const edm::ParameterSet &)
 
 ~TtSemiLepJetCombGeom () 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
 
double distance (const math::XYZTLorentzVector &, const math::XYZTLorentzVector &)
 
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_
 
bool useDeltaR_
 

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 10 of file TtSemiLepJetCombGeom.h.

Constructor & Destructor Documentation

◆ TtSemiLepJetCombGeom()

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

Definition at line 9 of file TtSemiLepJetCombGeom.cc.

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

References Exception, and maxNJets_.

◆ ~TtSemiLepJetCombGeom()

TtSemiLepJetCombGeom::~TtSemiLepJetCombGeom ( )
override

Definition at line 26 of file TtSemiLepJetCombGeom.cc.

26 {}

Member Function Documentation

◆ beginJob()

void TtSemiLepJetCombGeom::beginJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 16 of file TtSemiLepJetCombGeom.h.

16 {};

◆ distance()

double TtSemiLepJetCombGeom::distance ( const math::XYZTLorentzVector v1,
const math::XYZTLorentzVector v2 
)
private

Definition at line 147 of file TtSemiLepJetCombGeom.cc.

147  {
148  // calculate the distance between two lorentz vectors
149  // using DeltaR or DeltaTheta
150  if (useDeltaR_)
151  return ROOT::Math::VectorUtil::DeltaR(v1, v2);
152  return fabs(v1.theta() - v2.theta());
153 }

References electronAnalyzer_cfi::DeltaR, and useDeltaR_.

Referenced by produce().

◆ endJob()

void TtSemiLepJetCombGeom::endJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 18 of file TtSemiLepJetCombGeom.h.

18 {};

◆ isValid()

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

Definition at line 20 of file TtSemiLepJetCombGeom.h.

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

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

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

◆ produce()

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

Implements edm::EDProducer.

Definition at line 28 of file TtSemiLepJetCombGeom.cc.

28  {
29  std::unique_ptr<std::vector<std::vector<int> > > pOut(new std::vector<std::vector<int> >);
30  std::unique_ptr<int> pJetsConsidered(new int);
31 
32  std::vector<int> match;
33  for (unsigned int i = 0; i < 4; ++i)
34  match.push_back(-1);
35 
36  // get jets
39 
40  // get leptons
43 
44  // skip events without lepton candidate or less than 4 jets
45  if (leps->empty() || jets->size() < 4) {
46  pOut->push_back(match);
47  evt.put(std::move(pOut));
48  *pJetsConsidered = jets->size();
49  evt.put(std::move(pJetsConsidered), "NumberOfConsideredJets");
50  return;
51  }
52 
53  unsigned maxNJets = maxNJets_;
54  if (maxNJets_ == -1 || (int)jets->size() < maxNJets_)
55  maxNJets = jets->size();
56  *pJetsConsidered = maxNJets;
57  evt.put(std::move(pJetsConsidered), "NumberOfConsideredJets");
58 
59  std::vector<bool> isBJet;
60  std::vector<bool> isLJet;
61  int cntBJets = 0;
62  if (useBTagging_) {
63  for (unsigned int idx = 0; idx < maxNJets; ++idx) {
64  isBJet.push_back(((*jets)[idx].bDiscriminator(bTagAlgorithm_) > minBDiscBJets_));
65  isLJet.push_back(((*jets)[idx].bDiscriminator(bTagAlgorithm_) < maxBDiscLightJets_));
66  if ((*jets)[idx].bDiscriminator(bTagAlgorithm_) > minBDiscBJets_)
67  cntBJets++;
68  }
69  }
70 
71  // -----------------------------------------------------
72  // associate those two jets to the hadronic W boson that
73  // have the smallest distance to each other
74  // -----------------------------------------------------
75  double minDist = -1.;
76  int lightQ = -1;
77  int lightQBar = -1;
78  for (unsigned int idx = 0; idx < maxNJets; ++idx) {
79  if (useBTagging_ && (!isLJet[idx] || (cntBJets <= 2 && isBJet[idx])))
80  continue;
81  for (unsigned int jdx = (idx + 1); jdx < maxNJets; ++jdx) {
82  if (useBTagging_ &&
83  (!isLJet[jdx] || (cntBJets <= 2 && isBJet[jdx]) || (cntBJets == 3 && isBJet[idx] && isBJet[jdx])))
84  continue;
85  double dist = distance((*jets)[idx].p4(), (*jets)[jdx].p4());
86  if (minDist < 0. || dist < minDist) {
87  minDist = dist;
88  lightQ = idx;
89  lightQBar = jdx;
90  }
91  }
92  }
93 
95  if (isValid(lightQ, jets) && isValid(lightQBar, jets))
96  wHad = (*jets)[lightQ].p4() + (*jets)[lightQBar].p4();
97 
98  // -----------------------------------------------------
99  // associate to the hadronic b quark the remaining jet
100  // that has the smallest distance to the hadronic W
101  // -----------------------------------------------------
102  minDist = -1.;
103  int hadB = -1;
104  if (isValid(lightQ, jets) && isValid(lightQBar, jets)) {
105  for (unsigned int idx = 0; idx < maxNJets; ++idx) {
106  if (useBTagging_ && !isBJet[idx])
107  continue;
108  // make sure it's not used up already from the hadronic W
109  if ((int)idx != lightQ && (int)idx != lightQBar) {
110  double dist = distance((*jets)[idx].p4(), wHad);
111  if (minDist < 0. || dist < minDist) {
112  minDist = dist;
113  hadB = idx;
114  }
115  }
116  }
117  }
118 
119  // -----------------------------------------------------
120  // associate to the leptonic b quark the remaining jet
121  // that has the smallest distance to the leading lepton
122  // -----------------------------------------------------
123  minDist = -1.;
124  int lepB = -1;
125  for (unsigned int idx = 0; idx < maxNJets; ++idx) {
126  if (useBTagging_ && !isBJet[idx])
127  continue;
128  // make sure it's not used up already from the hadronic decay chain
129  if ((int)idx != lightQ && (int)idx != lightQBar && (int)idx != hadB) {
130  double dist = distance((*jets)[idx].p4(), (*leps)[0].p4());
131  if (minDist < 0. || dist < minDist) {
132  minDist = dist;
133  lepB = idx;
134  }
135  }
136  }
137 
142 
143  pOut->push_back(match);
144  evt.put(std::move(pOut));
145 }

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

Member Data Documentation

◆ bTagAlgorithm_

std::string TtSemiLepJetCombGeom::bTagAlgorithm_
private

Definition at line 30 of file TtSemiLepJetCombGeom.h.

Referenced by produce().

◆ jetsToken_

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

Definition at line 25 of file TtSemiLepJetCombGeom.h.

Referenced by produce().

◆ lepsToken_

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

Definition at line 26 of file TtSemiLepJetCombGeom.h.

Referenced by produce().

◆ maxBDiscLightJets_

double TtSemiLepJetCombGeom::maxBDiscLightJets_
private

Definition at line 32 of file TtSemiLepJetCombGeom.h.

Referenced by produce().

◆ maxNJets_

int TtSemiLepJetCombGeom::maxNJets_
private

Definition at line 27 of file TtSemiLepJetCombGeom.h.

Referenced by produce(), and TtSemiLepJetCombGeom().

◆ minBDiscBJets_

double TtSemiLepJetCombGeom::minBDiscBJets_
private

Definition at line 31 of file TtSemiLepJetCombGeom.h.

Referenced by produce().

◆ useBTagging_

bool TtSemiLepJetCombGeom::useBTagging_
private

Definition at line 29 of file TtSemiLepJetCombGeom.h.

Referenced by produce().

◆ useDeltaR_

bool TtSemiLepJetCombGeom::useDeltaR_
private

Definition at line 28 of file TtSemiLepJetCombGeom.h.

Referenced by distance().

TtSemiLepJetCombGeom::bTagAlgorithm_
std::string bTagAlgorithm_
Definition: TtSemiLepJetCombGeom.h:30
mps_fire.i
i
Definition: mps_fire.py:355
TtSemiLepEvtPartons::LightQBar
Definition: TtSemiLepEvtPartons.h:25
TtSemiLepJetCombGeom::lepsToken_
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
Definition: TtSemiLepJetCombGeom.h:26
TtSemiLepEvtPartons::LepB
Definition: TtSemiLepEvtPartons.h:25
charmTagsComputerCvsB_cfi.idx
idx
Definition: charmTagsComputerCvsB_cfi.py:108
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
edm::Handle
Definition: AssociativeIterator.h:50
reco::Particle::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
TtSemiLepHitFitProducer_Electrons_cfi.leps
leps
Definition: TtSemiLepHitFitProducer_Electrons_cfi.py:5
TtSemiLepJetCombGeom::distance
double distance(const math::XYZTLorentzVector &, const math::XYZTLorentzVector &)
Definition: TtSemiLepJetCombGeom.cc:147
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
TtSemiLepJetCombGeom::isValid
bool isValid(const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
Definition: TtSemiLepJetCombGeom.h:20
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TtSemiLepJetCombGeom::minBDiscBJets_
double minBDiscBJets_
Definition: TtSemiLepJetCombGeom.h:31
edm::View
Definition: CaloClusterFwd.h:14
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
TtSemiLepJetCombGeom::useDeltaR_
bool useDeltaR_
Definition: TtSemiLepJetCombGeom.h:28
p4
double p4[4]
Definition: TauolaWrapper.h:92
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
electronAnalyzer_cfi.DeltaR
DeltaR
Definition: electronAnalyzer_cfi.py:33
looper.cfg
cfg
Definition: looper.py:297
TtSemiLepJetCombGeom::maxNJets_
int maxNJets_
Definition: TtSemiLepJetCombGeom.h:27
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:246
TtSemiLepJetCombGeom::useBTagging_
bool useBTagging_
Definition: TtSemiLepJetCombGeom.h:29
TtSemiLepJetCombGeom::maxBDiscLightJets_
double maxBDiscLightJets_
Definition: TtSemiLepJetCombGeom.h:32
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:126
edm::InputTag
Definition: InputTag.h:15
TtSemiLepJetCombGeom::jetsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
Definition: TtSemiLepJetCombGeom.h:25