CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TtJetPartonMatch< C > Class Template Reference

#include <TtJetPartonMatch.h>

Inheritance diagram for TtJetPartonMatch< C >:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 write jet parton match objects into the event More...
 
 TtJetPartonMatch (const edm::ParameterSet &)
 default conructor More...
 
- 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
 
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

JetPartonMatching::algorithms readAlgorithm (const std::string &str) const
 convert string for algorithm into corresponding enumerator type More...
 

Private Attributes

JetPartonMatching::algorithms algorithm_
 choice of algorithm More...
 
edm::EDGetTokenT< TtGenEventgenEvt_
 TtGenEvent collection input. More...
 
edm::EDGetTokenT< edm::View< reco::Jet > > jets_
 jet collection input More...
 
double maxDist_
 
int maxNComb_
 
int maxNJets_
 
partons_
 partons More...
 
bool useDeltaR_
 switch to choose between deltaR/deltaTheta matching More...
 
bool useMaxDist_
 
int verbosity_
 verbosity level More...
 

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 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 ()
 
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

template<typename C>
class TtJetPartonMatch< C >

Definition at line 44 of file TtJetPartonMatch.h.

Constructor & Destructor Documentation

◆ TtJetPartonMatch()

template<typename C >
TtJetPartonMatch< C >::TtJetPartonMatch ( const edm::ParameterSet cfg)
explicit

default conructor

Definition at line 82 of file TtJetPartonMatch.h.

83  : partons_(cfg.getParameter<std::vector<std::string>>("partonsToIgnore")),
84  genEvt_(consumes<TtGenEvent>(edm::InputTag("genEvt"))),
85  jets_(consumes<edm::View<reco::Jet>>(cfg.getParameter<edm::InputTag>("jets"))),
86  maxNJets_(cfg.getParameter<int>("maxNJets")),
87  maxNComb_(cfg.getParameter<int>("maxNComb")),
88  algorithm_(readAlgorithm(cfg.getParameter<std::string>("algorithm"))),
89  useDeltaR_(cfg.getParameter<bool>("useDeltaR")),
90  useMaxDist_(cfg.getParameter<bool>("useMaxDist")),
91  maxDist_(cfg.getParameter<double>("maxDist")),
92  verbosity_(cfg.getParameter<int>("verbosity")) {
93  // produces a vector of jet/lepton indices in the order of
94  // * TtSemiLepEvtPartons
95  // * TtFullHadEvtPartons
96  // * TtFullLepEvtPartons
97  // and vectors of the corresponding quality parameters
98  produces<std::vector<std::vector<int>>>();
99  produces<std::vector<double>>("SumPt");
100  produces<std::vector<double>>("SumDR");
101  produces<int>("NumberOfConsideredJets");
102 }
JetPartonMatching::algorithms readAlgorithm(const std::string &str) const
convert string for algorithm into corresponding enumerator type
edm::EDGetTokenT< TtGenEvent > genEvt_
TtGenEvent collection input.
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
bool useDeltaR_
switch to choose between deltaR/deltaTheta matching
JetPartonMatching::algorithms algorithm_
choice of algorithm
edm::EDGetTokenT< edm::View< reco::Jet > > jets_
jet collection input
int verbosity_
verbosity level

Member Function Documentation

◆ produce()

template<typename C >
void TtJetPartonMatch< C >::produce ( edm::StreamID  ,
edm::Event evt,
const edm::EventSetup setup 
) const
overridevirtual

write jet parton match objects into the event

Implements edm::global::EDProducerBase.

Definition at line 105 of file TtJetPartonMatch.h.

References TtGenEvtProducer_cfi::genEvt, edm::Event::get(), JetPartonMatching::getMatchesForPartons(), JetPartonMatching::getNumberOfAvailableCombinations(), JetPartonMatching::getSumDeltaPt(), JetPartonMatching::getSumDeltaR(), PDWG_EXODelayedJetMET_cff::jets, match(), oniaPATMuonsWithTrigger_cff::matches, eostools::move(), dqmAnalyzer_cff::partons, JetPartonMatching::print(), edm::Event::put(), edm::View< T >::size(), TtFullHadEvtBuilder_cfi::sumDR, and TtFullHadEvtBuilder_cfi::sumPt.

