CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual void produce (edm::Event &, const edm::EventSetup &)
 write jet parton match objects into the event More...
 
 TtJetPartonMatch (const edm::ParameterSet &)
 default conructor More...
 
 ~TtJetPartonMatch ()
 default destructor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
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)
 
- 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 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 87 of file TtJetPartonMatch.h.

87  :
88  partons_ (cfg.getParameter<std::vector<std::string> >("partonsToIgnore")),
89  genEvt_ (consumes<TtGenEvent>(edm::InputTag("genEvt"))),
91  maxNJets_ (cfg.getParameter<int> ("maxNJets" )),
92  maxNComb_ (cfg.getParameter<int> ("maxNComb" )),
93  algorithm_ (readAlgorithm(cfg.getParameter<std::string>("algorithm" ))),
94  useDeltaR_ (cfg.getParameter<bool> ("useDeltaR" )),
95  useMaxDist_(cfg.getParameter<bool> ("useMaxDist" )),
96  maxDist_ (cfg.getParameter<double> ("maxDist" )),
97  verbosity_ (cfg.getParameter<int> ("verbosity" ))
98 {
99  // produces a vector of jet/lepton indices in the order of
100  // * TtSemiLepEvtPartons
101  // * TtFullHadEvtPartons
102  // * TtFullLepEvtPartons
103  // and vectors of the corresponding quality parameters
104  produces<std::vector<std::vector<int> > >();
105  produces<std::vector<double> >("SumPt");
106  produces<std::vector<double> >("SumDR");
107  produces<int>("NumberOfConsideredJets");
108 }
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 ( )

default destructor

Definition at line 111 of file TtJetPartonMatch.h.

112 {
113 }

Member Function Documentation

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

write jet parton match objects into the event

Implements edm::EDProducer.

Definition at line 117 of file TtJetPartonMatch.h.

References TtGenEvtProducer_cfi::genEvt, genEvt_(), edm::Event::getByToken(), JetPartonMatching::getMatchesForPartons(), JetPartonMatching::getNumberOfAvailableCombinations(), JetPartonMatching::getSumDeltaPt(), JetPartonMatching::getSumDeltaR(), fwrapper::jets, match(), matches, JetPartonMatching::print(), and edm::Event::put().

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

convert string for algorithm into corresponding enumerator type

Definition at line 185 of file TtJetPartonMatch.h.

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

186 {
187  if (str == "totalMinDist" ) return JetPartonMatching::totalMinDist;
188  else if(str == "minSumDist" ) return JetPartonMatching::minSumDist;
189  else if(str == "ptOrderedMinDist") return JetPartonMatching::ptOrderedMinDist;
190  else if(str == "unambiguousOnly" ) return JetPartonMatching::unambiguousOnly;
191  else throw cms::Exception("Configuration")
192  << "Chosen algorithm is not supported: " << str << "\n";
193 }

Member Data Documentation

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

choice of algorithm

Definition at line 73 of file TtJetPartonMatch.h.

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

TtGenEvent collection input.

Definition at line 63 of file TtJetPartonMatch.h.

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

jet collection input

Definition at line 65 of file TtJetPartonMatch.h.

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

threshold for outliers in the case that useMaxDist_ =true

Definition at line 81 of file TtJetPartonMatch.h.

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

maximal number of combinations for which the matching should be stored

Definition at line 71 of file TtJetPartonMatch.h.

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

maximal number of jets to be considered for the matching

Definition at line 68 of file TtJetPartonMatch.h.

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

partons

Definition at line 61 of file TtJetPartonMatch.h.

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

switch to choose between deltaR/deltaTheta matching

Definition at line 75 of file TtJetPartonMatch.h.

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

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

Definition at line 78 of file TtJetPartonMatch.h.

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

verbosity level

Definition at line 83 of file TtJetPartonMatch.h.