CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
void select (const HandleToCollection &hc, const edm::Event &e, const edm::EventSetup &s)
 
size_t size () const
 

Private Attributes

edm::InputTag matchTo_
 
container selected_
 

Detailed Description

Definition at line 10 of file GenJetClosestMatchSelectorDefinition.h.

Member Typedef Documentation

Definition at line 13 of file GenJetClosestMatchSelectorDefinition.h.

typedef container::const_iterator GenJetClosestMatchSelectorDefinition::const_iterator

Definition at line 16 of file GenJetClosestMatchSelectorDefinition.h.

Definition at line 15 of file GenJetClosestMatchSelectorDefinition.h.

Definition at line 14 of file GenJetClosestMatchSelectorDefinition.h.

Constructor & Destructor Documentation

GenJetClosestMatchSelectorDefinition::GenJetClosestMatchSelectorDefinition ( const edm::ParameterSet cfg)
inline

Definition at line 18 of file GenJetClosestMatchSelectorDefinition.h.

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

18  {
19 
20  matchTo_ = cfg.getParameter< edm::InputTag >( "MatchTo" );
21  }
T getParameter(std::string const &) const

Member Function Documentation

const_iterator GenJetClosestMatchSelectorDefinition::begin ( void  ) const
inline

Definition at line 23 of file GenJetClosestMatchSelectorDefinition.h.

References selected_.

const_iterator GenJetClosestMatchSelectorDefinition::end ( void  ) const
inline

Definition at line 25 of file GenJetClosestMatchSelectorDefinition.h.

References selected_.

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

Definition at line 27 of file GenJetClosestMatchSelectorDefinition.h.

References reco::deltaR2(), Geom::deltaR2(), edm::Event::getByLabel(), combine::key, matchTo_, and selected_.

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

Definition at line 87 of file GenJetClosestMatchSelectorDefinition.h.

References selected_.

Member Data Documentation

edm::InputTag GenJetClosestMatchSelectorDefinition::matchTo_
private
container GenJetClosestMatchSelectorDefinition::selected_
private

Definition at line 90 of file GenJetClosestMatchSelectorDefinition.h.

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