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