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