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