1 /**************************************************************************
2 * Copyright(c) 1998-2004, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 #include "AliITSUSDigit.h"
18 ClassImp(AliITSUSDigit)
23 // Addapted from ITS/AliITSpListItem, ruben.shahoyan@cern.ch
25 //______________________________________________________________________
26 AliITSUSDigit::AliITSUSDigit()
31 ,fSignalAfterElect(0.0)
33 // Default constructor
36 //______________________________________________________________________
37 AliITSUSDigit::AliITSUSDigit(UInt_t module,UInt_t index,Double_t noise)
42 ,fSignalAfterElect(0.0)
44 // Standard noise constructor
46 for (int i=kBuffSize;i--;) {
53 //______________________________________________________________________
54 AliITSUSDigit::AliITSUSDigit(Int_t track,Int_t hit,UInt_t module,UInt_t index,Double_t signal)
59 ,fSignalAfterElect(0.0)
61 // Standard signal constructor
63 // Int_t track The track number which produced this signal
64 // Int_t hit The hit number which produced this signal
65 // Int_t module The module where this signal occurred
66 // Int_t index The cell index where this signal occurred
67 // Double_t signal The value of the signal (ionization)
72 for (int i=1;i<kBuffSize;i++) {
79 //______________________________________________________________________
80 AliITSUSDigit& AliITSUSDigit::operator=(const AliITSUSDigit &source)
84 this->~AliITSUSDigit();
85 new(this) AliITSUSDigit(source);
91 //______________________________________________________________________
92 AliITSUSDigit::AliITSUSDigit(const AliITSUSDigit &source)
94 ,fModule(source.fModule)
95 ,fNTracks(source.fNTracks)
96 ,fTsignal(source.fTsignal)
97 ,fNoise(source.fNoise)
98 ,fSignalAfterElect(source.fSignalAfterElect)
101 for(Int_t i=kBuffSize;i--;) {
102 fTrack[i] = source.fTrack[i];
103 fSignal[i] = source.fSignal[i];
104 fHits[i] = source.fHits[i];
109 //______________________________________________________________________
110 void AliITSUSDigit::AddSignal(Int_t track,Int_t hit,Double_t signal)
112 // Adds this track number and signal to the pList and orders them
114 // Int_t track The track number which produced this signal
115 // Int_t hit The hit number which produced this signal
116 // Int_t module The module where this signal occurred
117 // Int_t index The cell index where this signal occurred
118 // Double_t signal The value of the signal (ionization)
122 if (TMath::Abs(signal)>2147483647.0) {
123 //PH 2147483647 is the max. integer
124 //PH This apparently is a problem which needs investigation
125 AliWarning(Form("Too big or too small signal value %f",signal));
126 signal = TMath::Sign((Double_t)2147483647,signal);
129 fTsignal += signal; // Keep track of sum signal.
130 for (i=fNTracks;i--;) {
131 if ( track==fTrack[i] ) {
132 fSignal[i] += signal;
139 if (fNTracks>1) { // resort arrays.
140 for (i=1;i<fNTracks;i++) {
142 while(j>0 && fSignal[j]>fSignal[j-1]) {
143 std::swap(fTrack[j-1],fTrack[j]);
144 std::swap(fHits[j-1] ,fHits[j]);
145 std::swap(fSignal[j-1],fSignal[j]);
149 } // end if added to existing and resorted array
153 // new entry add it in order.
154 // if this signal is <= smallest then don't add it.
155 if (fNTracks==(kBuffSize-1) && signal <= fSignal[kBuffSize-1]) return;
157 for (i=fNTracks;i--;) {
158 if (signal > fSignal[i]) {
159 fSignal[i+1] = fSignal[i];
160 fTrack[i+1] = fTrack[i];
161 fHits[i+1] = fHits[i];
163 fSignal[i+1] = signal;
167 return; // put it in the right place, now exit.
169 } // end if; end for i
171 // Still haven't found the right place. Must be at top of list.
179 //______________________________________________________________________
180 void AliITSUSDigit::Add(const AliITSUSDigit *pl)
182 // Adds the contents of pl to this
183 // pl could come from different module and index
185 for(int i=pl->GetNTracks();i--;) {
186 double sig = pl->GetSignal(i);
187 AddSignal(pl->GetTrack(i),pl->GetHit(i),sig);
190 fTsignal += (pl->fTsignal - sigT);
191 fNoise += pl->fNoise;
196 //______________________________________________________________________
197 void AliITSUSDigit::AddTo(Int_t fileIndex,const AliITSUSDigit *pl)
199 // Adds the contents of pl to this with track number off set given by
202 // Int_t fileIndex track number offset value
203 // AliITSUSDigit *pl an AliITSUSDigit to be added to this class.
205 for (int i=pl->GetNTracks();i--;) AddSignal(pl->GetTrack(i)+fileIndex,pl->GetHit(i),pl->GetSignal(i));
206 fSignalAfterElect += (pl->fSignalAfterElect + pl->fNoise - fNoise);
210 //______________________________________________________________________
211 void AliITSUSDigit::ShiftIndices(Int_t fileIndex)
213 // Shift track numbers
215 for (int i=GetNTracks();i--;) fTrack[i] += fileIndex;
218 //______________________________________________________________________
219 Int_t AliITSUSDigit::Compare(const TObject* obj) const
222 if (GetUniqueID()<obj->GetUniqueID()) return -1;
223 if (GetUniqueID()>obj->GetUniqueID()) return 1;
227 //______________________________________________________________________
228 void AliITSUSDigit::Print(Option_t*) const
231 printf("Mod: %4d Index:%7d Ntr:%2d | TotSignal:%.2e Noise:%.2e |",
232 fModule,GetUniqueID(),fNTracks,fTsignal,fNoise);
233 for (int i=0;i<fNTracks;i++) printf("%d(%.2e) |",fTrack[i],fSignal[i]); printf("\n");