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