]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFSDigit.cxx
Bug fixed (Christian)
[u/mrichter/AliRoot.git] / TOF / AliTOFSDigit.cxx
CommitLineData
5919c40c 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
88cb7938 16/* $Id$ */
5919c40c 17
0e46b9ae 18//_________________________________________________________________________//
19// //
20// TOF sdigit: 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 : TArrayF of TDC values //
27// fAdc : TArrayF of ADC values //
28// //
29// Getters, setters and member functions defined here //
30// //
31// -- Authors: F. Pierella, A. Seganti, D. Vicinanza //
32//_________________________________________________________________________//
ea7a588a 33
5919c40c 34#include "TArrayF.h"
35#include "TArrayI.h"
36
d076c8d5 37#include "AliLog.h"
0e46b9ae 38
0f4a7374 39#include "AliTOFGeometry.h"
88cb7938 40#include "AliTOFSDigit.h"
5919c40c 41
42ClassImp(AliTOFSDigit)
43
44////////////////////////////////////////////////////////////////////////
655e379f 45AliTOFSDigit::AliTOFSDigit():
46 fSector(-1),
47 fPlate(-1),
48 fStrip(-1),
49 fPadx(-1),
50 fPadz(-1),
51 fNDigits(0),
52 fTdc(0x0),
53 fAdc(0x0),
54 fTracks(0x0)
5919c40c 55{
ea7a588a 56 //
57 // default ctor
58 //
5919c40c 59}
60
61////////////////////////////////////////////////////////////////////////
655e379f 62AliTOFSDigit::AliTOFSDigit(Int_t tracknum, Int_t *vol,Float_t *digit):
63 TObject(),
64 fSector(-1),
65 fPlate(-1),
66 fStrip(-1),
67 fPadx(-1),
68 fPadz(-1),
69 fNDigits(0),
70 fTdc(0x0),
71 fAdc(0x0),
72 fTracks(0x0)
5919c40c 73{
ea7a588a 74 //
75 // Constructor of digit object
76 //
0f4a7374 77
5919c40c 78 fSector = vol[0];
79 fPlate = vol[1];
80 fStrip = vol[2];
81 fPadx = vol[3];
82 fPadz = vol[4];
83 fNDigits = 1;
84 fTdc = new TArrayF(fNDigits);
85 (*fTdc)[0] = digit[0];
86 fAdc = new TArrayF(fNDigits);
87 (*fAdc)[0] = digit[1];
88 fTracks = new TArrayI(kMAXDIGITS*fNDigits);
89 (*fTracks)[0] = tracknum;
90 for (Int_t i = 1; i <kMAXDIGITS*fNDigits; i++) {
91 (*fTracks)[i] = -1;
92 }
93}
94
95////////////////////////////////////////////////////////////////////////
655e379f 96AliTOFSDigit::AliTOFSDigit(const AliTOFSDigit & digit):
97 TObject(),
98 fSector(-1),
99 fPlate(-1),
100 fStrip(-1),
101 fPadx(-1),
102 fPadz(-1),
103 fNDigits(0),
104 fTdc(0x0),
105 fAdc(0x0),
106 fTracks(0x0)
5919c40c 107{
108 //
109 // copy ctor for AliTOFSDigit object
110 //
111 fSector = digit.fSector;
112 fPlate = digit.fPlate;
113 fStrip = digit.fStrip;
114 fPadx = digit.fPadx;
115 fPadz = digit.fPadz;
116 fNDigits = digit.fNDigits;
117 fTdc = new TArrayF(*digit.fTdc);
118 fAdc = new TArrayF(*digit.fAdc);
119 fTracks = new TArrayI(*digit.fTracks);
120}
121
7aeeaf38 122////////////////////////////////////////////////////////////////////////
123AliTOFSDigit& AliTOFSDigit::operator=(const AliTOFSDigit & digit)
124{
125 //
126 // copy ctor for AliTOFSDigit object
127 //
128 this->fSector = digit.fSector;
129 this->fPlate = digit.fPlate;
130 this->fStrip = digit.fStrip;
131 this->fPadx = digit.fPadx;
132 this->fPadz = digit.fPadz;
133 this->fNDigits = digit.fNDigits;
134 this->fTdc = digit.fTdc;
135 this->fAdc = digit.fAdc;
136 this->fTracks = digit.fTracks;
137 return *this;
138
139}
140
5919c40c 141////////////////////////////////////////////////////////////////////////
142AliTOFSDigit::AliTOFSDigit(Int_t sector, Int_t plate, Int_t strip, Int_t padx,
655e379f 143 Int_t padz, Float_t tdc, Float_t adc):
144 fSector(sector),
145 fPlate(plate),
146 fStrip(strip),
147 fPadx(padx),
148 fPadz(padz),
149 fNDigits(1),
150 fTdc(0x0),
151 fAdc(0x0),
152 fTracks(0x0)
5919c40c 153{
ea7a588a 154 //
155 // Constructor for sdigit
156 //
5919c40c 157 fTdc = new TArrayF(fNDigits);
158 (*fTdc)[0] = tdc;
159 fAdc = new TArrayF(fNDigits);
ea7a588a 160 (*fAdc)[0] = adc;
161 // no tracks were specified, set them to -1
5919c40c 162 fTracks = new TArrayI(kMAXDIGITS*fNDigits);
163 for (Int_t i = 0; i <kMAXDIGITS*fNDigits; i++) {
164 (*fTracks)[i] = -1;
165 }
166}
ea7a588a 167
5919c40c 168////////////////////////////////////////////////////////////////////////
169void AliTOFSDigit::GetLocation(Int_t *Loc) const
170{
ea7a588a 171 //
172 // Get the coordinates of the digit
173 // in terms of Sector - Plate - Strip - Pad
174 //
175
176 Loc[0]=fSector;
177 Loc[1]=fPlate;
178 Loc[2]=fStrip;
179 Loc[3]=fPadx;
180 Loc[4]=fPadz;
5919c40c 181}
182
183////////////////////////////////////////////////////////////////////////
b213b8bd 184void AliTOFSDigit::Update(Float_t tdcbin, Int_t tdc, Int_t adc, Int_t track)
5919c40c 185{
ea7a588a 186 //
187 // Add charge and track
188 //
189
5919c40c 190 Int_t sameTime = -1;
0f4a7374 191 Float_t tdcwindow=((Float_t)AliTOFGeometry::TimeDiff())/tdcbin;
5919c40c 192 for (Int_t i = 0; i < fNDigits; i++) {
b213b8bd 193 if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) {
5919c40c 194 sameTime = i;
195 break;
196 }
197 }
ea7a588a 198
5919c40c 199 if (sameTime >= 0) {
200 (*fAdc)[sameTime] += static_cast<Float_t>(adc);
ea7a588a 201 // update track - find the first -1 value and replace it by the
202 // track number
5919c40c 203 for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) {
204 if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) {
205 (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track;
206 break;
207 }
ea7a588a 208 // write warning about many tracks going to this pad
5919c40c 209 if (iTrack == kMAXDIGITS) {
d076c8d5 210 AliWarning("Many hits in the padhit");
211 // ToAliWarning(PrintPad());
5919c40c 212 }
213 }
214 } else {
ea7a588a 215 // add new time slot
5919c40c 216 fNDigits++;
217 fTdc->Set(fNDigits);
218 (*fTdc)[fNDigits-1] = tdc;
219 fAdc->Set(fNDigits);
220 (*fAdc)[fNDigits-1] = adc;
221 fTracks->Set(fNDigits*kMAXDIGITS);
222 (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track;
223 for (Int_t i = 1; i <kMAXDIGITS; i++) {
224 (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1;
225 }
226 }
ea7a588a 227
5919c40c 228}
8e72349e 229
230////////////////////////////////////////////////////////////////////////
231void AliTOFSDigit::Update(AliTOFSDigit* sdig)
232{
233
234 //
235 // Perform the sum with sdig
236 //
237
238 // start loop on all sdig locations
239 Int_t nlocations=sdig->GetNDigits();
240
241 for (Int_t j = 0; j < nlocations; j++) {
d3c7bfac 242 Float_t tdcbin = AliTOFGeometry::TdcBinWidth();// [ps] hardwired for the time being
8e72349e 243 Int_t tdc=(Int_t)sdig->GetTdc(j);
244 Int_t adc=(Int_t)sdig->GetAdc(j);
245 // getting here only the first track number
246 Int_t track=GetTrack(j,0);
247
248
249 Int_t sameTime = -1;
0f4a7374 250 Float_t tdcwindow=((Float_t)AliTOFGeometry::TimeDiff())/tdcbin;
8e72349e 251 for (Int_t i = 0; i < fNDigits; i++) {
252 if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) {
253 sameTime = i;
254 break;
255 }
256 }
257
258 if (sameTime >= 0) {
259 (*fAdc)[sameTime] += static_cast<Float_t>(adc);
260 // update track - find the first -1 value and replace it by the
261 // track number
262 for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) {
263 if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) {
264 (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track;
265 break;
266 }
267 // write warning about many tracks going to this pad
268 if (iTrack == kMAXDIGITS) {
d076c8d5 269 AliWarning("Many hits in the padhit");
270 // ToAliWarning(PrintPad());
8e72349e 271 }
272 }
273 } else {
274 // add new time slot
275 fNDigits++;
276 fTdc->Set(fNDigits);
277 (*fTdc)[fNDigits-1] = tdc;
278 fAdc->Set(fNDigits);
279 (*fAdc)[fNDigits-1] = adc;
280 fTracks->Set(fNDigits*kMAXDIGITS);
281 (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track;
282 for (Int_t i = 1; i <kMAXDIGITS; i++) {
283 (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1;
284 } // for (Int_t i = 1; i <kMAXDIGITS; i++)
285 } // if (sameTime >= 0)
286 } // end loop on sdig locations
287}
288
5919c40c 289////////////////////////////////////////////////////////////////////////
290AliTOFSDigit::~AliTOFSDigit()
291{
ea7a588a 292 //
293 // dtor
294 //
5919c40c 295 delete fTdc;
296 delete fAdc;
297 delete fTracks;
298}
299
300////////////////////////////////////////////////////////////////////////
301
d3c7bfac 302Int_t AliTOFSDigit::GetTotPad(AliTOFGeometry *tofGeom) const
5919c40c 303{
ea7a588a 304 //
305 // Get the "total" index of the pad inside a Sector
306 // starting from the digits data.
307 //
308
7e6dce66 309 Int_t pad = 2*fPadx + fPadz;
310 //Int_t pad = fPadx+AliTOFGeometry::NpadX()*fPadz;
5919c40c 311 Int_t before=0;
ea7a588a 312
5919c40c 313 switch(fPlate){
7e6dce66 314 case 0:
315 //before = 0;
ea7a588a 316 break;
7e6dce66 317 case 1:
d3c7bfac 318 before = tofGeom->NStripC();
ea7a588a 319 break;
7e6dce66 320 case 2:
d3c7bfac 321 before = AliTOFGeometry::NStripB() + tofGeom->NStripC();
ea7a588a 322 break;
7e6dce66 323 case 3:
d3c7bfac 324 before = AliTOFGeometry::NStripA() + AliTOFGeometry::NStripB() + tofGeom->NStripC();
ea7a588a 325 break;
7e6dce66 326 case 4:
d3c7bfac 327 before = AliTOFGeometry::NStripA() + 2*AliTOFGeometry::NStripB() + tofGeom->NStripC();
ea7a588a 328 break;
5919c40c 329 }
330
7e6dce66 331 Int_t strip = fStrip + before;
332 Int_t padTot = AliTOFGeometry::NpadXStrip()*strip + pad;
5919c40c 333 return padTot;
334}