]>
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$ */ | |
1ed3c5c2 | 17 | |
47c194a6 | 18 | #include "AliMUONBusStruct.h" |
b56232f8 | 19 | |
47c194a6 | 20 | #include "AliLog.h" |
1ed3c5c2 | 21 | #include <Riostream.h> |
22 | #include <string.h> | |
47c194a6 | 23 | |
00e86732 | 24 | /// \class AliMUONBusStruct |
47c194a6 | 25 | /// Bus patch structure for tracker raw data |
26 | /// each Dsp contains at most 5 bus patch structure | |
27 | /// Beside the total length and length of the below data | |
28 | /// the header of the block contains the bus patch id, trigger words | |
29 | /// and data structure itself (11bits for manu id, 6 bits for channel id and | |
30 | /// 12 bits for charge) | |
31 | /// | |
00e86732 | 32 | /// \author Christian Finck |
47c194a6 | 33 | |
13985652 | 34 | /// \cond CLASSIMP |
47c194a6 | 35 | ClassImp(AliMUONBusStruct) |
13985652 | 36 | /// \endcond |
47c194a6 | 37 | |
84ceeb06 | 38 | const Int_t AliMUONBusStruct::fgkHeaderLength = 4; |
39 | const UInt_t AliMUONBusStruct::fgkDefaultDataKey = 0xB000000B; | |
b56232f8 | 40 | const Int_t AliMUONBusStruct::fgkManuNofChannels(64); |
47c194a6 | 41 | |
42 | //___________________________________________ | |
43 | AliMUONBusStruct::AliMUONBusStruct() | |
44 | : TObject(), | |
84ceeb06 | 45 | fDataKey(0), |
47c194a6 | 46 | fTotalLength(0), |
47 | fLength(0), | |
48 | fBusPatchId(0), | |
b56232f8 | 49 | fBufSize(43*fgkManuNofChannels), |
878b883f | 50 | /* assuming 43 manus max per bustpatch. |
51 | Anyway fData is resized where needed (though it makes it slower) */ | |
52 | fData(new UInt_t[fBufSize]), | |
47c194a6 | 53 | fDspId(0), |
54 | fBlkId(0) | |
55 | { | |
00e86732 | 56 | /// |
57 | /// ctor | |
58 | /// | |
9f5dcca3 | 59 | |
47c194a6 | 60 | } |
61 | //___________________________________________ | |
62 | AliMUONBusStruct::~AliMUONBusStruct() | |
63 | { | |
00e86732 | 64 | /// |
65 | /// dtor | |
66 | /// | |
47c194a6 | 67 | delete[] fData; |
68 | } | |
69 | ||
70 | //___________________________________________ | |
71 | void AliMUONBusStruct::SetAlloc(Int_t size) | |
72 | { | |
00e86732 | 73 | /// |
74 | /// Allocate size | |
75 | /// return if size < fBufSize | |
76 | /// | |
47c194a6 | 77 | if (size < fBufSize) |
78 | return; | |
79 | else | |
80 | ResizeData(size); | |
81 | } | |
82 | //___________________________________________ | |
83 | void AliMUONBusStruct::AddData(UInt_t data) | |
84 | { | |
00e86732 | 85 | /// could have used class from ROOT |
86 | /// but the structure must be as simple as possible | |
87 | /// to be written on disc blockwise, not so sure ? | |
47c194a6 | 88 | if (fLength == fBufSize) |
89 | ResizeData(); | |
90 | fData[fLength++] = data; | |
91 | fTotalLength = fLength + fgkHeaderLength; | |
92 | } | |
93 | ||
94 | //___________________________________________ | |
95 | void AliMUONBusStruct::ResizeData(Int_t size) | |
96 | { | |
00e86732 | 97 | /// In case of resizing the vector |
98 | /// the most simplest way to do it | |
99 | /// | |
47c194a6 | 100 | if (size == 0) |
101 | fBufSize *= 2; | |
102 | else | |
103 | fBufSize = size; | |
104 | UInt_t* newData = new UInt_t[fBufSize]; | |
105 | for (Int_t i = 0; i < fLength; i++) | |
106 | newData[i] = fData[i]; | |
107 | delete[] fData; | |
108 | fData = newData; | |
109 | } | |
110 | //___________________________________________ | |
111 | AliMUONBusStruct:: | |
9f5dcca3 | 112 | AliMUONBusStruct(const AliMUONBusStruct& event) |
113 | : TObject(event), | |
114 | fDataKey(event.fDataKey), | |
115 | fTotalLength(event.fTotalLength), | |
116 | fLength(event.fLength), | |
117 | fBusPatchId(event.fBusPatchId), | |
9f5dcca3 | 118 | fBufSize(event.fBufSize), |
878b883f | 119 | fData(new UInt_t[event.fBufSize]), |
9f5dcca3 | 120 | fDspId(event.fDspId), |
121 | fBlkId(event.fBlkId) | |
47c194a6 | 122 | { |
00e86732 | 123 | /// |
124 | /// copy ctor | |
125 | /// | |
47c194a6 | 126 | |
47c194a6 | 127 | for (int i = 0; i < event.fBufSize; i++) |
128 | fData[i] = event.fData[i]; | |
129 | } | |
130 | //___________________________________________ | |
131 | AliMUONBusStruct& | |
132 | AliMUONBusStruct::operator=(const AliMUONBusStruct& event) | |
133 | { | |
00e86732 | 134 | /// |
135 | /// assignment operator | |
136 | /// | |
47c194a6 | 137 | if (this == &event) return *this; |
84ceeb06 | 138 | fDataKey = event.fDataKey; |
47c194a6 | 139 | fTotalLength = event.fTotalLength; |
140 | fLength = event.fLength; | |
141 | fBusPatchId = event.fBusPatchId; | |
47c194a6 | 142 | fBufSize = event.fBufSize; |
143 | ||
144 | fBlkId = event.fBlkId; | |
145 | fDspId = event.fDspId; | |
146 | ||
147 | delete [] fData; | |
148 | fData = new UInt_t[event.fBufSize]; | |
149 | for (int i = 0; i < event.fLength; i++) | |
150 | fData[i] = event.fData[i]; | |
151 | ||
152 | return *this; | |
153 | } | |
154 | //___________________________________________ | |
155 | Int_t AliMUONBusStruct::Compare(const TObject *obj) const | |
156 | { | |
00e86732 | 157 | /// |
158 | /// sort bus patch by bus patch number | |
159 | /// important for AliMUONRawWriter | |
160 | /// | |
47c194a6 | 161 | AliMUONBusStruct* event = (AliMUONBusStruct*) obj; |
162 | return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1; | |
163 | } | |
164 | ||
165 | //___________________________________________ | |
166 | void AliMUONBusStruct::Clear(Option_t *) | |
167 | { | |
00e86732 | 168 | /// clear |
169 | /// delete the allocated memory | |
170 | /// | |
47c194a6 | 171 | delete[] fData; |
172 | } | |
173 | //___________________________________________ | |
174 | UInt_t AliMUONBusStruct::GetData(Int_t n) const | |
175 | { | |
00e86732 | 176 | /// |
177 | /// get data | |
178 | /// | |
47c194a6 | 179 | if ( n>=0 && n<fLength ) return fData[n]; |
180 | ||
181 | AliError("Index outside limits."); | |
182 | return 0; | |
183 | } | |
184 | ||
185 | //___________________________________________ | |
186 | Char_t AliMUONBusStruct::GetParity(Int_t n) const | |
187 | { | |
00e86732 | 188 | /// |
189 | /// get parity | |
190 | /// | |
6dee95a7 | 191 | if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 31) & 0x1; |
47c194a6 | 192 | |
193 | AliError("Index outside limits."); | |
194 | return 0; | |
195 | } | |
196 | ||
197 | //___________________________________________ | |
198 | UShort_t AliMUONBusStruct::GetManuId(Int_t n) const | |
199 | { | |
00e86732 | 200 | /// |
201 | /// get manu Id | |
202 | /// | |
47c194a6 | 203 | if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) & 0x7FF; |
204 | ||
205 | AliError("Index outside limits."); | |
206 | return 0; | |
207 | } | |
208 | ||
209 | //___________________________________________ | |
000e9681 | 210 | UChar_t AliMUONBusStruct::GetChannelId(Int_t n) const |
47c194a6 | 211 | { |
00e86732 | 212 | /// |
213 | /// get channel Id | |
214 | /// | |
47c194a6 | 215 | if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F; |
216 | ||
217 | AliError("Index outside limits."); | |
218 | return 0; | |
219 | } | |
220 | ||
221 | //___________________________________________ | |
222 | UShort_t AliMUONBusStruct::GetCharge(Int_t n) const | |
223 | { | |
00e86732 | 224 | /// |
225 | /// get charge (in ADC) | |
226 | /// | |
47c194a6 | 227 | if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF); |
228 | ||
229 | AliError("Index outside limits."); | |
230 | return 0; | |
231 | } | |
1ed3c5c2 | 232 | |
233 | //___________________________________________ | |
234 | void AliMUONBusStruct::Print(Option_t* opt) const | |
235 | { | |
236 | /// print out | |
237 | ||
238 | cout << "Bus patch info" << endl; | |
239 | cout << "DataKey: " << fDataKey << endl; | |
240 | cout << "fTotalLength: " << fTotalLength << endl; | |
241 | cout << "fLength: " << fLength << endl; | |
242 | cout << "fBusPatchId: " << fBusPatchId << endl; | |
243 | cout << "fBufSize: " << fBufSize << endl; | |
244 | ||
245 | if (strstr(opt, "all")) { | |
246 | for (Int_t i = 0; i <fLength; ++i) | |
247 | cout << "Data["<< i << "] = " << fData[i] << endl; | |
248 | } | |
249 | } | |
250 | ||
251 |