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