Changeset 9318 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 02/11/09 17:35:54 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MLut.cc
r9257 r9318 57 57 } 58 58 59 void MLut::Delete(Option_t *option) 60 { 61 TObjArray::Delete(option); 62 63 fMaxEntries = 0; 64 fMinEntries = 0; 65 66 fMaxIndex = -1; 67 } 68 69 // -------------------------------------------------------------------------- 70 // 71 // Check if it is a default lut which would just map every entry to itself 72 // An empty Lut is a default lut 73 // 74 Bool_t MLut::IsDefault() const 75 { 76 if (IsEmpty()) 77 return kTRUE; 78 79 if (!HasConstantLength() || fMaxEntries!=1) 80 return kFALSE; 81 82 // Loop over all rows 83 for (Int_t y=0; y<GetEntriesFast(); y++) 84 if (GetRow(y)[0]!=y) 85 return kFALSE; 86 87 return kTRUE; 88 } 89 90 // -------------------------------------------------------------------------- 91 // 92 // Setup a default lut which just maps n-entris to themself 93 // 94 void MLut::SetDefault(UInt_t n) 95 { 96 Delete(); 97 98 for (UInt_t y=0; y<n; y++) 99 { 100 101 MArrayI &idx = *new MArrayI(1); 102 idx[0] = y; 103 Add(&idx); 104 } 105 106 fMinEntries = 1; 107 fMaxEntries = 1; 108 109 fMaxIndex = n; 110 } 111 59 112 // -------------------------------------------------------------------------- 60 113 // … … 165 218 MLut *lut = GetInverse(uniq); 166 219 167 Delete(); 220 // Keep fMaxIndex 221 TObjArray::Delete(); 168 222 169 223 for (Int_t i=0; i<=fMaxIndex; i++) … … 188 242 { 189 243 Delete(); 190 191 fMaxIndex = -1;192 fMaxEntries = 0;193 fMinEntries = 0;194 244 195 245 while (1) -
trunk/MagicSoft/Mars/mbase/MLut.h
r9255 r9318 13 13 { 14 14 private: 15 UInt_t fMinEntries; 16 UInt_t fMaxEntries; 15 UInt_t fMinEntries; // The minimum entries per row 16 UInt_t fMaxEntries; // The maximum entries per row 17 17 18 Int_t fMaxIndex; 18 Int_t fMaxIndex; // The maximum index fount in the lut 19 19 20 20 MLut *GetInverse(Bool_t uniq=kTRUE) const; 21 21 22 22 public: 23 MLut() : fMinEntries(0), fMaxEntries(0) { SetOwner(); } 23 MLut() : fMinEntries(0), fMaxEntries(0), fMaxIndex(0) { SetOwner(); } 24 25 // TObjArry 26 void Delete(Option_t *option=""); 24 27 25 28 // MLut Getter 26 29 const MArrayI &GetRow(UInt_t i) const; 30 31 Int_t GetNumRows() const { return GetEntriesFast(); } 27 32 28 33 UInt_t GetMaxEntries() const { return fMaxEntries; } … … 31 36 Bool_t HasConstantLength() const { return fMinEntries==fMaxEntries; } 32 37 Bool_t IsEmpty() const { return fMaxEntries==0; } 38 Bool_t IsDefault() const; 33 39 34 // MLut conver tions40 // MLut conversions 35 41 void SetInverse(const MLut &lut, Bool_t uniq=kTRUE); 36 42 void Invert(Bool_t uniq=kTRUE); 43 44 // Setter 45 void SetDefault(UInt_t n); 37 46 38 47 // MLut I/O
Note:
See TracChangeset
for help on using the changeset viewer.