CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TtSemiLepJetCombGeom Class Reference
Inheritance diagram for TtSemiLepJetCombGeom:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 TtSemiLepJetCombGeom (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

double distance (const math::XYZTLorentzVector &, const math::XYZTLorentzVector &) const
 
bool isValid (const int idx, const std::vector< pat::Jet > &jets) const
 
void produce (edm::StreamID, edm::Event &evt, const edm::EventSetup &setup) const 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::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
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< Bconsumes (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 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 ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
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 12 of file TtSemiLepJetCombGeom.cc.

Constructor & Destructor Documentation

◆ TtSemiLepJetCombGeom()

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

Definition at line 32 of file TtSemiLepJetCombGeom.cc.

References Exception, and maxNJets_.

33  : jetsToken_(consumes<std::vector<pat::Jet>>(cfg.getParameter<edm::InputTag>("jets"))),
35  maxNJets_(cfg.getParameter<int>("maxNJets")),
36  useDeltaR_(cfg.getParameter<bool>("useDeltaR")),
37  useBTagging_(cfg.getParameter<bool>("useBTagging")),
38  bTagAlgorithm_(cfg.getParameter<std::string>("bTagAlgorithm")),
39  minBDiscBJets_(cfg.getParameter<double>("minBDiscBJets")),
40  maxBDiscLightJets_(cfg.getParameter<double>("maxBDiscLightJets")) {
41  if (maxNJets_ < 4 && maxNJets_ != -1)
42  throw cms::Exception("WrongConfig") << "Parameter maxNJets can not be set to " << maxNJets_ << ". \n"
43  << "It has to be larger than 4 or can be set to -1 to take all jets.";
44 
45  produces<std::vector<std::vector<int>>>();
46  produces<int>("NumberOfConsideredJets");
47 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_

Member Function Documentation

◆ distance()

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

Definition at line 166 of file TtSemiLepJetCombGeom.cc.

References electronAnalyzer_cfi::DeltaR, and useDeltaR_.

Referenced by produce().

166  {
167  // calculate the distance between two lorentz vectors
168  // using DeltaR or DeltaTheta
169  if (useDeltaR_)
170  return ROOT::Math::VectorUtil::DeltaR(v1, v2);
171  return fabs(v1.theta() - v2.theta());
172 }

◆ isValid()

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

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 49 of file TtSemiLepJetCombGeom.cc.

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

49  {
50  auto pOut = std::make_unique<std::vector<std::vector<int>>>();
51  auto pJetsConsidered = std::make_unique<int>(0);
52 
53  std::vector<int> match;
54  for (unsigned int i = 0; i < 4; ++i)
55  match.push_back(-1);
56 
57  // get jets
58  const auto& jets = evt.get(jetsToken_);
59 
60  // get leptons
61  const auto& leps = evt.get(lepsToken_);
62 
63  // skip events without lepton candidate or less than 4 jets
64  if (leps.empty() || jets.size() < 4) {
65  pOut->push_back(match);
66  evt.put(std::move(pOut));
67  *pJetsConsidered = jets.size();
68  evt.put(std::move(pJetsConsidered), "NumberOfConsideredJets");
69  return;
70  }
71 
72  unsigned maxNJets = maxNJets_;
73  if (maxNJets_ == -1 || (int)jets.size() < maxNJets_)
74  maxNJets = jets.size();
75  *pJetsConsidered = maxNJets;
76  evt.put(std::move(pJetsConsidered), "NumberOfConsideredJets");
77 
78  std::vector<bool> isBJet;
79  std::vector<bool> isLJet;
80  int cntBJets = 0;
81  if (useBTagging_) {
82  for (unsigned int idx = 0; idx < maxNJets; ++idx) {
83  isBJet.push_back((jets[idx].bDiscriminator(bTagAlgorithm_) > minBDiscBJets_));
84  isLJet.push_back((jets[idx].bDiscriminator(bTagAlgorithm_) < maxBDiscLightJets_));
85  if (jets[idx].bDiscriminator(bTagAlgorithm_) > minBDiscBJets_)
86  cntBJets++;
87  }
88  }
89 
90  // -----------------------------------------------------
91  // associate those two jets to the hadronic W boson that
92  // have the smallest distance to each other
93  // -----------------------------------------------------
94  double minDist = -1.;
95  int lightQ = -1;
96  int lightQBar = -1;
97  for (unsigned int idx = 0; idx < maxNJets; ++idx) {
98  if (useBTagging_ && (!isLJet[idx] || (cntBJets <= 2 && isBJet[idx])))
99  continue;
100  for (unsigned int jdx = (idx + 1); jdx < maxNJets; ++jdx) {
101  if (useBTagging_ &&
102  (!isLJet[jdx] || (cntBJets <= 2 && isBJet[jdx]) || (cntBJets == 3 && isBJet[idx] && isBJet[jdx])))
103  continue;
104  double dist = distance(jets[idx].p4(), jets[jdx].p4());
105  if (minDist < 0. || dist < minDist) {
106  minDist = dist;
107  lightQ = idx;
108  lightQBar = jdx;
109  }
110  }
111  }
112 
114  if (isValid(lightQ, jets) && isValid(lightQBar, jets))
115  wHad = jets[lightQ].p4() + jets[lightQBar].p4();
116 
117  // -----------------------------------------------------
118  // associate to the hadronic b quark the remaining jet
119  // that has the smallest distance to the hadronic W
120  // -----------------------------------------------------
121  minDist = -1.;
122  int hadB = -1;
123  if (isValid(lightQ, jets) && isValid(lightQBar, jets)) {
124  for (unsigned int idx = 0; idx < maxNJets; ++idx) {
125  if (useBTagging_ && !isBJet[idx])
126  continue;
127  // make sure it's not used up already from the hadronic W
128  if ((int)idx != lightQ && (int)idx != lightQBar) {
129  double dist = distance(jets[idx].p4(), wHad);
130  if (minDist < 0. || dist < minDist) {
131  minDist = dist;
132  hadB = idx;
133  }
134  }
135  }
136  }
137 
138  // -----------------------------------------------------
139  // associate to the leptonic b quark the remaining jet
140  // that has the smallest distance to the leading lepton
141  // -----------------------------------------------------
142  minDist = -1.;
143  int lepB = -1;
144  for (unsigned int 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 ((int)idx != lightQ && (int)idx != lightQBar && (int)idx != hadB) {
149  double dist = distance(jets[idx].p4(), leps[0].p4());
150  if (minDist < 0. || dist < minDist) {
151  minDist = dist;
152  lepB = idx;
153  }
154  }
155  }
156 
161 
162  pOut->push_back(match);
163  evt.put(std::move(pOut));
164 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:347
double distance(const math::XYZTLorentzVector &, const math::XYZTLorentzVector &) const
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
bool isValid(const int idx, const std::vector< pat::Jet > &jets) const
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
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ bTagAlgorithm_

std::string TtSemiLepJetCombGeom::bTagAlgorithm_
private

Definition at line 27 of file TtSemiLepJetCombGeom.cc.

Referenced by produce().

◆ jetsToken_

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

Definition at line 22 of file TtSemiLepJetCombGeom.cc.

Referenced by produce().

◆ lepsToken_

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

Definition at line 23 of file TtSemiLepJetCombGeom.cc.

Referenced by produce().

◆ maxBDiscLightJets_

double TtSemiLepJetCombGeom::maxBDiscLightJets_
private

Definition at line 29 of file TtSemiLepJetCombGeom.cc.

Referenced by produce().

◆ maxNJets_

int TtSemiLepJetCombGeom::maxNJets_
private

Definition at line 24 of file TtSemiLepJetCombGeom.cc.

Referenced by produce(), and TtSemiLepJetCombGeom().

◆ minBDiscBJets_

double TtSemiLepJetCombGeom::minBDiscBJets_
private

Definition at line 28 of file TtSemiLepJetCombGeom.cc.

Referenced by produce().

◆ useBTagging_

bool TtSemiLepJetCombGeom::useBTagging_
private

Definition at line 26 of file TtSemiLepJetCombGeom.cc.

Referenced by produce().

◆ useDeltaR_

bool TtSemiLepJetCombGeom::useDeltaR_
private

Definition at line 25 of file TtSemiLepJetCombGeom.cc.

Referenced by distance().