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