]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFSDigit.cxx
Removing AliMC and AliMCProcess
[u/mrichter/AliRoot.git] / TOF / AliTOFSDigit.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
17 //_________________________________________________________________________
18 //  TOF sdigit: member variables 
19 //  fSector  : TOF sector
20 //  fPlate   : TOF plate
21 //  fStrip   : strips number
22 //  fPadx    : pad number along x
23 //  fPadz    : pad number along z
24 //  fTdc     : TArrayF of TDC values
25 //  fAdc     : TArrayF of ADC values
26 //              
27 //  Getters, setters and member functions  defined here
28 //
29 //*-- Authors: F. Pierella, A. Seganti, D. Vicinanza
30
31 #include <Riostream.h>
32 #include "TArrayF.h"
33 #include "TArrayI.h"
34
35 #include "AliTOF.h"
36 #include "AliTOFSDigit.h"
37 #include "AliTOFConstants.h"
38 #include "AliRun.h"
39
40 ClassImp(AliTOFSDigit)
41
42 ////////////////////////////////////////////////////////////////////////
43   AliTOFSDigit::AliTOFSDigit()
44 {
45   //
46   // default ctor
47   //
48   fNDigits = 0;
49   fTdc = 0;
50   fAdc = 0;
51   fTracks = 0;
52 }
53
54 ////////////////////////////////////////////////////////////////////////
55 AliTOFSDigit::AliTOFSDigit(Int_t tracknum, Int_t *vol,Float_t *digit)
56 {
57   //
58   // Constructor of digit object
59   //
60   fSector = vol[0];
61   fPlate  = vol[1];
62   fStrip  = vol[2];
63   fPadx   = vol[3];
64   fPadz   = vol[4];
65   fNDigits = 1;
66   fTdc = new TArrayF(fNDigits);
67   (*fTdc)[0] = digit[0];
68   fAdc = new TArrayF(fNDigits);
69   (*fAdc)[0] = digit[1];
70   fTracks = new TArrayI(kMAXDIGITS*fNDigits);
71   (*fTracks)[0] = tracknum;
72   for (Int_t i = 1; i <kMAXDIGITS*fNDigits; i++) {
73     (*fTracks)[i] = -1;
74   }
75 }
76
77 ////////////////////////////////////////////////////////////////////////
78 AliTOFSDigit::AliTOFSDigit(const AliTOFSDigit & digit)
79 {
80   // 
81   // copy ctor for AliTOFSDigit object
82   //
83   fSector = digit.fSector;
84   fPlate  = digit.fPlate;
85   fStrip  = digit.fStrip;
86   fPadx   = digit.fPadx;
87   fPadz   = digit.fPadz;
88   fNDigits = digit.fNDigits;
89   fTdc = new TArrayF(*digit.fTdc);  
90   fAdc = new TArrayF(*digit.fAdc);
91   fTracks = new TArrayI(*digit.fTracks);
92 }
93
94 ////////////////////////////////////////////////////////////////////////
95 AliTOFSDigit::AliTOFSDigit(Int_t sector, Int_t plate, Int_t strip, Int_t padx,
96                            Int_t padz, Float_t tdc, Float_t adc)
97 {
98   //
99   // Constructor for sdigit
100   //
101   fSector = sector;
102   fPlate  = plate;
103   fStrip  = strip;
104   fPadx   = padx;
105   fPadz   = padz;  
106   fNDigits = 1;
107   fTdc = new TArrayF(fNDigits);
108   (*fTdc)[0] = tdc;   
109   fAdc = new TArrayF(fNDigits);
110   (*fAdc)[0] = adc;   
111   // no tracks were specified, set them to -1
112   fTracks = new TArrayI(kMAXDIGITS*fNDigits);
113   for (Int_t i = 0; i <kMAXDIGITS*fNDigits; i++) {
114     (*fTracks)[i] = -1;
115   }
116 }
117
118 ////////////////////////////////////////////////////////////////////////
119 void AliTOFSDigit::GetLocation(Int_t *Loc) const
120 {
121   //
122   // Get the coordinates of the digit
123   // in terms of Sector - Plate - Strip - Pad
124   //
125   
126   Loc[0]=fSector;
127   Loc[1]=fPlate;
128   Loc[2]=fStrip;
129   Loc[3]=fPadx;
130   Loc[4]=fPadz;
131 }
132
133 ////////////////////////////////////////////////////////////////////////
134 void AliTOFSDigit::Update(Float_t tdcbin, Int_t tdc, Int_t adc, Int_t track)
135 {
136   //
137   // Add charge and track
138   //
139   
140   Int_t sameTime = -1;
141   Float_t tdcwindow=((Float_t)AliTOFConstants::fgkTimeDiff)/tdcbin;
142   for (Int_t i = 0; i < fNDigits; i++) {
143     if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) {
144       sameTime = i;
145       break;
146     }
147   }
148   
149   if (sameTime >= 0) {
150     (*fAdc)[sameTime] += static_cast<Float_t>(adc);
151     // update track - find the first -1  value and replace it by the
152     // track number
153     for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) {
154       if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) {
155         (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track;
156         break;
157       }
158       // write warning about many tracks going to this pad
159       if (iTrack == kMAXDIGITS) {
160         cerr<<"WARNING: AliTOFSDigit::Update  Many hits in the padhit"<<endl;
161         cerr<<"         ";
162         //      PrintPad();
163       }
164     }
165   } else {
166     // add new time slot
167     fNDigits++;
168     fTdc->Set(fNDigits);
169     (*fTdc)[fNDigits-1] = tdc;
170     fAdc->Set(fNDigits);
171     (*fAdc)[fNDigits-1] = adc;
172     fTracks->Set(fNDigits*kMAXDIGITS);
173     (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track;
174     for (Int_t i = 1; i <kMAXDIGITS; i++) {
175       (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1;
176     }
177   }
178   
179 }
180
181 ////////////////////////////////////////////////////////////////////////
182 void AliTOFSDigit::Update(AliTOFSDigit* sdig)
183 {
184
185   //
186   // Perform the sum with sdig
187   //
188
189   // start loop on all sdig locations
190   Int_t nlocations=sdig->GetNDigits();
191
192   for (Int_t j = 0; j < nlocations; j++) {
193     Float_t tdcbin=50.; // [ps] hardwired for the time being
194     Int_t tdc=(Int_t)sdig->GetTdc(j);
195     Int_t adc=(Int_t)sdig->GetAdc(j);
196     // getting here only the first track number
197     Int_t track=GetTrack(j,0);
198     
199     
200     Int_t sameTime = -1;
201     Float_t tdcwindow=((Float_t)AliTOFConstants::fgkTimeDiff)/tdcbin;
202     for (Int_t i = 0; i < fNDigits; i++) {
203       if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) {
204         sameTime = i;
205         break;
206       }
207     }
208     
209     if (sameTime >= 0) {
210       (*fAdc)[sameTime] += static_cast<Float_t>(adc);
211       // update track - find the first -1  value and replace it by the
212       // track number
213       for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) {
214         if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) {
215           (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track;
216           break;
217         }
218         // write warning about many tracks going to this pad
219         if (iTrack == kMAXDIGITS) {
220           cerr<<"WARNING: AliTOFSDigit::Update  Many hits in the padhit"<<endl;
221           cerr<<"         ";
222           //    PrintPad();
223         }
224       }
225     } else {
226       // add new time slot
227       fNDigits++;
228       fTdc->Set(fNDigits);
229       (*fTdc)[fNDigits-1] = tdc;
230       fAdc->Set(fNDigits);
231       (*fAdc)[fNDigits-1] = adc;
232       fTracks->Set(fNDigits*kMAXDIGITS);
233       (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track;
234       for (Int_t i = 1; i <kMAXDIGITS; i++) {
235         (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1;
236       } // for (Int_t i = 1; i <kMAXDIGITS; i++)
237     } // if (sameTime >= 0)
238   } // end loop on sdig locations
239 }
240
241 ////////////////////////////////////////////////////////////////////////
242 AliTOFSDigit::~AliTOFSDigit()
243 {
244   //
245   // dtor
246   //
247   delete fTdc;
248   delete fAdc;
249   delete fTracks;
250 }
251
252 ////////////////////////////////////////////////////////////////////////
253
254 Int_t AliTOFSDigit::GetTotPad() const
255 {
256   //
257   // Get the "total" index of the pad inside a Sector
258   // starting from the digits data.
259   //
260   
261   Int_t pad = fPadx+AliTOFConstants::fgkNpadX*(fPadz-1);
262   Int_t before=0;
263   
264   switch(fPlate){ 
265   case 1: before = 0;
266     break;
267   case 2: before = AliTOFConstants::fgkNStripC;
268     break;
269   case 3: before = AliTOFConstants::fgkNStripB + AliTOFConstants::fgkNStripC;
270     break;
271   case 4: before = AliTOFConstants::fgkNStripA + AliTOFConstants::fgkNStripB + AliTOFConstants::fgkNStripC;
272     break;
273   case 5: before = AliTOFConstants::fgkNStripA + 2*AliTOFConstants::fgkNStripB + AliTOFConstants::fgkNStripC;
274     break;
275   }
276   
277   Int_t strip = fStrip+before;
278   Int_t padTot = AliTOFConstants::fgkPadXStrip*(strip-1)+pad;
279   return padTot;
280 }
281