Changes in classes/SortableObject.h [341014c:3c46e17] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
classes/SortableObject.h
r341014c r3c46e17 26 26 */ 27 27 28 #include "TRef.h" 28 29 #include "TObject.h" 29 #include "TRef.h"30 30 #include "TRefArray.h" 31 31 … … 37 37 { 38 38 public: 39 virtual ~CompBase() { }39 virtual ~CompBase() { } 40 40 virtual Bool_t IsSortable(const TObject *) const { return kTRUE; } 41 41 virtual Int_t Compare(const TObject *obj1, const TObject *obj2) const = 0; … … 47 47 { 48 48 public: 49 49 50 Bool_t IsSortable() const { return GetCompare() ? GetCompare()->IsSortable(this) : kFALSE; } 50 51 Int_t Compare(const TObject *obj) const { return GetCompare()->Compare(this, obj); } … … 63 64 { 64 65 CompE() {} 65 66 66 public: 67 67 static CompE *Instance() … … 73 73 Int_t Compare(const TObject *obj1, const TObject *obj2) const 74 74 { 75 const T *t1 = static_cast<const T 76 const T *t2 = static_cast<const T 75 const T *t1 = static_cast<const T*>(obj1); 76 const T *t2 = static_cast<const T*>(obj2); 77 77 if(t1->E > t2->E) 78 78 return -1; … … 90 90 { 91 91 CompPT() {} 92 93 92 public: 94 93 static CompPT *Instance() … … 100 99 Int_t Compare(const TObject *obj1, const TObject *obj2) const 101 100 { 102 const T *t1 = static_cast<const T 103 const T *t2 = static_cast<const T 101 const T *t1 = static_cast<const T*>(obj1); 102 const T *t2 = static_cast<const T*>(obj2); 104 103 if(t1->PT > t2->PT) 105 104 return -1; … … 117 116 { 118 117 CompMomentumPt() {} 119 120 118 public: 121 119 static CompMomentumPt *Instance() … … 127 125 Int_t Compare(const TObject *obj1, const TObject *obj2) const 128 126 { 129 const T *t1 = static_cast<const T 130 const T *t2 = static_cast<const T 127 const T *t1 = static_cast<const T*>(obj1); 128 const T *t2 = static_cast<const T*>(obj2); 131 129 if(t1->Momentum.Pt() > t2->Momentum.Pt()) 132 130 return -1; … … 144 142 { 145 143 CompET() {} 146 147 144 public: 148 145 static CompET *Instance() … … 154 151 Int_t Compare(const TObject *obj1, const TObject *obj2) const 155 152 { 156 const T *t1 = static_cast<const T 157 const T *t2 = static_cast<const T 153 const T *t1 = static_cast<const T*>(obj1); 154 const T *t2 = static_cast<const T*>(obj2); 158 155 if(t1->ET > t2->ET) 159 156 return -1; … … 171 168 { 172 169 CompSumPT2() {} 173 174 170 public: 175 171 static CompSumPT2 *Instance() … … 181 177 Int_t Compare(const TObject *obj1, const TObject *obj2) const 182 178 { 183 const T *t1 = static_cast<const T 184 const T *t2 = static_cast<const T 179 const T *t1 = static_cast<const T*>(obj1); 180 const T *t2 = static_cast<const T*>(obj2); 185 181 if(t1->SumPT2 > t2->SumPT2) 186 182 return -1; … … 197 193 class CompDeltaR: public CompBase 198 194 { 199 CompDeltaR(const T2 *obj = 0) : 200 fObj(obj) {} 195 CompDeltaR(const T2 *obj = 0) : fObj(obj) {} 201 196 202 197 Double_t DeltaPhi(Double_t phi1, Double_t phi2) 203 198 { 204 199 Double_t phi = TMath::Abs(phi1 - phi2); 205 return (phi <= TMath::Pi()) ? phi : (2.0 *TMath::Pi()) - phi;206 } 207 208 Double_t Sqr(Double_t x) { return x *x; }200 return (phi <= TMath::Pi()) ? phi : (2.0*TMath::Pi()) - phi; 201 } 202 203 Double_t Sqr(Double_t x) { return x*x; } 209 204 210 205 Double_t SumSqr(Double_t a, Double_t b) … … 212 207 Double_t aAbs = TMath::Abs(a); 213 208 Double_t bAbs = TMath::Abs(b); 214 if(aAbs > bAbs) 215 return aAbs * TMath::Sqrt(1.0 + Sqr(bAbs / aAbs)); 216 else 217 return (bAbs == 0) ? 0.0 : bAbs * TMath::Sqrt(1.0 + Sqr(aAbs / bAbs)); 209 if(aAbs > bAbs) return aAbs * TMath::Sqrt(1.0 + Sqr(bAbs / aAbs)); 210 else return (bAbs == 0) ? 0.0 : bAbs * TMath::Sqrt(1.0 + Sqr(aAbs / bAbs)); 218 211 }; 219 212 … … 221 214 222 215 public: 223 static CompDeltaR *Instance(const T2 *obj = 0)224 { 225 static CompDeltaR single(obj);226 return &single;216 static CompDeltaR *Instance(const T2 *obj = 0) 217 { 218 static CompDeltaR single(obj); 219 return &single; 227 220 } 228 221 … … 232 225 { 233 226 Double_t eta[3], phi[3], deltaR[2]; 234 const T1 *t1 = static_cast<const T1 235 const T1 *t2 = static_cast<const T1 227 const T1 *t1 = static_cast<const T1*>(obj1); 228 const T1 *t2 = static_cast<const T1*>(obj2); 236 229 237 230 eta[0] = fObj->Eta; … … 257 250 258 251 #endif // SortableObject_h 252 253
Note:
See TracChangeset
for help on using the changeset viewer.