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