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 15 of file GenJetClosestMatchSelectorDefinition.h.

Member Typedef Documentation

Definition at line 18 of file GenJetClosestMatchSelectorDefinition.h.

typedef container::const_iterator GenJetClosestMatchSelectorDefinition::const_iterator

Definition at line 21 of file GenJetClosestMatchSelectorDefinition.h.

Definition at line 20 of file GenJetClosestMatchSelectorDefinition.h.

Definition at line 19 of file GenJetClosestMatchSelectorDefinition.h.

Constructor & Destructor Documentation

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

Definition at line 23 of file GenJetClosestMatchSelectorDefinition.h.

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

23  {
24 
26  }
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 28 of file GenJetClosestMatchSelectorDefinition.h.

References selected_.

const_iterator GenJetClosestMatchSelectorDefinition::end ( void  ) const
inline

Definition at line 30 of file GenJetClosestMatchSelectorDefinition.h.

References selected_.

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

Definition at line 32 of file GenJetClosestMatchSelectorDefinition.h.

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

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

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