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"
23 /// Bus patch structure for tracker raw data
24 /// each Dsp contains at most 5 bus patch structure
25 /// Beside the total length and length of the below data
26 /// the header of the block contains the bus patch id, trigger words
27 /// and data structure itself (11bits for manu id, 6 bits for channel id and
28 /// 12 bits for charge)
32 ClassImp(AliMUONBusStruct)
35 const Int_t AliMUONBusStruct::fgkHeaderLength = 4;
36 const UInt_t AliMUONBusStruct::fgkDefaultDataKey = 0xB000000B;
38 //___________________________________________
39 AliMUONBusStruct::AliMUONBusStruct()
46 /* assuming 43 manus max per bustpatch.
47 Anyway fData is resized where needed (though it makes it slower) */
48 fData(new UInt_t[fBufSize]),
57 //___________________________________________
58 AliMUONBusStruct::~AliMUONBusStruct()
66 //___________________________________________
67 void AliMUONBusStruct::SetAlloc(Int_t size)
71 // return if size < fBufSize
78 //___________________________________________
79 void AliMUONBusStruct::AddData(UInt_t data)
81 // could have used class from ROOT
82 // but the structure must be as simple as possible
83 // to be written on disc blockwise, not so sure ?
84 if (fLength == fBufSize)
86 fData[fLength++] = data;
87 fTotalLength = fLength + fgkHeaderLength;
90 //___________________________________________
91 void AliMUONBusStruct::ResizeData(Int_t size)
93 // In case of resizing the vector
94 // the most simplest way to do it
96 AliInfo("reallocating");
101 UInt_t* newData = new UInt_t[fBufSize];
102 for (Int_t i = 0; i < fLength; i++)
103 newData[i] = fData[i];
107 //___________________________________________
109 AliMUONBusStruct(const AliMUONBusStruct& event)
111 fDataKey(event.fDataKey),
112 fTotalLength(event.fTotalLength),
113 fLength(event.fLength),
114 fBusPatchId(event.fBusPatchId),
115 fBufSize(event.fBufSize),
116 fData(new UInt_t[event.fBufSize]),
117 fDspId(event.fDspId),
124 for (int i = 0; i < event.fBufSize; i++)
125 fData[i] = event.fData[i];
127 //___________________________________________
129 AliMUONBusStruct::operator=(const AliMUONBusStruct& event)
132 // assignment operator
134 if (this == &event) return *this;
135 fDataKey = event.fDataKey;
136 fTotalLength = event.fTotalLength;
137 fLength = event.fLength;
138 fBusPatchId = event.fBusPatchId;
139 fBufSize = event.fBufSize;
141 fBlkId = event.fBlkId;
142 fDspId = event.fDspId;
145 fData = new UInt_t[event.fBufSize];
146 for (int i = 0; i < event.fLength; i++)
147 fData[i] = event.fData[i];
151 //___________________________________________
152 Int_t AliMUONBusStruct::Compare(const TObject *obj) const
155 // sort bus patch by bus patch number
156 // important for AliMUONRawWriter
158 AliMUONBusStruct* event = (AliMUONBusStruct*) obj;
159 return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
162 //___________________________________________
163 void AliMUONBusStruct::Clear(Option_t *)
166 // 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 Char_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.");