Skip to content
Snippets Groups Projects
Commit 48a67276 authored by Stephen A. Wood's avatar Stephen A. Wood
Browse files

Move Compare method from THcHodoscopeHit to ThcRawHit since it should

work for any derived class.
parent 9b720776
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@ Int_t THcHodoscopeHit::GetData(Int_t signal) {
return(-1); // Actually should throw exception
}
#if 0
Int_t THcHodoscopeHit::Compare(const TObject* obj) const
{
// Compare to sort by plane and counter
......@@ -57,6 +58,7 @@ Int_t THcHodoscopeHit::Compare(const TObject* obj) const
else return 1;
}
}
#endif
//_____________________________________________________________________________
THcHodoscopeHit& THcHodoscopeHit::operator=( const THcHodoscopeHit& rhs )
{
......
......@@ -20,8 +20,8 @@ class THcHodoscopeHit : public THcRawHit {
void SetData(Int_t signal, Int_t data);
Int_t GetData(Int_t signal);
virtual Bool_t IsSortable () const {return kTRUE; }
virtual Int_t Compare(const TObject* obj) const;
// virtual Bool_t IsSortable () const {return kTRUE; }
// virtual Int_t Compare(const TObject* obj) const;
Int_t fADC_pos;
Int_t fADC_neg;
......
......@@ -13,6 +13,27 @@
//THcRawHit::~THcRawHit()
//{}
Int_t THcRawHit::Compare(const TObject* obj) const
{
// Compare to sort by plane and counter
const THcRawHit* hit = dynamic_cast<const THcRawHit*>(obj);
if(!hit) return -1;
Int_t p1 = fPlane;
Int_t p2 = hit->fPlane;
if(p1 < p2) return -1;
else if(p1 > p2) return 1;
else {
Int_t c1 = fCounter;
Int_t c2 = hit->fCounter;
if(c1 < c2) return -1;
else if (c1 == c2) return 0;
else return 1;
}
}
ClassImp(THcRawHit)
//_____________________________________________________________________________
......@@ -29,8 +29,10 @@ public:
virtual Int_t GetData(Int_t signal) {return 0;};
// Derived objects must be sortable and supply Compare method
virtual Bool_t IsSortable () const {return kFALSE; }
virtual Int_t Compare(const TObject* obj) const {return 0;}
// virtual Bool_t IsSortable () const {return kFALSE; }
// virtual Int_t Compare(const TObject* obj) const {return 0;}
virtual Bool_t IsSortable () const {return kTRUE; }
virtual Int_t Compare(const TObject* obj) const;
Int_t fPlane;
Int_t fCounter;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment