CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CandidateWithRef.h
Go to the documentation of this file.
1 #ifndef Candidate_CandidateWithRef_h
2 #define Candidate_CandidateWithRef_h
3 
14 
15 namespace reco {
16 
17  template<typename Ref>
19  public:
20  typedef Ref reference;
24  CandidateWithRef( const LorentzVector & p4, Charge q = 0, const Point & vtx = Point( 0, 0, 0 ) ) :
25  LeafCandidate( q, p4, vtx ) { }
27  virtual ~CandidateWithRef();
29  virtual CandidateWithRef * clone() const;
31  void setRef( const Ref & r ) { ref_ = r; }
33  reference ref() const { return ref_; }
34 
35  private:
37  virtual bool overlap( const Candidate & ) const;
40  };
41 
42  // the following has to be added for any single Ref type
43  // GET_DEFAULT_CANDIDATE_COMPONENT( CandidateWithRef<Ref>, CandidateWithRef<Ref>::reference, ref )
44 
45  template<typename Ref>
47  }
48 
49  template<typename Ref>
51  return new CandidateWithRef<Ref>( * this );
52  }
53 
54  template<typename Ref>
55  bool CandidateWithRef<Ref>::overlap( const Candidate & c ) const {
56  const CandidateWithRef * o = dynamic_cast<const CandidateWithRef *>( & c );
57  if ( o == 0 ) return false;
58  if ( ref().isNull() ) return false;
59  if ( o->ref().isNull() ) return false;
60  return ( ref() != o->ref() );
61  }
62 
63 }
64 
65 #endif
int Charge
electric charge type
Definition: Candidate.h:37
CandidateWithRef(const LorentzVector &p4, Charge q=0, const Point &vtx=Point(0, 0, 0))
constructor from values
reference ref_
reference to a CaloRecHit
CandidateWithRef()
default constructor
virtual bool overlap(const Candidate &) const
check overlap with another candidate
virtual CandidateWithRef * clone() const
returns a clone of the candidate
virtual ~CandidateWithRef()
destructor
void setRef(const Ref &r)
set reference
reference ref() const
reference
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:39
math::XYZPoint Point
point in the space
Definition: Candidate.h:43
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:29