]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFdigit.cxx
Merging of the three alignment macros into one
[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(vol[0]),
60    fPlate(vol[1]),
61    fStrip(vol[2]),
62    fPadx(vol[3]),
63    fPadz(vol[4]),
64    fTdc(digit[0]),
65    fTdcND(digit[3]),
66    fAdc(digit[1]),
67    fToT(digit[2])
68 {
69 //
70 // Constructor of digit object
71 //
72 }
73
74 //____________________________________________________________________________
75 AliTOFdigit::AliTOFdigit(const AliTOFdigit & digit)
76   :AliDigit(digit),
77    fSector(digit.fSector),
78    fPlate(digit.fPlate),
79    fStrip(digit.fStrip),
80    fPadx(digit.fPadx),
81    fPadz(digit.fPadz),
82    fTdc(digit.fTdc),
83    fTdcND(digit.fTdcND),
84    fAdc(digit.fAdc),
85    fToT(digit.fToT)
86 {
87   // 
88   // copy ctor for AliTOFdigit object
89   //
90
91   Int_t i ;
92   for ( i = 0; i < 3 ; i++)
93     fTracks[i]  = digit.fTracks[i] ;
94
95 }
96
97 //______________________________________________________________________________
98 AliTOFdigit::AliTOFdigit(Int_t sector, Int_t plate, Int_t strip, Int_t padx,
99                          Int_t padz, Int_t tdc, Int_t adc):
100    fSector(sector),
101    fPlate(plate),
102    fStrip(strip),
103    fPadx(padx),
104    fPadz(padz),
105    fTdc(tdc),
106    fTdcND(0),
107    fAdc(adc),
108    fToT(0)
109 {
110 //
111 // Constructor for sdigit
112 //
113 }
114    
115 //______________________________________________________________________________
116 void AliTOFdigit::GetLocation(Int_t *loc) const
117 {
118 //
119 // Get the cohordinates of the digit
120 // in terms of Sector - Plate - Strip - Pad
121 //
122
123    loc[0] = fSector;
124    loc[1] = fPlate;
125    loc[2] = fStrip;
126    loc[3] = fPadx;
127    loc[4] = fPadz;
128 }
129
130 //______________________________________________________________________________
131 Int_t AliTOFdigit::GetTotPad() const
132 {
133 //
134 // Get the "total" index of the pad inside a Sector
135 // starting from the digits data.
136 //
137
138   Int_t before=0;
139
140   switch(fPlate){ 
141   case 0:
142     //before = 0;
143     break;
144   case 1:
145     before = AliTOFGeometry::NStripC();
146     break;
147   case 2:
148     before = AliTOFGeometry::NStripC() +   AliTOFGeometry::NStripB();
149     break;
150   case 3:
151     before = AliTOFGeometry::NStripC() +   AliTOFGeometry::NStripB() + AliTOFGeometry::NStripA();
152     break;
153   case 4:
154     before = AliTOFGeometry::NStripC() + 2*AliTOFGeometry::NStripB() + AliTOFGeometry::NStripA();
155     break;
156   }
157   
158   Int_t pad = 2*fPadx + fPadz;
159   //Int_t pad = fPadx+AliTOFGeometry::NpadX()*fPadz;
160   Int_t strip  = fStrip + before;
161   Int_t padTot = AliTOFGeometry::NpadXStrip()*strip + pad;
162
163   return padTot;
164 }
165
166 //______________________________________________________________________________
167 void AliTOFdigit::AddTrack(Int_t track)
168 {
169 //
170 // Add a new and different track to the digit 
171 //
172   if (track==fTracks[0] || track==fTracks[1] || track==fTracks[2]) return;
173    if (fTracks[1]==0){
174       fTracks[1] = track;
175    }else if (fTracks[2]==0){
176       fTracks[2] = track;
177    }else{
178    // printf("AliTOFdigit::AddTrack ERROR: Too many Tracks (>3) \n");
179    }
180 }
181
182 // Overloading of Streaming, Sum and Comparison operators
183
184 //______________________________________________________________________________
185 Bool_t AliTOFdigit::operator==(AliTOFdigit const &digit) const
186 {
187 //
188 // Overloading of Comparison operator
189 //   
190  if (fSector==digit.fSector &&
191      fPlate==digit.fPlate &&
192      fStrip==digit.fStrip &&
193      fPadx==digit.fPadx &&
194      fPadz==digit.fPadz &&
195      fTdc==digit.fTdc &&
196      fTdcND==digit.fTdcND &&
197      fAdc==digit.fAdc &&
198      fToT==digit.fToT ) return kTRUE;
199      else return kFALSE;
200 }
201
202 //______________________________________________________________________________
203 AliTOFdigit AliTOFdigit::operator+(const AliTOFdigit &digit)
204 {
205 //
206 // Overloading of Sum operator
207 // Note: Some convolution 
208 // between the two digit variables has to be inserted
209 //
210 if  (fSector==digit.fSector &&
211      fPlate==digit.fPlate &&
212      fStrip==digit.fStrip &&
213      fPadx==digit.fPadx &&
214      fPadz==digit.fPadz) {
215                             // convolution to be inserted here
216                              fTdc+=digit.fTdc;
217                              fAdc+=digit.fAdc;
218                            } else
219                 AliTOFdigit(fSector,fPlate,fStrip,fPadx,fPadz,fTdc,fAdc);
220   return *this;
221 }
222
223 //______________________________________________________________________________
224 ostream& operator << (ostream& out, const AliTOFdigit &digit)
225 {
226   //
227   // Output streamer: output of the digit data
228   //
229
230   out << "Sector " << digit.fSector << ", Plate " << digit.fPlate << ", Strip " << digit.fStrip << endl;
231   out << "Padx" << digit.fPadx << ", Padz " << digit.fPadz << endl;
232   out << "TDC " << digit.fTdc << ", ADC "<< digit.fAdc << endl;
233
234   return out;
235 }