]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSubEventTracker.cxx
Updated documentation (Ivana)
[u/mrichter/AliRoot.git] / MUON / AliMUONSubEventTracker.cxx
CommitLineData
69be760c 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 **************************************************************************/
36bd4e3a 15
16// $Id$
8c343c7c 17
69be760c 18#include "AliMUONSubEventTracker.h"
19
36bd4e3a 20#include "AliLog.h"
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
d3709ca3 32const Int_t AliMUONSubEventTracker::fgkHeaderLength = 4;
69be760c 33
d3709ca3 34ClassImp(AliMUONSubEventTracker)
c8f4be1a 35
69be760c 36//___________________________________________
37AliMUONSubEventTracker::AliMUONSubEventTracker()
38 : TObject(),
39 fTotalLength(0),
40 fLength(0),
41 fBusPatchId(0),
42 fTriggerWord(0),
43 fBufSize(1024)
44{
36bd4e3a 45 //
69be760c 46 //ctor
36bd4e3a 47 //
69be760c 48 fData = new UInt_t[fBufSize];
49}
50//___________________________________________
51AliMUONSubEventTracker::~AliMUONSubEventTracker()
52{
36bd4e3a 53 //
54 // dtor
55 //
d3709ca3 56 delete[] fData;
69be760c 57}
58
59//___________________________________________
60void AliMUONSubEventTracker::SetAlloc(Int_t size)
61{
36bd4e3a 62 //
63 // Allocate size per default 1024;
64 // return if size < 1024
65 //
69be760c 66 if (size < fBufSize)
67 return;
68 else
69 ResizeData(size);
70}
71//___________________________________________
72void AliMUONSubEventTracker::AddData(UInt_t data)
73{
74 // could have used class from ROOT
75 // but the structure must be as simple as possible
c8f4be1a 76 // to be written on disc blockwise, not so sure ?
69be760c 77 if (fLength == fBufSize)
78 ResizeData();
79 fData[fLength++] = data;
80 fTotalLength = fLength + 4;
81}
82
83//___________________________________________
84void AliMUONSubEventTracker::ResizeData(Int_t size)
85{
36bd4e3a 86 // In case of resizing the vector
87 // the most simplest way to do it
88 //
69be760c 89 if (size == 0)
90 fBufSize *= 2;
91 else
92 fBufSize = size;
93 UInt_t* newData = new UInt_t[fBufSize];
94 for (Int_t i = 0; i < fLength; i++)
95 newData[i] = fData[i];
96 delete[] fData;
97 fData = newData;
98}
99//___________________________________________
100AliMUONSubEventTracker::
101AliMUONSubEventTracker(const AliMUONSubEventTracker& event): TObject(event)
102{
36bd4e3a 103 //
104 // copy ctor
105 //
69be760c 106 fTotalLength = event.fTotalLength;
36bd4e3a 107 fLength = event.fLength;
108 fBusPatchId = event.fBusPatchId;
69be760c 109 fTriggerWord = event.fTriggerWord;
36bd4e3a 110 fBufSize = event.fBufSize;
69be760c 111
112 fData = new UInt_t[event.fBufSize];
113 for (int i = 0; i < event.fBufSize; i++)
114 fData[i] = event.fData[i];
115}
116//___________________________________________
117AliMUONSubEventTracker&
118AliMUONSubEventTracker::operator=(const AliMUONSubEventTracker& event)
119{
36bd4e3a 120 //
121 // assignment operator
122 //
69be760c 123 if (this == &event) return *this;
124 fTotalLength = event.fTotalLength;
36bd4e3a 125 fLength = event.fLength;
126 fBusPatchId = event.fBusPatchId;
69be760c 127 fTriggerWord = event.fTriggerWord;
36bd4e3a 128 fBufSize = event.fBufSize;
129
130 delete [] fData;
131 fData = new UInt_t[event.fBufSize];
132 for (int i = 0; i < event.fBufSize; i++)
69be760c 133 fData[i] = event.fData[i];
134
135 return *this;
136}
137//___________________________________________
138Int_t AliMUONSubEventTracker::Compare(const TObject *obj) const
139{
36bd4e3a 140 //
141 // sort bus patch by bus patch number
142 // important for AliMUONRawWriter
143 //
69be760c 144 AliMUONSubEventTracker* event = (AliMUONSubEventTracker*) obj;
145 return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
146}
36bd4e3a 147
148//___________________________________________
149UInt_t AliMUONSubEventTracker::GetData(Int_t n) const
150{
151 //
152 // get data
153 //
154 if ( n>=0 && n<fLength ) return fData[n];
155
156 AliError("Index outside limits.");
157 return 0;
158}
159
160//___________________________________________
161Char_t AliMUONSubEventTracker::GetParity(Int_t n) const
162{
163 //
164 // get pariry
165 //
166 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 29) & 0x7;
167
168 AliError("Index outside limits.");
169 return 0;
170}
171
172//___________________________________________
173UShort_t AliMUONSubEventTracker::GetManuId(Int_t n) const
174{
175 //
176 // get manu Id
177 //
178 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] >> 18) & 0x7FF;
179
180 AliError("Index outside limits.");
181 return 0;
182}
183
184//___________________________________________
185Char_t AliMUONSubEventTracker::GetChannelId(Int_t n) const
186{
187 //
188 // get channel Id
189 //
190 if ( n>=0 && n<fLength ) return (Char_t)(fData[n] >> 12) & 0x3F;
191
192 AliError("Index outside limits.");
193 return 0;
194}
195
196//___________________________________________
197UShort_t AliMUONSubEventTracker::GetCharge(Int_t n) const
198{
199 //
200 // get charge (in ADC)
201 //
202 if ( n>=0 && n<fLength ) return (UShort_t)(fData[n] & 0xFFF);
203
204 AliError("Index outside limits.");
205 return 0;
206}