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 //-----------------------------------------------------------------------------
37 ClassImp(AliMUONBusStruct)
40 const Int_t AliMUONBusStruct::fgkHeaderLength = 4;
41 const UInt_t AliMUONBusStruct::fgkDefaultDataKey = 0xB000000B;
42 const Int_t AliMUONBusStruct::fgkManuNofChannels(64);
44 //___________________________________________
45 AliMUONBusStruct::AliMUONBusStruct()
51 fBufSize(43*fgkManuNofChannels),
52 /* assuming 43 manus max per bustpatch.
53 Anyway fData is resized where needed (though it makes it slower) */
54 fData(new UInt_t[fBufSize]),
63 //___________________________________________
64 AliMUONBusStruct::~AliMUONBusStruct()
72 //___________________________________________
73 void AliMUONBusStruct::SetAlloc(Int_t size)
77 /// return if size < fBufSize
84 //___________________________________________
85 void AliMUONBusStruct::AddData(UInt_t data)
87 /// could have used class from ROOT
88 /// but the structure must be as simple as possible
89 /// to be written on disc blockwise, not so sure ?
90 if (fLength == fBufSize)
92 fData[fLength++] = data;
93 fTotalLength = fLength + fgkHeaderLength;
96 //___________________________________________
97 void AliMUONBusStruct::ResizeData(Int_t size)
99 /// In case of resizing the vector
100 /// the most simplest way to do it
106 UInt_t* newData = new UInt_t[fBufSize];
107 for (Int_t i = 0; i < fLength; i++)
108 newData[i] = fData[i];
112 //___________________________________________
114 AliMUONBusStruct(const AliMUONBusStruct& event)
116 fDataKey(event.fDataKey),
117 fTotalLength(event.fTotalLength),
118 fLength(event.fLength),
119 fBusPatchId(event.fBusPatchId),
120 fBufSize(event.fBufSize),
121 fData(new UInt_t[event.fBufSize]),
122 fDspId(event.fDspId),
129 for (int i = 0; i < event.fBufSize; i++)
130 fData[i] = event.fData[i];
132 //___________________________________________
134 AliMUONBusStruct::operator=(const AliMUONBusStruct& event)
137 /// assignment operator
139 if (this == &event) return *this;
140 fDataKey = event.fDataKey;
141 fTotalLength = event.fTotalLength;
142 fLength = event.fLength;
143 fBusPatchId = event.fBusPatchId;
144 fBufSize = event.fBufSize;
146 fBlkId = event.fBlkId;
147 fDspId = event.fDspId;
150 fData = new UInt_t[event.fBufSize];
151 for (int i = 0; i < event.fLength; i++)
152 fData[i] = event.fData[i];
156 //___________________________________________
157 Int_t AliMUONBusStruct::Compare(const TObject *obj) const
160 /// sort bus patch by bus patch number
161 /// important for AliMUONRawWriter
163 AliMUONBusStruct* event = (AliMUONBusStruct*) obj;
164 return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
167 //___________________________________________
168 void AliMUONBusStruct::Clear(Option_t *)
171 /// delete the allocated memory
175 //___________________________________________
176 UInt_t AliMUONBusStruct::GetData(Int_t n) const
181 if ( n>=0 && n<fLength ) return fData[n];
183 AliError("Index outside limits.");
187 //___________________________________________
188 Char_t AliMUONBusStruct::GetParity(Int_t n) const
193 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 31) & 0x1;
195 AliError("Index outside limits.");
199 //___________________________________________
200 UShort_t AliMUONBusStruct::GetManuId(Int_t n) const
205 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) & 0x7FF;
207 AliError("Index outside limits.");
211 //___________________________________________
212 UChar_t AliMUONBusStruct::GetChannelId(Int_t n) const
217 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F;
219 AliError("Index outside limits.");
223 //___________________________________________
224 UShort_t AliMUONBusStruct::GetCharge(Int_t n) const
227 /// get charge (in ADC)
229 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF);
231 AliError("Index outside limits.");
235 //___________________________________________
236 void AliMUONBusStruct::Print(Option_t* opt) const
240 cout << "Bus patch info" << endl;
241 cout << "DataKey: " << fDataKey << endl;
242 cout << "fTotalLength: " << fTotalLength << endl;
243 cout << "fLength: " << fLength << endl;
244 cout << "fBusPatchId: " << fBusPatchId << endl;
245 cout << "fBufSize: " << fBufSize << endl;
247 if (strstr(opt, "all")) {
248 for (Int_t i = 0; i <fLength; ++i)
249 cout << "Data["<< i << "] = " << fData[i] << endl;