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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

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

JetPartonMatching::algorithms readAlgorithm (const std::string &str)
 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::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
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

Detailed Description

template<typename C>
class TtJetPartonMatch< C >

Definition at line 44 of file TtJetPartonMatch.h.

Constructor & Destructor Documentation

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

default conructor

Definition at line 84 of file TtJetPartonMatch.h.

85  : partons_(cfg.getParameter<std::vector<std::string> >("partonsToIgnore")),
86  genEvt_(consumes<TtGenEvent>(edm::InputTag("genEvt"))),
88  maxNJets_(cfg.getParameter<int>("maxNJets")),
89  maxNComb_(cfg.getParameter<int>("maxNComb")),
91  useDeltaR_(cfg.getParameter<bool>("useDeltaR")),
92  useMaxDist_(cfg.getParameter<bool>("useMaxDist")),
93  maxDist_(cfg.getParameter<double>("maxDist")),
94  verbosity_(cfg.getParameter<int>("verbosity")) {
95  // produces a vector of jet/lepton indices in the order of
96  // * TtSemiLepEvtPartons
97  // * TtFullHadEvtPartons
98  // * TtFullLepEvtPartons
99  // and vectors of the corresponding quality parameters
100  produces<std::vector<std::vector<int> > >();
101  produces<std::vector<double> >("SumPt");
102  produces<std::vector<double> >("SumDR");
103  produces<int>("NumberOfConsideredJets");
104 }
T getParameter(std::string const &) const
edm::EDGetTokenT< TtGenEvent > genEvt_
TtGenEvent collection input.
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
JetPartonMatching::algorithms readAlgorithm(const std::string &str)
convert string for algorithm into corresponding enumerator type
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
template<typename C >
TtJetPartonMatch< C >::~TtJetPartonMatch ( )
override

default destructor

Definition at line 107 of file TtJetPartonMatch.h.

107 {}

Member Function Documentation

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

write jet parton match objects into the event

Definition at line 110 of file TtJetPartonMatch.h.

References TtJetPartonMatch< C >::algorithm_, TtGenEvtProducer_cfi::genEvt, TtJetPartonMatch< C >::genEvt_, edm::Event::getByToken(), JetPartonMatching::getMatchesForPartons(), JetPartonMatching::getNumberOfAvailableCombinations(), JetPartonMatching::getSumDeltaPt(), JetPartonMatching::getSumDeltaR(), singleTopDQM_cfi::jets, TtJetPartonMatch< C >::jets_, match(), patCandidatesForDimuonsSequences_cff::matches, TtJetPartonMatch< C >::maxDist_, TtJetPartonMatch< C >::maxNComb_, TtJetPartonMatch< C >::maxNJets_, eostools::move(), dqmAnalyzer_cff::partons, TtJetPartonMatch< C >::partons_, JetPartonMatching::print(), edm::Event::put(), TtFullHadEvtBuilder_cfi::sumDR, TtFullHadEvtBuilder_cfi::sumPt, TtJetPartonMatch< C >::useDeltaR_, TtJetPartonMatch< C >::useMaxDist_, and TtJetPartonMatch< C >::verbosity_.

