]>
Commit | Line | Data |
---|---|---|
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 | |
ea7a588a | 18 | //_________________________________________________________________________ |
19 | // TOF sdigit: member variables | |
20 | // fSector : TOF sector | |
21 | // fPlate : TOF plate | |
22 | // fStrip : strips number | |
23 | // fPadx : pad number along x | |
24 | // fPadz : pad number along z | |
25 | // fTdc : TArrayF of TDC values | |
26 | // fAdc : TArrayF of ADC values | |
27 | // | |
28 | // Getters, setters and member functions defined here | |
29 | // | |
30 | //*-- Authors: F. Pierella, A. Seganti, D. Vicinanza | |
31 | ||
f8014e68 | 32 | #include <Riostream.h> |
5919c40c | 33 | #include "TArrayF.h" |
34 | #include "TArrayI.h" | |
35 | ||
d076c8d5 | 36 | #include "AliLog.h" |
88cb7938 | 37 | #include "AliRun.h" |
5919c40c | 38 | #include "AliTOF.h" |
0f4a7374 | 39 | #include "AliTOFGeometry.h" |
88cb7938 | 40 | #include "AliTOFSDigit.h" |
5919c40c | 41 | |
42 | ClassImp(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 | //////////////////////////////////////////////////////////////////////// | |
57 | AliTOFSDigit::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 | //////////////////////////////////////////////////////////////////////// | |
82 | AliTOFSDigit::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 | ||
99 | //////////////////////////////////////////////////////////////////////// | |
100 | AliTOFSDigit::AliTOFSDigit(Int_t sector, Int_t plate, Int_t strip, Int_t padx, | |
ea7a588a | 101 | Int_t padz, Float_t tdc, Float_t adc) |
5919c40c | 102 | { |
ea7a588a | 103 | // |
104 | // Constructor for sdigit | |
105 | // | |
5919c40c | 106 | fSector = sector; |
107 | fPlate = plate; | |
108 | fStrip = strip; | |
109 | fPadx = padx; | |
110 | fPadz = padz; | |
111 | fNDigits = 1; | |
112 | fTdc = new TArrayF(fNDigits); | |
113 | (*fTdc)[0] = tdc; | |
114 | fAdc = new TArrayF(fNDigits); | |
ea7a588a | 115 | (*fAdc)[0] = adc; |
116 | // no tracks were specified, set them to -1 | |
5919c40c | 117 | fTracks = new TArrayI(kMAXDIGITS*fNDigits); |
118 | for (Int_t i = 0; i <kMAXDIGITS*fNDigits; i++) { | |
119 | (*fTracks)[i] = -1; | |
120 | } | |
121 | } | |
ea7a588a | 122 | |
5919c40c | 123 | //////////////////////////////////////////////////////////////////////// |
124 | void AliTOFSDigit::GetLocation(Int_t *Loc) const | |
125 | { | |
ea7a588a | 126 | // |
127 | // Get the coordinates of the digit | |
128 | // in terms of Sector - Plate - Strip - Pad | |
129 | // | |
130 | ||
131 | Loc[0]=fSector; | |
132 | Loc[1]=fPlate; | |
133 | Loc[2]=fStrip; | |
134 | Loc[3]=fPadx; | |
135 | Loc[4]=fPadz; | |
5919c40c | 136 | } |
137 | ||
138 | //////////////////////////////////////////////////////////////////////// | |
b213b8bd | 139 | void AliTOFSDigit::Update(Float_t tdcbin, Int_t tdc, Int_t adc, Int_t track) |
5919c40c | 140 | { |
ea7a588a | 141 | // |
142 | // Add charge and track | |
143 | // | |
144 | ||
5919c40c | 145 | Int_t sameTime = -1; |
0f4a7374 | 146 | Float_t tdcwindow=((Float_t)AliTOFGeometry::TimeDiff())/tdcbin; |
5919c40c | 147 | for (Int_t i = 0; i < fNDigits; i++) { |
b213b8bd | 148 | if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) { |
5919c40c | 149 | sameTime = i; |
150 | break; | |
151 | } | |
152 | } | |
ea7a588a | 153 | |
5919c40c | 154 | if (sameTime >= 0) { |
155 | (*fAdc)[sameTime] += static_cast<Float_t>(adc); | |
ea7a588a | 156 | // update track - find the first -1 value and replace it by the |
157 | // track number | |
5919c40c | 158 | for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) { |
159 | if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) { | |
160 | (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track; | |
161 | break; | |
162 | } | |
ea7a588a | 163 | // write warning about many tracks going to this pad |
5919c40c | 164 | if (iTrack == kMAXDIGITS) { |
d076c8d5 | 165 | AliWarning("Many hits in the padhit"); |
166 | // ToAliWarning(PrintPad()); | |
5919c40c | 167 | } |
168 | } | |
169 | } else { | |
ea7a588a | 170 | // add new time slot |
5919c40c | 171 | fNDigits++; |
172 | fTdc->Set(fNDigits); | |
173 | (*fTdc)[fNDigits-1] = tdc; | |
174 | fAdc->Set(fNDigits); | |
175 | (*fAdc)[fNDigits-1] = adc; | |
176 | fTracks->Set(fNDigits*kMAXDIGITS); | |
177 | (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track; | |
178 | for (Int_t i = 1; i <kMAXDIGITS; i++) { | |
179 | (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1; | |
180 | } | |
181 | } | |
ea7a588a | 182 | |
5919c40c | 183 | } |
8e72349e | 184 | |
185 | //////////////////////////////////////////////////////////////////////// | |
186 | void AliTOFSDigit::Update(AliTOFSDigit* sdig) | |
187 | { | |
188 | ||
189 | // | |
190 | // Perform the sum with sdig | |
191 | // | |
192 | ||
193 | // start loop on all sdig locations | |
194 | Int_t nlocations=sdig->GetNDigits(); | |
195 | ||
196 | for (Int_t j = 0; j < nlocations; j++) { | |
197 | Float_t tdcbin=50.; // [ps] hardwired for the time being | |
198 | Int_t tdc=(Int_t)sdig->GetTdc(j); | |
199 | Int_t adc=(Int_t)sdig->GetAdc(j); | |
200 | // getting here only the first track number | |
201 | Int_t track=GetTrack(j,0); | |
202 | ||
203 | ||
204 | Int_t sameTime = -1; | |
0f4a7374 | 205 | Float_t tdcwindow=((Float_t)AliTOFGeometry::TimeDiff())/tdcbin; |
8e72349e | 206 | for (Int_t i = 0; i < fNDigits; i++) { |
207 | if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) { | |
208 | sameTime = i; | |
209 | break; | |
210 | } | |
211 | } | |
212 | ||
213 | if (sameTime >= 0) { | |
214 | (*fAdc)[sameTime] += static_cast<Float_t>(adc); | |
215 | // update track - find the first -1 value and replace it by the | |
216 | // track number | |
217 | for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) { | |
218 | if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) { | |
219 | (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track; | |
220 | break; | |
221 | } | |
222 | // write warning about many tracks going to this pad | |
223 | if (iTrack == kMAXDIGITS) { | |
d076c8d5 | 224 | AliWarning("Many hits in the padhit"); |
225 | // ToAliWarning(PrintPad()); | |
8e72349e | 226 | } |
227 | } | |
228 | } else { | |
229 | // add new time slot | |
230 | fNDigits++; | |
231 | fTdc->Set(fNDigits); | |
232 | (*fTdc)[fNDigits-1] = tdc; | |
233 | fAdc->Set(fNDigits); | |
234 | (*fAdc)[fNDigits-1] = adc; | |
235 | fTracks->Set(fNDigits*kMAXDIGITS); | |
236 | (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track; | |
237 | for (Int_t i = 1; i <kMAXDIGITS; i++) { | |
238 | (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1; | |
239 | } // for (Int_t i = 1; i <kMAXDIGITS; i++) | |
240 | } // if (sameTime >= 0) | |
241 | } // end loop on sdig locations | |
242 | } | |
243 | ||
5919c40c | 244 | //////////////////////////////////////////////////////////////////////// |
245 | AliTOFSDigit::~AliTOFSDigit() | |
246 | { | |
ea7a588a | 247 | // |
248 | // dtor | |
249 | // | |
5919c40c | 250 | delete fTdc; |
251 | delete fAdc; | |
252 | delete fTracks; | |
253 | } | |
254 | ||
255 | //////////////////////////////////////////////////////////////////////// | |
256 | ||
257 | Int_t AliTOFSDigit::GetTotPad() const | |
258 | { | |
ea7a588a | 259 | // |
260 | // Get the "total" index of the pad inside a Sector | |
261 | // starting from the digits data. | |
262 | // | |
263 | ||
7e6dce66 | 264 | Int_t pad = 2*fPadx + fPadz; |
265 | //Int_t pad = fPadx+AliTOFGeometry::NpadX()*fPadz; | |
5919c40c | 266 | Int_t before=0; |
ea7a588a | 267 | |
5919c40c | 268 | switch(fPlate){ |
7e6dce66 | 269 | case 0: |
270 | //before = 0; | |
ea7a588a | 271 | break; |
7e6dce66 | 272 | case 1: |
273 | before = AliTOFGeometry::NStripC(); | |
ea7a588a | 274 | break; |
7e6dce66 | 275 | case 2: |
276 | before = AliTOFGeometry::NStripB() + AliTOFGeometry::NStripC(); | |
ea7a588a | 277 | break; |
7e6dce66 | 278 | case 3: |
279 | before = AliTOFGeometry::NStripA() + AliTOFGeometry::NStripB() + AliTOFGeometry::NStripC(); | |
ea7a588a | 280 | break; |
7e6dce66 | 281 | case 4: |
282 | before = AliTOFGeometry::NStripA() + 2*AliTOFGeometry::NStripB() + AliTOFGeometry::NStripC(); | |
ea7a588a | 283 | break; |
5919c40c | 284 | } |
285 | ||
7e6dce66 | 286 | Int_t strip = fStrip + before; |
287 | Int_t padTot = AliTOFGeometry::NpadXStrip()*strip + pad; | |
5919c40c | 288 | return padTot; |
289 | } | |
290 |