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