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 **************************************************************************/
15 #include <Riostream.h>
18 #include "AliITSpListItem.h"
19 // ************************************************************************
20 // the data member "fa" of the AliITSpList class
21 // is a TObjectArray of AliITSpListItem objects
22 // each AliITSpListItem object contains information related to
23 // the digitization such signal, noise, module number,...
24 // plus some info related to the simulation (hits/track)
25 // in order to allow efficiency studies
26 //************************************************************************
27 ClassImp(AliITSpListItem)
28 //______________________________________________________________________
29 AliITSpListItem::AliITSpListItem():
34 fSignalAfterElect(0.0){
35 // Default constructor
41 // A zeroed/empty AliITSpListItem class.
43 for(Int_t i=0;i<this->fgksize;i++){
46 this->fSignal[i] = 0.0;
49 //______________________________________________________________________
50 AliITSpListItem::AliITSpListItem(Int_t module,Int_t index,Double_t noise):
55 fSignalAfterElect(0.0){
56 // Standard noise constructor
58 // Int_t module The module where this noise occurred
59 // Int_t index The cell index where this noise occurred
60 // Double_t noise The value of the noise.
64 // A setup and noise filled AliITSpListItem class.
66 for(Int_t i=0;i<this->fgksize;i++){
68 this->fSignal[i] = 0.0;
72 //______________________________________________________________________
73 AliITSpListItem::AliITSpListItem(Int_t track,Int_t hit,Int_t module,
74 Int_t index,Double_t signal):
79 fSignalAfterElect(0.0){
80 // Standard signal constructor
82 // Int_t track The track number which produced this signal
83 // Int_t hit The hit number which produced this signal
84 // Int_t module The module where this signal occurred
85 // Int_t index The cell index where this signal occurred
86 // Double_t signal The value of the signal (ionization)
90 // A setup and signal filled AliITSpListItem class.
92 this->fTrack[0] = track;
94 this->fSignal[0] = signal;
95 for(Int_t i=1;i<this->fgksize;i++){
97 this->fSignal[i] = 0.0;
101 //______________________________________________________________________
102 AliITSpListItem::~AliITSpListItem(){
109 // A properly destroyed AliITSpListItem class.
112 //______________________________________________________________________
113 AliITSpListItem& AliITSpListItem::operator=(const AliITSpListItem &source){
116 // AliITSpListItem &source A AliITSpListItem Object
120 // A copied AliITSpListItem object
121 this->~AliITSpListItem();
122 new(this) AliITSpListItem(source);
126 //______________________________________________________________________
127 AliITSpListItem::AliITSpListItem(const AliITSpListItem &source) :
129 fmodule(source.fmodule),
130 findex(source.findex),
131 fTsignal(source.fTsignal),
132 fNoise(source.fNoise),
133 fSignalAfterElect(source.fSignalAfterElect){
136 // AliITSpListItem &source A AliITSpListItem Object
140 // A copied AliITSpListItem object
142 for(Int_t i=0;i<this->fgksize;i++){
143 this->fTrack[i] = source.fTrack[i];
144 this->fSignal[i] = source.fSignal[i];
145 this->fHits[i] = source.fHits[i];
149 //______________________________________________________________________
150 void AliITSpListItem::AddSignal(Int_t track,Int_t hit,Int_t module,
151 Int_t index,Double_t signal){
152 // Adds this track number and signal to the pList and orders them
154 // Int_t track The track number which produced this signal
155 // Int_t hit The hit number which produced this signal
156 // Int_t module The module where this signal occurred
157 // Int_t index The cell index where this signal occurred
158 // Double_t signal The value of the signal (ionization)
167 if (TMath::Abs(signal)>2147483647.0) {
168 //PH 2147483647 is the max. integer
169 //PH This apparently is a problem which needs investigation
170 AliWarning(Form("Too big or too small signal value %f",signal));
171 signal = TMath::Sign((Double_t)2147483647,signal);
173 if(findex!=index || fmodule!=module)
174 Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d",
175 index,findex,module,fmodule);
176 fTsignal += signal; // Keep track of sum signal.
178 // for(i=0;i<fgksize;i++) if( track==fTrack[i] && hit==fHits[i] ){
179 for(i=0;i<fgksize;i++) if( track==fTrack[i] ){
180 fSignal[i] += signal;
183 //cout << "track="<<track<<endl;
184 if(flg){ // resort arrays.
185 for(i=1;i<fgksize;i++){
187 while(j>0 && fSignal[j]>fSignal[j-1]){
191 fTrack[j-1] = fTrack[j];
192 fHits[j-1] = fHits[j];
193 fSignal[j-1] = fSignal[j];
197 //cout << "#fTrack["<<j-1<<"]="<<fTrack[j-1]<< " fTrack["<<
198 // j<<"]="<<fTrack[j]<<endl;
203 } // end if added to existing and resorted array
205 // new entry add it in order.
206 // if this signal is <= smallest then don't add it.
207 if(signal <= fSignal[fgksize-1]) return;
208 for(i=fgksize-2;i>=0;i--){
209 if(signal > fSignal[i]){
210 fSignal[i+1] = fSignal[i];
211 fTrack[i+1] = fTrack[i];
212 fHits[i+1] = fHits[i];
214 fSignal[i+1] = signal;
217 return; // put it in the right place, now exit.
219 //cout << "$fTrack["<<i+1<<"]="<<fTrack[i+1]<< " fTrack["<<i<<"]="
220 //<<fTrack[i]<< " fHits["<<i+1<<"]="<<fHits[i+1]<< " fHits["<<i<<"]="
221 //<<fHits[i]<< " fSignal["<<i+1<<"]="<<fSignal[i+1]<< " fSignal["<<i
222 //<<"]="<<fSignal[i]<<endl;
223 } // end if; end for i
224 // Still haven't found the right place. Must be at top of list.
228 //cout << "$fTrack["<<0<<"]="<<fTrack[0]<<" fHits["<<0<<"]="<<fHits[0]
229 //<<" fSignal["<<0<<"]="<<fSignal[0]<<endl;
232 //______________________________________________________________________
233 void AliITSpListItem::AddNoise(Int_t module,Int_t index,Double_t noise){
234 // Adds noise to this existing list.
236 // Int_t module The module where this noise occurred
237 // Int_t index The cell index where this noise occurred
238 // Double_t noise The value of the noise.
244 if(findex!=index || fmodule!=module)
245 Warning("AddNoise","index=%d != findex=%d or module=%d != fmodule=%d",
246 index,findex,module,fmodule);
247 fNoise += noise; // Keep track of sum signal.
249 //______________________________________________________________________
250 void AliITSpListItem::AddSignalAfterElect(Int_t module,Int_t index,Double_t signal){
251 // Adds signal after electronics to this existing list.
253 // Int_t module The module where this noise occurred
254 // Int_t index The cell index where this noise occurred
255 // Double_t signal The value of the signal.
261 if(findex!=index || fmodule!=module)
262 Warning("AddSignalAfterElect","index=%d != findex=%d or module=%d "
263 "!= fmodule=%d",index,findex,module,fmodule);
264 fSignalAfterElect += signal; // Keep track of sum signal.
266 //______________________________________________________________________
267 void AliITSpListItem::Add(AliITSpListItem *pl){
268 // Adds the contents of pl to this
269 // pl could come from different module and index
271 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
280 for(i=0;i<pl->GetNsignals();i++){
281 sig = pl->GetSignal(i);
282 if( sig <= 0.0 ) break; // no more signals
283 AddSignal(pl->GetTrack(i),pl->GetHit(i),fmodule,findex,sig);
286 fTsignal += (pl->fTsignal - sigT);
287 fNoise += pl->fNoise;
290 //______________________________________________________________________
291 void AliITSpListItem::AddTo(Int_t fileIndex,AliITSpListItem *pl){
292 // Adds the contents of pl to this with track number off set given by
295 // Int_t fileIndex track number offset value
296 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
304 Int_t module = pl->GetModule();
305 Int_t index = pl->GetIndex();
306 for(i=0;i<pl->GetNsignals();i++){
307 sig = pl->GetSignal(i);
308 if( sig <= 0.0 ) break; // no more signals
309 trk = pl->GetTrack(i);
311 AddSignal(trk,pl->GetHit(i),module,index,sig);
313 fSignalAfterElect += (pl->fSignalAfterElect + pl->fNoise - fNoise);
317 //______________________________________________________________________
318 Int_t AliITSpListItem::ShiftIndex(Int_t in,Int_t trk) const {
319 // Shift an index number to occupy the upper four bits. No longer used.
321 // Int_t in The file number
322 // Int_t trk The track number
326 // Int_t The track number with the file number in the upper bits.
327 Int_t si = sizeof(Int_t) * 8;
328 UInt_t uin,utrk; // use UInt_t to avoid interger overflow-> goes negative.
332 for(Int_t i=0;i<si-4;i++) uin *= 2;
337 //______________________________________________________________________
338 void AliITSpListItem::Print(ostream *os) const {
339 //Standard output format for this class
341 // ostream *os The output stream
348 *os << fmodule <<","<<findex<<",";
349 *os << fgksize <<",";
350 for(i=0;i<fgksize;i++) *os << fTrack[i] <<",";
351 for(i=0;i<fgksize;i++) *os << fHits[i] <<",";
352 for(i=0;i<fgksize;i++) *os << fSignal[i] <<",";
353 *os << fTsignal <<","<< fNoise << "," << fSignalAfterElect;
355 //______________________________________________________________________
356 void AliITSpListItem::Read(istream *is){
357 // Standard output streaming function.
359 // istream *is The input stream
366 *is >> fmodule >> findex;
367 *is >> iss; // read in fgksize
368 for(i=0;i<fgksize&&i<iss;i++) *is >> fTrack[i];
369 for(i=0;i<fgksize&&i<iss;i++) *is >> fHits[i];
370 for(i=0;i<fgksize&&i<iss;i++) *is >> fSignal[i];
371 *is >> fTsignal >> fNoise >> fSignalAfterElect;
373 //______________________________________________________________________
374 ostream &operator<<(ostream &os,AliITSpListItem &source){
375 // Standard output streaming function.
377 // ostream &os The output stream
378 // AliITSpListItem &source The AliITSpListItem object to be written out.
382 // ostream The output stream
387 //______________________________________________________________________
388 istream &operator>>(istream &os,AliITSpListItem &source){
389 // Standard output streaming function.
391 // istream os The input stream
392 // AliITSpListItem &source The AliITSpListItem object to be inputted
396 // istream The input stream.