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