]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSdigit.cxx
New functions added to retrieve initial point information.
[u/mrichter/AliRoot.git] / ITS / AliITSdigit.cxx
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
17 ////////////////////////////////////////////////
18 //  Digits classes for all ITS detectors      //
19 ////////////////////////////////////////////////
20 #include <TObjArray.h>
21 #include <TArrayI.h>
22 #include <TArrayF.h>
23 #include <TMath.h>
24 #include "AliITSdigit.h"
25
26 //______________________________________________________________________
27 ClassImp(AliITSdigit)
28 AliITSdigit::AliITSdigit(const Int_t *digits) {
29   // Creates a real data digit object
30
31   fCoord1       = digits[0];
32   fCoord2       = digits[1];
33   fSignal       = digits[2];
34 }
35 //______________________________________________________________________
36 void AliITSdigit::Print(ostream *os){
37     //Standard output format for this class
38
39     *os << fCoord1 <<","<< fCoord2 <<","<< fSignal;
40 }
41 //______________________________________________________________________
42 void AliITSdigit::Read(istream *os){
43     //Standard input for this class
44
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 //______________________________________________________________________
62 ClassImp(AliITSdigitSPD)
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.
67     Int_t i;
68
69     for(i=0;i<fkSspd;i++) fTracks[i]  = -3;
70     for(i=0;i<fkSspd;i++) fHits[i]    = -1;
71 }
72 //______________________________________________________________________
73 AliITSdigitSPD::AliITSdigitSPD(const Int_t *digits){
74     // Creates a SPD digit object
75     Int_t i;
76
77     for(i=0;i<fkSspd;i++) fTracks[i]  = -3;
78     for(i=0;i<fkSspd;i++) fHits[i]    = -1;
79     fCoord1       = digits[0];
80     fCoord2       = digits[1];
81     fSignal       = 1;
82     fSignalSPD    = digits[2];
83 }
84 //______________________________________________________________________
85 AliITSdigitSPD::AliITSdigitSPD(const Int_t *digits,const Int_t *tracks,
86                                const Int_t *hits){
87     // Creates a simulated SPD digit object
88
89     for(Int_t i=0; i<fkSspd; i++) {
90         fTracks[i] = tracks[i];
91         fHits[i]   = hits[i];
92     } // end for i
93     fCoord1       = digits[0];
94     fCoord2       = digits[1];
95     fSignal       = 1;
96     fSignalSPD    = digits[2];
97 }
98 //______________________________________________________________________
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 //______________________________________________________________________
130 void AliITSdigitSPD::Print(ostream *os){
131     //Standard output format for this class
132     Int_t i;
133
134     AliITSdigit::Print(os);
135     for(i=0;i<fkSspd;i++) *os <<","<< fTracks[i];
136     for(i=0;i<fkSspd;i++) *os <<","<< fHits[i];
137     *os << "," << fSignalSPD;
138 }
139 //______________________________________________________________________
140 void AliITSdigitSPD::Read(istream *os){
141     //Standard input for this class
142     Int_t i;
143
144     AliITSdigit::Read(os);
145     for(i=0;i<fkSspd;i++) *os >> fTracks[i];
146     for(i=0;i<fkSspd;i++) *os >> fHits[i];
147     *os >> fSignalSPD;
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.
159
160     source.Read(&os);
161     return os;
162 }
163 //______________________________________________________________________
164 ClassImp(AliITSdigitSDD)
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.
169     Int_t i;
170
171     for(i=0;i<fkSsdd;i++) fTracks[i] = -3;
172     for(i=0;i<fkSsdd;i++) fHits[i]   = -1;
173     fPhysics = 0;
174     for(i=0;i<fkSsdd;i++) fTcharges[i] = 0;
175 }
176 //________________________________________________________________________
177 AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits):
178     AliITSdigit(digits){
179     // Creates a simulated SDD digit object to be updated
180
181     fPhysics = phys;
182 }
183 //_____________________________________________________________________________
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;
191     for(Int_t i=0; i<fkSsdd; i++) {
192         fTcharges[i] = charges[i];
193         fTracks[i]   = tracks[i];
194         fHits[i]     = hits[i];
195     } // end for i
196 }
197 //______________________________________________________________________
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 //______________________________________________________________________
261 void AliITSdigitSDD::Print(ostream *os){
262     //Standard output format for this class
263     Int_t i;
264
265     AliITSdigit::Print(os);
266     *os <<","<< fPhysics;
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];
270 }
271 //______________________________________________________________________
272 void AliITSdigitSDD::Read(istream *os){
273     //Standard input for this class
274     Int_t i;
275
276     AliITSdigit::Read(os);
277     *os >>fPhysics;
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];
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.
292
293     source.Read(&os);
294     return os;
295 }
296 //______________________________________________________________________
297 ClassImp(AliITSTransientDigit)
298 AliITSTransientDigit::AliITSTransientDigit(Float_t phys,const Int_t *digits): 
299     AliITSdigitSDD(phys,digits) {
300     // Creates a digit object in a list of digits to be updated
301
302     fTrackList   = new TObjArray;  
303 }
304 //__________________________________________________________________________
305 AliITSTransientDigit::AliITSTransientDigit(const AliITSTransientDigit &source){
306     // Copy Constructor 
307     if(&source == this) return;
308     this->fTrackList = source.fTrackList;
309     return;
310 }
311 //_________________________________________________________________________
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;
318 }
319 //______________________________________________________________________
320 void AliITSTransientDigit::Print(ostream *os){
321     //Standard output format for this class
322
323     AliITSdigitSDD::Print(os);
324 }
325 //______________________________________________________________________
326 void AliITSTransientDigit::Read(istream *os){
327     //Standard input for this class
328
329     AliITSdigitSDD::Read(os);
330 }
331 //______________________________________________________________________
332 ostream &operator<<(ostream &os,AliITSTransientDigit &source){
333     // Standard output streaming function.
334
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
349     Int_t i;
350
351     for(i=0; i<fkSssd; i++) fTracks[i] = -3;
352     for(i=0; i<fkSssd; i++) fHits[i] = -1;
353 }
354 //__________________________________________________________________________
355 AliITSdigitSSD::AliITSdigitSSD(const Int_t *digits):AliITSdigit(digits){
356     // Creates a real SSD digit object
357 }
358 //_____________________________________________________________________________
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
363     for(Int_t i=0; i<fkSssd; i++) {
364         fTracks[i] = tracks[i];
365         fHits[i]   = hits[i];
366     } // end for i
367 }
368 //______________________________________________________________________
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 //______________________________________________________________________
400 void AliITSdigitSSD::Print(ostream *os){
401     //Standard output format for this class
402     Int_t i;
403
404     AliITSdigit::Print(os);
405     for(i=0; i<fkSssd; i++) *os <<","<< fTracks[i];
406     for(i=0; i<fkSssd; i++) *os <<","<< fHits[i];
407 }
408 //______________________________________________________________________
409 void AliITSdigitSSD::Read(istream *os){
410     //Standard input for this class
411     Int_t i;
412
413     AliITSdigit::Read(os);
414     for(i=0; i<fkSssd; i++) *os >> fTracks[i];
415     for(i=0; i<fkSssd; i++) *os >> fHits[i];
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 }