]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFdigit.cxx
Default TOF decoder: updated
[u/mrichter/AliRoot.git] / TOF / AliTOFdigit.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 //_________________________________________________________________________//
19 //                                                                         //
20 //  TOF digit: member variables                                            //
21 //  fSector  : TOF sector                                                  //
22 //  fPlate   : TOF plate                                                   //
23 //  fStrip   : strips number                                               //
24 //  fPadx    : pad number along x                                          //
25 //  fPadz    : pad number along z                                          //
26 //  fTdc     : TDC                                                         //
27 //  fAdc     : ADC                                                         //
28 //                                                                         //
29 //  Getters, setters and member functions  defined here                    //
30 //                                                                         //
31 // -- Authors: F. Pierella, A. Seganti, D. Vicinanza                       //
32 //_________________________________________________________________________//
33
34  
35 #include "Riostream.h"
36
37 #include "AliTOFdigit.h"
38 #include "AliTOFGeometry.h"
39
40 ClassImp(AliTOFdigit)
41
42 //______________________________________________________________________________
43 AliTOFdigit::AliTOFdigit()
44   :AliDigit(),
45    fSector(-1),
46    fPlate(-1),
47    fStrip(-1),
48    fPadx(-1),
49    fPadz(-1),
50    fTdc(0),
51    fTdcND(0),
52    fAdc(0),
53    fToT(0)
54 {
55 }
56 //______________________________________________________________________________
57 AliTOFdigit::AliTOFdigit(Int_t *tracks, Int_t *vol,Int_t *digit)
58   :AliDigit(tracks),
59    fSector(-1),
60    fPlate(-1),
61    fStrip(-1),
62    fPadx(-1),
63    fPadz(-1),
64    fTdc(0),
65    fTdcND(0),
66    fAdc(0),
67    fToT(0)
68 {
69 //
70 // Constructor of digit object
71 //
72
73   fSector = vol[0];
74   fPlate  = vol[1];
75   fStrip  = vol[2];
76   fPadx   = vol[3];
77   fPadz   = vol[4];
78   fTdc    = digit[0];
79   fAdc    = digit[1];
80   fToT    = digit[2];
81   fTdcND  = digit[3];
82
83 }
84
85 //____________________________________________________________________________
86 AliTOFdigit::AliTOFdigit(const AliTOFdigit & digit)
87   :AliDigit(digit),
88    fSector(-1),
89    fPlate(-1),
90    fStrip(-1),
91    fPadx(-1),
92    fPadz(-1),
93    fTdc(0),
94    fTdcND(0),
95    fAdc(0),
96    fToT(0)
97 {
98   // 
99   // copy ctor for AliTOFdigit object
100   //
101
102   Int_t i ;
103   for ( i = 0; i < 3 ; i++)
104     fTracks[i]  = digit.fTracks[i] ;
105   fSector = digit.fSector;
106   fPlate  = digit.fPlate;
107   fStrip  = digit.fStrip;
108   fPadx   = digit.fPadx;
109   fPadz   = digit.fPadz;
110   fTdc    = digit.fTdc;
111   fTdcND    = digit.fTdcND;
112   fAdc    = digit.fAdc;
113   fToT = digit.fToT;
114
115 }
116
117 //______________________________________________________________________________
118 AliTOFdigit::AliTOFdigit(Int_t sector, Int_t plate, Int_t strip, Int_t padx,
119                          Int_t padz, Int_t tdc, Int_t adc):
120    fSector(-1),
121    fPlate(-1),
122    fStrip(-1),
123    fPadx(-1),
124    fPadz(-1),
125    fTdc(0),
126    fTdcND(0),
127    fAdc(0),
128    fToT(0)
129 {
130 //
131 // Constructor for sdigit
132 //
133   fSector = sector;
134   fPlate  = plate;
135   fStrip  = strip;
136   fPadx   = padx;
137   fPadz   = padz;  
138   fTdc    = tdc;   
139   fTdcND    = 0;   
140   fAdc    = adc;     
141   fToT = 0;
142 }
143    
144 //______________________________________________________________________________
145 void AliTOFdigit::GetLocation(Int_t *Loc) const
146 {
147 //
148 // Get the cohordinates of the digit
149 // in terms of Sector - Plate - Strip - Pad
150 //
151
152    Loc[0]=fSector;
153    Loc[1]=fPlate;
154    Loc[2]=fStrip;
155    Loc[3]=fPadx;
156    Loc[4]=fPadz;
157 }
158
159 //______________________________________________________________________________
160 Int_t AliTOFdigit::GetTotPad() const
161 {
162 //
163 // Get the "total" index of the pad inside a Sector
164 // starting from the digits data.
165 //
166
167   Int_t before=0;
168
169   switch(fPlate){ 
170   case 0:
171     //before = 0;
172     break;
173   case 1:
174     before = AliTOFGeometry::NStripC();
175     break;
176   case 2:
177     before = AliTOFGeometry::NStripC() +   AliTOFGeometry::NStripB();
178     break;
179   case 3:
180     before = AliTOFGeometry::NStripC() +   AliTOFGeometry::NStripB() + AliTOFGeometry::NStripA();
181     break;
182   case 4:
183     before = AliTOFGeometry::NStripC() + 2*AliTOFGeometry::NStripB() + AliTOFGeometry::NStripA();
184     break;
185   }
186   
187   Int_t pad = 2*fPadx + fPadz;
188   //Int_t pad = fPadx+AliTOFGeometry::NpadX()*fPadz;
189   Int_t strip  = fStrip + before;
190   Int_t padTot = AliTOFGeometry::NpadXStrip()*strip + pad;
191
192   return padTot;
193 }
194
195 //______________________________________________________________________________
196 void AliTOFdigit::AddTrack(Int_t track)
197 {
198 //
199 // Add a new and different track to the digit 
200 //
201   if (track==fTracks[0] || track==fTracks[1] || track==fTracks[2]) return;
202    if (fTracks[1]==0){
203       fTracks[1] = track;
204    }else if (fTracks[2]==0){
205       fTracks[2] = track;
206    }else{
207    // printf("AliTOFdigit::AddTrack ERROR: Too many Tracks (>3) \n");
208    }
209 }
210
211 // Overloading of Streaming, Sum and Comparison operators
212
213 //______________________________________________________________________________
214 Bool_t AliTOFdigit::operator==(AliTOFdigit const &digit) const
215 {
216 //
217 // Overloading of Comparison operator
218 //   
219  if (fSector==digit.fSector &&
220      fPlate==digit.fPlate &&
221      fStrip==digit.fStrip &&
222      fPadx==digit.fPadx &&
223      fPadz==digit.fPadz &&
224      fTdc==digit.fTdc &&
225      fTdcND==digit.fTdcND &&
226      fAdc==digit.fAdc &&
227      fToT==digit.fToT ) return kTRUE;
228      else return kFALSE;
229 }
230
231 //______________________________________________________________________________
232 AliTOFdigit AliTOFdigit::operator+(const AliTOFdigit &digit)
233 {
234 //
235 // Overloading of Sum operator
236 // Note: Some convolution 
237 // between the two digit variables has to be inserted
238 //
239 if  (fSector==digit.fSector &&
240      fPlate==digit.fPlate &&
241      fStrip==digit.fStrip &&
242      fPadx==digit.fPadx &&
243      fPadz==digit.fPadz) {
244                             // convolution to be inserted here
245                              fTdc+=digit.fTdc;
246                              fAdc+=digit.fAdc;
247                            } else
248                 AliTOFdigit(fSector,fPlate,fStrip,fPadx,fPadz,fTdc,fAdc);
249   return *this;
250 }
251
252 //______________________________________________________________________________
253 ostream& operator << (ostream& out, const AliTOFdigit &digit)
254 {
255   //
256   // Output streamer: output of the digit data
257   //
258
259   out << "Sector " << digit.fSector << ", Plate " << digit.fPlate << ", Strip " << digit.fStrip << endl;
260   out << "Padx" << digit.fPadx << ", Padz " << digit.fPadz << endl;
261   out << "TDC " << digit.fTdc << ", ADC "<< digit.fAdc << endl;
262
263   return out;
264 }