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