]>
Commit | Line | Data |
---|---|---|
451f5018 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2004, 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 | **************************************************************************/ | |
451f5018 | 15 | #include <TMath.h> |
16 | #include "AliLog.h" | |
17 | #include "AliITSUSDigit.h" | |
18 | ClassImp(AliITSUSDigit) | |
19 | ||
e61afb80 | 20 | using std::istream; |
21 | using std::swap; | |
a11ef2e4 | 22 | using namespace TMath; |
e61afb80 | 23 | |
451f5018 | 24 | // Addapted from ITS/AliITSpListItem, ruben.shahoyan@cern.ch |
25 | ||
26 | //______________________________________________________________________ | |
27 | AliITSUSDigit::AliITSUSDigit() | |
852af72e | 28 | : fChip(0) |
451f5018 | 29 | ,fNTracks(0) |
3d249dbb | 30 | ,fROCycle(0) |
451f5018 | 31 | ,fTsignal(0.0) |
32 | ,fNoise(0.0) | |
33 | ,fSignalAfterElect(0.0) | |
34 | { | |
35 | // Default constructor | |
44785f3e | 36 | for (int i=kBuffSize;i--;) { |
37 | fTrack[i] = -2; | |
38 | fHits[i] = -1; | |
39 | fSignal[i] = 0; | |
40 | } | |
451f5018 | 41 | } |
42 | ||
43 | //______________________________________________________________________ | |
852af72e | 44 | AliITSUSDigit::AliITSUSDigit(UInt_t chip,UInt_t index,Double_t noise,Int_t roCycle) |
45 | :fChip(chip) | |
451f5018 | 46 | ,fNTracks(0) |
3d249dbb | 47 | ,fROCycle(roCycle) |
451f5018 | 48 | ,fTsignal(0.0) |
49 | ,fNoise(noise) | |
50 | ,fSignalAfterElect(0.0) | |
51 | { | |
52 | // Standard noise constructor | |
53 | SetUniqueID(index); | |
54 | for (int i=kBuffSize;i--;) { | |
55 | fTrack[i] = -2; | |
56 | fHits[i] = -1; | |
57 | fSignal[i] = 0; | |
58 | } | |
59 | } | |
60 | ||
61 | //______________________________________________________________________ | |
852af72e | 62 | AliITSUSDigit::AliITSUSDigit(Int_t track,Int_t hit,UInt_t chip,UInt_t index,Double_t signal,Int_t roCycle) |
63 | :fChip(chip) | |
451f5018 | 64 | ,fNTracks(1) |
3d249dbb | 65 | ,fROCycle(roCycle) |
451f5018 | 66 | ,fTsignal(signal) |
67 | ,fNoise(0.0) | |
68 | ,fSignalAfterElect(0.0) | |
69 | { | |
70 | // Standard signal constructor | |
71 | // Inputs: | |
72 | // Int_t track The track number which produced this signal | |
73 | // Int_t hit The hit number which produced this signal | |
852af72e | 74 | // Int_t chip The chip where this signal occurred |
451f5018 | 75 | // Int_t index The cell index where this signal occurred |
76 | // Double_t signal The value of the signal (ionization) | |
3d249dbb | 77 | // Int_t roCycle Read-Out cycle |
451f5018 | 78 | SetUniqueID(index); |
79 | fTrack[0] = track; | |
80 | fHits[0] = hit; | |
81 | fSignal[0] = signal; | |
82 | for (int i=1;i<kBuffSize;i++) { | |
83 | fTrack[i] = -2; | |
84 | fHits[i] = -1; | |
85 | fSignal[i] = 0; | |
86 | } | |
87 | } | |
88 | ||
89 | //______________________________________________________________________ | |
90 | AliITSUSDigit& AliITSUSDigit::operator=(const AliITSUSDigit &source) | |
91 | { | |
92 | // = operator | |
93 | if (&source!=this) { | |
94 | this->~AliITSUSDigit(); | |
95 | new(this) AliITSUSDigit(source); | |
96 | } | |
97 | return *this; | |
98 | // | |
99 | } | |
100 | ||
101 | //______________________________________________________________________ | |
102 | AliITSUSDigit::AliITSUSDigit(const AliITSUSDigit &source) | |
103 | :TObject(source) | |
852af72e | 104 | ,fChip(source.fChip) |
451f5018 | 105 | ,fNTracks(source.fNTracks) |
3d249dbb | 106 | ,fROCycle(source.fROCycle) |
451f5018 | 107 | ,fTsignal(source.fTsignal) |
108 | ,fNoise(source.fNoise) | |
109 | ,fSignalAfterElect(source.fSignalAfterElect) | |
110 | { | |
111 | // Copy operator | |
112 | for(Int_t i=kBuffSize;i--;) { | |
113 | fTrack[i] = source.fTrack[i]; | |
114 | fSignal[i] = source.fSignal[i]; | |
115 | fHits[i] = source.fHits[i]; | |
116 | } // end if i | |
117 | // | |
118 | } | |
119 | ||
120 | //______________________________________________________________________ | |
121 | void AliITSUSDigit::AddSignal(Int_t track,Int_t hit,Double_t signal) | |
122 | { | |
123 | // Adds this track number and signal to the pList and orders them | |
124 | // Inputs: | |
125 | // Int_t track The track number which produced this signal | |
126 | // Int_t hit The hit number which produced this signal | |
852af72e | 127 | // Int_t chip The chip where this signal occurred |
451f5018 | 128 | // Int_t index The cell index where this signal occurred |
129 | // Double_t signal The value of the signal (ionization) | |
130 | Int_t i,j; | |
131 | Bool_t flg=kFALSE; | |
132 | // | |
a11ef2e4 | 133 | if (Abs(signal)>2147483647.0) { |
451f5018 | 134 | //PH 2147483647 is the max. integer |
135 | //PH This apparently is a problem which needs investigation | |
136 | AliWarning(Form("Too big or too small signal value %f",signal)); | |
a11ef2e4 | 137 | signal = Sign((Double_t)2147483647,signal); |
451f5018 | 138 | } |
139 | // | |
140 | fTsignal += signal; // Keep track of sum signal. | |
141 | for (i=fNTracks;i--;) { | |
142 | if ( track==fTrack[i] ) { | |
143 | fSignal[i] += signal; | |
144 | flg = kTRUE; | |
145 | break; | |
146 | } // end for i & if. | |
147 | } | |
148 | // | |
4fa9d550 | 149 | if (flg) { |
150 | if (fNTracks>1) { // resort arrays. | |
151 | for (i=1;i<fNTracks;i++) { | |
152 | j = i; | |
153 | while(j>0 && fSignal[j]>fSignal[j-1]) { | |
8ca924ef | 154 | std::swap(fTrack[j-1],fTrack[j]); |
155 | std::swap(fHits[j-1] ,fHits[j]); | |
156 | std::swap(fSignal[j-1],fSignal[j]); | |
4fa9d550 | 157 | j--; |
158 | } // end while | |
159 | } // end if i | |
160 | } // end if added to existing and resorted array | |
451f5018 | 161 | return; |
4fa9d550 | 162 | } |
451f5018 | 163 | // |
164 | // new entry add it in order. | |
4ae6efd8 | 165 | if (fNTracks==(kBuffSize-1) && signal<=fSignal[kBuffSize-1]) return; // if this signal is <= smallest then don't add it. |
451f5018 | 166 | // |
167 | for (i=fNTracks;i--;) { | |
4ae6efd8 | 168 | if (signal > fSignal[i]) { // shift smaller signals to the end of the list |
169 | if (i<kBuffSize-2) { // (if there is a space...) | |
170 | fSignal[i+1] = fSignal[i]; | |
171 | fTrack[i+1] = fTrack[i]; | |
172 | fHits[i+1] = fHits[i]; | |
173 | } | |
451f5018 | 174 | } else { |
175 | fSignal[i+1] = signal; | |
176 | fTrack[i+1] = track; | |
177 | fHits[i+1] = hit; | |
4ae6efd8 | 178 | if (fNTracks<kBuffSize-1) fNTracks++; |
451f5018 | 179 | return; // put it in the right place, now exit. |
180 | } // end if | |
181 | } // end if; end for i | |
182 | // | |
183 | // Still haven't found the right place. Must be at top of list. | |
184 | fSignal[0] = signal; | |
185 | fTrack[0] = track; | |
186 | fHits[0] = hit; | |
187 | fNTracks++; | |
188 | return; | |
189 | } | |
190 | ||
191 | //______________________________________________________________________ | |
192 | void AliITSUSDigit::Add(const AliITSUSDigit *pl) | |
193 | { | |
194 | // Adds the contents of pl to this | |
852af72e | 195 | // pl could come from different chip and index |
451f5018 | 196 | Double_t sigT = 0.0; |
197 | for(int i=pl->GetNTracks();i--;) { | |
198 | double sig = pl->GetSignal(i); | |
199 | AddSignal(pl->GetTrack(i),pl->GetHit(i),sig); | |
200 | sigT += sig; | |
201 | } // end for i | |
202 | fTsignal += (pl->fTsignal - sigT); | |
203 | fNoise += pl->fNoise; | |
204 | return; | |
205 | // | |
206 | } | |
207 | ||
208 | //______________________________________________________________________ | |
209 | void AliITSUSDigit::AddTo(Int_t fileIndex,const AliITSUSDigit *pl) | |
210 | { | |
211 | // Adds the contents of pl to this with track number off set given by | |
212 | // fileIndex. | |
213 | // Inputs: | |
214 | // Int_t fileIndex track number offset value | |
215 | // AliITSUSDigit *pl an AliITSUSDigit to be added to this class. | |
216 | // | |
217 | for (int i=pl->GetNTracks();i--;) AddSignal(pl->GetTrack(i)+fileIndex,pl->GetHit(i),pl->GetSignal(i)); | |
218 | fSignalAfterElect += (pl->fSignalAfterElect + pl->fNoise - fNoise); | |
219 | fNoise = pl->fNoise; | |
220 | } | |
221 | ||
222 | //______________________________________________________________________ | |
223 | void AliITSUSDigit::ShiftIndices(Int_t fileIndex) | |
224 | { | |
225 | // Shift track numbers | |
226 | // | |
227 | for (int i=GetNTracks();i--;) fTrack[i] += fileIndex; | |
228 | } | |
229 | ||
451f5018 | 230 | //______________________________________________________________________ |
231 | Int_t AliITSUSDigit::Compare(const TObject* obj) const | |
232 | { | |
233 | // compare objects | |
234 | if (GetUniqueID()<obj->GetUniqueID()) return -1; | |
235 | if (GetUniqueID()>obj->GetUniqueID()) return 1; | |
236 | return 0; | |
237 | } | |
238 | ||
239 | //______________________________________________________________________ | |
240 | void AliITSUSDigit::Print(Option_t*) const | |
241 | { | |
242 | // print itself | |
3d249dbb | 243 | printf("Mod: %4d Index:%7d Ntr:%2d | TotSignal:%.2e Noise:%.2e ROCycle: %d|", |
852af72e | 244 | fChip,GetUniqueID(),fNTracks,fTsignal,fNoise,fROCycle); |
4fa9d550 | 245 | for (int i=0;i<fNTracks;i++) printf("%d(%.2e) |",fTrack[i],fSignal[i]); printf("\n"); |
451f5018 | 246 | } |