CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Attributes
TopProjectorFwdPtrOverlap< Top, Bottom > Class Template Reference

This checks a slew of possible overlaps for FwdPtr<Candidate> and derivatives. More...

Public Types

typedef edm::FwdPtr< Bottom > BottomFwdPtr
 
typedef edm::FwdPtr< Top > TopFwdPtr
 

Public Member Functions

bool operator() (TopFwdPtr const &top) const
 
void setBottom (BottomFwdPtr const &bottom)
 
 TopProjectorFwdPtrOverlap ()
 
 TopProjectorFwdPtrOverlap (edm::ParameterSet const &iConfig)
 

Protected Attributes

BottomFwdPtr const * bottom_
 
const bool matchByPtrDirect_ = false
 

Detailed Description

template<class Top, class Bottom>
class TopProjectorFwdPtrOverlap< Top, Bottom >

This checks a slew of possible overlaps for FwdPtr<Candidate> and derivatives.

Definition at line 38 of file TopProjector.cc.

Member Typedef Documentation

◆ BottomFwdPtr

template<class Top , class Bottom >
typedef edm::FwdPtr<Bottom> TopProjectorFwdPtrOverlap< Top, Bottom >::BottomFwdPtr

Definition at line 41 of file TopProjector.cc.

◆ TopFwdPtr

template<class Top , class Bottom >
typedef edm::FwdPtr<Top> TopProjectorFwdPtrOverlap< Top, Bottom >::TopFwdPtr

Definition at line 40 of file TopProjector.cc.

Constructor & Destructor Documentation

◆ TopProjectorFwdPtrOverlap() [1/2]

template<class Top , class Bottom >
TopProjectorFwdPtrOverlap< Top, Bottom >::TopProjectorFwdPtrOverlap ( )
inlineexplicit

Definition at line 43 of file TopProjector.cc.

References TopProjectorFwdPtrOverlap< Top, Bottom >::bottom_.

43 { bottom_ = 0; }
BottomFwdPtr const * bottom_
Definition: TopProjector.cc:97

◆ TopProjectorFwdPtrOverlap() [2/2]

template<class Top , class Bottom >
TopProjectorFwdPtrOverlap< Top, Bottom >::TopProjectorFwdPtrOverlap ( edm::ParameterSet const &  iConfig)
inlineexplicit

Definition at line 45 of file TopProjector.cc.

46  : bottom_(nullptr), matchByPtrDirect_(iConfig.getParameter<bool>("matchByPtrDirect")) {}
BottomFwdPtr const * bottom_
Definition: TopProjector.cc:97

Member Function Documentation

◆ operator()()

template<class Top , class Bottom >
bool TopProjectorFwdPtrOverlap< Top, Bottom >::operator() ( TopFwdPtr const &  top) const
inline

Definition at line 50 of file TopProjector.cc.

References edm::FwdPtr< T >::backPtr(), TopProjectorFwdPtrOverlap< Top, Bottom >::bottom_, edm::Ptr< T >::isAvailable(), edm::Ptr< T >::isNonnull(), edm::Ptr< T >::key(), TopProjectorFwdPtrOverlap< Top, Bottom >::matchByPtrDirect_, muonTagProbeFilters_cff::matched, edm::FwdPtr< T >::ptr(), edm::Ptr< T >::refCore(), reco::Candidate::sourceCandidatePtr(), and relativeConstraints::value.

50  {
52  return top.ptr().refCore() == bottom_->ptr().refCore() && top.ptr().key() == bottom_->ptr().key();
53  bool topFwdGood = top.ptr().isNonnull() && top.ptr().isAvailable();
54  bool topBckGood = top.backPtr().isNonnull() && top.backPtr().isAvailable();
55  bool bottomFwdGood = bottom_->ptr().isNonnull() && bottom_->ptr().isAvailable();
56  bool bottomBckGood = bottom_->backPtr().isNonnull() && bottom_->backPtr().isAvailable();
57 
58  bool matched = (topFwdGood && bottomFwdGood && top.ptr().refCore() == bottom_->ptr().refCore() &&
59  top.ptr().key() == bottom_->ptr().key()) ||
60  (topFwdGood && bottomBckGood && top.ptr().refCore() == bottom_->backPtr().refCore() &&
61  top.ptr().key() == bottom_->backPtr().key()) ||
62  (topBckGood && bottomFwdGood && top.backPtr().refCore() == bottom_->ptr().refCore() &&
63  top.backPtr().key() == bottom_->ptr().key()) ||
64  (topBckGood && bottomBckGood && top.backPtr().refCore() == bottom_->backPtr().refCore() &&
65  top.backPtr().key() == bottom_->backPtr().key());
66  if (!matched) {
67  for (unsigned isource = 0; isource < top->numberOfSourceCandidatePtrs(); ++isource) {
68  reco::CandidatePtr const& topSrcPtr = top->sourceCandidatePtr(isource);
69  bool topSrcGood = topSrcPtr.isNonnull() && topSrcPtr.isAvailable();
70  if ((topSrcGood && bottomFwdGood && topSrcPtr.refCore() == bottom_->ptr().refCore() &&
71  topSrcPtr.key() == bottom_->ptr().key()) ||
72  (topSrcGood && bottomBckGood && topSrcPtr.refCore() == bottom_->backPtr().refCore() &&
73  topSrcPtr.key() == bottom_->backPtr().key())) {
74  matched = true;
75  break;
76  }
77  }
78  }
79  if (!matched) {
80  for (unsigned isource = 0; isource < (*bottom_)->numberOfSourceCandidatePtrs(); ++isource) {
81  reco::CandidatePtr const& bottomSrcPtr = (*bottom_)->sourceCandidatePtr(isource);
82  bool bottomSrcGood = bottomSrcPtr.isNonnull() && bottomSrcPtr.isAvailable();
83  if ((topFwdGood && bottomSrcGood && bottomSrcPtr.refCore() == top.ptr().refCore() &&
84  bottomSrcPtr.key() == top.ptr().key()) ||
85  (topBckGood && bottomSrcGood && bottomSrcPtr.refCore() == top.backPtr().refCore() &&
86  bottomSrcPtr.key() == top.backPtr().key())) {
87  matched = true;
88  break;
89  }
90  }
91  }
92 
93  return matched;
94  }
BottomFwdPtr const * bottom_
Definition: TopProjector.cc:97
bool isAvailable() const
Definition: Ptr.h:234
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:148
Ptr< value_type > const & backPtr() const
Definition: FwdPtr.h:117
RefCore const & refCore() const
Definition: Ptr.h:171
key_type key() const
Definition: Ptr.h:167
Ptr< value_type > const & ptr() const
Definition: FwdPtr.h:116
virtual CandidatePtr sourceCandidatePtr(size_type i) const
Definition: Candidate.h:169

◆ setBottom()

template<class Top , class Bottom >
void TopProjectorFwdPtrOverlap< Top, Bottom >::setBottom ( BottomFwdPtr const &  bottom)
inline

Definition at line 48 of file TopProjector.cc.

References TopProjectorFwdPtrOverlap< Top, Bottom >::bottom_.

48 { bottom_ = &bottom; }
BottomFwdPtr const * bottom_
Definition: TopProjector.cc:97

Member Data Documentation

◆ bottom_

template<class Top , class Bottom >
BottomFwdPtr const* TopProjectorFwdPtrOverlap< Top, Bottom >::bottom_
protected

◆ matchByPtrDirect_

template<class Top , class Bottom >
const bool TopProjectorFwdPtrOverlap< Top, Bottom >::matchByPtrDirect_ = false
protected