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