]>
Commit | Line | Data |
---|---|---|
f8dece8d | 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 | /* $Id$ */ | |
16 | ||
3bd79107 | 17 | //////////////////////////////////////////////// |
f8dece8d | 18 | // Digits classes for all ITS detectors // |
3bd79107 | 19 | //////////////////////////////////////////////// |
ff116811 | 20 | #include <TObjArray.h> |
21 | #include <TArrayI.h> | |
22 | #include <TArrayF.h> | |
23 | #include <TMath.h> | |
58005f18 | 24 | #include "AliITSdigit.h" |
3bd79107 | 25 | |
f8dece8d | 26 | //______________________________________________________________________ |
58005f18 | 27 | ClassImp(AliITSdigit) |
f8dece8d | 28 | AliITSdigit::AliITSdigit(const Int_t *digits) { |
3bd79107 | 29 | // Creates a real data digit object |
f8dece8d | 30 | |
3bd79107 | 31 | fCoord1 = digits[0]; |
32 | fCoord2 = digits[1]; | |
33 | fSignal = digits[2]; | |
34 | } | |
f8dece8d | 35 | //______________________________________________________________________ |
36 | void AliITSdigit::Print(ostream *os){ | |
37 | //Standard output format for this class | |
3bd79107 | 38 | |
f8dece8d | 39 | *os << fCoord1 <<","<< fCoord2 <<","<< fSignal; |
40 | } | |
41 | //______________________________________________________________________ | |
42 | void AliITSdigit::Read(istream *os){ | |
43 | //Standard input for this class | |
3bd79107 | 44 | |
f8dece8d | 45 | *os >> fCoord1 >> fCoord2 >> fSignal; |
46 | } | |
47 | //______________________________________________________________________ | |
48 | ostream &operator<<(ostream &os,AliITSdigit &source){ | |
49 | // Standard output streaming function. | |
50 | ||
51 | source.Print(&os); | |
52 | return os; | |
53 | } | |
54 | //______________________________________________________________________ | |
55 | istream &operator>>(istream &os,AliITSdigit &source){ | |
56 | // Standard output streaming function. | |
57 | ||
58 | source.Read(&os); | |
59 | return os; | |
60 | } | |
61 | //______________________________________________________________________ | |
3bd79107 | 62 | ClassImp(AliITSdigitSPD) |
f8dece8d | 63 | AliITSdigitSPD::AliITSdigitSPD():AliITSdigit(){ |
64 | // default constructor, zero coordinates and set array | |
65 | // elements to clearly unphysical values. A value of 0 may | |
66 | // be a valide track of hit number. | |
7e743662 | 67 | Int_t i; |
f8dece8d | 68 | |
7e743662 | 69 | for(i=0;i<fkSspd;i++) fTracks[i] = -3; |
f8d9a5b8 | 70 | for(i=0;i<fkSspd;i++) fHits[i] = -1; |
3bd79107 | 71 | } |
f8dece8d | 72 | //______________________________________________________________________ |
75bc3366 | 73 | AliITSdigitSPD::AliITSdigitSPD(const Int_t *digits){ |
f8dece8d | 74 | // Creates a SPD digit object |
7e743662 | 75 | Int_t i; |
58005f18 | 76 | |
7e743662 | 77 | for(i=0;i<fkSspd;i++) fTracks[i] = -3; |
f8d9a5b8 | 78 | for(i=0;i<fkSspd;i++) fHits[i] = -1; |
75bc3366 | 79 | fCoord1 = digits[0]; |
80 | fCoord2 = digits[1]; | |
81 | fSignal = 1; | |
82 | fSignalSPD = digits[2]; | |
58005f18 | 83 | } |
f8dece8d | 84 | //______________________________________________________________________ |
85 | AliITSdigitSPD::AliITSdigitSPD(const Int_t *digits,const Int_t *tracks, | |
75bc3366 | 86 | const Int_t *hits){ |
f8dece8d | 87 | // Creates a simulated SPD digit object |
3bd79107 | 88 | |
7e743662 | 89 | for(Int_t i=0; i<fkSspd; i++) { |
f8dece8d | 90 | fTracks[i] = tracks[i]; |
91 | fHits[i] = hits[i]; | |
92 | } // end for i | |
75bc3366 | 93 | fCoord1 = digits[0]; |
94 | fCoord2 = digits[1]; | |
95 | fSignal = 1; | |
96 | fSignalSPD = digits[2]; | |
f8dece8d | 97 | } |
98 | //______________________________________________________________________ | |
ff116811 | 99 | Int_t AliITSdigitSPD::GetListOfTracks(TArrayI &t){ |
100 | // Fills the TArrayI t with the tracks found in fTracks removing | |
101 | // duplicated tracks, but otherwise in the same order. It will return | |
102 | // the number of tracks and fill the remaining elements to the array | |
103 | // t with -1. | |
104 | // Inputs: | |
105 | // TArrayI &t Reference to a TArrayI to contain the list of | |
106 | // nonduplicated track numbers. | |
107 | // Output: | |
108 | // TArrayI &t The input array filled with the nonduplicated track | |
109 | // numbers. | |
110 | // Return: | |
111 | // Int_t The number of none -1 entries in the TArrayI t. | |
112 | Int_t nt = t.GetSize(); | |
113 | Int_t nth = this->GetNTracks(); | |
114 | Int_t n = 0,i,j; | |
115 | Bool_t inlist = kFALSE; | |
116 | ||
117 | t.Reset(-1); // -1 array. | |
118 | for(i=0;i<nth;i++) { | |
119 | if(this->GetTrack(i) == -1) continue; | |
120 | inlist = kFALSE; | |
121 | for(j=0;j<n;j++)if(this->GetTrack(i) == t.At(j)) inlist = kTRUE; | |
122 | if(!inlist){ // add to end of list | |
123 | t.AddAt(this->GetTrack(i),n); | |
124 | if(n<nt) n++; | |
125 | } // end if | |
126 | } // end for i | |
127 | return n; | |
128 | } | |
129 | //______________________________________________________________________ | |
f8dece8d | 130 | void AliITSdigitSPD::Print(ostream *os){ |
131 | //Standard output format for this class | |
7e743662 | 132 | Int_t i; |
f8dece8d | 133 | |
134 | AliITSdigit::Print(os); | |
7e743662 | 135 | for(i=0;i<fkSspd;i++) *os <<","<< fTracks[i]; |
136 | for(i=0;i<fkSspd;i++) *os <<","<< fHits[i]; | |
75bc3366 | 137 | *os << "," << fSignalSPD; |
f8dece8d | 138 | } |
139 | //______________________________________________________________________ | |
140 | void AliITSdigitSPD::Read(istream *os){ | |
141 | //Standard input for this class | |
7e743662 | 142 | Int_t i; |
f8dece8d | 143 | |
144 | AliITSdigit::Read(os); | |
7e743662 | 145 | for(i=0;i<fkSspd;i++) *os >> fTracks[i]; |
146 | for(i=0;i<fkSspd;i++) *os >> fHits[i]; | |
147 | *os >> fSignalSPD; | |
f8dece8d | 148 | } |
149 | //______________________________________________________________________ | |
150 | ostream &operator<<(ostream &os,AliITSdigitSPD &source){ | |
151 | // Standard output streaming function. | |
152 | ||
153 | source.Print(&os); | |
154 | return os; | |
155 | } | |
156 | //______________________________________________________________________ | |
157 | istream &operator>>(istream &os,AliITSdigitSPD &source){ | |
158 | // Standard output streaming function. | |
3bd79107 | 159 | |
f8dece8d | 160 | source.Read(&os); |
161 | return os; | |
162 | } | |
163 | //______________________________________________________________________ | |
3bd79107 | 164 | ClassImp(AliITSdigitSDD) |
f8dece8d | 165 | AliITSdigitSDD::AliITSdigitSDD():AliITSdigit(){ |
166 | // default constructor, zero coordinates and set array | |
167 | // elements to clearly unphysical values. A value of 0 may | |
168 | // be a valide track of hit number. | |
7e743662 | 169 | Int_t i; |
92c19c36 | 170 | |
7e743662 | 171 | for(i=0;i<fkSsdd;i++) fTracks[i] = -3; |
f8d9a5b8 | 172 | for(i=0;i<fkSsdd;i++) fHits[i] = -1; |
f8dece8d | 173 | fPhysics = 0; |
7e743662 | 174 | for(i=0;i<fkSsdd;i++) fTcharges[i] = 0; |
3bd79107 | 175 | } |
f8dece8d | 176 | //________________________________________________________________________ |
177 | AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits): | |
178 | AliITSdigit(digits){ | |
179 | // Creates a simulated SDD digit object to be updated | |
3bd79107 | 180 | |
f8dece8d | 181 | fPhysics = phys; |
182 | } | |
3bd79107 | 183 | //_____________________________________________________________________________ |
f8dece8d | 184 | AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits, |
185 | const Int_t *tracks,const Int_t *hits, | |
186 | const Float_t *charges): | |
187 | AliITSdigit(digits){ | |
188 | // Creates a simulated SDD digit object | |
189 | ||
190 | fPhysics = phys; | |
7e743662 | 191 | for(Int_t i=0; i<fkSsdd; i++) { |
f8dece8d | 192 | fTcharges[i] = charges[i]; |
193 | fTracks[i] = tracks[i]; | |
194 | fHits[i] = hits[i]; | |
195 | } // end for i | |
3bd79107 | 196 | } |
f8dece8d | 197 | //______________________________________________________________________ |
ff116811 | 198 | Int_t AliITSdigitSDD::GetListOfTracks(TArrayI &t,TArrayF &c){ |
199 | // Fills the TArrayI t with the tracks found in fTracks removing | |
200 | // duplicated tracks, summing up their charge, and ordering the tracks | |
201 | // by the charge contributed to this digit. It will return | |
202 | // the number of tracks and fill the remaining elements to the array | |
203 | // t with -1. | |
204 | // Inputs: | |
205 | // TArrayI &t Reference to a TArrayI to contain the list of | |
206 | // nonduplicated track numbers. | |
207 | // TArrayF &c Reference to a TArrayF to contain the summed charge | |
208 | // contributed by each track. | |
209 | // Output: | |
210 | // TArrayI &t The input array filled with the nonduplicated track | |
211 | // numbers. | |
212 | // TArrayF &c The input array filled with the summed charge | |
213 | // contributed by the corresponding track in the array t. | |
214 | // Return: | |
215 | // Int_t The number of none -1 entries in the TArrayI t. | |
216 | Int_t nt = t.GetSize(); | |
217 | nt = TMath::Min(nt,c.GetSize()); | |
218 | Int_t nth = this->GetNTracks(); | |
219 | Int_t n = 0,i,j; | |
220 | Bool_t inlist = kFALSE; | |
221 | ||
222 | t.Reset(-1); // -1 array. | |
223 | c.Reset(0.0); // zero array. | |
224 | for(i=0;i<nth;i++) { | |
225 | if(this->GetTrack(i) == -1) continue; | |
226 | inlist = kFALSE; | |
227 | for(j=0;j<n;j++)if(this->GetTrack(i) == t.At(j)){ | |
228 | inlist = kTRUE; | |
229 | c.AddAt(this->GetCharge(i)+c.At(j),j); | |
230 | } // end for j/end if | |
231 | if(!inlist){ // add to end of list | |
232 | t.AddAt(this->GetTrack(i),n); | |
233 | c.AddAt(this->GetCharge(i),n); | |
234 | if(n<nt) n++; | |
235 | } // end if | |
236 | } // end for i | |
237 | ||
238 | // Now lets sort the TArrays according to the charge. This algorithm | |
239 | // is based on the method from Chapter 8 section 1 Straight Insertion | |
240 | // sort. Wiliam H. Press, Saul A. Teukolsky, William T. Vetterling | |
241 | // and Brian P. Flannery, "Numerical Recipeis in C, The Art of Scientific | |
242 | // Computing", second Edition page 330 (1997). | |
243 | Int_t tr; | |
244 | Float_t ch; | |
245 | for(i=0;i<n;i++){ | |
246 | tr = t.At(i); | |
247 | ch = c.At(i); | |
248 | j = i-1; | |
249 | while(j>-1 && c.At(j)>ch){ | |
250 | t.AddAt(t.At(j+1),j); | |
251 | c.AddAt(c.At(j+1),j); | |
252 | j--; | |
253 | } // end while | |
254 | t.AddAt(tr,j+1); | |
255 | c.AddAt(ch,j+1); | |
256 | } // end for i | |
257 | // | |
258 | return n; | |
259 | } | |
260 | //______________________________________________________________________ | |
f8dece8d | 261 | void AliITSdigitSDD::Print(ostream *os){ |
262 | //Standard output format for this class | |
7e743662 | 263 | Int_t i; |
3bd79107 | 264 | |
f8dece8d | 265 | AliITSdigit::Print(os); |
266 | *os <<","<< fPhysics; | |
7e743662 | 267 | for(i=0; i<fkSsdd; i++) *os <<","<< fTcharges[i]; |
268 | for(i=0; i<fkSsdd; i++) *os <<","<< fTracks[i]; | |
269 | for(i=0; i<fkSsdd; i++) *os <<","<< fHits[i]; | |
f8dece8d | 270 | } |
271 | //______________________________________________________________________ | |
272 | void AliITSdigitSDD::Read(istream *os){ | |
273 | //Standard input for this class | |
7e743662 | 274 | Int_t i; |
f8dece8d | 275 | |
276 | AliITSdigit::Read(os); | |
277 | *os >>fPhysics; | |
7e743662 | 278 | for(i=0; i<fkSsdd; i++) *os >> fTcharges[i]; |
279 | for(i=0; i<fkSsdd; i++) *os >> fTracks[i]; | |
280 | for(i=0; i<fkSsdd; i++) *os >> fHits[i]; | |
f8dece8d | 281 | } |
282 | //______________________________________________________________________ | |
283 | ostream &operator<<(ostream &os,AliITSdigitSDD &source){ | |
284 | // Standard output streaming function. | |
285 | ||
286 | source.Print(&os); | |
287 | return os; | |
288 | } | |
289 | //______________________________________________________________________ | |
290 | istream &operator>>(istream &os,AliITSdigitSDD &source){ | |
291 | // Standard output streaming function. | |
3bd79107 | 292 | |
f8dece8d | 293 | source.Read(&os); |
294 | return os; | |
295 | } | |
296 | //______________________________________________________________________ | |
3bd79107 | 297 | ClassImp(AliITSTransientDigit) |
f8dece8d | 298 | AliITSTransientDigit::AliITSTransientDigit(Float_t phys,const Int_t *digits): |
3bd79107 | 299 | AliITSdigitSDD(phys,digits) { |
f8dece8d | 300 | // Creates a digit object in a list of digits to be updated |
3bd79107 | 301 | |
f8dece8d | 302 | fTrackList = new TObjArray; |
303 | } | |
3bd79107 | 304 | //__________________________________________________________________________ |
305 | AliITSTransientDigit::AliITSTransientDigit(const AliITSTransientDigit &source){ | |
f8dece8d | 306 | // Copy Constructor |
307 | if(&source == this) return; | |
308 | this->fTrackList = source.fTrackList; | |
309 | return; | |
3bd79107 | 310 | } |
3bd79107 | 311 | //_________________________________________________________________________ |
f8dece8d | 312 | AliITSTransientDigit& AliITSTransientDigit::operator=( |
313 | const AliITSTransientDigit &source) { | |
314 | // Assignment operator | |
315 | if(&source == this) return *this; | |
316 | this->fTrackList = source.fTrackList; | |
317 | return *this; | |
3bd79107 | 318 | } |
f8dece8d | 319 | //______________________________________________________________________ |
320 | void AliITSTransientDigit::Print(ostream *os){ | |
321 | //Standard output format for this class | |
3bd79107 | 322 | |
f8dece8d | 323 | AliITSdigitSDD::Print(os); |
324 | } | |
325 | //______________________________________________________________________ | |
326 | void AliITSTransientDigit::Read(istream *os){ | |
327 | //Standard input for this class | |
92c19c36 | 328 | |
f8dece8d | 329 | AliITSdigitSDD::Read(os); |
3bd79107 | 330 | } |
f8dece8d | 331 | //______________________________________________________________________ |
332 | ostream &operator<<(ostream &os,AliITSTransientDigit &source){ | |
333 | // Standard output streaming function. | |
3bd79107 | 334 | |
f8dece8d | 335 | source.Print(&os); |
336 | return os; | |
337 | } | |
338 | //______________________________________________________________________ | |
339 | istream &operator>>(istream &os,AliITSTransientDigit &source){ | |
340 | // Standard output streaming function. | |
341 | ||
342 | source.Read(&os); | |
343 | return os; | |
344 | } | |
345 | //______________________________________________________________________ | |
346 | ClassImp(AliITSdigitSSD) | |
347 | AliITSdigitSSD::AliITSdigitSSD():AliITSdigit(){ | |
348 | // default constructor | |
7e743662 | 349 | Int_t i; |
f8dece8d | 350 | |
7e743662 | 351 | for(i=0; i<fkSssd; i++) fTracks[i] = -3; |
352 | for(i=0; i<fkSssd; i++) fHits[i] = -1; | |
f8dece8d | 353 | } |
354 | //__________________________________________________________________________ | |
355 | AliITSdigitSSD::AliITSdigitSSD(const Int_t *digits):AliITSdigit(digits){ | |
356 | // Creates a real SSD digit object | |
357 | } | |
3bd79107 | 358 | //_____________________________________________________________________________ |
f8dece8d | 359 | AliITSdigitSSD::AliITSdigitSSD(const Int_t *digits,const Int_t *tracks, |
360 | const Int_t *hits):AliITSdigit(digits){ | |
361 | // Creates a simulated SSD digit object | |
362 | ||
7e743662 | 363 | for(Int_t i=0; i<fkSssd; i++) { |
f8dece8d | 364 | fTracks[i] = tracks[i]; |
365 | fHits[i] = hits[i]; | |
366 | } // end for i | |
3bd79107 | 367 | } |
f8dece8d | 368 | //______________________________________________________________________ |
ff116811 | 369 | Int_t AliITSdigitSSD::GetListOfTracks(TArrayI &t){ |
370 | // Fills the TArrayI t with the tracks found in fTracks removing | |
371 | // duplicated tracks, but otherwise in the same order. It will return | |
372 | // the number of tracks and fill the remaining elements to the array | |
373 | // t with -1. | |
374 | // Inputs: | |
375 | // TArrayI &t Reference to a TArrayI to contain the list of | |
376 | // nonduplicated track numbers. | |
377 | // Output: | |
378 | // TArrayI &t The input array filled with the nonduplicated track | |
379 | // numbers. | |
380 | // Return: | |
381 | // Int_t The number of none -1 entries in the TArrayI t. | |
382 | Int_t nt = t.GetSize(); | |
383 | Int_t nth = this->GetNTracks(); | |
384 | Int_t n = 0,i,j; | |
385 | Bool_t inlist = kFALSE; | |
386 | ||
387 | t.Reset(-1); // -1 array. | |
388 | for(i=0;i<nth;i++) { | |
389 | if(this->GetTrack(i) == -1) continue; | |
390 | inlist = kFALSE; | |
391 | for(j=0;j<n;j++)if(this->GetTrack(i) == t.At(j)) inlist = kTRUE; | |
392 | if(!inlist){ // add to end of list | |
393 | t.AddAt(this->GetTrack(i),n); | |
394 | if(n<nt) n++; | |
395 | } // end if | |
396 | } // end for i | |
397 | return n; | |
398 | } | |
399 | //______________________________________________________________________ | |
f8dece8d | 400 | void AliITSdigitSSD::Print(ostream *os){ |
401 | //Standard output format for this class | |
7e743662 | 402 | Int_t i; |
3bd79107 | 403 | |
f8dece8d | 404 | AliITSdigit::Print(os); |
7e743662 | 405 | for(i=0; i<fkSssd; i++) *os <<","<< fTracks[i]; |
406 | for(i=0; i<fkSssd; i++) *os <<","<< fHits[i]; | |
f8dece8d | 407 | } |
408 | //______________________________________________________________________ | |
409 | void AliITSdigitSSD::Read(istream *os){ | |
410 | //Standard input for this class | |
7e743662 | 411 | Int_t i; |
f8dece8d | 412 | |
413 | AliITSdigit::Read(os); | |
7e743662 | 414 | for(i=0; i<fkSssd; i++) *os >> fTracks[i]; |
415 | for(i=0; i<fkSssd; i++) *os >> fHits[i]; | |
f8dece8d | 416 | } |
417 | //______________________________________________________________________ | |
418 | ostream &operator<<(ostream &os,AliITSdigitSSD &source){ | |
419 | // Standard output streaming function. | |
420 | ||
421 | source.Print(&os); | |
422 | return os; | |
423 | } | |
424 | //______________________________________________________________________ | |
425 | istream &operator>>(istream &os,AliITSdigitSSD &source){ | |
426 | // Standard output streaming function. | |
427 | ||
428 | source.Read(&os); | |
429 | return os; | |
430 | } |