]>
Commit | Line | Data |
---|---|---|
a6c02c85 | 1 | // @(#) $Id$ |
4aa41877 | 2 | // Original: AliHLTMemHandler.h,v 1.30 2004/10/06 08:51:20 cvetan |
a6c02c85 | 3 | #ifndef ALIHLTTPC_MEMHANDLER_H |
4 | #define ALIHLTTPC_MEMHANDLER_H | |
5578cf60 | 5 | /* This file is property of and copyright by the ALICE HLT Project * |
6 | * ALICE Experiment at CERN, All rights reserved. * | |
7 | * See cxx source for full Copyright notice */ | |
8 | ||
9 | /** @file AliHLTTPCMemHandler.h | |
10 | @author U. Frankenfeld, A. Vestbo, C. Loizides, maintained by | |
11 | Matthias Richter | |
12 | @date | |
13 | @brief input interface base class for the TPC tracking code before | |
14 | migration to the HLT component framework | |
15 | ||
16 | // see below for class documentation | |
17 | // or | |
18 | // refer to README to build package | |
19 | // or | |
20 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
21 | */ | |
a6c02c85 | 22 | //_____________________________________________________________ |
23 | // AliHLTTPCMemHandler | |
24 | // | |
25 | // The HLT Binary File handler | |
26 | // | |
27 | // This class does all the memory I/O handling of HLT binary files. | |
28 | // | |
29 | // Author: Uli Frankenfeld <mailto:franken@fi.uib.no>, | |
30 | // Anders Vestbo <mailto:vestbo$fi.uib.no>, | |
31 | // Constantin Loizides <mailto:loizides@ikf.uni-frankfurt.de> | |
32 | // *-- Copyright © ALICE HLT Group | |
33 | ||
34 | class AliHLTTPCDigitData; | |
35 | class AliHLTTPCSpacePointData; | |
36 | class AliHLTTPCDigitRowData; | |
37 | class AliHLTTPCTrackSegmentData; | |
38 | class AliHLTTPCTrackArray; | |
39 | class AliHLTTPCRandomPointData; | |
40 | class AliHLTTPCRandomDigitData; | |
41 | ||
a6c02c85 | 42 | class AliRunLoader; |
43 | class AliRawEvent; | |
e419b223 | 44 | #include "AliTPCRawStream.h" |
a6c02c85 | 45 | |
46 | class AliHLTTPCMemHandler { | |
47 | ||
48 | public: | |
49 | AliHLTTPCMemHandler(); | |
50 | virtual ~AliHLTTPCMemHandler(); | |
a6c02c85 | 51 | |
52 | void Reset(){CloseBinaryInput();CloseBinaryOutput();Free();} | |
53 | void Init(Int_t s,Int_t p, Int_t *r=0); | |
54 | ||
55 | Bool_t SetBinaryInput(char *name); | |
56 | Bool_t SetBinaryInput(FILE *file); | |
57 | void CloseBinaryInput(); | |
58 | ||
59 | Bool_t SetBinaryOutput(char *name); | |
60 | Bool_t SetBinaryOutput(FILE *file); | |
61 | void CloseBinaryOutput(); | |
62 | ||
63 | //Random cluster | |
64 | void SetRandomCluster(Int_t maxnumber); | |
65 | void SetRandomSeed(UInt_t seed){srand(seed);} | |
66 | void SetRandomSeed(); | |
67 | ||
68 | void ResetRandom(){fNDigits = 0; fNUsed = 0;} | |
69 | void Generate(Int_t row); | |
70 | void SetNGenerate(Int_t number){(number>fNRandom)?fNGenerate=fNRandom:fNGenerate = number;} | |
71 | ||
72 | void SetROI(Float_t *eta,Int_t *slice); | |
73 | void ResetROI(); | |
74 | ||
5578cf60 | 75 | //////////////////////////////////////////////////////////////////////////////////// |
76 | // | |
77 | // Digit IO | |
78 | ||
79 | /** | |
80 | * Write digit data to binary file. | |
81 | * The function loops over the rows and dumps all data of the | |
82 | * AliHLTTPCDigitRowData in binary format to the file. | |
83 | * @param nrow size of the array | |
84 | * @param data data array | |
85 | * @return kTRUE if succeeded, kFALSE if error | |
86 | */ | |
87 | Bool_t Memory2BinaryFile(UInt_t nrow,AliHLTTPCDigitRowData *data); | |
88 | ||
89 | /** | |
90 | * Read digit data from binary file. | |
91 | * @param nrow size of the array | |
92 | * @param data data buffer to receive the data | |
93 | * @param sz [IN] buffer size [OUT] total output size | |
94 | * @return kTRUE if succeeded, kFALSE if error | |
95 | */ | |
a38a7850 | 96 | Bool_t Binary2Memory(UInt_t & nrow,AliHLTTPCDigitRowData *data, UInt_t& sz); |
5578cf60 | 97 | |
98 | // Matthias 18.09.2007 | |
99 | // this function is highly error prone, no size check for data buffer | |
100 | // depricated | |
101 | //Bool_t Binary2Memory(UInt_t & nrow,AliHLTTPCDigitRowData *data){UInt_t tmp;return Binary2Memory(nrow,data,tmp);}; | |
a6c02c85 | 102 | |
103 | Int_t Memory2CompMemory(UInt_t nrow,AliHLTTPCDigitRowData *data,UInt_t *comp); | |
a38a7850 | 104 | Int_t CompMemory2Memory(UInt_t nrow,AliHLTTPCDigitRowData *data,UInt_t *comp,UInt_t& sz); |
105 | Int_t CompMemory2Memory(UInt_t nrow,AliHLTTPCDigitRowData *data,UInt_t *comp) {UInt_t tmp;return CompMemory2Memory(nrow,data,comp,tmp);}; | |
a6c02c85 | 106 | Bool_t CompMemory2CompBinary(UInt_t nrow,UInt_t *comp, UInt_t size=0); |
107 | Bool_t CompBinary2CompMemory(UInt_t & nrow,UInt_t *comp); | |
108 | ||
a38a7850 | 109 | virtual AliHLTTPCDigitRowData *CompBinary2Memory(UInt_t & nrow, UInt_t& sz); |
110 | virtual AliHLTTPCDigitRowData *CompBinary2Memory(UInt_t & nrow){UInt_t tmp;return CompBinary2Memory(nrow,tmp);}; | |
a6c02c85 | 111 | virtual Bool_t Memory2CompBinary(UInt_t nrow,AliHLTTPCDigitRowData *data); |
112 | ||
113 | UInt_t GetNRow(UInt_t *comp,UInt_t size); | |
114 | ||
115 | //Point IO | |
116 | Bool_t Memory2Binary(UInt_t npoint,AliHLTTPCSpacePointData *data); | |
a38a7850 | 117 | Bool_t Binary2Memory(UInt_t & npoint,AliHLTTPCSpacePointData *data, UInt_t& sz); |
118 | Bool_t Binary2Memory(UInt_t & npoint,AliHLTTPCSpacePointData *data) {UInt_t tmp; return Binary2Memory(npoint,data,tmp);}; | |
a6c02c85 | 119 | Bool_t Transform(UInt_t npoint,AliHLTTPCSpacePointData *data,Int_t slice); |
120 | static void UpdateRowPointer(AliHLTTPCDigitRowData *&tempPt); | |
121 | ||
122 | //Track IO | |
123 | Bool_t Memory2Binary(UInt_t ntrack,AliHLTTPCTrackSegmentData *data); | |
124 | Bool_t Binary2Memory(UInt_t & ntrack,AliHLTTPCTrackSegmentData *data); | |
125 | Bool_t TrackArray2Binary(AliHLTTPCTrackArray *array); | |
126 | Bool_t Binary2TrackArray(AliHLTTPCTrackArray *array); | |
127 | Bool_t TrackArray2Memory(UInt_t & ntrack,AliHLTTPCTrackSegmentData *data,AliHLTTPCTrackArray *array) const; | |
128 | Bool_t Memory2TrackArray(UInt_t ntrack,AliHLTTPCTrackSegmentData *data,AliHLTTPCTrackArray *array) const; | |
129 | Bool_t Memory2TrackArray(UInt_t ntrack,AliHLTTPCTrackSegmentData *data,AliHLTTPCTrackArray *array,Int_t slice) const; | |
130 | ||
131 | //Memory Allocation | |
132 | UInt_t GetAllocatedSize() const {return fSize;} | |
133 | UInt_t GetFileSize(); | |
134 | UInt_t GetMemorySize(UInt_t nrow,UInt_t *comp) const; | |
135 | UInt_t GetCompMemorySize(UInt_t nrow,AliHLTTPCDigitRowData *data) const; | |
136 | UInt_t GetRandomSize() const; | |
137 | ||
138 | Byte_t *Allocate(UInt_t size); | |
139 | Byte_t *Allocate(); // allocate size of Binary Input File | |
140 | Byte_t *Allocate(AliHLTTPCTrackArray *array); | |
141 | Byte_t *GetDataPointer(UInt_t &size) {size = fSize; return fPt;} | |
142 | FILE *GetFilePointer() {return fInBinary;} | |
143 | void Free(); | |
144 | ||
145 | //Getters: | |
146 | Int_t GetRowMin() const {return fRowMin;} | |
147 | Int_t GetRowMax() const {return fRowMax;} | |
148 | Int_t GetSlice() const {return fSlice;} | |
149 | Int_t GetPatch() const {return fPatch;} | |
150 | ||
151 | //virtual functions: | |
152 | virtual void FreeDigitsTree() {fDummy=0; return;} | |
153 | virtual Bool_t SetAliInput(char */*name*/){fDummy=0; return 0;} | |
a6c02c85 | 154 | virtual Bool_t SetAliInput(AliRunLoader */*runloader*/){fDummy=0; return 0;} |
a6c02c85 | 155 | virtual void CloseAliInput(){fDummy=0; return;} |
156 | virtual Bool_t IsDigit(Int_t /*i*/=0){fDummy=0; return 0;} | |
157 | virtual Bool_t SetMCOutput(char */*name*/){fDummy=0; return 0;} | |
158 | virtual Bool_t SetMCOutput(FILE */*file*/){fDummy=0; return 0;} | |
159 | virtual void CloseMCOutput(){fDummy=0; return;} | |
160 | virtual Bool_t AliDigits2Binary(Int_t /*event*/=0,Bool_t /*altro*/=kFALSE){fDummy=0; return 0;} | |
161 | virtual Bool_t AliDigits2CompBinary(Int_t /*event*/=0,Bool_t /*altro*/=kFALSE){fDummy=0; return 0;} | |
162 | virtual AliHLTTPCDigitRowData *AliDigits2Memory(UInt_t & /*nrow*/,Int_t /*event*/=0){fDummy=0; return 0;} | |
163 | virtual AliHLTTPCDigitRowData *AliAltroDigits2Memory(UInt_t & /*nrow*/,Int_t /*event*/=0,Bool_t /*eventmerge*/=kFALSE){fDummy=0; return 0;} | |
164 | virtual void AliDigits2RootFile(AliHLTTPCDigitRowData */*rowPt*/,Char_t */*new_digitsfile*/){fDummy=0; return;} | |
165 | virtual Bool_t AliPoints2Binary(Int_t /*eventn*/=0){fDummy=0; return 0;} | |
166 | virtual AliHLTTPCSpacePointData *AliPoints2Memory(UInt_t & /*npoint*/,Int_t /*eventn*/=0){fDummy=0; return 0;} | |
167 | ||
168 | //AliHLTTPCRawDataFileHandler | |
169 | virtual Bool_t SetRawInput(Char_t */*name*/){fDummy=0; return 0;} | |
170 | virtual Bool_t SetRawInput(ifstream */*file*/){fDummy=0; return 0;} | |
171 | virtual void CloseRawInput(){} | |
172 | virtual Int_t ReadRawInput(){fDummy=0; return 0;} | |
173 | virtual Short_t** GetRawData(Int_t &/*channels*/, Int_t & /*timebins*/){fDummy=0; return 0;} | |
174 | ||
175 | virtual Bool_t SetRawOutput(Char_t */*name*/){fDummy=0; return 0;} | |
176 | virtual Bool_t SetRawOutput(ofstream */*file*/){fDummy=0; return 0;} | |
177 | virtual void CloseRawOutput(){} | |
178 | virtual Bool_t SaveRawOutput(){fDummy=0; return 0;} | |
179 | ||
180 | virtual Bool_t SetMappingFile(Char_t */*name*/){fDummy=0; return 0;} | |
181 | virtual Bool_t SetMappingFile(FILE */*file*/){fDummy=0; return 0;} | |
182 | virtual void CloseMappingFile(){} | |
183 | virtual Int_t ReadMappingFile(){fDummy=0; return 0;} | |
184 | ||
185 | virtual Bool_t SetRawPedestalsInput(Char_t */*name*/){fDummy=0; return 0;} | |
186 | virtual Bool_t SetRawPedestalsInput(ifstream */*file*/){fDummy=0; return 0;} | |
187 | virtual void CloseRawPedestalsInput(){} | |
188 | virtual Int_t ReadRawPedestalsInput(){fDummy=0; return 0;} | |
189 | ||
190 | virtual AliHLTTPCDigitRowData* RawData2Memory(UInt_t &/*nrow*/,Int_t /*event*/=-1){fDummy=0; return 0;} | |
191 | virtual Bool_t RawData2CompMemory(Int_t /*event*/=-1){fDummy=0; return 0;} | |
192 | ||
193 | //AliHLTTPCDDLDataFileHandler | |
a6c02c85 | 194 | virtual Bool_t SetReaderInput(AliRawEvent */*rawevent*/){fDummy=0; return 0;} |
195 | virtual Bool_t SetReaderInput(Char_t */*name*/,Int_t /*event*/=0){fDummy=0; return 0;} | |
a6c02c85 | 196 | virtual void CloseReaderInput(){}; |
197 | ||
198 | virtual AliHLTTPCDigitRowData* DDLData2Memory(UInt_t &/*nrow*/,Int_t /*event*/=-1){fDummy=0; return 0;} | |
199 | virtual Bool_t DDLData2CompBinary(Int_t /*event*/=-1){fDummy=0; return 0;} | |
200 | ||
201 | virtual AliTPCRawStream* GetTPCRawStream(){fDummy=0; return 0;} | |
202 | ||
203 | protected: | |
204 | Int_t fRowMin; //min row | |
205 | Int_t fRowMax; //max row | |
206 | Int_t fSlice; //slice | |
207 | Int_t fPatch; //patch | |
208 | ||
209 | Int_t fEtaMinTimeBin[159]; //for ROI in eta only | |
210 | Int_t fEtaMaxTimeBin[159]; //for ROI in eta only | |
211 | ||
212 | FILE *fInBinary;//! | |
213 | FILE *fOutBinary;//! | |
214 | ||
215 | private: | |
5578cf60 | 216 | /** copy constructor prohibited */ |
217 | AliHLTTPCMemHandler(const AliHLTTPCMemHandler& src); | |
218 | /** assignment operator prohibited */ | |
219 | AliHLTTPCMemHandler& operator=(const AliHLTTPCMemHandler& src); | |
a6c02c85 | 220 | |
221 | Byte_t *fPt;//! | |
222 | UInt_t fSize; //size of allocated data structure | |
223 | ||
224 | Bool_t fIsRandom; //random data generated | |
225 | Int_t fNRandom; //count random digits | |
226 | Int_t fNGenerate; //count generated digits | |
227 | Int_t fNUsed; //count used digits | |
228 | Int_t fNDigits; //count digits from digitstree | |
229 | ||
230 | AliHLTTPCRandomDigitData **fDPt;//! | |
231 | AliHLTTPCRandomDigitData *fRandomDigits;//! | |
232 | ||
233 | Int_t fDummy; // to fool the virtual const problem | |
234 | // of the coding conventions tool | |
235 | ||
236 | void Write(UInt_t *comp, UInt_t & index, UInt_t & subindex, UShort_t value) const; | |
237 | UShort_t Read(UInt_t *comp, UInt_t & index, UInt_t & subindex) const; | |
238 | UShort_t Test(UInt_t *comp, UInt_t index, UInt_t subindex) const; | |
239 | ||
240 | void DigitizePoint(Int_t row,Int_t pad, Int_t time,Int_t charge); | |
241 | void QSort(AliHLTTPCRandomDigitData **a, Int_t first, Int_t last); | |
242 | Int_t ComparePoints(UInt_t row,UShort_t pad,UShort_t time) const ; | |
243 | Int_t CompareDigits(AliHLTTPCRandomDigitData *a,AliHLTTPCRandomDigitData *b) const; | |
244 | void AddData(AliHLTTPCDigitData *data,UInt_t & ndata, | |
245 | UInt_t row,UShort_t pad,UShort_t time,UShort_t charge) const; | |
246 | void AddRandom(AliHLTTPCDigitData *data,UInt_t & ndata); | |
247 | void MergeDataRandom(AliHLTTPCDigitData *data,UInt_t & ndata, | |
248 | UInt_t row,UShort_t pad,UShort_t time,UShort_t charge); | |
249 | void AddDataRandom(AliHLTTPCDigitData *data,UInt_t & ndata, | |
250 | UInt_t row,UShort_t pad,UShort_t time,UShort_t charge); | |
251 | ||
252 | ||
253 | ClassDef(AliHLTTPCMemHandler,1) // Memory handler class | |
254 | }; | |
255 | #endif |