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"
20 #include <Riostream.h>
23 /// \class AliMUONBusStruct
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)
31 /// \author Christian Finck
34 ClassImp(AliMUONBusStruct)
37 const Int_t AliMUONBusStruct::fgkHeaderLength = 4;
38 const UInt_t AliMUONBusStruct::fgkDefaultDataKey = 0xB000000B;
40 //___________________________________________
41 AliMUONBusStruct::AliMUONBusStruct()
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]),
59 //___________________________________________
60 AliMUONBusStruct::~AliMUONBusStruct()
68 //___________________________________________
69 void AliMUONBusStruct::SetAlloc(Int_t size)
73 /// return if size < fBufSize
80 //___________________________________________
81 void AliMUONBusStruct::AddData(UInt_t data)
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 ?
86 if (fLength == fBufSize)
88 fData[fLength++] = data;
89 fTotalLength = fLength + fgkHeaderLength;
92 //___________________________________________
93 void AliMUONBusStruct::ResizeData(Int_t size)
95 /// In case of resizing the vector
96 /// the most simplest way to do it
102 UInt_t* newData = new UInt_t[fBufSize];
103 for (Int_t i = 0; i < fLength; i++)
104 newData[i] = fData[i];
108 //___________________________________________
110 AliMUONBusStruct(const AliMUONBusStruct& event)
112 fDataKey(event.fDataKey),
113 fTotalLength(event.fTotalLength),
114 fLength(event.fLength),
115 fBusPatchId(event.fBusPatchId),
116 fBufSize(event.fBufSize),
117 fData(new UInt_t[event.fBufSize]),
118 fDspId(event.fDspId),
125 for (int i = 0; i < event.fBufSize; i++)
126 fData[i] = event.fData[i];
128 //___________________________________________
130 AliMUONBusStruct::operator=(const AliMUONBusStruct& event)
133 /// assignment operator
135 if (this == &event) return *this;
136 fDataKey = event.fDataKey;
137 fTotalLength = event.fTotalLength;
138 fLength = event.fLength;
139 fBusPatchId = event.fBusPatchId;
140 fBufSize = event.fBufSize;
142 fBlkId = event.fBlkId;
143 fDspId = event.fDspId;
146 fData = new UInt_t[event.fBufSize];
147 for (int i = 0; i < event.fLength; i++)
148 fData[i] = event.fData[i];
152 //___________________________________________
153 Int_t AliMUONBusStruct::Compare(const TObject *obj) const
156 /// sort bus patch by bus patch number
157 /// important for AliMUONRawWriter
159 AliMUONBusStruct* event = (AliMUONBusStruct*) obj;
160 return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
163 //___________________________________________
164 void AliMUONBusStruct::Clear(Option_t *)
167 /// delete the allocated memory
171 //___________________________________________
172 UInt_t AliMUONBusStruct::GetData(Int_t n) const
177 if ( n>=0 && n<fLength ) return fData[n];
179 AliError("Index outside limits.");
183 //___________________________________________
184 Char_t AliMUONBusStruct::GetParity(Int_t n) const
189 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 31) & 0x1;
191 AliError("Index outside limits.");
195 //___________________________________________
196 UShort_t AliMUONBusStruct::GetManuId(Int_t n) const
201 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) & 0x7FF;
203 AliError("Index outside limits.");
207 //___________________________________________
208 UChar_t AliMUONBusStruct::GetChannelId(Int_t n) const
213 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F;
215 AliError("Index outside limits.");
219 //___________________________________________
220 UShort_t AliMUONBusStruct::GetCharge(Int_t n) const
223 /// get charge (in ADC)
225 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF);
227 AliError("Index outside limits.");
231 //___________________________________________
232 void AliMUONBusStruct::Print(Option_t* opt) const
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;
243 if (strstr(opt, "all")) {
244 for (Int_t i = 0; i <fLength; ++i)
245 cout << "Data["<< i << "] = " << fData[i] << endl;