adding the date to the comment and other updates
[u/mrichter/AliRoot.git] / TRD / AliTRDSignalIndex.h
CommitLineData
ffc57435 1#ifndef ALITRDSIGNALINDEX_H
2#define ALITRDSIGNALINDEX_H
ca21baaa 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
c8ab4518 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////////////////////////////////////////////////////////////////////////////
ca21baaa 20
ca21baaa 21class AliTRDSignalIndex : public TObject
22{
534529cb 23protected:
c8ab4518 24
534529cb 25 union RowCol{
26 Short_t rc;
27 struct{
28 UChar_t col;
29 Char_t row;
30 }s;
31 };
32
33public:
ca21baaa 34
35 AliTRDSignalIndex();
36 AliTRDSignalIndex(Int_t nrow, Int_t ncol,Int_t ntime);
37 AliTRDSignalIndex(const AliTRDSignalIndex &d);
c8ab4518 38 virtual ~AliTRDSignalIndex();
ca21baaa 39 AliTRDSignalIndex &operator=(const AliTRDSignalIndex &d);
ca21baaa 40
e484a267 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();
ffc57435 48 void ResetTbinCounter() const { };
e484a267 49
50 void ResetArrays();
51
534529cb 52 // Store the index row-column as an interesting one
53 void AddIndexRC(const Int_t row, const Int_t col){
54 Int_t num=row*fNcols+col;
55 if(fBoolIndex[num])return;
56 fBoolIndex[num]=kTRUE;
57 fSortedIndex[fCountRC].s.col=col;
58 fSortedIndex[fCountRC].s.row=row;
59 fCountRC++;
60 };
e484a267 61
62 // Get the next pad (row and column) and return kTRUE on success
63 Bool_t NextRCIndex(Int_t &row, Int_t &col);
64 // Get the next timebin of a pad (row and column) and return kTRUE on success
65 Bool_t NextRCTbinIndex(Int_t &row, Int_t &col, Int_t &tbin);
66 // Get the next active timebin and return kTRUE on success
67 Bool_t NextTbinIndex(Int_t &tbin);
68
69 Int_t GetCurrentRow() const { return fCurrRow; }
70 Int_t GetCurrentCol() const { return fCurrCol; }
71 Int_t GetCurrentTbin() const { return fCurrTbin; }
72
73 Bool_t IsBoolIndex(Int_t row, Int_t col) const {return fBoolIndex[row*fNcols+col];};
74 void InitSortedIndex();
75
76 // Clear the array, actually destroy and recreate w/o allocating
77 void ClearAll();
78 // Return kTRUE if array allocated and there is no need to call allocate
79 Bool_t IsAllocated() const { if (!fBoolIndex) return kFALSE;
80 if (fMaxLimit <= 0) return kFALSE;
81 else return kTRUE;}
82
83 void SetSM(const Int_t ix) { fSM = ix; }
84 void SetStack(const Int_t ix) { fStack = ix; }
85 void SetLayer(const Int_t ix) { fLayer = ix; }
86 void SetDetNumber(const Int_t ix) { fDet = ix; }
c8ab4518 87
e484a267 88 Int_t GetDetNumber() const { return fDet; } // Get Det number
89 Int_t GetLayer() const { return fLayer; } // Layer position of the chamber in TRD
90 Int_t GetStack() const { return fStack; } // Stack position of the chamber in TRD
91 Int_t GetSM() const { return fSM; } // Super module of the TRD
534529cb 92 Short_t *GetArray() const { return (Short_t*)fSortedIndex; } // Get the array pointer for god knows what reason
93 Int_t GetNoOfIndexes() const { return fCountRC-1; }
ca21baaa 94
534529cb 95 Bool_t HasEntry() const { return fCountRC > 1 ? kTRUE : kFALSE; } // Return status if has an entry
ca21baaa 96
e484a267 97 Int_t GetNrow() const { return fNrows; } // Get Nrows
98 Int_t GetNcol() const { return fNcols; } // Get Ncols
99 Int_t GetNtime() const { return fNtbins; } // Get Ntbins
ca21baaa 100
c8ab4518 101 private:
ca21baaa 102
c8ab4518 103 Int_t fDet; // Detector number
053767a4 104 Int_t fLayer; // Layer position in the full TRD
105 Int_t fStack; // Stack position in the full TRD
c8ab4518 106 Int_t fSM; // Super module - position in the full TRD
ca21baaa 107
ffc57435 108 Bool_t *fBoolIndex; // Indices
534529cb 109 RowCol *fSortedIndex; // Sorted indices
064d808d 110 Int_t fMaxLimit; // Max number of things in the array
111 Int_t fPositionRC; // Position in the SortedIndex
534529cb 112 Int_t fCountRC; // the number of added rc combinations
064d808d 113 Bool_t fSortedWasInit; // Was SortedIndex initialized?
ca21baaa 114
064d808d 115 Int_t fCurrRow; // Last Row read out of SortedIndex
116 Int_t fCurrCol; // Last Col read out of SortedIndex
117 Int_t fCurrTbin; // Last outgiven Tbin
118
c8ab4518 119 Int_t fNrows; // Number of rows in the chamber
120 Int_t fNcols; // Number of cols in the chamber
534529cb 121 Int_t fNtbins; // Number of tbins in the chamber
ca21baaa 122
c8ab4518 123 ClassDef(AliTRDSignalIndex,2) // Data container for one TRD detector segment
ca21baaa 124
125};
ca21baaa 126#endif
064d808d 127
128/*
129Comment from 22 Dec 2008
130
131The structure of the Index was changed. Now no Tbin is saved anymore,
132only RC combination are saved! (reasons see below)
133
134For the readout, all tbins for a RC combination must be read out to find
135the time bin of signal > 0.
136
137THE WRITING PROCEDURE:
138AddIndexTBin is now obsolate, use AddIndexRC instead as AddIndexTBin will
139be deleted in future.
140
141example that gives exactely the same output as before:
142as it was:
143 AliTRDSignalIndexes *indexes;
144 AliTRDarrayADC *Signal; //or AliTRDarraySignal *Signal;
145 if(Signal->GetDataB(row, col, time)>0)
146 indexes->AddIndexTBin(row, col, time);
147
148as it should be from no on:
149 AliTRDSignalIndexes *indexes;
150 AliTRDarrayADC *Signal; //or AliTRDarraySignal *Signal;
151 if(Signal->GetDataB(row, col, time)>0)
152 indexes->AddIndexRC(row, col);
153
154
155
156THE READING PROCEDURE:
157In most cases you can leave anything as it is.
158See more in the example.
159
160example:
161as it was:
162 AliTRDSignalIndexes *indexes;
163 AliTRDarraySignal *Signal;
164 while(indexes->NextRCTbinIndex(row, col, time))
165 {...}
166
167as it should be from no on to get the exactely the same output as before:
168 AliTRDSignalIndexes *indexes;
169 AliTRDarraySignal *Signal;
170 while(indexes->NextRCTbinIndex(row, col, time))
171 if(Signal->GetData(row, col, time)>0)
172 {...}
173
174as it should be idealy:
175 AliTRDSignalIndexes *indexes;
176 AliTRDarraySignal *Signal;
177 for(time = 0; time < Ntime; time++)
178 while(indexes->NextRCIndex(row, col, time))
179 if(Signal->GetData(row, col, time)>0)
180 {...}
181
182
183REASON OF THE CHANGES:
184
185The array saved the information nicely, but it turned out that sorting
186the array by column would have many benefits.
187I.e. it is crucial for fivePadClusters and it if much faster to allocate.
188But the sorting is not fast if the tbin is also saved.
189Moreover the tbin information was alsmost useless because,
190whenever an RC index existed, many of the possible tbins where used.
191
192Theodor Rascanu
193
194*/