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