CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
GenJetClosestMatchSelectorDefinition Struct Reference

#include <GenJetClosestMatchSelectorDefinition.h>

Public Types

typedef reco::GenJetCollection collection
 
typedef container::const_iterator const_iterator
 
typedef std::vector< reco::GenJet * > container
 
typedef edm::Handle< collectionHandleToCollection
 

Public Member Functions

const_iterator begin () const
 
const_iterator end () const
 
 GenJetClosestMatchSelectorDefinition (const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
 
void select (const HandleToCollection &hc, const edm::Event &e, const edm::EventSetup &s)
 
size_t size () const
 

Private Attributes

edm::EDGetTokenT< edm::View< reco::Candidate > > matchTo_
 
container selected_
 

Detailed Description

Definition at line 12 of file GenJetClosestMatchSelectorDefinition.h.

Member Typedef Documentation

Definition at line 15 of file GenJetClosestMatchSelectorDefinition.h.

typedef container::const_iterator GenJetClosestMatchSelectorDefinition::const_iterator

Definition at line 18 of file GenJetClosestMatchSelectorDefinition.h.

Definition at line 17 of file GenJetClosestMatchSelectorDefinition.h.

Definition at line 16 of file GenJetClosestMatchSelectorDefinition.h.

Constructor & Destructor Documentation

GenJetClosestMatchSelectorDefinition::GenJetClosestMatchSelectorDefinition ( const edm::ParameterSet cfg,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 20 of file GenJetClosestMatchSelectorDefinition.h.

References edm::ParameterSet::getParameter(), and matchTo_.

20  {
21 
23  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< reco::Candidate > > matchTo_

Member Function Documentation

const_iterator GenJetClosestMatchSelectorDefinition::begin ( void  ) const
inline

Definition at line 25 of file GenJetClosestMatchSelectorDefinition.h.

References selected_.

const_iterator GenJetClosestMatchSelectorDefinition::end ( void  ) const
inline

Definition at line 27 of file GenJetClosestMatchSelectorDefinition.h.

References selected_.

void GenJetClosestMatchSelectorDefinition::select ( const HandleToCollection hc,
const edm::Event e,
const edm::EventSetup s 
)
inline

Definition at line 29 of file GenJetClosestMatchSelectorDefinition.h.

References reco::deltaR2(), edm::Event::getByToken(), crabWrapper::key, matchTo_, and selected_.

32  {
33 
34  selected_.clear();
35 
37  e.getByToken( matchTo_, matchCandidates);
38 
39 
40  unsigned key=0;
41 
42  // std::cout<<"number of candidates "<<matchCandidates->size()<<std::endl;
43 
45  for( IC ic = matchCandidates->begin();
46  ic!= matchCandidates->end(); ++ic ) {
47 
48  double eta2 = ic->eta();
49  double phi2 = ic->phi();
50 
51  // std::cout<<"cand "<<eta2<<" "<<phi2<<std::endl;
52 
53 
54  // look for the closest gen jet
55  double deltaR2Min = 9999;
56  collection::const_iterator closest = hc->end();
57  for( collection::const_iterator genjet = hc->begin();
58  genjet != hc->end();
59  ++genjet, ++key) {
60 
61  reco::GenJetRef genJetRef(hc, key);
62 
63  // is it matched?
64 
65  double eta1 = genjet->eta();
66  double phi1 = genjet->phi();
67 
68 
69  double deltaR2 = reco::deltaR2(eta1, phi1, eta2, phi2);
70 
71  // std::cout<<" genjet "<<eta1<<" "<<phi1<<" "<<deltaR2<<std::endl;
72 
73  // cut should be a parameter
74  if( deltaR2<deltaR2Min ) {
75  deltaR2Min = deltaR2;
76  closest = genjet;
77  }
78  }
79 
80  if(deltaR2Min<0.01 ) {
81  // std::cout<<deltaR2Min<<std::endl;
82  selected_.push_back( new reco::GenJet(*closest) );
83  }
84  } // end collection iteration
85 
86  // std::cout<<selected_.size()<<std::endl;
87  } // end select()
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
edm::EDGetTokenT< edm::View< reco::Candidate > > matchTo_
Jets made from MC generator particles.
Definition: GenJet.h:24
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
susybsm::HSCParticleCollection hc
Definition: classes.h:25
size_t GenJetClosestMatchSelectorDefinition::size ( void  ) const
inline

Member Data Documentation

edm::EDGetTokenT<edm::View<reco::Candidate> > GenJetClosestMatchSelectorDefinition::matchTo_
private
container GenJetClosestMatchSelectorDefinition::selected_
private

Definition at line 92 of file GenJetClosestMatchSelectorDefinition.h.

Referenced by begin(), end(), select(), and size().