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::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 ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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::InputTag 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
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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

85  :
86  partons_ (cfg.getParameter<std::vector<std::string> >("partonsToIgnore")),
87  jets_ (cfg.getParameter<edm::InputTag> ("jets" )),
88  maxNJets_ (cfg.getParameter<int> ("maxNJets" )),
89  maxNComb_ (cfg.getParameter<int> ("maxNComb" )),
90  algorithm_ (readAlgorithm(cfg.getParameter<std::string>("algorithm" ))),
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 {
96  // produces a vector of jet/lepton indices in the order of
97  // * TtSemiLepEvtPartons
98  // * TtFullHadEvtPartons
99  // * TtFullLepEvtPartons
100  // and vectors of the corresponding quality parameters
101  produces<std::vector<std::vector<int> > >();
102  produces<std::vector<double> >("SumPt");
103  produces<std::vector<double> >("SumDR");
104  produces<int>("NumberOfConsideredJets");
105 }
T getParameter(std::string const &) const
edm::InputTag jets_
jet collection input
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
int verbosity_
verbosity level
template<typename C >
TtJetPartonMatch< C >::~TtJetPartonMatch ( )

default destructor

Definition at line 108 of file TtJetPartonMatch.h.

109 {
110 }

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

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

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

convert string for algorithm into corresponding enumerator type

Definition at line 182 of file TtJetPartonMatch.h.

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

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

Member Data Documentation

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

choice of algorithm

Definition at line 71 of file TtJetPartonMatch.h.

template<typename C >
edm::InputTag TtJetPartonMatch< C >::jets_
private

jet collection input

Definition at line 63 of file TtJetPartonMatch.h.

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

threshold for outliers in the case that useMaxDist_ =true

Definition at line 79 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 69 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 66 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 73 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 76 of file TtJetPartonMatch.h.

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

verbosity level

Definition at line 81 of file TtJetPartonMatch.h.