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 **************************************************************************/
16 #include "AliMUONBusStruct.h"
21 /// Bus patch structure for tracker raw data
22 /// each Dsp contains at most 5 bus patch structure
23 /// Beside the total length and length of the below data
24 /// the header of the block contains the bus patch id, trigger words
25 /// and data structure itself (11bits for manu id, 6 bits for channel id and
26 /// 12 bits for charge)
30 ClassImp(AliMUONBusStruct)
32 const Int_t AliMUONBusStruct::fgkHeaderLength = 4;
34 //___________________________________________
35 AliMUONBusStruct::AliMUONBusStruct()
48 fData = new UInt_t[fBufSize];
50 //___________________________________________
51 AliMUONBusStruct::~AliMUONBusStruct()
59 //___________________________________________
60 void AliMUONBusStruct::SetAlloc(Int_t size)
63 // Allocate size per default 1024;
64 // return if size < 1024
71 //___________________________________________
72 void AliMUONBusStruct::AddData(UInt_t data)
74 // could have used class from ROOT
75 // but the structure must be as simple as possible
76 // to be written on disc blockwise, not so sure ?
77 if (fLength == fBufSize)
79 fData[fLength++] = data;
80 fTotalLength = fLength + fgkHeaderLength;
83 //___________________________________________
84 void AliMUONBusStruct::ResizeData(Int_t size)
86 // In case of resizing the vector
87 // the most simplest way to do it
93 UInt_t* newData = new UInt_t[fBufSize];
94 for (Int_t i = 0; i < fLength; i++)
95 newData[i] = fData[i];
99 //___________________________________________
101 AliMUONBusStruct(const AliMUONBusStruct& event): TObject(event)
106 fTotalLength = event.fTotalLength;
107 fLength = event.fLength;
108 fBusPatchId = event.fBusPatchId;
109 fTriggerWord = event.fTriggerWord;
110 fBufSize = event.fBufSize;
112 fBlkId = event.fBlkId;
113 fDspId = event.fDspId;
115 fData = new UInt_t[event.fBufSize];
116 for (int i = 0; i < event.fBufSize; i++)
117 fData[i] = event.fData[i];
119 //___________________________________________
121 AliMUONBusStruct::operator=(const AliMUONBusStruct& event)
124 // assignment operator
126 if (this == &event) return *this;
127 fTotalLength = event.fTotalLength;
128 fLength = event.fLength;
129 fBusPatchId = event.fBusPatchId;
130 fTriggerWord = event.fTriggerWord;
131 fBufSize = event.fBufSize;
133 fBlkId = event.fBlkId;
134 fDspId = event.fDspId;
137 fData = new UInt_t[event.fBufSize];
138 for (int i = 0; i < event.fLength; i++)
139 fData[i] = event.fData[i];
143 //___________________________________________
144 Int_t AliMUONBusStruct::Compare(const TObject *obj) const
147 // sort bus patch by bus patch number
148 // important for AliMUONRawWriter
150 AliMUONBusStruct* event = (AliMUONBusStruct*) obj;
151 return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
154 //___________________________________________
155 void AliMUONBusStruct::Clear(Option_t *)
158 // delete the allocated memory
163 //___________________________________________
164 UInt_t AliMUONBusStruct::GetData(Int_t n) const
169 if ( n>=0 && n<fLength ) return fData[n];
171 AliError("Index outside limits.");
175 //___________________________________________
176 Char_t AliMUONBusStruct::GetParity(Int_t n) const
181 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 29) & 0x7;
183 AliError("Index outside limits.");
187 //___________________________________________
188 UShort_t AliMUONBusStruct::GetManuId(Int_t n) const
193 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) & 0x7FF;
195 AliError("Index outside limits.");
199 //___________________________________________
200 Char_t AliMUONBusStruct::GetChannelId(Int_t n) const
205 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F;
207 AliError("Index outside limits.");
211 //___________________________________________
212 UShort_t AliMUONBusStruct::GetCharge(Int_t n) const
215 // get charge (in ADC)
217 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF);
219 AliError("Index outside limits.");