]>
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 | ||
88cb7938 | 36 | #include "AliRun.h" |
5919c40c | 37 | #include "AliTOF.h" |
5919c40c | 38 | #include "AliTOFConstants.h" |
88cb7938 | 39 | #include "AliTOFSDigit.h" |
5919c40c | 40 | |
41 | ClassImp(AliTOFSDigit) | |
42 | ||
43 | //////////////////////////////////////////////////////////////////////// | |
ea7a588a | 44 | AliTOFSDigit::AliTOFSDigit() |
5919c40c | 45 | { |
ea7a588a | 46 | // |
47 | // default ctor | |
48 | // | |
5919c40c | 49 | fNDigits = 0; |
50 | fTdc = 0; | |
51 | fAdc = 0; | |
52 | fTracks = 0; | |
53 | } | |
54 | ||
55 | //////////////////////////////////////////////////////////////////////// | |
56 | AliTOFSDigit::AliTOFSDigit(Int_t tracknum, Int_t *vol,Float_t *digit) | |
5c016a7b | 57 | :TObject() |
5919c40c | 58 | { |
ea7a588a | 59 | // |
60 | // Constructor of digit object | |
61 | // | |
5919c40c | 62 | fSector = vol[0]; |
63 | fPlate = vol[1]; | |
64 | fStrip = vol[2]; | |
65 | fPadx = vol[3]; | |
66 | fPadz = vol[4]; | |
67 | fNDigits = 1; | |
68 | fTdc = new TArrayF(fNDigits); | |
69 | (*fTdc)[0] = digit[0]; | |
70 | fAdc = new TArrayF(fNDigits); | |
71 | (*fAdc)[0] = digit[1]; | |
72 | fTracks = new TArrayI(kMAXDIGITS*fNDigits); | |
73 | (*fTracks)[0] = tracknum; | |
74 | for (Int_t i = 1; i <kMAXDIGITS*fNDigits; i++) { | |
75 | (*fTracks)[i] = -1; | |
76 | } | |
77 | } | |
78 | ||
79 | //////////////////////////////////////////////////////////////////////// | |
80 | AliTOFSDigit::AliTOFSDigit(const AliTOFSDigit & digit) | |
5c016a7b | 81 | :TObject() |
5919c40c | 82 | { |
83 | // | |
84 | // copy ctor for AliTOFSDigit object | |
85 | // | |
86 | fSector = digit.fSector; | |
87 | fPlate = digit.fPlate; | |
88 | fStrip = digit.fStrip; | |
89 | fPadx = digit.fPadx; | |
90 | fPadz = digit.fPadz; | |
91 | fNDigits = digit.fNDigits; | |
92 | fTdc = new TArrayF(*digit.fTdc); | |
93 | fAdc = new TArrayF(*digit.fAdc); | |
94 | fTracks = new TArrayI(*digit.fTracks); | |
95 | } | |
96 | ||
97 | //////////////////////////////////////////////////////////////////////// | |
98 | AliTOFSDigit::AliTOFSDigit(Int_t sector, Int_t plate, Int_t strip, Int_t padx, | |
ea7a588a | 99 | Int_t padz, Float_t tdc, Float_t adc) |
5919c40c | 100 | { |
ea7a588a | 101 | // |
102 | // Constructor for sdigit | |
103 | // | |
5919c40c | 104 | fSector = sector; |
105 | fPlate = plate; | |
106 | fStrip = strip; | |
107 | fPadx = padx; | |
108 | fPadz = padz; | |
109 | fNDigits = 1; | |
110 | fTdc = new TArrayF(fNDigits); | |
111 | (*fTdc)[0] = tdc; | |
112 | fAdc = new TArrayF(fNDigits); | |
ea7a588a | 113 | (*fAdc)[0] = adc; |
114 | // no tracks were specified, set them to -1 | |
5919c40c | 115 | fTracks = new TArrayI(kMAXDIGITS*fNDigits); |
116 | for (Int_t i = 0; i <kMAXDIGITS*fNDigits; i++) { | |
117 | (*fTracks)[i] = -1; | |
118 | } | |
119 | } | |
ea7a588a | 120 | |
5919c40c | 121 | //////////////////////////////////////////////////////////////////////// |
122 | void AliTOFSDigit::GetLocation(Int_t *Loc) const | |
123 | { | |
ea7a588a | 124 | // |
125 | // Get the coordinates of the digit | |
126 | // in terms of Sector - Plate - Strip - Pad | |
127 | // | |
128 | ||
129 | Loc[0]=fSector; | |
130 | Loc[1]=fPlate; | |
131 | Loc[2]=fStrip; | |
132 | Loc[3]=fPadx; | |
133 | Loc[4]=fPadz; | |
5919c40c | 134 | } |
135 | ||
136 | //////////////////////////////////////////////////////////////////////// | |
b213b8bd | 137 | void AliTOFSDigit::Update(Float_t tdcbin, Int_t tdc, Int_t adc, Int_t track) |
5919c40c | 138 | { |
ea7a588a | 139 | // |
140 | // Add charge and track | |
141 | // | |
142 | ||
5919c40c | 143 | Int_t sameTime = -1; |
b213b8bd | 144 | Float_t tdcwindow=((Float_t)AliTOFConstants::fgkTimeDiff)/tdcbin; |
5919c40c | 145 | for (Int_t i = 0; i < fNDigits; i++) { |
b213b8bd | 146 | if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) { |
5919c40c | 147 | sameTime = i; |
148 | break; | |
149 | } | |
150 | } | |
ea7a588a | 151 | |
5919c40c | 152 | if (sameTime >= 0) { |
153 | (*fAdc)[sameTime] += static_cast<Float_t>(adc); | |
ea7a588a | 154 | // update track - find the first -1 value and replace it by the |
155 | // track number | |
5919c40c | 156 | for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) { |
157 | if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) { | |
158 | (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track; | |
159 | break; | |
160 | } | |
ea7a588a | 161 | // write warning about many tracks going to this pad |
5919c40c | 162 | if (iTrack == kMAXDIGITS) { |
163 | cerr<<"WARNING: AliTOFSDigit::Update Many hits in the padhit"<<endl; | |
164 | cerr<<" "; | |
ea7a588a | 165 | // PrintPad(); |
5919c40c | 166 | } |
167 | } | |
168 | } else { | |
ea7a588a | 169 | // add new time slot |
5919c40c | 170 | fNDigits++; |
171 | fTdc->Set(fNDigits); | |
172 | (*fTdc)[fNDigits-1] = tdc; | |
173 | fAdc->Set(fNDigits); | |
174 | (*fAdc)[fNDigits-1] = adc; | |
175 | fTracks->Set(fNDigits*kMAXDIGITS); | |
176 | (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track; | |
177 | for (Int_t i = 1; i <kMAXDIGITS; i++) { | |
178 | (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1; | |
179 | } | |
180 | } | |
ea7a588a | 181 | |
5919c40c | 182 | } |
8e72349e | 183 | |
184 | //////////////////////////////////////////////////////////////////////// | |
185 | void AliTOFSDigit::Update(AliTOFSDigit* sdig) | |
186 | { | |
187 | ||
188 | // | |
189 | // Perform the sum with sdig | |
190 | // | |
191 | ||
192 | // start loop on all sdig locations | |
193 | Int_t nlocations=sdig->GetNDigits(); | |
194 | ||
195 | for (Int_t j = 0; j < nlocations; j++) { | |
196 | Float_t tdcbin=50.; // [ps] hardwired for the time being | |
197 | Int_t tdc=(Int_t)sdig->GetTdc(j); | |
198 | Int_t adc=(Int_t)sdig->GetAdc(j); | |
199 | // getting here only the first track number | |
200 | Int_t track=GetTrack(j,0); | |
201 | ||
202 | ||
203 | Int_t sameTime = -1; | |
204 | Float_t tdcwindow=((Float_t)AliTOFConstants::fgkTimeDiff)/tdcbin; | |
205 | for (Int_t i = 0; i < fNDigits; i++) { | |
206 | if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) { | |
207 | sameTime = i; | |
208 | break; | |
209 | } | |
210 | } | |
211 | ||
212 | if (sameTime >= 0) { | |
213 | (*fAdc)[sameTime] += static_cast<Float_t>(adc); | |
214 | // update track - find the first -1 value and replace it by the | |
215 | // track number | |
216 | for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) { | |
217 | if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) { | |
218 | (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track; | |
219 | break; | |
220 | } | |
221 | // write warning about many tracks going to this pad | |
222 | if (iTrack == kMAXDIGITS) { | |
223 | cerr<<"WARNING: AliTOFSDigit::Update Many hits in the padhit"<<endl; | |
224 | cerr<<" "; | |
225 | // PrintPad(); | |
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 | ||
b213b8bd | 264 | Int_t pad = fPadx+AliTOFConstants::fgkNpadX*(fPadz-1); |
5919c40c | 265 | Int_t before=0; |
ea7a588a | 266 | |
5919c40c | 267 | switch(fPlate){ |
268 | case 1: before = 0; | |
ea7a588a | 269 | break; |
b213b8bd | 270 | case 2: before = AliTOFConstants::fgkNStripC; |
ea7a588a | 271 | break; |
b213b8bd | 272 | case 3: before = AliTOFConstants::fgkNStripB + AliTOFConstants::fgkNStripC; |
ea7a588a | 273 | break; |
b213b8bd | 274 | case 4: before = AliTOFConstants::fgkNStripA + AliTOFConstants::fgkNStripB + AliTOFConstants::fgkNStripC; |
ea7a588a | 275 | break; |
b213b8bd | 276 | case 5: before = AliTOFConstants::fgkNStripA + 2*AliTOFConstants::fgkNStripB + AliTOFConstants::fgkNStripC; |
ea7a588a | 277 | break; |
5919c40c | 278 | } |
279 | ||
280 | Int_t strip = fStrip+before; | |
b213b8bd | 281 | Int_t padTot = AliTOFConstants::fgkPadXStrip*(strip-1)+pad; |
5919c40c | 282 | return padTot; |
283 | } | |
284 |