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