CMS 3D CMS Logo

CandidateWithRef.h
Go to the documentation of this file.
1 #ifndef Candidate_CandidateWithRef_h
2 #define Candidate_CandidateWithRef_h
3 
15 
16 namespace reco {
17 
18  template<typename Ref>
20  public:
21  typedef Ref reference;
25  CandidateWithRef( const LorentzVector & p4, Charge q = 0, const Point & vtx = Point( 0, 0, 0 ) ) :
26  LeafCandidate( q, p4, vtx ) { }
28  ~CandidateWithRef() override;
30  CandidateWithRef * clone() const override;
32  void setRef( const Ref & r ) { ref_ = r; }
34  reference ref() const { return ref_; }
35 
37 
38  private:
40  bool overlap( const Candidate & ) const override;
42  reference ref_;
43  };
44 
45  // the following has to be added for any single Ref type
46  // GET_DEFAULT_CANDIDATE_COMPONENT( CandidateWithRef<Ref>, CandidateWithRef<Ref>::reference, ref )
47 
48  template<typename Ref>
50  }
51 
52  template<typename Ref>
54  return new CandidateWithRef<Ref>( * this );
55  }
56 
57  template<typename Ref>
58  bool CandidateWithRef<Ref>::overlap( const Candidate & c ) const {
59  const CandidateWithRef * o = dynamic_cast<const CandidateWithRef *>( & c );
60  if ( o == 0 ) return false;
61  if ( ref().isNull() ) return false;
62  if ( o->ref().isNull() ) return false;
63  return ( ref() != o->ref() );
64  }
65 
66 }
67 
68 #endif
int Charge
electric charge type
Definition: Candidate.h:35
CandidateWithRef(const LorentzVector &p4, Charge q=0, const Point &vtx=Point(0, 0, 0))
constructor from values
reference ref_
reference to a CaloRecHit
CandidateWithRef * clone() const override
returns a clone of the candidate
#define CMS_CLASS_VERSION(_version_)
Definition: classes.h:31
CandidateWithRef()
default constructor
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:520
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
~CandidateWithRef() override
destructor
void setRef(const Ref &r)
set reference
reference ref() const
reference
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
bool overlap(const Candidate &) const override
check overlap with another candidate
fixed size matrix
math::XYZPoint Point
point in the space
Definition: Candidate.h:41
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:27