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