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()
52 fData = new UInt_t[fBufSize];
54 //___________________________________________
55 AliMUONBusStruct::~AliMUONBusStruct()
63 //___________________________________________
64 void AliMUONBusStruct::SetAlloc(Int_t size)
67 // Allocate size per default 1024;
68 // return if size < 1024
75 //___________________________________________
76 void AliMUONBusStruct::AddData(UInt_t data)
78 // could have used class from ROOT
79 // but the structure must be as simple as possible
80 // to be written on disc blockwise, not so sure ?
81 if (fLength == fBufSize)
83 fData[fLength++] = data;
84 fTotalLength = fLength + fgkHeaderLength;
87 //___________________________________________
88 void AliMUONBusStruct::ResizeData(Int_t size)
90 // In case of resizing the vector
91 // the most simplest way to do it
97 UInt_t* newData = new UInt_t[fBufSize];
98 for (Int_t i = 0; i < fLength; i++)
99 newData[i] = fData[i];
103 //___________________________________________
105 AliMUONBusStruct(const AliMUONBusStruct& event): TObject(event)
110 fDataKey = event.fDataKey;
111 fTotalLength = event.fTotalLength;
112 fLength = event.fLength;
113 fBusPatchId = event.fBusPatchId;
114 fBufSize = event.fBufSize;
116 fBlkId = event.fBlkId;
117 fDspId = event.fDspId;
119 fData = new UInt_t[event.fBufSize];
120 for (int i = 0; i < event.fBufSize; i++)
121 fData[i] = event.fData[i];
123 //___________________________________________
125 AliMUONBusStruct::operator=(const AliMUONBusStruct& event)
128 // assignment operator
130 if (this == &event) return *this;
131 fDataKey = event.fDataKey;
132 fTotalLength = event.fTotalLength;
133 fLength = event.fLength;
134 fBusPatchId = event.fBusPatchId;
135 fBufSize = event.fBufSize;
137 fBlkId = event.fBlkId;
138 fDspId = event.fDspId;
141 fData = new UInt_t[event.fBufSize];
142 for (int i = 0; i < event.fLength; i++)
143 fData[i] = event.fData[i];
147 //___________________________________________
148 Int_t AliMUONBusStruct::Compare(const TObject *obj) const
151 // sort bus patch by bus patch number
152 // important for AliMUONRawWriter
154 AliMUONBusStruct* event = (AliMUONBusStruct*) obj;
155 return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
158 //___________________________________________
159 void AliMUONBusStruct::Clear(Option_t *)
162 // delete the allocated memory
167 //___________________________________________
168 UInt_t AliMUONBusStruct::GetData(Int_t n) const
173 if ( n>=0 && n<fLength ) return fData[n];
175 AliError("Index outside limits.");
179 //___________________________________________
180 Char_t AliMUONBusStruct::GetParity(Int_t n) const
185 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 29) & 0x7;
187 AliError("Index outside limits.");
191 //___________________________________________
192 UShort_t AliMUONBusStruct::GetManuId(Int_t n) const
197 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) & 0x7FF;
199 AliError("Index outside limits.");
203 //___________________________________________
204 Char_t AliMUONBusStruct::GetChannelId(Int_t n) const
209 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F;
211 AliError("Index outside limits.");
215 //___________________________________________
216 UShort_t AliMUONBusStruct::GetCharge(Int_t n) const
219 // get charge (in ADC)
221 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF);
223 AliError("Index outside limits.");