]>
Commit | Line | Data |
---|---|---|
47c194a6 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
13985652 | 15 | |
16 | /* $Id$ */ | |
47c194a6 | 17 | |
18 | #include "AliMUONBusStruct.h" | |
19 | #include "AliLog.h" | |
20 | ||
21 | ||
22 | /// | |
23 | /// Bus patch structure for tracker raw data | |
24 | /// each Dsp contains at most 5 bus patch structure | |
25 | /// Beside the total length and length of the below data | |
26 | /// the header of the block contains the bus patch id, trigger words | |
27 | /// and data structure itself (11bits for manu id, 6 bits for channel id and | |
28 | /// 12 bits for charge) | |
29 | /// | |
30 | ||
13985652 | 31 | /// \cond CLASSIMP |
47c194a6 | 32 | ClassImp(AliMUONBusStruct) |
13985652 | 33 | /// \endcond |
47c194a6 | 34 | |
84ceeb06 | 35 | const Int_t AliMUONBusStruct::fgkHeaderLength = 4; |
36 | const UInt_t AliMUONBusStruct::fgkDefaultDataKey = 0xB000000B; | |
47c194a6 | 37 | |
38 | //___________________________________________ | |
39 | AliMUONBusStruct::AliMUONBusStruct() | |
40 | : TObject(), | |
84ceeb06 | 41 | fDataKey(0), |
47c194a6 | 42 | fTotalLength(0), |
43 | fLength(0), | |
44 | fBusPatchId(0), | |
878b883f | 45 | fBufSize(43*64), |
46 | /* assuming 43 manus max per bustpatch. | |
47 | Anyway fData is resized where needed (though it makes it slower) */ | |
48 | fData(new UInt_t[fBufSize]), | |
47c194a6 | 49 | fDspId(0), |
50 | fBlkId(0) | |
51 | { | |
52 | // | |
53 | // ctor | |
54 | // | |
9f5dcca3 | 55 | |
47c194a6 | 56 | } |
57 | //___________________________________________ | |
58 | AliMUONBusStruct::~AliMUONBusStruct() | |
59 | { | |
60 | // | |
61 | // dtor | |
62 | // | |
63 | delete[] fData; | |
64 | } | |
65 | ||
66 | //___________________________________________ | |
67 | void AliMUONBusStruct::SetAlloc(Int_t size) | |
68 | { | |
69 | // | |
878b883f | 70 | // Allocate size |
71 | // return if size < fBufSize | |
47c194a6 | 72 | // |
73 | if (size < fBufSize) | |
74 | return; | |
75 | else | |
76 | ResizeData(size); | |
77 | } | |
78 | //___________________________________________ | |
79 | void AliMUONBusStruct::AddData(UInt_t data) | |
80 | { | |
81 | // could have used class from ROOT | |
82 | // but the structure must be as simple as possible | |
83 | // to be written on disc blockwise, not so sure ? | |
84 | if (fLength == fBufSize) | |
85 | ResizeData(); | |
86 | fData[fLength++] = data; | |
87 | fTotalLength = fLength + fgkHeaderLength; | |
88 | } | |
89 | ||
90 | //___________________________________________ | |
91 | void AliMUONBusStruct::ResizeData(Int_t size) | |
92 | { | |
93 | // In case of resizing the vector | |
94 | // the most simplest way to do it | |
95 | // | |
878b883f | 96 | AliInfo("reallocating"); |
47c194a6 | 97 | if (size == 0) |
98 | fBufSize *= 2; | |
99 | else | |
100 | fBufSize = size; | |
101 | UInt_t* newData = new UInt_t[fBufSize]; | |
102 | for (Int_t i = 0; i < fLength; i++) | |
103 | newData[i] = fData[i]; | |
104 | delete[] fData; | |
105 | fData = newData; | |
106 | } | |
107 | //___________________________________________ | |
108 | AliMUONBusStruct:: | |
9f5dcca3 | 109 | AliMUONBusStruct(const AliMUONBusStruct& event) |
110 | : TObject(event), | |
111 | fDataKey(event.fDataKey), | |
112 | fTotalLength(event.fTotalLength), | |
113 | fLength(event.fLength), | |
114 | fBusPatchId(event.fBusPatchId), | |
9f5dcca3 | 115 | fBufSize(event.fBufSize), |
878b883f | 116 | fData(new UInt_t[event.fBufSize]), |
9f5dcca3 | 117 | fDspId(event.fDspId), |
118 | fBlkId(event.fBlkId) | |
47c194a6 | 119 | { |
120 | // | |
121 | // copy ctor | |
122 | // | |
47c194a6 | 123 | |
47c194a6 | 124 | for (int i = 0; i < event.fBufSize; i++) |
125 | fData[i] = event.fData[i]; | |
126 | } | |
127 | //___________________________________________ | |
128 | AliMUONBusStruct& | |
129 | AliMUONBusStruct::operator=(const AliMUONBusStruct& event) | |
130 | { | |
131 | // | |
132 | // assignment operator | |
133 | // | |
134 | if (this == &event) return *this; | |
84ceeb06 | 135 | fDataKey = event.fDataKey; |
47c194a6 | 136 | fTotalLength = event.fTotalLength; |
137 | fLength = event.fLength; | |
138 | fBusPatchId = event.fBusPatchId; | |
47c194a6 | 139 | fBufSize = event.fBufSize; |
140 | ||
141 | fBlkId = event.fBlkId; | |
142 | fDspId = event.fDspId; | |
143 | ||
144 | delete [] fData; | |
145 | fData = new UInt_t[event.fBufSize]; | |
146 | for (int i = 0; i < event.fLength; i++) | |
147 | fData[i] = event.fData[i]; | |
148 | ||
149 | return *this; | |
150 | } | |
151 | //___________________________________________ | |
152 | Int_t AliMUONBusStruct::Compare(const TObject *obj) const | |
153 | { | |
154 | // | |
155 | // sort bus patch by bus patch number | |
156 | // important for AliMUONRawWriter | |
157 | // | |
158 | AliMUONBusStruct* event = (AliMUONBusStruct*) obj; | |
159 | return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1; | |
160 | } | |
161 | ||
162 | //___________________________________________ | |
163 | void AliMUONBusStruct::Clear(Option_t *) | |
164 | { | |
165 | // clear | |
166 | // delete the allocated memory | |
167 | // | |
878b883f | 168 | AliInfo("here"); |
47c194a6 | 169 | delete[] fData; |
170 | } | |
171 | //___________________________________________ | |
172 | UInt_t AliMUONBusStruct::GetData(Int_t n) const | |
173 | { | |
174 | // | |
175 | // get data | |
176 | // | |
177 | if ( n>=0 && n<fLength ) return fData[n]; | |
178 | ||
179 | AliError("Index outside limits."); | |
180 | return 0; | |
181 | } | |
182 | ||
183 | //___________________________________________ | |
184 | Char_t AliMUONBusStruct::GetParity(Int_t n) const | |
185 | { | |
186 | // | |
187 | // get parity | |
188 | // | |
6dee95a7 | 189 | if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 31) & 0x1; |
47c194a6 | 190 | |
191 | AliError("Index outside limits."); | |
192 | return 0; | |
193 | } | |
194 | ||
195 | //___________________________________________ | |
196 | UShort_t AliMUONBusStruct::GetManuId(Int_t n) const | |
197 | { | |
198 | // | |
199 | // get manu Id | |
200 | // | |
201 | if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) & 0x7FF; | |
202 | ||
203 | AliError("Index outside limits."); | |
204 | return 0; | |
205 | } | |
206 | ||
207 | //___________________________________________ | |
208 | Char_t AliMUONBusStruct::GetChannelId(Int_t n) const | |
209 | { | |
210 | // | |
211 | // get channel Id | |
212 | // | |
213 | if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F; | |
214 | ||
215 | AliError("Index outside limits."); | |
216 | return 0; | |
217 | } | |
218 | ||
219 | //___________________________________________ | |
220 | UShort_t AliMUONBusStruct::GetCharge(Int_t n) const | |
221 | { | |
222 | // | |
223 | // get charge (in ADC) | |
224 | // | |
225 | if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF); | |
226 | ||
227 | AliError("Index outside limits."); | |
228 | return 0; | |
229 | } |