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