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;
37 //___________________________________________
38 AliMUONBusStruct::AliMUONBusStruct()
51 fData = new UInt_t[fBufSize];
53 //___________________________________________
54 AliMUONBusStruct::~AliMUONBusStruct()
62 //___________________________________________
63 void AliMUONBusStruct::SetAlloc(Int_t size)
66 // Allocate size per default 1024;
67 // return if size < 1024
74 //___________________________________________
75 void AliMUONBusStruct::AddData(UInt_t data)
77 // could have used class from ROOT
78 // but the structure must be as simple as possible
79 // to be written on disc blockwise, not so sure ?
80 if (fLength == fBufSize)
82 fData[fLength++] = data;
83 fTotalLength = fLength + fgkHeaderLength;
86 //___________________________________________
87 void AliMUONBusStruct::ResizeData(Int_t size)
89 // In case of resizing the vector
90 // the most simplest way to do it
96 UInt_t* newData = new UInt_t[fBufSize];
97 for (Int_t i = 0; i < fLength; i++)
98 newData[i] = fData[i];
102 //___________________________________________
104 AliMUONBusStruct(const AliMUONBusStruct& event): TObject(event)
109 fTotalLength = event.fTotalLength;
110 fLength = event.fLength;
111 fBusPatchId = event.fBusPatchId;
112 fTriggerWord = event.fTriggerWord;
113 fBufSize = event.fBufSize;
115 fBlkId = event.fBlkId;
116 fDspId = event.fDspId;
118 fData = new UInt_t[event.fBufSize];
119 for (int i = 0; i < event.fBufSize; i++)
120 fData[i] = event.fData[i];
122 //___________________________________________
124 AliMUONBusStruct::operator=(const AliMUONBusStruct& event)
127 // assignment operator
129 if (this == &event) return *this;
130 fTotalLength = event.fTotalLength;
131 fLength = event.fLength;
132 fBusPatchId = event.fBusPatchId;
133 fTriggerWord = event.fTriggerWord;
134 fBufSize = event.fBufSize;
136 fBlkId = event.fBlkId;
137 fDspId = event.fDspId;
140 fData = new UInt_t[event.fBufSize];
141 for (int i = 0; i < event.fLength; i++)
142 fData[i] = event.fData[i];
146 //___________________________________________
147 Int_t AliMUONBusStruct::Compare(const TObject *obj) const
150 // sort bus patch by bus patch number
151 // important for AliMUONRawWriter
153 AliMUONBusStruct* event = (AliMUONBusStruct*) obj;
154 return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
157 //___________________________________________
158 void AliMUONBusStruct::Clear(Option_t *)
161 // delete the allocated memory
166 //___________________________________________
167 UInt_t AliMUONBusStruct::GetData(Int_t n) const
172 if ( n>=0 && n<fLength ) return fData[n];
174 AliError("Index outside limits.");
178 //___________________________________________
179 Char_t AliMUONBusStruct::GetParity(Int_t n) const
184 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 29) & 0x7;
186 AliError("Index outside limits.");
190 //___________________________________________
191 UShort_t AliMUONBusStruct::GetManuId(Int_t n) const
196 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) & 0x7FF;
198 AliError("Index outside limits.");
202 //___________________________________________
203 Char_t AliMUONBusStruct::GetChannelId(Int_t n) const
208 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F;
210 AliError("Index outside limits.");
214 //___________________________________________
215 UShort_t AliMUONBusStruct::GetCharge(Int_t n) const
218 // get charge (in ADC)
220 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF);
222 AliError("Index outside limits.");