]>
Commit | Line | Data |
---|---|---|
3e87ef69 | 1 | // @(#) $Id$ |
2 | ||
4499ed26 | 3 | #ifndef ALIL3_MEMHANDLER_H |
4 | #define ALIL3_MEMHANDLER_H | |
108615fc | 5 | |
d2fd868a | 6 | #include "AliL3RootTypes.h" |
108615fc | 7 | #include "AliL3DigitData.h" |
494fad94 | 8 | |
108615fc | 9 | class AliL3SpacePointData; |
10 | class AliL3DigitRowData; | |
11 | class AliL3TrackSegmentData; | |
12 | class AliL3TrackArray; | |
13 | class AliL3RandomPointData; | |
14 | ||
de3c3890 | 15 | #ifdef use_newio |
16 | class AliRunLoader; | |
17 | #endif | |
18 | ||
b1ed0288 | 19 | class AliL3MemHandler { |
108615fc | 20 | private: |
b25c64e5 | 21 | |
108615fc | 22 | Byte_t *fPt;//! |
b1ed0288 | 23 | UInt_t fSize; //size of allocated data structure |
108615fc | 24 | |
25 | AliL3RandomDigitData **fDPt;//! | |
b1ed0288 | 26 | AliL3RandomDigitData *fRandomDigits;//! |
27 | Bool_t fIsRandom; //random data generated | |
28 | Int_t fNRandom; //count random digits | |
29 | Int_t fNGenerate; //count generated digits | |
30 | Int_t fNUsed; //count used digits | |
31 | Int_t fNDigits; //count digits from digitstree | |
32 | ||
33 | void Write(UInt_t *comp, UInt_t & index, UInt_t & subindex, UShort_t value) const; | |
34 | UShort_t Read(UInt_t *comp, UInt_t & index, UInt_t & subindex) const; | |
35 | UShort_t Test(UInt_t *comp, UInt_t index, UInt_t subindex) const; | |
108615fc | 36 | |
37 | void DigitizePoint(Int_t row,Int_t pad, Int_t time,Int_t charge); | |
38 | void QSort(AliL3RandomDigitData **a, Int_t first, Int_t last); | |
b1ed0288 | 39 | Int_t ComparePoints(UInt_t row,UShort_t pad,UShort_t time) const ; |
40 | Int_t CompareDigits(AliL3RandomDigitData *a,AliL3RandomDigitData *b) const; | |
108615fc | 41 | void AddData(AliL3DigitData *data,UInt_t & ndata, |
b1ed0288 | 42 | UInt_t row,UShort_t pad,UShort_t time,UShort_t charge) const; |
108615fc | 43 | void AddRandom(AliL3DigitData *data,UInt_t & ndata); |
44 | void MergeDataRandom(AliL3DigitData *data,UInt_t & ndata, | |
45 | UInt_t row,UShort_t pad,UShort_t time,UShort_t charge); | |
46 | void AddDataRandom(AliL3DigitData *data,UInt_t & ndata, | |
47 | UInt_t row,UShort_t pad,UShort_t time,UShort_t charge); | |
48 | ||
49 | protected: | |
b1ed0288 | 50 | Int_t fRowMin; //min row |
51 | Int_t fRowMax; //max row | |
52 | Int_t fSlice; //slice | |
53 | Int_t fPatch; //patch | |
108615fc | 54 | |
3e87ef69 | 55 | Int_t fEtaMinTimeBin[159]; //for ROI in eta only |
b1ed0288 | 56 | Int_t fEtaMaxTimeBin[159]; //for ROI in eta only |
256c7399 | 57 | |
58 | FILE *fInBinary;//! | |
59 | FILE *fOutBinary;//! | |
60 | ||
108615fc | 61 | public: |
62 | AliL3MemHandler(); | |
63 | virtual ~AliL3MemHandler(); | |
64 | ||
65 | void Reset(){CloseBinaryInput();CloseBinaryOutput();Free();} | |
eeddc64d | 66 | void Init(Int_t s,Int_t p, Int_t *r=0); |
108615fc | 67 | |
68 | Bool_t SetBinaryInput(char *name); | |
69 | Bool_t SetBinaryInput(FILE *file); | |
70 | void CloseBinaryInput(); | |
71 | ||
72 | Bool_t SetBinaryOutput(char *name); | |
73 | Bool_t SetBinaryOutput(FILE *file); | |
74 | void CloseBinaryOutput(); | |
75 | ||
76 | //Random cluster | |
77 | void SetRandomCluster(Int_t maxnumber); | |
78 | void SetRandomSeed(UInt_t seed){srand(seed);} | |
79 | void SetRandomSeed(); | |
80 | ||
81 | void ResetRandom(){fNDigits = 0; fNUsed = 0;} | |
82 | void Generate(Int_t row); | |
83 | void SetNGenerate(Int_t number){(number>fNRandom)?fNGenerate=fNRandom:fNGenerate = number;} | |
84 | ||
85 | void SetROI(Float_t *eta,Int_t *slice); | |
86 | void ResetROI(); | |
87 | ||
88 | //Digit IO | |
89 | Bool_t Memory2Binary(UInt_t nrow,AliL3DigitRowData *data); | |
90 | Bool_t Binary2Memory(UInt_t & nrow,AliL3DigitRowData *data); | |
91 | ||
92 | Int_t Memory2CompMemory(UInt_t nrow,AliL3DigitRowData *data,UInt_t *comp); | |
93 | Int_t CompMemory2Memory(UInt_t nrow,AliL3DigitRowData *data,UInt_t *comp); | |
94 | Bool_t CompMemory2CompBinary(UInt_t nrow,UInt_t *comp, UInt_t size=0); | |
95 | Bool_t CompBinary2CompMemory(UInt_t & nrow,UInt_t *comp); | |
96 | ||
256c7399 | 97 | virtual AliL3DigitRowData *CompBinary2Memory(UInt_t & nrow); |
98 | virtual Bool_t Memory2CompBinary(UInt_t nrow,AliL3DigitRowData *data); | |
99 | ||
108615fc | 100 | UInt_t GetNRow(UInt_t *comp,UInt_t size); |
101 | ||
102 | //Point IO | |
103 | Bool_t Memory2Binary(UInt_t npoint,AliL3SpacePointData *data); | |
104 | Bool_t Binary2Memory(UInt_t & npoint,AliL3SpacePointData *data); | |
c51c6aaa | 105 | Bool_t Transform(UInt_t npoint,AliL3SpacePointData *data,Int_t slice); |
a830c5a6 | 106 | static void UpdateRowPointer(AliL3DigitRowData *&tempPt); |
9bd4d591 | 107 | |
108615fc | 108 | //Track IO |
109 | Bool_t Memory2Binary(UInt_t ntrack,AliL3TrackSegmentData *data); | |
110 | Bool_t Binary2Memory(UInt_t & ntrack,AliL3TrackSegmentData *data); | |
111 | Bool_t TrackArray2Binary(AliL3TrackArray *array); | |
112 | Bool_t Binary2TrackArray(AliL3TrackArray *array); | |
b1ed0288 | 113 | Bool_t TrackArray2Memory(UInt_t & ntrack,AliL3TrackSegmentData *data,AliL3TrackArray *array) const; |
114 | Bool_t Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *data,AliL3TrackArray *array) const; | |
115 | Bool_t Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *data,AliL3TrackArray *array,Int_t slice) const; | |
4499ed26 | 116 | |
108615fc | 117 | //Memory Allocation |
b1ed0288 | 118 | UInt_t GetAllocatedSize() const {return fSize;} |
108615fc | 119 | UInt_t GetFileSize(); |
b1ed0288 | 120 | UInt_t GetMemorySize(UInt_t nrow,UInt_t *comp) const; |
121 | UInt_t GetCompMemorySize(UInt_t nrow,AliL3DigitRowData *data) const; | |
122 | UInt_t GetRandomSize() const; | |
108615fc | 123 | |
124 | Byte_t *Allocate(UInt_t size); | |
125 | Byte_t *Allocate(); // allocate size of Binary Input File | |
126 | Byte_t *Allocate(AliL3TrackArray *array); | |
b661165c | 127 | Byte_t *GetDataPointer(UInt_t &size) {size = fSize; return fPt;} |
3e87ef69 | 128 | FILE *GetFilePointer() {return fInBinary;} |
108615fc | 129 | void Free(); |
130 | ||
f8bc0cc9 | 131 | //Getters: |
b1ed0288 | 132 | Int_t GetRowMin() const {return fRowMin;} |
133 | Int_t GetRowMax() const {return fRowMax;} | |
134 | Int_t GetSlice() const {return fSlice;} | |
135 | Int_t GetPatch() const {return fPatch;} | |
f8bc0cc9 | 136 | |
137 | //virtual functions: | |
a815f9dd | 138 | virtual void FreeDigitsTree() {return;} |
dd7d3870 | 139 | virtual Bool_t SetAliInput(char */*name*/){return 0;} |
de3c3890 | 140 | #ifdef use_newio |
141 | virtual Bool_t SetAliInput(AliRunLoader */*runloader*/){return 0;} | |
142 | #endif | |
f8bc0cc9 | 143 | virtual void CloseAliInput(){return;} |
dd7d3870 | 144 | virtual Bool_t IsDigit(Int_t /*i*/=0){return 0;} |
145 | virtual Bool_t SetMCOutput(char */*name*/){return 0;} | |
146 | virtual Bool_t SetMCOutput(FILE */*file*/){return 0;} | |
f8bc0cc9 | 147 | virtual void CloseMCOutput(){return;} |
dd7d3870 | 148 | virtual Bool_t AliDigits2Binary(Int_t /*event*/=0,Bool_t /*altro*/=kFALSE){return 0;} |
149 | virtual Bool_t AliDigits2CompBinary(Int_t /*event*/=0,Bool_t /*altro*/=kFALSE){return 0;} | |
150 | virtual AliL3DigitRowData *AliDigits2Memory(UInt_t & /*nrow*/,Int_t /*event*/=0){return 0;} | |
151 | virtual AliL3DigitRowData *AliAltroDigits2Memory(UInt_t & /*nrow*/,Int_t /*event*/=0,Bool_t /*eventmerge*/=kFALSE){return 0;} | |
152 | virtual void AliDigits2RootFile(AliL3DigitRowData */*rowPt*/,Char_t */*new_digitsfile*/){return;} | |
153 | virtual Bool_t AliPoints2Binary(Int_t /*eventn*/=0){return 0;} | |
154 | virtual AliL3SpacePointData *AliPoints2Memory(UInt_t & /*npoint*/,Int_t /*eventn*/=0){return 0;} | |
3e87ef69 | 155 | |
156 | //AliL3RawDataFileHandler | |
dd7d3870 | 157 | virtual Bool_t SetRawInput(Char_t */*name*/){return 0;} |
158 | virtual Bool_t SetRawInput(ifstream */*file*/){return 0;} | |
3e87ef69 | 159 | virtual void CloseRawInput(){} |
160 | virtual Int_t ReadRawInput(){return 0;} | |
dd7d3870 | 161 | virtual Short_t** GetRawData(Int_t &/*channels*/, Int_t & /*timebins*/){return 0;} |
3e87ef69 | 162 | |
dd7d3870 | 163 | virtual Bool_t SetRawOutput(Char_t */*name*/){return 0;} |
164 | virtual Bool_t SetRawOutput(ofstream */*file*/){return 0;} | |
3e87ef69 | 165 | virtual void CloseRawOutput(){} |
166 | virtual Bool_t SaveRawOutput(){return 0;} | |
167 | ||
dd7d3870 | 168 | virtual Bool_t SetMappingFile(Char_t */*name*/){return 0;} |
169 | virtual Bool_t SetMappingFile(FILE */*file*/){return 0;} | |
3e87ef69 | 170 | virtual void CloseMappingFile(){} |
171 | virtual Int_t ReadMappingFile(){return 0;} | |
172 | ||
dd7d3870 | 173 | virtual Bool_t SetRawPedestalsInput(Char_t */*name*/){return 0;} |
174 | virtual Bool_t SetRawPedestalsInput(ifstream */*file*/){return 0;} | |
3e87ef69 | 175 | virtual void CloseRawPedestalsInput(){} |
176 | virtual Int_t ReadRawPedestalsInput(){return 0;} | |
177 | ||
dd7d3870 | 178 | virtual AliL3DigitRowData* RawData2Memory(UInt_t &/*nrow*/,Int_t /*event*/=-1){return 0;} |
179 | virtual Bool_t RawData2CompMemory(Int_t /*event*/=-1){return 0;} | |
240d63be | 180 | |
181 | //AliL3DDLDataFileHandler | |
b2a02bce | 182 | #ifdef use_newio |
dd7d3870 | 183 | virtual Bool_t SetReaderInput(Char_t */*name*/,Int_t /*event*/=0){return 0;} |
b2a02bce | 184 | #else |
dd7d3870 | 185 | virtual Bool_t SetReaderInput(Char_t */*name*/,Bool_t /*add*/=kTRUE){return 0;} |
b2a02bce | 186 | #endif |
240d63be | 187 | virtual void CloseReaderInput(){}; |
188 | ||
dd7d3870 | 189 | virtual AliL3DigitRowData* DDLData2Memory(UInt_t &/*nrow*/,Int_t /*event*/=-1){return 0;} |
190 | virtual Bool_t DDLData2CompBinary(Int_t /*event*/=-1){return 0;} | |
f8bc0cc9 | 191 | |
b661165c | 192 | ClassDef(AliL3MemHandler,1) // Memory handler class |
108615fc | 193 | }; |
194 | ||
b1ed0288 | 195 | inline Int_t AliL3MemHandler::ComparePoints(UInt_t /*row*/,UShort_t pad,UShort_t time) const |
196 | { | |
108615fc | 197 | if(fNUsed>=fNDigits) return -2; |
198 | ||
199 | if(pad==fDPt[fNUsed]->fPad&&time==fDPt[fNUsed]->fTime) return 0; | |
200 | ||
201 | if(pad<fDPt[fNUsed]->fPad) return -1; | |
202 | if(pad==fDPt[fNUsed]->fPad&&time<fDPt[fNUsed]->fTime) return -1; | |
203 | ||
204 | return 1; | |
205 | } | |
206 | ||
b1ed0288 | 207 | inline Int_t AliL3MemHandler::CompareDigits(AliL3RandomDigitData *a,AliL3RandomDigitData *b) const |
208 | { | |
108615fc | 209 | if(a->fPad==b->fPad && a->fTime == b->fTime) return 0; |
210 | ||
211 | if(a->fPad<b->fPad) return -1; | |
212 | if(a->fPad==b->fPad && a->fTime<b->fTime) return -1; | |
213 | ||
214 | return 1; | |
215 | } | |
216 | ||
217 | #endif |