FEDRA emulsion software from the OPERA Collaboration
TIndexCell.h
Go to the documentation of this file.
1 #ifndef ROOT_TIndexCell
2 #define ROOT_TIndexCell
3 
5 // //
6 // TIndexCell //
7 // //
8 // sort collection with attributes //
9 // //
11 
12 #include "TObject.h"
13 #include "TString.h"
14 #include "TObjArray.h"
15 
16 
17 
18 //__________________________________________________________________________
19 class TIndexCell : public TObject {
20 
21  friend class TIndexCellIter;
22  friend class TIndexCellIterV;
23 
24  private:
25 
26  Long_t fValue; // hash value
27 
28  TObjArray *fList; // list of TIndexCell's
29 
30  public:
31  TIndexCell():fValue(0) { fList=0; }
32  TIndexCell(Long_t p1):fValue(p1) { fList=0; }
34  ~TIndexCell();
35 
36  Int_t ComparePatterns( Int_t nind, TIndexCell *cin, Int_t srtip=0 );
37  Int_t ComparePatterns( Int_t nind, Long_t vdiff[], TIndexCell *cin, Int_t strip=0 );
38 
39  void Shift( Long_t vshift ) { SetValue( Value()+vshift ); }
40  void Shift( Int_t n, Long_t vshift[] );
41 
42  void Delete();
43 
44  void Drop();
45  void Drop(int i);
46  int DropCouples(int level);
47 
48  //void DropFirst( int level );
49  //void DropLast( int level );
50  void DropButFirst( int level );
51  void DropButLast( int level );
52 
53  Int_t Nlevels() const;
54  Int_t N() const;
55  Int_t N(Int_t level) const;
56 
57  Int_t MinN(Int_t level, Int_t vind[]) const;
58  Int_t MaxN(Int_t level, Int_t vind[]) const;
59  Long_t MinV(Int_t level, Int_t vind[]) const;
60  Long_t MaxV(Int_t level, Int_t vind[]) const;
61 
62  Int_t MinN(Int_t level) const;
63  Int_t MaxN(Int_t level) const;
64  Long_t MinV(Int_t level) const;
65  Long_t MaxV(Int_t level) const;
66 
67  Int_t Add( Int_t narg, Long_t varg[] );
68  Int_t Add( Long_t p1 );
69 
70  TIndexCell *FindAdd( Long_t p1 );
71  TIndexCell *Find( Int_t narg, Long_t varg[] ) const;
72  TIndexCell *Find( Long_t p1 ) const;
73  TIndexCell const *At( Int_t narg, Int_t vind[] ) const;
74  TIndexCell *At( Int_t idx) const
75  { if(fList) return (TIndexCell*)(fList->At(idx));
76  else return 0; }
77 
78  TObjArray *List() const { return fList; }
79  Long_t Value() const { return fValue; }
80  Int_t GetValues(Int_t level, Int_t vind[], Long_t val[] ) const;
81 
82  Int_t GetEntriesFast() const
83  { if(fList) return fList->GetEntriesFast();
84  else return 0; }
85 
86  void SetName(const char *varlist);
87  void SetValue( Long_t p1) { fValue=p1; }
88  void Print(Option_t *) const;
89  void PrintStat() const;
90  void PrintPopulation(int level) const;
91  void Sort(Int_t upto = kMaxInt);
92  void Purge(int level);
93 
94  ULong_t Hash() const { return fValue; }
95  Bool_t IsEqual(const TObject *obj) const
96  { return fValue == ((TIndexCell*)obj)->Value(); }
97  Bool_t IsSortable() const { return kTRUE; }
98  Int_t Compare(const TObject *obj) const
99  { if (fValue > ((TIndexCell*)obj)->Value())
100  return 1;
101  else if (fValue < ((TIndexCell*)obj)->Value())
102  return -1;
103  else
104  return 0; }
105 
106  ClassDef(TIndexCell,1) // sort collection with attributes
107 };
108 
109 //__________________________________________________________________________
110 class TIndexCellIter : public TObject {
111 
112 private:
113 
114  const TIndexCell *fCell; //cell being iterated
115  Int_t *fVind; //current position in array
116  Int_t fLevel0; //level to be iterated on
117  Int_t fLevel; //current level
118  Int_t fPass; //number of cells iterated
119  Bool_t fDirection; //iteration direction
120 
122 
123 public:
124  TIndexCellIter(const TIndexCell *cell,
125  int level,
126  Bool_t dir = kIterForward);
127  //TIndexCellIter(const TIndexCellIter &iter);
128  ~TIndexCellIter();
129  //TIterator &operator=(const TIterator &rhs);
130  //TObjArrayIter &operator=(const TObjArrayIter &rhs);
131 
132  const TIndexCell *GetCell() const { return fCell; }
133  TIndexCell const *Next();
134  void Reset();
135  int LevelDown();
136  void Test();
137 
138  ClassDef(TIndexCellIter,0) // IndexCell iterator
139 };
140 
141 //__________________________________________________________________________
142 class TIndexCellIterV : public TObject {
143 
144 private:
145 
146  const TIndexCell *fCell; // cell being iterated
147  Int_t fLevel0; // level to be iterated on
148  Long_t *fVcent; // central subcell
149  Long_t *fVdiff; // volume to be iterated around Vcent
150 
151  Int_t *fVind; //current position in array
152  Long_t *fVval; //values corresponding to Vind
153  Int_t fLevel; //current level
154  Int_t fPass; //number of cells iterated
155  Bool_t fDirection; //iteration direction
156 
158 
159 public:
160 
161  TIndexCellIterV(const TIndexCell *cell,
162  int level,
163  long vcent[],
164  long vdiff[],
165  Bool_t dir = kIterForward);
166 
168 
169  const TIndexCell *GetCell() const { return fCell; }
170  TIndexCell const *Next();
171  TIndexCell const *NextAll();
172  void Reset();
173  int LevelDown();
174  void Test();
175 
176  ClassDef(TIndexCellIterV,0) // IndexCell volume iterator
177 };
178 
179 #endif /* TIndexCell */
Definition: TIndexCell.h:142
void Test()
Definition: TIndexCell.cpp:835
void Reset()
Definition: TIndexCell.cpp:761
const TIndexCell * fCell
Definition: TIndexCell.h:146
Long_t * fVval
Definition: TIndexCell.h:152
Int_t fLevel0
Definition: TIndexCell.h:147
Int_t fLevel
Definition: TIndexCell.h:153
int LevelDown()
Definition: TIndexCell.cpp:818
TIndexCell const * Next()
Definition: TIndexCell.cpp:773
Int_t * fVind
Definition: TIndexCell.h:151
TIndexCellIterV()
Definition: TIndexCell.h:157
Int_t fPass
Definition: TIndexCell.h:154
Long_t * fVdiff
Definition: TIndexCell.h:149
Long_t * fVcent
Definition: TIndexCell.h:148
Bool_t fDirection
Definition: TIndexCell.h:155
TIndexCell const * NextAll()
Definition: TIndexCell.cpp:794
const TIndexCell * GetCell() const
Definition: TIndexCell.h:169
~TIndexCellIterV()
Definition: TIndexCell.h:167
Definition: TIndexCell.h:110
~TIndexCellIter()
Definition: TIndexCell.cpp:657
int LevelDown()
Definition: TIndexCell.cpp:688
void Test()
Definition: TIndexCell.cpp:718
Int_t fPass
Definition: TIndexCell.h:118
const TIndexCell * fCell
Definition: TIndexCell.h:114
const TIndexCell * GetCell() const
Definition: TIndexCell.h:132
Int_t * fVind
Definition: TIndexCell.h:115
TIndexCell const * Next()
Definition: TIndexCell.cpp:664
Int_t fLevel
Definition: TIndexCell.h:117
Int_t fLevel0
Definition: TIndexCell.h:116
TIndexCellIter()
Definition: TIndexCell.h:121
void Reset()
Definition: TIndexCell.cpp:705
Bool_t fDirection
Definition: TIndexCell.h:119
Definition: TIndexCell.h:19
Bool_t IsSortable() const
Definition: TIndexCell.h:97
Long_t fValue
Definition: TIndexCell.h:26
void DropButLast(int level)
Definition: TIndexCell.cpp:191
TObjArray * fList
Definition: TIndexCell.h:28
void Drop()
Definition: TIndexCell.cpp:237
TObjArray * List() const
Definition: TIndexCell.h:78
Long_t MaxV(Int_t level, Int_t vind[]) const
Definition: TIndexCell.cpp:411
Long_t Value() const
Definition: TIndexCell.h:79
Int_t GetEntriesFast() const
Definition: TIndexCell.h:82
TIndexCell * At(Int_t idx) const
Definition: TIndexCell.h:74
Int_t ComparePatterns(Int_t nind, TIndexCell *cin, Int_t srtip=0)
Definition: TIndexCell.cpp:141
void PrintStat() const
Definition: TIndexCell.cpp:264
Int_t MinN(Int_t level, Int_t vind[]) const
Definition: TIndexCell.cpp:443
TIndexCell const * At(Int_t narg, Int_t vind[]) const
Definition: TIndexCell.cpp:519
void Sort(Int_t upto=kMaxInt)
Definition: TIndexCell.cpp:539
Int_t Nlevels() const
Definition: TIndexCell.cpp:328
TIndexCell * FindAdd(Long_t p1)
Definition: TIndexCell.cpp:575
void SetValue(Long_t p1)
Definition: TIndexCell.h:87
Int_t GetValues(Int_t level, Int_t vind[], Long_t val[]) const
Definition: TIndexCell.cpp:505
Long_t MinV(Int_t level, Int_t vind[]) const
Definition: TIndexCell.cpp:379
TIndexCell(const TIndexCell &c)
TIndexCell * Find(Int_t narg, Long_t varg[]) const
Definition: TIndexCell.cpp:613
Bool_t IsEqual(const TObject *obj) const
Definition: TIndexCell.h:95
void Print(Option_t *) const
Definition: TIndexCell.cpp:292
Int_t Add(Int_t narg, Long_t varg[])
Definition: TIndexCell.cpp:602
Int_t N(Int_t level) const
~TIndexCell()
Definition: TIndexCell.cpp:43
void SetName(const char *varlist)
Definition: TIndexCell.cpp:549
TIndexCell()
Definition: TIndexCell.h:31
ULong_t Hash() const
Definition: TIndexCell.h:94
Int_t N() const
Definition: TIndexCell.cpp:344
void Delete()
Definition: TIndexCell.cpp:49
Int_t MaxN(Int_t level, Int_t vind[]) const
Definition: TIndexCell.cpp:479
void Shift(Long_t vshift)
Definition: TIndexCell.h:39
TIndexCell(Long_t p1)
Definition: TIndexCell.h:32
void PrintPopulation(int level) const
Definition: TIndexCell.cpp:244
int DropCouples(int level)
Definition: TIndexCell.cpp:206
void DropButFirst(int level)
Definition: TIndexCell.cpp:176
Int_t Compare(const TObject *obj) const
Definition: TIndexCell.h:98
void Purge(int level)
Definition: TIndexCell.cpp:306