]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONBusStruct.cxx
Updated comments for Doxygen - corrected warnings
[u/mrichter/AliRoot.git] / MUON / AliMUONBusStruct.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /* $Id$ */
17  
18 #include "AliMUONBusStruct.h"
19 #include "AliLog.h"
20
21
22 /// 
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)
29 ///
30
31 /// \cond CLASSIMP
32 ClassImp(AliMUONBusStruct)
33 /// \endcond
34
35 const Int_t AliMUONBusStruct::fgkHeaderLength = 4;
36
37 //___________________________________________
38 AliMUONBusStruct::AliMUONBusStruct()
39   :  TObject(),
40      fTotalLength(0),
41      fLength(0),
42      fBusPatchId(0),
43      fTriggerWord(0),
44      fBufSize(1024),
45      fDspId(0),
46      fBlkId(0)
47 {
48   //
49   // ctor
50   // 
51   fData = new UInt_t[fBufSize];
52 }
53 //___________________________________________
54 AliMUONBusStruct::~AliMUONBusStruct()
55 {
56   //
57   // dtor
58   //
59   delete[] fData;
60 }
61
62 //___________________________________________
63 void AliMUONBusStruct::SetAlloc(Int_t size)
64 {
65   //
66   // Allocate size per default 1024;
67   // return if size < 1024
68   //
69   if (size < fBufSize) 
70     return;
71   else 
72     ResizeData(size);
73 }
74 //___________________________________________
75 void AliMUONBusStruct::AddData(UInt_t data)
76 {
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) 
81     ResizeData();
82   fData[fLength++] = data;
83   fTotalLength = fLength + fgkHeaderLength;
84 }
85
86 //___________________________________________
87 void AliMUONBusStruct::ResizeData(Int_t size)
88 {
89   // In case of resizing the vector
90   // the most simplest way to do it
91   //
92   if (size == 0)
93     fBufSize *= 2;
94   else
95     fBufSize = size;
96   UInt_t* newData = new UInt_t[fBufSize];
97   for (Int_t i = 0; i < fLength; i++)
98     newData[i] = fData[i];
99   delete[] fData;
100   fData = newData;
101 }
102 //___________________________________________
103 AliMUONBusStruct::
104 AliMUONBusStruct(const AliMUONBusStruct& event): TObject(event)
105 {
106   //
107   // copy ctor
108   //
109   fTotalLength = event.fTotalLength;
110   fLength      = event.fLength;
111   fBusPatchId  = event.fBusPatchId;
112   fTriggerWord = event.fTriggerWord;
113   fBufSize     = event.fBufSize;
114
115   fBlkId = event.fBlkId;
116   fDspId = event.fDspId;
117
118   fData =  new UInt_t[event.fBufSize];
119   for (int i = 0; i < event.fBufSize; i++)
120     fData[i] = event.fData[i];
121 }
122 //___________________________________________
123 AliMUONBusStruct&
124 AliMUONBusStruct::operator=(const AliMUONBusStruct& event)
125 {
126   //
127   // assignment operator
128   //
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;
135
136   fBlkId = event.fBlkId;
137   fDspId = event.fDspId;
138
139   delete [] fData;  
140   fData =  new UInt_t[event.fBufSize];
141   for (int i = 0; i < event.fLength; i++)
142     fData[i] = event.fData[i];
143
144   return *this;
145 }
146 //___________________________________________
147 Int_t AliMUONBusStruct::Compare(const TObject *obj) const
148 {
149   // 
150   // sort bus patch by bus patch number
151   // important for AliMUONRawWriter
152   //
153   AliMUONBusStruct* event = (AliMUONBusStruct*) obj;
154   return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
155 }
156
157 //___________________________________________
158 void AliMUONBusStruct::Clear(Option_t *)
159 {
160   // clear
161   // delete the allocated memory 
162   //
163
164   delete[] fData;
165 }
166 //___________________________________________
167 UInt_t AliMUONBusStruct::GetData(Int_t n) const 
168 {
169   //
170   // get data
171   //
172   if ( n>=0 && n<fLength ) return fData[n];
173
174   AliError("Index outside limits."); 
175   return 0; 
176 }
177
178 //___________________________________________
179 Char_t AliMUONBusStruct::GetParity(Int_t n) const   
180 {
181   //
182   // get parity
183   //
184   if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 29) &  0x7;
185
186   AliError("Index outside limits."); 
187   return 0; 
188 }
189
190 //___________________________________________
191 UShort_t AliMUONBusStruct::GetManuId(Int_t n) const     
192 {
193   //
194   // get manu Id
195   //
196   if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) &  0x7FF;
197
198   AliError("Index outside limits."); 
199   return 0; 
200 }
201
202 //___________________________________________
203 Char_t AliMUONBusStruct::GetChannelId(Int_t n) const  
204 {
205   // 
206   // get channel Id
207   //
208   if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F;
209
210   AliError("Index outside limits."); 
211   return 0; 
212 }
213
214 //___________________________________________
215 UShort_t AliMUONBusStruct::GetCharge(Int_t n) const     
216 {
217   //
218   // get charge (in ADC)
219   //
220   if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF);
221
222   AliError("Index outside limits."); 
223   return 0; 
224 }