105  {
106  // will write
107  // * parton match
108  // * sumPt
109  // * sumDR
110  // to the event
111  auto match = std::make_unique<std::vector<std::vector<int>>>();
112  auto sumPt = std::make_unique<std::vector<double>>();
113  auto sumDR = std::make_unique<std::vector<double>>();
114  std::unique_ptr<int> pJetsConsidered(new int);
115 
116  // get TtGenEvent and jet collection from the event
117  const TtGenEvent& genEvt = evt.get(genEvt_);
118 
119  const edm::View<reco::Jet>& topJets = evt.get(jets_);
120 
121  // fill vector of partons in the order of
122  // * TtFullLepEvtPartons
123  // * TtSemiLepEvtPartons
124  // * TtFullHadEvtPartons
125  std::vector<const reco::Candidate*> partons = partons_.vec(genEvt);
126 
127  // prepare vector of jets
128  std::vector<const reco::Candidate*> jets;
129  for (unsigned int ij = 0; ij < topJets.size(); ++ij) {
130  // take all jets if maxNJets_ == -1; otherwise use
131  // maxNJets_ if maxNJets_ is big enough or use same
132  // number of jets as partons if maxNJets_ < number
133  // of partons
134  if (maxNJets_ != -1) {
135  if (maxNJets_ >= (int)partons.size()) {
136  if ((int)ij == maxNJets_)
137  break;
138  } else {
139  if (ij == partons.size())
140  break;
141  }
142  }
143  jets.push_back(&topJets[ij]);
144  }
145  *pJetsConsidered = jets.size();
146 
147  // do the matching with specified parameters
149 
150  // print some info for each event
151  // if corresponding verbosity level set
152  if (verbosity_ > 0)
153  jetPartonMatch.print();
154 
155  for (unsigned int ic = 0; ic < jetPartonMatch.getNumberOfAvailableCombinations(); ++ic) {
156  if ((int)ic >= maxNComb_ && maxNComb_ >= 0)
157  break;
158  std::vector<int> matches = jetPartonMatch.getMatchesForPartons(ic);
159  partons_.expand(matches); // insert dummy indices for partons that were chosen to be ignored
160  match->push_back(matches);
161  sumPt->push_back(jetPartonMatch.getSumDeltaPt(ic));
162  sumDR->push_back(jetPartonMatch.getSumDeltaR(ic));
163  }
164  evt.put(std::move(match));
165  evt.put(std::move(sumPt), "SumPt");
166  evt.put(std::move(sumDR), "SumDR");
167  evt.put(std::move(pJetsConsidered), "NumberOfConsideredJets");
168 }
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
edm::EDGetTokenT< TtGenEvent > genEvt_
TtGenEvent collection input.
size_type size() const
Class derived from the TopGenEvent for ttbar events.
Definition: TtGenEvent.h:18
bool useDeltaR_
switch to choose between deltaR/deltaTheta matching
JetPartonMatching::algorithms algorithm_
choice of algorithm
edm::EDGetTokenT< edm::View< reco::Jet > > jets_
jet collection input
int verbosity_
verbosity level
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
def move(src, dest)
Definition: eostools.py:511

◆ readAlgorithm()

template<typename C >
JetPartonMatching::algorithms TtJetPartonMatch< C >::readAlgorithm ( const std::string &  str) const
private

convert string for algorithm into corresponding enumerator type

Definition at line 171 of file TtJetPartonMatch.h.

References Exception, JetPartonMatching::minSumDist, JetPartonMatching::ptOrderedMinDist, str, JetPartonMatching::totalMinDist, and JetPartonMatching::unambiguousOnly.

171  {
172  if (str == "totalMinDist")
174  else if (str == "minSumDist")
176  else if (str == "ptOrderedMinDist")
178  else if (str == "unambiguousOnly")
180  else
181  throw cms::Exception("Configuration") << "Chosen algorithm is not supported: " << str << "\n";
182 }
#define str(s)

Member Data Documentation

◆ algorithm_

template<typename C >
JetPartonMatching::algorithms TtJetPartonMatch< C >::algorithm_
private

choice of algorithm

Definition at line 68 of file TtJetPartonMatch.h.

◆ genEvt_

template<typename C >
edm::EDGetTokenT<TtGenEvent> TtJetPartonMatch< C >::genEvt_
private

TtGenEvent collection input.

Definition at line 58 of file TtJetPartonMatch.h.

◆ jets_

template<typename C >
edm::EDGetTokenT<edm::View<reco::Jet> > TtJetPartonMatch< C >::jets_
private

jet collection input

Definition at line 60 of file TtJetPartonMatch.h.

◆ maxDist_

template<typename C >
double TtJetPartonMatch< C >::maxDist_
private

threshold for outliers in the case that useMaxDist_ =true

Definition at line 76 of file TtJetPartonMatch.h.

◆ maxNComb_

template<typename C >
int TtJetPartonMatch< C >::maxNComb_
private

maximal number of combinations for which the matching should be stored

Definition at line 66 of file TtJetPartonMatch.h.

◆ maxNJets_

template<typename C >
int TtJetPartonMatch< C >::maxNJets_
private

maximal number of jets to be considered for the matching

Definition at line 63 of file TtJetPartonMatch.h.

◆ partons_

template<typename C >
C TtJetPartonMatch< C >::partons_
private

partons

Definition at line 56 of file TtJetPartonMatch.h.

◆ useDeltaR_

template<typename C >
bool TtJetPartonMatch< C >::useDeltaR_
private

switch to choose between deltaR/deltaTheta matching

Definition at line 70 of file TtJetPartonMatch.h.

◆ useMaxDist_

template<typename C >
bool TtJetPartonMatch< C >::useMaxDist_
private

switch to choose whether an outlier rejection should be applied or not

Definition at line 73 of file TtJetPartonMatch.h.

◆ verbosity_

template<typename C >
int TtJetPartonMatch< C >::verbosity_
private

verbosity level

Definition at line 78 of file TtJetPartonMatch.h.