]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONBusStruct.cxx
Updated list of MUON libraries
[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"
19#include "AliLog.h"
1ed3c5c2 20#include <Riostream.h>
21#include <string.h>
47c194a6 22
00e86732 23/// \class AliMUONBusStruct
47c194a6 24/// Bus patch structure for tracker raw data
25/// each Dsp contains at most 5 bus patch structure
26/// Beside the total length and length of the below data
27/// the header of the block contains the bus patch id, trigger words
28/// and data structure itself (11bits for manu id, 6 bits for channel id and
29/// 12 bits for charge)
30///
00e86732 31/// \author Christian Finck
47c194a6 32
13985652 33/// \cond CLASSIMP
47c194a6 34ClassImp(AliMUONBusStruct)
13985652 35/// \endcond
47c194a6 36
84ceeb06 37const Int_t AliMUONBusStruct::fgkHeaderLength = 4;
38const UInt_t AliMUONBusStruct::fgkDefaultDataKey = 0xB000000B;
47c194a6 39
40//___________________________________________
41AliMUONBusStruct::AliMUONBusStruct()
42 : TObject(),
84ceeb06 43 fDataKey(0),
47c194a6 44 fTotalLength(0),
45 fLength(0),
46 fBusPatchId(0),
878b883f 47 fBufSize(43*64),
48 /* assuming 43 manus max per bustpatch.
49 Anyway fData is resized where needed (though it makes it slower) */
50 fData(new UInt_t[fBufSize]),
47c194a6 51 fDspId(0),
52 fBlkId(0)
53{
00e86732 54 ///
55 /// ctor
56 ///
9f5dcca3 57
47c194a6 58}
59//___________________________________________
60AliMUONBusStruct::~AliMUONBusStruct()
61{
00e86732 62 ///
63 /// dtor
64 ///
47c194a6 65 delete[] fData;
66}
67
68//___________________________________________
69void AliMUONBusStruct::SetAlloc(Int_t size)
70{
00e86732 71 ///
72 /// Allocate size
73 /// return if size < fBufSize
74 ///
47c194a6 75 if (size < fBufSize)
76 return;
77 else
78 ResizeData(size);
79}
80//___________________________________________
81void AliMUONBusStruct::AddData(UInt_t data)
82{
00e86732 83 /// could have used class from ROOT
84 /// but the structure must be as simple as possible
85 /// to be written on disc blockwise, not so sure ?
47c194a6 86 if (fLength == fBufSize)
87 ResizeData();
88 fData[fLength++] = data;
89 fTotalLength = fLength + fgkHeaderLength;
90}
91
92//___________________________________________
93void AliMUONBusStruct::ResizeData(Int_t size)
94{
00e86732 95 /// In case of resizing the vector
96 /// the most simplest way to do it
97 ///
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//___________________________________________
109AliMUONBusStruct::
9f5dcca3 110AliMUONBusStruct(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//___________________________________________
129AliMUONBusStruct&
130AliMUONBusStruct::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//___________________________________________
153Int_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//___________________________________________
164void AliMUONBusStruct::Clear(Option_t *)
165{
00e86732 166 /// clear
167 /// delete the allocated memory
168 ///
47c194a6 169 delete[] fData;
170}
171//___________________________________________
172UInt_t AliMUONBusStruct::GetData(Int_t n) const
173{
00e86732 174 ///
175 /// get data
176 ///
47c194a6 177 if ( n>=0 && n<fLength ) return fData[n];
178
179 AliError("Index outside limits.");
180 return 0;
181}
182
183//___________________________________________
184Char_t AliMUONBusStruct::GetParity(Int_t n) const
185{
00e86732 186 ///
187 /// get parity
188 ///
6dee95a7 189 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 31) & 0x1;
47c194a6 190
191 AliError("Index outside limits.");
192 return 0;
193}
194
195//___________________________________________
196UShort_t AliMUONBusStruct::GetManuId(Int_t n) const
197{
00e86732 198 ///
199 /// get manu Id
200 ///
47c194a6 201 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) & 0x7FF;
202
203 AliError("Index outside limits.");
204 return 0;
205}
206
207//___________________________________________
000e9681 208UChar_t AliMUONBusStruct::GetChannelId(Int_t n) const
47c194a6 209{
00e86732 210 ///
211 /// get channel Id
212 ///
47c194a6 213 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F;
214
215 AliError("Index outside limits.");
216 return 0;
217}
218
219//___________________________________________
220UShort_t AliMUONBusStruct::GetCharge(Int_t n) const
221{
00e86732 222 ///
223 /// get charge (in ADC)
224 ///
47c194a6 225 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF);
226
227 AliError("Index outside limits.");
228 return 0;
229}
1ed3c5c2 230
231//___________________________________________
232void AliMUONBusStruct::Print(Option_t* opt) const
233{
234 /// print out
235
236 cout << "Bus patch info" << endl;
237 cout << "DataKey: " << fDataKey << endl;
238 cout << "fTotalLength: " << fTotalLength << endl;
239 cout << "fLength: " << fLength << endl;
240 cout << "fBusPatchId: " << fBusPatchId << endl;
241 cout << "fBufSize: " << fBufSize << endl;
242
243 if (strstr(opt, "all")) {
244 for (Int_t i = 0; i <fLength; ++i)
245 cout << "Data["<< i << "] = " << fData[i] << endl;
246 }
247}
248
249