AliRoot Core  v5-06-15 (45dab64)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONBusStruct.cxx
Go to the documentation of this file.
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 /* $Id$ */
17 
18 #include "AliMUONBusStruct.h"
19 
20 #include "AliLog.h"
21 #include <Riostream.h>
22 #include <string.h>
23 
24 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
35 
36 using std::cout;
37 using std::endl;
41 
42 const Int_t AliMUONBusStruct::fgkHeaderLength = 4;
43 const UInt_t AliMUONBusStruct::fgkDefaultDataKey = 0xB000000B;
44 const Int_t AliMUONBusStruct::fgkManuNofChannels(64);
45 
46 //___________________________________________
48  : TObject(),
49  fDataKey(0),
50  fTotalLength(0),
51  fLength(0),
52  fBusPatchId(0),
53 fBufSize(43*fgkManuNofChannels),
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]),
57  fDspId(0),
58  fBlkId(0)
59 {
63 
64 }
65 //___________________________________________
67 {
71  delete[] fData;
72 }
73 
74 //___________________________________________
76 {
81  if (size < fBufSize)
82  return;
83  else
84  ResizeData(size);
85 }
86 //___________________________________________
87 void AliMUONBusStruct::AddData(UInt_t data)
88 {
92  if (fLength == fBufSize)
93  ResizeData();
94  fData[fLength++] = data;
96 }
97 
98 //___________________________________________
100 {
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 //___________________________________________
117  : TObject(event),
118  fDataKey(event.fDataKey),
119  fTotalLength(event.fTotalLength),
120  fLength(event.fLength),
121  fBusPatchId(event.fBusPatchId),
122  fBufSize(event.fBufSize),
123  fData(new UInt_t[event.fBufSize]),
124  fDspId(event.fDspId),
125  fBlkId(event.fBlkId)
126 {
130 
131  for (int i = 0; i < event.fBufSize; i++)
132  fData[i] = event.fData[i];
133 }
134 //___________________________________________
137 {
141  if (this == &event) return *this;
142  fDataKey = event.fDataKey;
143  fTotalLength = event.fTotalLength;
144  fLength = event.fLength;
145  fBusPatchId = event.fBusPatchId;
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 //___________________________________________
159 Int_t AliMUONBusStruct::Compare(const TObject *obj) const
160 {
165  AliMUONBusStruct* event = (AliMUONBusStruct*) obj;
166  return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
167 }
168 
169 //___________________________________________
170 void AliMUONBusStruct::Clear(Option_t *)
171 {
175  delete[] fData;
176 }
177 //___________________________________________
178 UInt_t AliMUONBusStruct::GetData(Int_t n) const
179 {
183  if ( n>=0 && n<fLength ) return fData[n];
184 
185  AliError("Index outside limits.");
186  return 0;
187 }
188 
189 //___________________________________________
190 Char_t AliMUONBusStruct::GetParity(Int_t n) const
191 {
195  if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 31) & 0x1;
196 
197  AliError("Index outside limits.");
198  return 0;
199 }
200 
201 //___________________________________________
202 UShort_t AliMUONBusStruct::GetManuId(Int_t n) const
203 {
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 //___________________________________________
214 UChar_t AliMUONBusStruct::GetChannelId(Int_t n) const
215 {
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 //___________________________________________
226 UShort_t AliMUONBusStruct::GetCharge(Int_t n) const
227 {
231  if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF);
232 
233  AliError("Index outside limits.");
234  return 0;
235 }
236 
237 //___________________________________________
238 void AliMUONBusStruct::Print(Option_t* opt) const
239 {
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 
Int_t fLength
length of raw data
UShort_t GetCharge(Int_t n) const
Int_t fBlkId
block numer for monitoring
Int_t fBufSize
initial size for data array
UInt_t * GetData() const
Return data.
Int_t fTotalLength
total length of buspatch structure
static const Int_t fgkHeaderLength
header length in word
Int_t fDataKey
Data key word for bus patch header.
void Clear(Option_t *opt)
void Print(Option_t *opt) const
void AddData(UInt_t d)
Int_t Compare(const TObject *obj) const
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
UInt_t * fData
data
AliMUONBusStruct & operator=(const AliMUONBusStruct &rhs)
UShort_t GetManuId(Int_t n) const
Int_t fDspId
Dsp number for monitoring.
Int_t fBusPatchId
bus patch id
Char_t GetParity(Int_t n) const
void SetAlloc(Int_t size)
void ResizeData(Int_t size=0)
virtual ~AliMUONBusStruct()
UChar_t GetChannelId(Int_t n) const
MUON buspatch structure for tracker.