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)
20 // Addapted from ITS/AliITSpListItem, ruben.shahoyan@cern.ch
22 //______________________________________________________________________
23 AliITSUSDigit::AliITSUSDigit()
28 ,fSignalAfterElect(0.0)
30 // Default constructor
33 //______________________________________________________________________
34 AliITSUSDigit::AliITSUSDigit(UInt_t module,UInt_t index,Double_t noise)
39 ,fSignalAfterElect(0.0)
41 // Standard noise constructor
43 for (int i=kBuffSize;i--;) {
50 //______________________________________________________________________
51 AliITSUSDigit::AliITSUSDigit(Int_t track,Int_t hit,UInt_t module,UInt_t index,Double_t signal)
56 ,fSignalAfterElect(0.0)
58 // Standard signal constructor
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)
69 for (int i=1;i<kBuffSize;i++) {
76 //______________________________________________________________________
77 AliITSUSDigit& AliITSUSDigit::operator=(const AliITSUSDigit &source)
81 this->~AliITSUSDigit();
82 new(this) AliITSUSDigit(source);
88 //______________________________________________________________________
89 AliITSUSDigit::AliITSUSDigit(const AliITSUSDigit &source)
91 ,fModule(source.fModule)
92 ,fNTracks(source.fNTracks)
93 ,fTsignal(source.fTsignal)
94 ,fNoise(source.fNoise)
95 ,fSignalAfterElect(source.fSignalAfterElect)
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];
106 //______________________________________________________________________
107 void AliITSUSDigit::AddSignal(Int_t track,Int_t hit,Double_t signal)
109 // Adds this track number and signal to the pList and orders them
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)
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);
126 fTsignal += signal; // Keep track of sum signal.
127 for (i=fNTracks;i--;) {
128 if ( track==fTrack[i] ) {
129 fSignal[i] += signal;
136 if (fNTracks>1) { // resort arrays.
137 for (i=1;i<fNTracks;i++) {
139 while(j>0 && fSignal[j]>fSignal[j-1]) {
140 std::swap(fTrack[j-1],fTrack[j]);
141 std::swap(fHits[j-1] ,fHits[j]);
142 std::swap(fSignal[j-1],fSignal[j]);
146 } // end if added to existing and resorted array
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;
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];
160 fSignal[i+1] = signal;
164 return; // put it in the right place, now exit.
166 } // end if; end for i
168 // Still haven't found the right place. Must be at top of list.
176 //______________________________________________________________________
177 void AliITSUSDigit::Add(const AliITSUSDigit *pl)
179 // Adds the contents of pl to this
180 // pl could come from different module and index
182 for(int i=pl->GetNTracks();i--;) {
183 double sig = pl->GetSignal(i);
184 AddSignal(pl->GetTrack(i),pl->GetHit(i),sig);
187 fTsignal += (pl->fTsignal - sigT);
188 fNoise += pl->fNoise;
193 //______________________________________________________________________
194 void AliITSUSDigit::AddTo(Int_t fileIndex,const AliITSUSDigit *pl)
196 // Adds the contents of pl to this with track number off set given by
199 // Int_t fileIndex track number offset value
200 // AliITSUSDigit *pl an AliITSUSDigit to be added to this class.
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);
207 //______________________________________________________________________
208 void AliITSUSDigit::ShiftIndices(Int_t fileIndex)
210 // Shift track numbers
212 for (int i=GetNTracks();i--;) fTrack[i] += fileIndex;
215 //______________________________________________________________________
216 Int_t AliITSUSDigit::Compare(const TObject* obj) const
219 if (GetUniqueID()<obj->GetUniqueID()) return -1;
220 if (GetUniqueID()>obj->GetUniqueID()) return 1;
224 //______________________________________________________________________
225 void AliITSUSDigit::Print(Option_t*) const
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");