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()
45 fData(new UInt_t[1024]),
55 //___________________________________________
56 AliMUONBusStruct::~AliMUONBusStruct()
64 //___________________________________________
65 void AliMUONBusStruct::SetAlloc(Int_t size)
68 // Allocate size per default 1024;
69 // return if size < 1024
76 //___________________________________________
77 void AliMUONBusStruct::AddData(UInt_t data)
79 // could have used class from ROOT
80 // but the structure must be as simple as possible
81 // to be written on disc blockwise, not so sure ?
82 if (fLength == fBufSize)
84 fData[fLength++] = data;
85 fTotalLength = fLength + fgkHeaderLength;
88 //___________________________________________
89 void AliMUONBusStruct::ResizeData(Int_t size)
91 // In case of resizing the vector
92 // the most simplest way to do it
98 UInt_t* newData = new UInt_t[fBufSize];
99 for (Int_t i = 0; i < fLength; i++)
100 newData[i] = fData[i];
104 //___________________________________________
106 AliMUONBusStruct(const AliMUONBusStruct& event)
108 fDataKey(event.fDataKey),
109 fTotalLength(event.fTotalLength),
110 fLength(event.fLength),
111 fBusPatchId(event.fBusPatchId),
112 fData(new UInt_t[event.fBufSize]),
113 fBufSize(event.fBufSize),
114 fDspId(event.fDspId),
121 for (int i = 0; i < event.fBufSize; i++)
122 fData[i] = event.fData[i];
124 //___________________________________________
126 AliMUONBusStruct::operator=(const AliMUONBusStruct& event)
129 // assignment operator
131 if (this == &event) return *this;
132 fDataKey = event.fDataKey;
133 fTotalLength = event.fTotalLength;
134 fLength = event.fLength;
135 fBusPatchId = event.fBusPatchId;
136 fBufSize = event.fBufSize;
138 fBlkId = event.fBlkId;
139 fDspId = event.fDspId;
142 fData = new UInt_t[event.fBufSize];
143 for (int i = 0; i < event.fLength; i++)
144 fData[i] = event.fData[i];
148 //___________________________________________
149 Int_t AliMUONBusStruct::Compare(const TObject *obj) const
152 // sort bus patch by bus patch number
153 // important for AliMUONRawWriter
155 AliMUONBusStruct* event = (AliMUONBusStruct*) obj;
156 return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
159 //___________________________________________
160 void AliMUONBusStruct::Clear(Option_t *)
163 // delete the allocated memory
168 //___________________________________________
169 UInt_t AliMUONBusStruct::GetData(Int_t n) const
174 if ( n>=0 && n<fLength ) return fData[n];
176 AliError("Index outside limits.");
180 //___________________________________________
181 Char_t AliMUONBusStruct::GetParity(Int_t n) const
186 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 31) & 0x1;
188 AliError("Index outside limits.");
192 //___________________________________________
193 UShort_t AliMUONBusStruct::GetManuId(Int_t n) const
198 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) & 0x7FF;
200 AliError("Index outside limits.");
204 //___________________________________________
205 Char_t AliMUONBusStruct::GetChannelId(Int_t n) const
210 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F;
212 AliError("Index outside limits.");
216 //___________________________________________
217 UShort_t AliMUONBusStruct::GetCharge(Int_t n) const
220 // get charge (in ADC)
222 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF);
224 AliError("Index outside limits.");