FEDRA emulsion software from the OPERA Collaboration
TIndexCell.h
Go to the documentation of this file.
1#ifndef ROOT_TIndexCell
2#define ROOT_TIndexCell
5
11
12#include "TObject.h"
13#include "TString.h"
14#include "TObjArray.h"
15
16
17
19class TIndexCell : public TObject {
20
21 friend class TIndexCellIter;
22 friend class TIndexCellIterV;
23
24 private:
25
26 Long_t fValue;
27
28 TObjArray *fList;
29
30 public:
32 TIndexCell(Long_t p1):fValue(p1) { fList=0; }
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 GetEntries() 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
110class TIndexCellIter : public TObject {
111
112private:
113
115 Int_t *fVind;
116 Int_t fLevel0;
117 Int_t fLevel;
118 Int_t fPass;
119 Bool_t fDirection;
120
122
123public:
124 TIndexCellIter(const TIndexCell *cell,
125 int level,
126 Bool_t dir = kIterForward);
127 //TIndexCellIter(const TIndexCellIter &iter);
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
142class TIndexCellIterV : public TObject {
143
144private:
145
147 Int_t fLevel0;
148 Long_t *fVcent;
149 Long_t *fVdiff;
150
151 Int_t *fVind;
152 Long_t *fVval;
153 Int_t fLevel;
154 Int_t fPass;
155 Bool_t fDirection;
156
158
159public:
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 */
IndexCell volume iterator.
Definition: TIndexCell.h:142
void Test()
Definition: TIndexCell.cpp:835
void Reset()
Definition: TIndexCell.cpp:761
const TIndexCell * fCell
cell being iterated
Definition: TIndexCell.h:146
Long_t * fVval
values corresponding to Vind
Definition: TIndexCell.h:152
const TIndexCell * GetCell() const
Definition: TIndexCell.h:169
Int_t fLevel0
level to be iterated on
Definition: TIndexCell.h:147
Int_t fLevel
current level
Definition: TIndexCell.h:153
int LevelDown()
Definition: TIndexCell.cpp:818
TIndexCell const * Next()
Definition: TIndexCell.cpp:773
Int_t * fVind
current position in array
Definition: TIndexCell.h:151
TIndexCellIterV()
Definition: TIndexCell.h:157
Int_t fPass
number of cells iterated
Definition: TIndexCell.h:154
Long_t * fVdiff
volume to be iterated around Vcent
Definition: TIndexCell.h:149
Long_t * fVcent
central subcell
Definition: TIndexCell.h:148
Bool_t fDirection
iteration direction
Definition: TIndexCell.h:155
TIndexCell const * NextAll()
Definition: TIndexCell.cpp:794
~TIndexCellIterV()
Definition: TIndexCell.h:167
IndexCell iterator.
Definition: TIndexCell.h:110
~TIndexCellIter()
Definition: TIndexCell.cpp:657
int LevelDown()
Definition: TIndexCell.cpp:688
void Test()
Definition: TIndexCell.cpp:718
Int_t fPass
number of cells iterated
Definition: TIndexCell.h:118
const TIndexCell * GetCell() const
Definition: TIndexCell.h:132
const TIndexCell * fCell
cell being iterated
Definition: TIndexCell.h:114
Int_t * fVind
current position in array
Definition: TIndexCell.h:115
TIndexCell const * Next()
Definition: TIndexCell.cpp:664
Int_t fLevel
current level
Definition: TIndexCell.h:117
Int_t fLevel0
level to be iterated on
Definition: TIndexCell.h:116
TIndexCellIter()
Definition: TIndexCell.h:121
void Reset()
Definition: TIndexCell.cpp:705
Bool_t fDirection
iteration direction
Definition: TIndexCell.h:119
sort collection with attributes
Definition: TIndexCell.h:19
Bool_t IsSortable() const
Definition: TIndexCell.h:97
Long_t fValue
hash value
Definition: TIndexCell.h:26
void DropButLast(int level)
Definition: TIndexCell.cpp:191
TObjArray * fList
list of TIndexCell's
Definition: TIndexCell.h:28
void Drop()
Definition: TIndexCell.cpp:237
Long_t MaxV(Int_t level, Int_t vind[]) const
Definition: TIndexCell.cpp:411
Long_t Value() const
Definition: TIndexCell.h:79
Int_t GetEntries() const
Definition: TIndexCell.h:82
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 * At(Int_t idx) const
Definition: TIndexCell.h:74
~TIndexCell()
Definition: TIndexCell.cpp:43
TObjArray * List() const
Definition: TIndexCell.h:78
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