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