]>
Commit | Line | Data |
---|---|---|
1 | #ifndef ALIL3_MEMHANDLER_H | |
2 | #define ALIL3_MEMHANDLER_H | |
3 | ||
4 | #include <stdlib.h> | |
5 | #include "AliL3RootTypes.h" | |
6 | #include "AliL3DigitData.h" | |
7 | ||
8 | class AliL3SpacePointData; | |
9 | class AliL3DigitRowData; | |
10 | class AliL3TrackSegmentData; | |
11 | class AliL3TrackArray; | |
12 | class AliL3RandomPointData; | |
13 | ||
14 | class AliL3MemHandler{ | |
15 | private: | |
16 | ||
17 | Byte_t *fPt;//! | |
18 | UInt_t fSize; | |
19 | ||
20 | AliL3RandomDigitData **fDPt;//! | |
21 | AliL3RandomDigitData *fDigits;//! | |
22 | Bool_t IsRandom; | |
23 | Int_t fNRandom; | |
24 | Int_t fNGenerate; | |
25 | Int_t fNUsed; | |
26 | Int_t fNDigits; | |
27 | ||
28 | void Write(UInt_t *comp, UInt_t & index, UInt_t & subindex, UShort_t value); | |
29 | UShort_t Read(UInt_t *comp, UInt_t & index, UInt_t & subindex); | |
30 | UShort_t Test(UInt_t *comp, UInt_t index, UInt_t subindex); | |
31 | ||
32 | void DigitizePoint(Int_t row,Int_t pad, Int_t time,Int_t charge); | |
33 | void QSort(AliL3RandomDigitData **a, Int_t first, Int_t last); | |
34 | Int_t ComparePoints(UInt_t row,UShort_t pad,UShort_t time); | |
35 | Int_t CompareDigits(AliL3RandomDigitData *a,AliL3RandomDigitData *b); | |
36 | void AddData(AliL3DigitData *data,UInt_t & ndata, | |
37 | UInt_t row,UShort_t pad,UShort_t time,UShort_t charge); | |
38 | void AddRandom(AliL3DigitData *data,UInt_t & ndata); | |
39 | void MergeDataRandom(AliL3DigitData *data,UInt_t & ndata, | |
40 | UInt_t row,UShort_t pad,UShort_t time,UShort_t charge); | |
41 | void AddDataRandom(AliL3DigitData *data,UInt_t & ndata, | |
42 | UInt_t row,UShort_t pad,UShort_t time,UShort_t charge); | |
43 | ||
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]; | |
52 | Int_t fEtaMaxTimeBin[159]; | |
53 | ||
54 | FILE *fInBinary;//! | |
55 | FILE *fOutBinary;//! | |
56 | ||
57 | public: | |
58 | AliL3MemHandler(); | |
59 | virtual ~AliL3MemHandler(); | |
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,AliL3DigitRowData *data); | |
86 | Bool_t Binary2Memory(UInt_t & nrow,AliL3DigitRowData *data); | |
87 | ||
88 | Int_t Memory2CompMemory(UInt_t nrow,AliL3DigitRowData *data,UInt_t *comp); | |
89 | Int_t CompMemory2Memory(UInt_t nrow,AliL3DigitRowData *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 AliL3DigitRowData *CompBinary2Memory(UInt_t & nrow); | |
94 | virtual Bool_t Memory2CompBinary(UInt_t nrow,AliL3DigitRowData *data); | |
95 | ||
96 | UInt_t GetNRow(UInt_t *comp,UInt_t size); | |
97 | ||
98 | //Point IO | |
99 | Bool_t Memory2Binary(UInt_t npoint,AliL3SpacePointData *data); | |
100 | Bool_t Binary2Memory(UInt_t & npoint,AliL3SpacePointData *data); | |
101 | Bool_t Transform(UInt_t npoint,AliL3SpacePointData *data,Int_t slice); | |
102 | static void UpdateRowPointer(AliL3DigitRowData *&tempPt); | |
103 | ||
104 | //Track IO | |
105 | Bool_t Memory2Binary(UInt_t ntrack,AliL3TrackSegmentData *data); | |
106 | Bool_t Binary2Memory(UInt_t & ntrack,AliL3TrackSegmentData *data); | |
107 | Bool_t TrackArray2Binary(AliL3TrackArray *array); | |
108 | Bool_t Binary2TrackArray(AliL3TrackArray *array); | |
109 | Bool_t TrackArray2Memory(UInt_t & ntrack,AliL3TrackSegmentData *data, | |
110 | AliL3TrackArray *array); | |
111 | Bool_t Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *data, | |
112 | AliL3TrackArray *array); | |
113 | Bool_t Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *data, | |
114 | AliL3TrackArray *array,Int_t slice); | |
115 | ||
116 | //Memory Allocation | |
117 | UInt_t GetAllocatedSize(){return fSize;} | |
118 | UInt_t GetFileSize(); | |
119 | UInt_t GetMemorySize(UInt_t nrow,UInt_t *comp); | |
120 | UInt_t GetCompMemorySize(UInt_t nrow,AliL3DigitRowData *data); | |
121 | UInt_t GetRandomSize(); | |
122 | ||
123 | Byte_t *Allocate(UInt_t size); | |
124 | Byte_t *Allocate(); // allocate size of Binary Input File | |
125 | Byte_t *Allocate(AliL3TrackArray *array); | |
126 | Byte_t *GetDataPointer(UInt_t &size) {size = fSize; return fPt;} | |
127 | void Free(); | |
128 | ||
129 | //Getters: | |
130 | Int_t GetRowMin(){return fRowMin;} | |
131 | Int_t GetRowMax(){return fRowMax;} | |
132 | Int_t GetSlice(){return fSlice;} | |
133 | Int_t GetPatch(){return fPatch;} | |
134 | ||
135 | //virtual functions: | |
136 | virtual void FreeDigitsTree() {return;} | |
137 | virtual Bool_t SetAliInput(char *name){return 0;} | |
138 | virtual void CloseAliInput(){return;} | |
139 | virtual Bool_t IsDigit(){return 0;} | |
140 | virtual Bool_t SetMCOutput(char *name){return 0;} | |
141 | virtual Bool_t SetMCOutput(FILE *file){return 0;} | |
142 | virtual void CloseMCOutput(){return;} | |
143 | virtual Bool_t AliDigits2Binary(Int_t event=0){return 0;} | |
144 | virtual AliL3DigitRowData *AliDigits2Memory(UInt_t & nrow,Int_t event=0){return 0;} | |
145 | virtual AliL3DigitRowData *AliAltroDigits2Memory(UInt_t & nrow,Int_t event=0){return 0;} | |
146 | virtual Bool_t AliDigits2CompBinary(Int_t event=0,Bool_t altro=kFALSE){return 0;} | |
147 | virtual void AliDigits2RootFile(AliL3DigitRowData *rowPt,Char_t *new_digitsfile){return;} | |
148 | virtual Bool_t AliPoints2Binary(){return 0;} | |
149 | virtual AliL3SpacePointData *AliPoints2Memory(UInt_t & npoint){return 0;} | |
150 | ||
151 | ClassDef(AliL3MemHandler,1) // Memory handler class | |
152 | }; | |
153 | ||
154 | inline Int_t AliL3MemHandler::ComparePoints(UInt_t row,UShort_t pad,UShort_t time){ | |
155 | if(fNUsed>=fNDigits) return -2; | |
156 | ||
157 | if(pad==fDPt[fNUsed]->fPad&&time==fDPt[fNUsed]->fTime) return 0; | |
158 | ||
159 | if(pad<fDPt[fNUsed]->fPad) return -1; | |
160 | if(pad==fDPt[fNUsed]->fPad&&time<fDPt[fNUsed]->fTime) return -1; | |
161 | ||
162 | return 1; | |
163 | } | |
164 | ||
165 | inline Int_t AliL3MemHandler::CompareDigits(AliL3RandomDigitData *a,AliL3RandomDigitData *b){ | |
166 | if(a->fPad==b->fPad && a->fTime == b->fTime) return 0; | |
167 | ||
168 | if(a->fPad<b->fPad) return -1; | |
169 | if(a->fPad==b->fPad && a->fTime<b->fTime) return -1; | |
170 | ||
171 | return 1; | |
172 | } | |
173 | ||
174 | #endif |