]>
Commit | Line | Data |
---|---|---|
108615fc | 1 | #ifndef ALIL3MEMHANDLER_H |
2 | #define ALIL3MEMHANDLER_H | |
3 | ||
4 | #include "AliL3RootTypes.h" | |
17e961af | 5 | #include "AliL3Transform.h" |
108615fc | 6 | #include <stdio.h> |
7 | #include <stdlib.h> | |
8 | #include "AliL3DigitData.h" | |
494fad94 | 9 | |
108615fc | 10 | class AliL3SpacePointData; |
11 | class AliL3DigitRowData; | |
12 | class AliL3TrackSegmentData; | |
13 | class AliL3TrackArray; | |
14 | class AliL3RandomPointData; | |
15 | ||
16 | class AliL3MemHandler{ | |
17 | private: | |
b25c64e5 | 18 | |
108615fc | 19 | Byte_t *fPt;//! |
20 | UInt_t fSize; | |
21 | ||
22 | AliL3RandomDigitData **fDPt;//! | |
23 | AliL3RandomDigitData *fDigits;//! | |
24 | Bool_t IsRandom; | |
25 | Int_t fNRandom; | |
26 | Int_t fNGenerate; | |
27 | Int_t fNUsed; | |
28 | Int_t fNDigits; | |
29 | ||
30 | void Write(UInt_t *comp, UInt_t & index, UInt_t & subindex, UShort_t value); | |
31 | UShort_t Read(UInt_t *comp, UInt_t & index, UInt_t & subindex); | |
32 | UShort_t Test(UInt_t *comp, UInt_t index, UInt_t subindex); | |
33 | ||
34 | void DigitizePoint(Int_t row,Int_t pad, Int_t time,Int_t charge); | |
35 | void QSort(AliL3RandomDigitData **a, Int_t first, Int_t last); | |
36 | Int_t ComparePoints(UInt_t row,UShort_t pad,UShort_t time); | |
37 | Int_t CompareDigits(AliL3RandomDigitData *a,AliL3RandomDigitData *b); | |
38 | void AddData(AliL3DigitData *data,UInt_t & ndata, | |
39 | UInt_t row,UShort_t pad,UShort_t time,UShort_t charge); | |
40 | void AddRandom(AliL3DigitData *data,UInt_t & ndata); | |
41 | void MergeDataRandom(AliL3DigitData *data,UInt_t & ndata, | |
42 | UInt_t row,UShort_t pad,UShort_t time,UShort_t charge); | |
43 | void AddDataRandom(AliL3DigitData *data,UInt_t & ndata, | |
44 | UInt_t row,UShort_t pad,UShort_t time,UShort_t charge); | |
256c7399 | 45 | |
108615fc | 46 | |
47 | protected: | |
48 | Int_t fRowMin; | |
49 | Int_t fRowMax; | |
50 | Int_t fSlice; | |
51 | Int_t fPatch; | |
52 | ||
ae97a0b9 | 53 | Int_t fEtaMinTimeBin[176]; |
54 | Int_t fEtaMaxTimeBin[176]; | |
256c7399 | 55 | |
56 | FILE *fInBinary;//! | |
57 | FILE *fOutBinary;//! | |
58 | ||
108615fc | 59 | public: |
60 | AliL3MemHandler(); | |
61 | virtual ~AliL3MemHandler(); | |
62 | ||
63 | void Reset(){CloseBinaryInput();CloseBinaryOutput();Free();} | |
eeddc64d | 64 | void Init(Int_t s,Int_t p, Int_t *r=0); |
108615fc | 65 | |
66 | Bool_t SetBinaryInput(char *name); | |
67 | Bool_t SetBinaryInput(FILE *file); | |
68 | void CloseBinaryInput(); | |
69 | ||
70 | Bool_t SetBinaryOutput(char *name); | |
71 | Bool_t SetBinaryOutput(FILE *file); | |
72 | void CloseBinaryOutput(); | |
73 | ||
74 | //Random cluster | |
75 | void SetRandomCluster(Int_t maxnumber); | |
76 | void SetRandomSeed(UInt_t seed){srand(seed);} | |
77 | void SetRandomSeed(); | |
78 | ||
79 | void ResetRandom(){fNDigits = 0; fNUsed = 0;} | |
80 | void Generate(Int_t row); | |
81 | void SetNGenerate(Int_t number){(number>fNRandom)?fNGenerate=fNRandom:fNGenerate = number;} | |
82 | ||
83 | void SetROI(Float_t *eta,Int_t *slice); | |
84 | void ResetROI(); | |
85 | ||
86 | //Digit IO | |
87 | Bool_t Memory2Binary(UInt_t nrow,AliL3DigitRowData *data); | |
88 | Bool_t Binary2Memory(UInt_t & nrow,AliL3DigitRowData *data); | |
89 | ||
90 | Int_t Memory2CompMemory(UInt_t nrow,AliL3DigitRowData *data,UInt_t *comp); | |
91 | Int_t CompMemory2Memory(UInt_t nrow,AliL3DigitRowData *data,UInt_t *comp); | |
92 | Bool_t CompMemory2CompBinary(UInt_t nrow,UInt_t *comp, UInt_t size=0); | |
93 | Bool_t CompBinary2CompMemory(UInt_t & nrow,UInt_t *comp); | |
94 | ||
256c7399 | 95 | virtual AliL3DigitRowData *CompBinary2Memory(UInt_t & nrow); |
96 | virtual Bool_t Memory2CompBinary(UInt_t nrow,AliL3DigitRowData *data); | |
97 | ||
108615fc | 98 | UInt_t GetNRow(UInt_t *comp,UInt_t size); |
99 | ||
100 | //Point IO | |
101 | Bool_t Memory2Binary(UInt_t npoint,AliL3SpacePointData *data); | |
102 | Bool_t Binary2Memory(UInt_t & npoint,AliL3SpacePointData *data); | |
c51c6aaa | 103 | Bool_t Transform(UInt_t npoint,AliL3SpacePointData *data,Int_t slice); |
a830c5a6 | 104 | static void UpdateRowPointer(AliL3DigitRowData *&tempPt); |
9bd4d591 | 105 | |
108615fc | 106 | //Track IO |
107 | Bool_t Memory2Binary(UInt_t ntrack,AliL3TrackSegmentData *data); | |
108 | Bool_t Binary2Memory(UInt_t & ntrack,AliL3TrackSegmentData *data); | |
109 | Bool_t TrackArray2Binary(AliL3TrackArray *array); | |
110 | Bool_t Binary2TrackArray(AliL3TrackArray *array); | |
111 | Bool_t TrackArray2Memory(UInt_t & ntrack,AliL3TrackSegmentData *data, | |
112 | AliL3TrackArray *array); | |
113 | Bool_t Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *data, | |
114 | AliL3TrackArray *array); | |
115 | Bool_t Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *data, | |
c51c6aaa | 116 | AliL3TrackArray *array,Int_t slice); |
9bd4d591 | 117 | |
118 | ||
108615fc | 119 | //Memory Allocation |
120 | UInt_t GetAllocatedSize(){return fSize;} | |
121 | UInt_t GetFileSize(); | |
122 | UInt_t GetMemorySize(UInt_t nrow,UInt_t *comp); | |
123 | UInt_t GetCompMemorySize(UInt_t nrow,AliL3DigitRowData *data); | |
124 | UInt_t GetRandomSize(); | |
125 | ||
126 | Byte_t *Allocate(UInt_t size); | |
127 | Byte_t *Allocate(); // allocate size of Binary Input File | |
128 | Byte_t *Allocate(AliL3TrackArray *array); | |
b661165c | 129 | Byte_t *GetDataPointer(UInt_t &size) {size = fSize; return fPt;} |
108615fc | 130 | void Free(); |
131 | ||
f8bc0cc9 | 132 | //Getters: |
133 | Int_t GetRowMin(){return fRowMin;} | |
134 | Int_t GetRowMax(){return fRowMax;} | |
135 | Int_t GetSlice(){return fSlice;} | |
136 | Int_t GetPatch(){return fPatch;} | |
137 | ||
138 | //virtual functions: | |
a815f9dd | 139 | virtual void FreeDigitsTree() {return;} |
f8bc0cc9 | 140 | virtual Bool_t SetAliInput(char *name){return 0;} |
141 | virtual void CloseAliInput(){return;} | |
142 | virtual Bool_t IsDigit(){return 0;} | |
143 | virtual Bool_t SetMCOutput(char *name){return 0;} | |
144 | virtual Bool_t SetMCOutput(FILE *file){return 0;} | |
145 | virtual void CloseMCOutput(){return;} | |
146 | virtual Bool_t AliDigits2Binary(Int_t event=0){return 0;} | |
147 | virtual AliL3DigitRowData *AliDigits2Memory(UInt_t & nrow,Int_t event=0){return 0;} | |
148 | virtual Bool_t AliDigits2CompBinary(Int_t event=0){return 0;} | |
149 | virtual void AliDigits2RootFile(AliL3DigitRowData *rowPt,Char_t *new_digitsfile){return;} | |
150 | virtual Bool_t AliPoints2Binary(){return 0;} | |
151 | virtual AliL3SpacePointData *AliPoints2Memory(UInt_t & npoint){return 0;} | |
152 | ||
b661165c | 153 | ClassDef(AliL3MemHandler,1) // Memory handler class |
108615fc | 154 | }; |
155 | ||
156 | inline Int_t AliL3MemHandler::ComparePoints(UInt_t row,UShort_t pad,UShort_t time){ | |
157 | if(fNUsed>=fNDigits) return -2; | |
158 | ||
159 | if(pad==fDPt[fNUsed]->fPad&&time==fDPt[fNUsed]->fTime) return 0; | |
160 | ||
161 | if(pad<fDPt[fNUsed]->fPad) return -1; | |
162 | if(pad==fDPt[fNUsed]->fPad&&time<fDPt[fNUsed]->fTime) return -1; | |
163 | ||
164 | return 1; | |
165 | } | |
166 | ||
167 | inline Int_t AliL3MemHandler::CompareDigits(AliL3RandomDigitData *a,AliL3RandomDigitData *b){ | |
168 | if(a->fPad==b->fPad && a->fTime == b->fTime) return 0; | |
169 | ||
170 | if(a->fPad<b->fPad) return -1; | |
171 | if(a->fPad==b->fPad && a->fTime<b->fTime) return -1; | |
172 | ||
173 | return 1; | |
174 | } | |
175 | ||
f8bc0cc9 | 176 | |
108615fc | 177 | #endif |