1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONBusStruct.h"
21 #include <Riostream.h>
24 //-----------------------------------------------------------------------------
25 /// \class AliMUONBusStruct
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)
33 /// \author Christian Finck
34 //-----------------------------------------------------------------------------
39 ClassImp(AliMUONBusStruct)
42 const Int_t AliMUONBusStruct::fgkHeaderLength = 4;
43 const UInt_t AliMUONBusStruct::fgkDefaultDataKey = 0xB000000B;
44 const Int_t AliMUONBusStruct::fgkManuNofChannels(64);
46 //___________________________________________
47 AliMUONBusStruct::AliMUONBusStruct()
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]),
65 //___________________________________________
66 AliMUONBusStruct::~AliMUONBusStruct()
74 //___________________________________________
75 void AliMUONBusStruct::SetAlloc(Int_t size)
79 /// return if size < fBufSize
86 //___________________________________________
87 void AliMUONBusStruct::AddData(UInt_t data)
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 ?
92 if (fLength == fBufSize)
94 fData[fLength++] = data;
95 fTotalLength = fLength + fgkHeaderLength;
98 //___________________________________________
99 void AliMUONBusStruct::ResizeData(Int_t size)
101 /// In case of resizing the vector
102 /// the most simplest way to do it
108 UInt_t* newData = new UInt_t[fBufSize];
109 for (Int_t i = 0; i < fLength; i++)
110 newData[i] = fData[i];
114 //___________________________________________
116 AliMUONBusStruct(const AliMUONBusStruct& 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),
131 for (int i = 0; i < event.fBufSize; i++)
132 fData[i] = event.fData[i];
134 //___________________________________________
136 AliMUONBusStruct::operator=(const AliMUONBusStruct& event)
139 /// assignment operator
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;
148 fBlkId = event.fBlkId;
149 fDspId = event.fDspId;
152 fData = new UInt_t[event.fBufSize];
153 for (int i = 0; i < event.fLength; i++)
154 fData[i] = event.fData[i];
158 //___________________________________________
159 Int_t AliMUONBusStruct::Compare(const TObject *obj) const
162 /// sort bus patch by bus patch number
163 /// important for AliMUONRawWriter
165 AliMUONBusStruct* event = (AliMUONBusStruct*) obj;
166 return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
169 //___________________________________________
170 void AliMUONBusStruct::Clear(Option_t *)
173 /// delete the allocated memory
177 //___________________________________________
178 UInt_t AliMUONBusStruct::GetData(Int_t n) const
183 if ( n>=0 && n<fLength ) return fData[n];
185 AliError("Index outside limits.");
189 //___________________________________________
190 Char_t AliMUONBusStruct::GetParity(Int_t n) const
195 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 31) & 0x1;
197 AliError("Index outside limits.");
201 //___________________________________________
202 UShort_t AliMUONBusStruct::GetManuId(Int_t n) const
207 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) & 0x7FF;
209 AliError("Index outside limits.");
213 //___________________________________________
214 UChar_t AliMUONBusStruct::GetChannelId(Int_t n) const
219 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F;
221 AliError("Index outside limits.");
225 //___________________________________________
226 UShort_t AliMUONBusStruct::GetCharge(Int_t n) const
229 /// get charge (in ADC)
231 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF);
233 AliError("Index outside limits.");
237 //___________________________________________
238 void AliMUONBusStruct::Print(Option_t* opt) const
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;
249 if (strstr(opt, "all")) {
250 for (Int_t i = 0; i <fLength; ++i)
251 cout << "Data["<< i << "] = " << fData[i] << endl;