Line data Source code
1 : #ifndef ALITRDSIGNALINDEX_H
2 : #define ALITRDSIGNALINDEX_H
3 :
4 : /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 : * See cxx source for full Copyright notice */
6 :
7 : /* $Id$ */
8 :
9 : #include "TObject.h"
10 :
11 : ////////////////////////////////////////////////////////////////////////////
12 : // //
13 : // General container for data from TRD detector segments //
14 : // Adapted from AliDigits, origin M.Ivanov //
15 : // //
16 : // Author: //
17 : // Mateusz Ploskon (ploskon@ikf.uni-frankfurt.de) //
18 : // //
19 : ////////////////////////////////////////////////////////////////////////////
20 :
21 : class AliTRDSignalIndex : public TObject
22 : {
23 : protected:
24 :
25 : union RowCol{
26 : Short_t rc;
27 : struct{
28 : UChar_t col;
29 : Char_t row;
30 : }s;
31 : };
32 :
33 : public:
34 :
35 : AliTRDSignalIndex();
36 : AliTRDSignalIndex(Int_t nrow, Int_t ncol,Int_t ntime);
37 : AliTRDSignalIndex(const AliTRDSignalIndex &d);
38 : virtual ~AliTRDSignalIndex();
39 : AliTRDSignalIndex &operator=(const AliTRDSignalIndex &d);
40 :
41 : void Copy(TObject &d) const;
42 : void Allocate(const Int_t nrow, const Int_t ncol, const Int_t ntime);
43 :
44 : void Reset();
45 : void ResetContentConditional(const Int_t nrow, const Int_t ncol, const Int_t ntime);
46 : void ResetContent();
47 : void ResetCounters();
48 0 : void ResetTbinCounter() const { };
49 :
50 : void ResetArrays();
51 :
52 : // Store the index row-column as an interesting one
53 : inline void AddIndexRC(const Int_t row, const Int_t col);
54 : // Get the next pad (row and column) and return kTRUE on success
55 : inline Bool_t NextRCIndex(Int_t &row, Int_t &col);
56 : // Get the next timebin of a pad (row and column) and return kTRUE on success
57 : Bool_t NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin);
58 : // Get the next active timebin and return kTRUE on success
59 : Bool_t NextTbinIndex(Int_t &tbin);
60 :
61 : Bool_t CheckSorting(Int_t &row, Int_t &col);
62 :
63 0 : Int_t GetCurrentRow() const { return fCurrRow; }
64 0 : Int_t GetCurrentCol() const { return fCurrCol; }
65 0 : Int_t GetCurrentTbin() const { return fCurrTbin; }
66 :
67 0 : Bool_t IsBoolIndex(Int_t row, Int_t col) const {return fBoolIndex[row*fNcols+col];};
68 : void InitSortedIndex();
69 :
70 : // Clear the array, actually destroy and recreate w/o allocating
71 : void ClearAll();
72 : // Return kTRUE if array allocated and there is no need to call allocate
73 414206 : Bool_t IsAllocated() const { if (!fBoolIndex) return kFALSE;
74 206173 : if (fMaxLimit <= 0) return kFALSE;
75 412966 : else return kTRUE;}
76 :
77 9016 : void SetSM(const Int_t ix) { fSM = ix; }
78 9016 : void SetStack(const Int_t ix) { fStack = ix; }
79 9016 : void SetLayer(const Int_t ix) { fLayer = ix; }
80 9016 : void SetDetNumber(const Int_t ix) { fDet = ix; }
81 :
82 0 : Int_t GetDetNumber() const { return fDet; } // Get Det number
83 752 : Int_t GetLayer() const { return fLayer; } // Layer position of the chamber in TRD
84 752 : Int_t GetStack() const { return fStack; } // Stack position of the chamber in TRD
85 752 : Int_t GetSM() const { return fSM; } // Super module of the TRD
86 0 : Short_t *GetArray() const { return (Short_t*)fSortedIndex; } // Get the array pointer for god knows what reason
87 752 : Int_t GetNoOfIndexes() const { return fCountRC-1; }
88 :
89 4696 : Bool_t HasEntry() const { return fCountRC > 1 ? kTRUE : kFALSE; } // Return status if has an entry
90 :
91 752 : Int_t GetNrow() const { return fNrows; } // Get Nrows
92 752 : Int_t GetNcol() const { return fNcols; } // Get Ncols
93 0 : Int_t GetNtime() const { return fNtbins; } // Get Ntbins
94 :
95 : private:
96 :
97 : Int_t fDet; // Detector number
98 : Int_t fLayer; // Layer position in the full TRD
99 : Int_t fStack; // Stack position in the full TRD
100 : Int_t fSM; // Super module - position in the full TRD
101 :
102 : Bool_t *fBoolIndex; // Indices
103 : RowCol *fSortedIndex; // Sorted indices
104 : Int_t fMaxLimit; // Max number of things in the array
105 : Int_t fPositionRC; // Position in the SortedIndex
106 : Int_t fCountRC; // the number of added rc combinations
107 : Bool_t fSortedWasInit; // Was SortedIndex initialized?
108 :
109 : Int_t fCurrRow; // Last Row read out of SortedIndex
110 : Int_t fCurrCol; // Last Col read out of SortedIndex
111 : Int_t fCurrTbin; // Last outgiven Tbin
112 :
113 : Int_t fNrows; // Number of rows in the chamber
114 : Int_t fNcols; // Number of cols in the chamber
115 : Int_t fNtbins; // Number of tbins in the chamber
116 :
117 48 : ClassDef(AliTRDSignalIndex,2) // Data container for one TRD detector segment
118 :
119 : };
120 :
121 : void AliTRDSignalIndex::AddIndexRC(const Int_t row, const Int_t col)
122 : {
123 : //
124 : // Adds RC combination to array
125 : //
126 :
127 187948 : const Int_t num=row*fNcols+col;
128 181282 : if(fBoolIndex[num])return;
129 6666 : fBoolIndex[num]=kTRUE;
130 6666 : fSortedIndex[fCountRC].s.col=col;
131 6666 : fSortedIndex[fCountRC].s.row=row;
132 6666 : fCountRC++;
133 100640 : }
134 :
135 : Bool_t AliTRDSignalIndex::NextRCIndex(Int_t &row, Int_t &col)
136 : {
137 : //
138 : // Returns next used RC combination
139 : //
140 :
141 401826 : if (!IsAllocated())
142 0 : return kFALSE;
143 :
144 200913 : if(fSortedIndex[fPositionRC].rc>-1){
145 189687 : row = fCurrRow = fSortedIndex[fPositionRC].s.row;
146 189687 : col = fCurrCol = fSortedIndex[fPositionRC].s.col;
147 189687 : fPositionRC++;
148 189687 : return kTRUE;
149 : }
150 : else
151 11226 : return CheckSorting(row, col);
152 200913 : }
153 :
154 : #endif
155 :
156 : /*
157 : Comment from 22 Dec 2008
158 :
159 : The structure of the Index was changed. Now no Tbin is saved anymore,
160 : only RC combination are saved! (reasons see below)
161 :
162 : For the readout, all tbins for a RC combination must be read out to find
163 : the time bin of signal > 0.
164 :
165 : THE WRITING PROCEDURE:
166 : AddIndexTBin is now obsolate, use AddIndexRC instead as AddIndexTBin will
167 : be deleted in future.
168 :
169 : example that gives exactely the same output as before:
170 : as it was:
171 : AliTRDSignalIndexes *indexes;
172 : AliTRDarrayADC *Signal; //or AliTRDarraySignal *Signal;
173 : if(Signal->GetDataB(row, col, time)>0)
174 : indexes->AddIndexTBin(row, col, time);
175 :
176 : as it should be from no on:
177 : AliTRDSignalIndexes *indexes;
178 : AliTRDarrayADC *Signal; //or AliTRDarraySignal *Signal;
179 : if(Signal->GetDataB(row, col, time)>0)
180 : indexes->AddIndexRC(row, col);
181 :
182 :
183 :
184 : THE READING PROCEDURE:
185 : In most cases you can leave anything as it is.
186 : See more in the example.
187 :
188 : example:
189 : as it was:
190 : AliTRDSignalIndexes *indexes;
191 : AliTRDarraySignal *Signal;
192 : while(indexes->NextRCTbinIndex(row, col, time))
193 : {...}
194 :
195 : as it should be from no on to get the exactely the same output as before:
196 : AliTRDSignalIndexes *indexes;
197 : AliTRDarraySignal *Signal;
198 : while(indexes->NextRCTbinIndex(row, col, time))
199 : if(Signal->GetData(row, col, time)>0)
200 : {...}
201 :
202 : as it should be idealy:
203 : AliTRDSignalIndexes *indexes;
204 : AliTRDarraySignal *Signal;
205 : for(time = 0; time < Ntime; time++)
206 : while(indexes->NextRCIndex(row, col, time))
207 : if(Signal->GetData(row, col, time)>0)
208 : {...}
209 :
210 :
211 : REASON OF THE CHANGES:
212 :
213 : The array saved the information nicely, but it turned out that sorting
214 : the array by column would have many benefits.
215 : I.e. it is crucial for fivePadClusters and it if much faster to allocate.
216 : But the sorting is not fast if the tbin is also saved.
217 : Moreover the tbin information was alsmost useless because,
218 : whenever an RC index existed, many of the possible tbins where used.
219 :
220 : Theodor Rascanu
221 :
222 : */
|