19 #ifndef SortableObject_h 20 #define SortableObject_h 35 #include "TRefArray.h" 47 virtual Bool_t
IsSortable(
const TObject *)
const {
return kTRUE; }
48 virtual Int_t
Compare(
const TObject *obj1,
const TObject *obj2)
const = 0;
57 Bool_t
IsSortable()
const {
return GetCompare() ? GetCompare()->IsSortable(
this) : kFALSE; }
58 Int_t
Compare(
const TObject *obj)
const {
return GetCompare()->Compare(
this, obj); }
60 virtual const CompBase *GetCompare()
const = 0;
80 Int_t
Compare(
const TObject *obj1,
const TObject *obj2)
const 82 auto t1 =
static_cast<const T*
>(obj1);
83 auto t2 =
static_cast<const T*
>(obj2);
86 else if(t1->E < t2->E)
106 Int_t
Compare(
const TObject *obj1,
const TObject *obj2)
const 108 auto t1 =
static_cast<const T*
>(obj1);
109 auto t2 =
static_cast<const T*
>(obj2);
112 else if(t1->PT < t2->PT)
121 template <
typename T>
132 Int_t
Compare(
const TObject *obj1,
const TObject *obj2)
const 134 auto t1 =
static_cast<const T*
>(obj1);
135 auto t2 =
static_cast<const T*
>(obj2);
136 if(t1->Momentum.Pt() > t2->Momentum.Pt())
138 else if(t1->Momentum.Pt() < t2->Momentum.Pt())
147 template <
typename T>
158 Int_t
Compare(
const TObject *obj1,
const TObject *obj2)
const 160 auto t1 =
static_cast<const T*
>(obj1);
161 auto t2 =
static_cast<const T*
>(obj2);
164 else if(t1->ET < t2->ET)
173 template <
typename T1,
typename T2>
178 Double_t DeltaPhi(Double_t phi1, Double_t phi2)
180 auto phi = TMath::Abs(phi1 - phi2);
184 Double_t Sqr(Double_t x) {
return x*x; }
186 Double_t SumSqr(Double_t a, Double_t b)
188 auto aAbs = TMath::Abs(a);
189 auto bAbs = TMath::Abs(b);
190 if(aAbs > bAbs)
return aAbs * TMath::Sqrt(1.0 + Sqr(bAbs / aAbs));
191 else return (bAbs == 0) ? 0.0 : bAbs * TMath::Sqrt(1.0 + Sqr(aAbs / bAbs));
205 Int_t
Compare(
const TObject *obj1,
const TObject *obj2)
const 207 Double_t eta[3], phi[3], deltaR[2];
208 auto t1 =
static_cast<const T1*
>(obj1);
209 auto t2 =
static_cast<const T1*
>(obj2);
220 deltaR[0] = SumSqr(TMath::Abs(eta[0] - eta[1]), DeltaPhi(phi[0], phi[1]));
221 deltaR[1] = SumSqr(TMath::Abs(eta[0] - eta[2]), DeltaPhi(phi[0], phi[2]));
223 if(deltaR[0] < deltaR[1])
225 else if(deltaR[0] > deltaR[1])
236 #endif // SortableObject_h static CompE * Instance()
Definition: SortableObject.h:74
virtual Int_t Compare(const TObject *obj1, const TObject *obj2) const =0
Definition: SortableObject.h:43
static CompDeltaR * Instance(const T2 *obj=0)
Definition: SortableObject.h:197
Bool_t IsSortable() const
Definition: SortableObject.h:57
static CompET * Instance()
Definition: SortableObject.h:152
static CompPT * Instance()
Definition: SortableObject.h:100
virtual ~CompBase()
Definition: SortableObject.h:46
Definition: SortableObject.h:148
Int_t Compare(const TObject *obj1, const TObject *obj2) const
Definition: SortableObject.h:106
static CompMomentumPt * Instance()
Definition: SortableObject.h:126
Int_t Compare(const TObject *obj1, const TObject *obj2) const
Definition: SortableObject.h:80
virtual Bool_t IsSortable(const TObject *) const
Definition: SortableObject.h:47
Int_t Compare(const TObject *obj1, const TObject *obj2) const
Definition: SortableObject.h:158
Definition: SortableObject.h:96
Definition: SortableObject.h:70
Int_t Compare(const TObject *obj1, const TObject *obj2) const
Definition: SortableObject.h:205
void SetObject(const T2 *obj)
Definition: SortableObject.h:203
Definition: SortableObject.h:122
Int_t Compare(const TObject *obj1, const TObject *obj2) const
Definition: SortableObject.h:132
constexpr double Pi()
Constant .
Definition: Si.hh:46
Definition: SortableObject.h:53
Definition: SortableObject.h:174
Int_t Compare(const TObject *obj) const
Definition: SortableObject.h:58