110  {
111  // will write
112  // * parton match
113  // * sumPt
114  // * sumDR
115  // to the event
116  std::unique_ptr<std::vector<std::vector<int> > > match(new std::vector<std::vector<int> >);
117  std::unique_ptr<std::vector<double> > sumPt(new std::vector<double>);
118  std::unique_ptr<std::vector<double> > sumDR(new std::vector<double>);
119  std::unique_ptr<int> pJetsConsidered(new int);
120 
121  // get TtGenEvent and jet collection from the event
123  evt.getByToken(genEvt_, genEvt);
124 
126  evt.getByToken(jets_, topJets);
127 
128  // fill vector of partons in the order of
129  // * TtFullLepEvtPartons
130  // * TtSemiLepEvtPartons
131  // * TtFullHadEvtPartons
132  std::vector<const reco::Candidate*> partons = partons_.vec(*genEvt);
133 
134  // prepare vector of jets
135  std::vector<const reco::Candidate*> jets;
136  for (unsigned int ij = 0; ij < topJets->size(); ++ij) {
137  // take all jets if maxNJets_ == -1; otherwise use
138  // maxNJets_ if maxNJets_ is big enough or use same
139  // number of jets as partons if maxNJets_ < number
140  // of partons
141  if (maxNJets_ != -1) {
142  if (maxNJets_ >= (int)partons.size()) {
143  if ((int)ij == maxNJets_)
144  break;
145  } else {
146  if (ij == partons.size())
147  break;
148  }
149  }
150  jets.push_back((const reco::Candidate*)&(*topJets)[ij]);
151  }
152  *pJetsConsidered = jets.size();
153 
154  // do the matching with specified parameters
155  JetPartonMatching jetPartonMatch(partons, jets, algorithm_, useMaxDist_, useDeltaR_, maxDist_);
156 
157  // print some info for each event
158  // if corresponding verbosity level set
159  if (verbosity_ > 0)
160  jetPartonMatch.print();
161 
162  for (unsigned int ic = 0; ic < jetPartonMatch.getNumberOfAvailableCombinations(); ++ic) {
163  if ((int)ic >= maxNComb_ && maxNComb_ >= 0)
164  break;
165  std::vector<int> matches = jetPartonMatch.getMatchesForPartons(ic);
166  partons_.expand(matches); // insert dummy indices for partons that were chosen to be ignored
167  match->push_back(matches);
168  sumPt->push_back(jetPartonMatch.getSumDeltaPt(ic));
169  sumDR->push_back(jetPartonMatch.getSumDeltaR(ic));
170  }
171  evt.put(std::move(match));
172  evt.put(std::move(sumPt), "SumPt");
173  evt.put(std::move(sumDR), "SumDR");
174  evt.put(std::move(pJetsConsidered), "NumberOfConsideredJets");
175 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
edm::EDGetTokenT< TtGenEvent > genEvt_
TtGenEvent collection input.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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
template<typename C >
JetPartonMatching::algorithms TtJetPartonMatch< C >::readAlgorithm ( const std::string &  str)
private

convert string for algorithm into corresponding enumerator type

Definition at line 178 of file TtJetPartonMatch.h.

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

178  {
179  if (str == "totalMinDist")
181  else if (str == "minSumDist")
183  else if (str == "ptOrderedMinDist")
185  else if (str == "unambiguousOnly")
187  else
188  throw cms::Exception("Configuration") << "Chosen algorithm is not supported: " << str << "\n";
189 }
#define str(s)

Member Data Documentation

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

choice of algorithm

Definition at line 70 of file TtJetPartonMatch.h.

Referenced by TtJetPartonMatch< C >::produce().

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

TtGenEvent collection input.

Definition at line 60 of file TtJetPartonMatch.h.

Referenced by TtJetPartonMatch< C >::produce().

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

jet collection input

Definition at line 62 of file TtJetPartonMatch.h.

Referenced by TtJetPartonMatch< C >::produce().

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

threshold for outliers in the case that useMaxDist_ =true

Definition at line 78 of file TtJetPartonMatch.h.

Referenced by TtJetPartonMatch< C >::produce().

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

maximal number of combinations for which the matching should be stored

Definition at line 68 of file TtJetPartonMatch.h.

Referenced by TtJetPartonMatch< C >::produce().

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

maximal number of jets to be considered for the matching

Definition at line 65 of file TtJetPartonMatch.h.

Referenced by TtJetPartonMatch< C >::produce().

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

partons

Definition at line 58 of file TtJetPartonMatch.h.

Referenced by TtJetPartonMatch< C >::produce().

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

switch to choose between deltaR/deltaTheta matching

Definition at line 72 of file TtJetPartonMatch.h.

Referenced by TtJetPartonMatch< C >::produce().

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

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

Definition at line 75 of file TtJetPartonMatch.h.

Referenced by TtJetPartonMatch< C >::produce().

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

verbosity level

Definition at line 80 of file TtJetPartonMatch.h.

Referenced by TtJetPartonMatch< C >::produce().