]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSubEventTracker.cxx
Adding commented lines for setting local misalignment data
[u/mrichter/AliRoot.git] / MUON / AliMUONSubEventTracker.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 "AliMUONSubEventTracker.h"
19
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
32 const Int_t AliMUONSubEventTracker::fgkHeaderLength = 4;
33
34 ClassImp(AliMUONSubEventTracker)
35
36 //___________________________________________
37 AliMUONSubEventTracker::AliMUONSubEventTracker()
38   :  TObject(),
39      fTotalLength(0),
40      fLength(0),
41      fBusPatchId(0),
42      fTriggerWord(0),
43      fBufSize(1024)
44 {
45   //
46   //ctor
47   //
48   fData = new UInt_t[fBufSize];
49 }
50 //___________________________________________
51 AliMUONSubEventTracker::~AliMUONSubEventTracker()
52 {
53   //
54   // dtor
55   //
56   delete[] fData;
57 }
58
59 //___________________________________________
60 void AliMUONSubEventTracker::SetAlloc(Int_t size)
61 {
62   //
63   // Allocate size per default 1024;
64   // return if size < 1024
65   //
66   if (size < fBufSize) 
67     return;
68   else 
69     ResizeData(size);
70 }
71 //___________________________________________
72 void AliMUONSubEventTracker::AddData(UInt_t data)
73 {
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) 
78     ResizeData();
79   fData[fLength++] = data;
80   fTotalLength = fLength + 4;
81 }
82
83 //___________________________________________
84 void AliMUONSubEventTracker::ResizeData(Int_t size)
85 {
86   // In case of resizing the vector
87   // the most simplest way to do it
88   //
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 //___________________________________________
100 AliMUONSubEventTracker::
101 AliMUONSubEventTracker(const AliMUONSubEventTracker& event): TObject(event)
102 {
103   //
104   // copy ctor
105   //
106   fTotalLength = event.fTotalLength;
107   fLength      = event.fLength;
108   fBusPatchId  = event.fBusPatchId;
109   fTriggerWord = event.fTriggerWord;
110   fBufSize     = event.fBufSize;
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 //___________________________________________
117 AliMUONSubEventTracker&
118 AliMUONSubEventTracker::operator=(const AliMUONSubEventTracker& event)
119 {
120   //
121   // assignment operator
122   //
123   if (this == &event) return *this;
124   fTotalLength = event.fTotalLength;
125   fLength      = event.fLength;
126   fBusPatchId  = event.fBusPatchId;
127   fTriggerWord = event.fTriggerWord;
128   fBufSize     = event.fBufSize;
129
130   delete [] fData;  
131   fData =  new UInt_t[event.fBufSize];
132   for (int i = 0; i < event.fBufSize; i++)
133     fData[i] = event.fData[i];
134
135   return *this;
136 }
137 //___________________________________________
138 Int_t AliMUONSubEventTracker::Compare(const TObject *obj) const
139 {
140   // 
141   // sort bus patch by bus patch number
142   // important for AliMUONRawWriter
143   //
144   AliMUONSubEventTracker* event = (AliMUONSubEventTracker*) obj;
145   return (fBusPatchId > event->GetBusPatchId()) ? 1 : -1;
146 }
147
148 //___________________________________________
149 UInt_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 //___________________________________________
161 Char_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 //___________________________________________
173 UShort_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 //___________________________________________
185 Char_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 //___________________________________________
197 UShort_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 }