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

◆ collection

Definition at line 16 of file GenJetClosestMatchSelectorDefinition.h.

◆ const_iterator

typedef container::const_iterator GenJetClosestMatchSelectorDefinition::const_iterator

Definition at line 19 of file GenJetClosestMatchSelectorDefinition.h.

◆ container

Definition at line 18 of file GenJetClosestMatchSelectorDefinition.h.

◆ HandleToCollection

Definition at line 17 of file GenJetClosestMatchSelectorDefinition.h.

Constructor & Destructor Documentation

◆ GenJetClosestMatchSelectorDefinition()

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

Definition at line 21 of file GenJetClosestMatchSelectorDefinition.h.

References looper::cfg, and matchTo_.

21  {
22  matchTo_ = iC.consumes<edm::View<reco::Candidate>>(cfg.getParameter<edm::InputTag>("MatchTo"));
23  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< reco::Candidate > > matchTo_

Member Function Documentation

◆ begin()

const_iterator GenJetClosestMatchSelectorDefinition::begin ( void  ) const
inline

Definition at line 25 of file GenJetClosestMatchSelectorDefinition.h.

References selected_.

◆ end()

const_iterator GenJetClosestMatchSelectorDefinition::end ( void  ) const
inline

Definition at line 27 of file GenJetClosestMatchSelectorDefinition.h.

References selected_.

◆ select()

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

Definition at line 29 of file GenJetClosestMatchSelectorDefinition.h.

References pv::closest(), reco::deltaR2(), HLTMuonOfflineAnalyzer_cfi::deltaR2, MillePedeFileConverter_cfg::e, HLT_2022v15_cff::eta1, HLT_2022v15_cff::eta2, crabWrapper::key, matchTo_, and selected_.

29  {
30  selected_.clear();
31 
33  e.getByToken(matchTo_, matchCandidates);
34 
35  unsigned key = 0;
36 
37  // std::cout<<"number of candidates
38  // "<<matchCandidates->size()<<std::endl;
39 
41  for (IC ic = matchCandidates->begin(); ic != matchCandidates->end(); ++ic) {
42  double eta2 = ic->eta();
43  double phi2 = ic->phi();
44 
45  // std::cout<<"cand "<<eta2<<" "<<phi2<<std::endl;
46 
47  // look for the closest gen jet
48  double deltaR2Min = 9999;
49  collection::const_iterator closest = hc->end();
50  for (collection::const_iterator genjet = hc->begin(); genjet != hc->end(); ++genjet, ++key) {
51  reco::GenJetRef genJetRef(hc, key);
52 
53  // is it matched?
54 
55  double eta1 = genjet->eta();
56  double phi1 = genjet->phi();
57 
58  double deltaR2 = reco::deltaR2(eta1, phi1, eta2, phi2);
59 
60  // std::cout<<" genjet "<<eta1<<" "<<phi1<<" "<<deltaR2<<std::endl;
61 
62  // cut should be a parameter
63  if (deltaR2 < deltaR2Min) {
64  deltaR2Min = deltaR2;
65  closest = genjet;
66  }
67  }
68 
69  if (deltaR2Min < 0.01) {
70  // std::cout<<deltaR2Min<<std::endl;
71  selected_.push_back(new reco::GenJet(*closest));
72  }
73  } // end collection iteration
74 
75  // std::cout<<selected_.size()<<std::endl;
76  } // end select()
int closest(std::vector< int > const &vec, int value)
edm::EDGetTokenT< edm::View< reco::Candidate > > matchTo_
Jets made from MC generator particles.
Definition: GenJet.h:23
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

◆ size()

size_t GenJetClosestMatchSelectorDefinition::size ( void  ) const
inline

Member Data Documentation

◆ matchTo_

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

◆ selected_

container GenJetClosestMatchSelectorDefinition::selected_
private

Definition at line 81 of file GenJetClosestMatchSelectorDefinition.h.

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