]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSdigitSDD.cxx
Changes needed to properly add and subtract the SDD low threshold with data compresse...
[u/mrichter/AliRoot.git] / ITS / AliITSdigitSDD.cxx
1 /**************************************************************************
2  * Copyright(c) 2004-2006, 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
16 #include <AliITSdigitSDD.h>
17 #include <AliITSCalibrationSDD.h>
18 #include <TArrayI.h>
19 #include <TArrayF.h>
20
21 ///////////////////////////////////////////////////////////////////
22 //                                                               //
23 // Class defining the digit object
24 // for SDD
25 // Inherits from AliITSdigit
26 //                                                               //
27 ///////////////////////////////////////////////////////////////////
28
29 ClassImp(AliITSdigitSDD)
30
31
32 //______________________________________________________________________
33 AliITSdigitSDD::AliITSdigitSDD():AliITSdigit(),
34 fPhysics(0),
35 fSignalExpanded(0){
36     // default constructor, zero coordinates and set array
37     // elements to clearly unphysical values. A value of 0 may
38     // be a valide track of hit number.
39     Int_t i;
40
41     for(i=0;i<fgkSize;i++) fTracks[i] = -3;
42     for(i=0;i<fgkSize;i++) fHits[i]   = -1;
43     for(i=0;i<fgkSize;i++) fTcharges[i] = 0;
44     SetSignalExpanded(-1000);
45 }
46 //________________________________________________________________________
47 AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits): AliITSdigit(digits),
48 fPhysics(phys),
49 fSignalExpanded(0){
50  
51    // Creates a simulated SDD digit object to be updated
52   for(Int_t i=0;i<fgkSize;i++) fTracks[i] = -3;
53   for(Int_t i=0;i<fgkSize;i++) fHits[i]   = -1;
54   for(Int_t i=0;i<fgkSize;i++) fTcharges[i] = 0;
55   
56   SetSignalExpanded(-1000);
57 }
58
59 //________________________________________________________________________
60 void AliITSdigitSDD::InitObject(Float_t phys,const Int_t *tracks,
61                            const Int_t *hits,const Float_t *charges){
62
63   // Protected function used by standard constructors
64   fPhysics = phys;
65   for(Int_t i=0; i<fgkSize; i++) {
66     fTcharges[i] = charges[i];
67     fTracks[i]   = tracks[i];
68     fHits[i]     = hits[i];
69   }
70 }
71  
72 //_____________________________________________________________________________
73 AliITSdigitSDD::AliITSdigitSDD(Float_t phys,const Int_t *digits,
74                                const Int_t *tracks,const Int_t *hits,
75                                const Float_t *charges):AliITSdigit(digits),
76 fPhysics(0),
77 fSignalExpanded(0){
78
79 // standard constructor
80   InitObject(phys,tracks,hits,charges);
81   SetSignalExpanded(-1000);
82 }
83 //_____________________________________________________________________________
84 AliITSdigitSDD::AliITSdigitSDD( Float_t phys,const Int_t *digits,
85     const Int_t *tracks,const Int_t *hits,const Float_t *charges, Int_t sige): AliITSdigit(digits),
86 fPhysics(0),
87 fSignalExpanded(0){
88
89   //constructor setting also fSignalExpanded
90   InitObject(phys,tracks,hits,charges);
91   SetSignalExpanded(sige);
92 }
93
94 //_____________________________________________________________________________
95 Int_t AliITSdigitSDD::GetListOfTracks(TArrayI &t,TArrayF &c){
96
97     // Fills the TArrayI t with the tracks found in fTracks removing
98     // duplicated tracks, summing up their charge, and ordering the tracks
99     // by the charge contributed to this digit. It will return
100     // the number of tracks and fill the remaining elements to the array
101     // t with -1.
102     // Inputs:
103     //   TArrayI  &t Reference to a TArrayI to contain the list of
104     //               nonduplicated track numbers.
105     //   TArrayF  &c Reference to a TArrayF to contain the summed charge
106     //               contributed by each track.
107     // Output:
108     //   TArrayI  &t The input array filled with the nonduplicated track
109     //               numbers.
110     //   TArrayF  &c The input array filled with the summed charge 
111     //               contributed by the corresponding track in the array t.
112     // Return:
113     //   Int_t The number of none -1 entries in the TArrayI t.
114     Int_t nt = t.GetSize();
115     nt = TMath::Min(nt,c.GetSize());
116     Int_t nth = this->GetNTracks();
117     Int_t n = 0,i,j;
118     Bool_t inlist = kFALSE;
119
120     t.Reset(-1); // -1 array.
121     c.Reset(0.0); // zero array.
122     for(i=0;i<nth;i++) {
123         if(this->GetTrack(i) == -1) continue;
124         inlist = kFALSE;
125         for(j=0;j<n;j++)if(this->GetTrack(i) == t.At(j)){
126             inlist = kTRUE;
127             c.AddAt(this->GetCharge(i)+c.At(j),j);
128         } // end for j/end if
129         if(!inlist){ // add to end of list
130             t.AddAt(this->GetTrack(i),n);
131             c.AddAt(this->GetCharge(i),n);
132             if(n<nt) n++;
133         } // end if
134     } // end for i
135
136     // Now lets sort the TArrays according to the charge. This algorithm
137     // is based on the method from Chapter 8 section 1 Straight Insertion
138     // sort. Wiliam H. Press, Saul A. Teukolsky, William T. Vetterling
139     // and Brian P. Flannery, "Numerical Recipeis in C, The Art of Scientific
140     // Computing", second Edition page 330 (1997).
141     Int_t   tr;
142     Float_t ch;
143     for(i=0;i<n;i++){
144         tr = t.At(i);
145         ch = c.At(i);
146         j = i-1;
147         while(j>-1 && c.At(j)>ch){
148             t.AddAt(t.At(j+1),j);
149             c.AddAt(c.At(j+1),j);
150             j--;
151         } // end while
152         t.AddAt(tr,j+1);
153         c.AddAt(ch,j+1);
154     } // end for i
155     //
156     return n;
157 }
158
159
160 //______________________________________________________________________
161 void AliITSdigitSDD::Print(ostream *os){
162
163
164   //Standard output format for this class
165     Int_t i;
166
167     AliITSdigit::Print(os);
168     *os <<","<< fPhysics;
169     for(i=0; i<fgkSize; i++) *os <<","<< fTcharges[i];
170     for(i=0; i<fgkSize; i++) *os <<","<< fTracks[i];
171     for(i=0; i<fgkSize; i++) *os <<","<< fHits[i];
172     *os <<","<< fSignalExpanded;
173 }
174 //______________________________________________________________________
175 void AliITSdigitSDD::Read(istream *os){
176
177   //Standard input for this class
178   Int_t i;
179
180     AliITSdigit::Read(os);
181     *os >>fPhysics;
182     for(i=0; i<fgkSize; i++) *os >> fTcharges[i];
183     for(i=0; i<fgkSize; i++) *os >> fTracks[i];
184     for(i=0; i<fgkSize; i++) *os >> fHits[i];
185     *os >>fSignalExpanded;
186 }
187 //______________________________________________________________________
188 ostream &operator<<(ostream &os,AliITSdigitSDD &source){
189
190   // Standard output streaming function.
191
192     source.Print(&os);
193     return os;
194 }
195 //______________________________________________________________________
196 istream &operator>>(istream &os,AliITSdigitSDD &source){
197   
198   // Standard output streaming function.
199
200     source.Read(&os);
201     return os;
202 }