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