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