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(){
30 // Default constructor
36 // A zeroed/empty AliITSpListItem class.
40 for(Int_t i=0;i<this->fgksize;i++){
43 this->fSignal[i] = 0.0;
47 fSignalAfterElect = 0.0;
49 //______________________________________________________________________
50 AliITSpListItem::AliITSpListItem(Int_t module,Int_t index,Double_t noise){
51 // Standard noise constructor
53 // Int_t module The module where this noise occurred
54 // Int_t index The cell index where this noise occurred
55 // Double_t noise The value of the noise.
59 // A setup and noise filled AliITSpListItem class.
61 this->fmodule = module;
63 for(Int_t i=0;i<this->fgksize;i++){
65 this->fSignal[i] = 0.0;
69 this->fSignalAfterElect = 0.0;
72 //______________________________________________________________________
73 AliITSpListItem::AliITSpListItem(Int_t track,Int_t hit,Int_t module,
74 Int_t index,Double_t signal){
75 // Standard signal constructor
77 // Int_t track The track number which produced this signal
78 // Int_t hit The hit number which produced this signal
79 // Int_t module The module where this signal occurred
80 // Int_t index The cell index where this signal occurred
81 // Double_t signal The value of the signal (ionization)
85 // A setup and signal filled AliITSpListItem class.
87 this->fmodule = module;
89 this->fTrack[0] = track;
91 this->fSignal[0] = signal;
92 for(Int_t i=1;i<this->fgksize;i++){
94 this->fSignal[i] = 0.0;
97 this->fTsignal = signal;
99 this->fSignalAfterElect = 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
123 if(this == &source) return *this;
125 this->fmodule = source.fmodule;
126 this->findex = source.findex;
127 for(i=0;i<this->fgksize;i++){
128 this->fTrack[i] = source.fTrack[i];
129 this->fSignal[i] = source.fSignal[i];
130 this->fHits[i] = source.fHits[i];
132 this->fTsignal = source.fTsignal;
133 this->fNoise = source.fNoise;
134 this->fSignalAfterElect = source.fSignalAfterElect;
136 cout <<"this fTrack[0-9]=";
137 for(i=0;i<this->fgksize;i++) cout <<this->fTrack[i]<<",";
138 cout <<" fHits[0-9]=";
139 for(i=0;i<this->fgksize;i++) cout <<this->fHits[i]<<",";
140 cout <<" fSignal[0-9]=";
141 for(i=0;i<this->fgksize;i++) cout <<this->fSignal[i]<<",";
143 cout <<"source fTrack[0-9]=";
144 for(i=0;i<this->fgksize;i++) cout <<source.fTrack[i]<<",";
145 cout <<" fHits[0-9]=";
146 for(i=0;i<this->fgksize;i++) cout <<source.fHits[i]<<",";
147 cout <<" fSignal[0-9]=";
148 for(i=0;i<this->fgksize;i++) cout <<source.fSignal[i]<<",";
153 //______________________________________________________________________
154 AliITSpListItem::AliITSpListItem(AliITSpListItem &source) : TObject(source){
157 // AliITSpListItem &source A AliITSpListItem Object
161 // A copied AliITSpListItem object
165 //______________________________________________________________________
166 void AliITSpListItem::AddSignal(Int_t track,Int_t hit,Int_t module,
167 Int_t index,Double_t signal){
168 // Adds this track number and signal to the pList and orders them
170 // Int_t track The track number which produced this signal
171 // Int_t hit The hit number which produced this signal
172 // Int_t module The module where this signal occurred
173 // Int_t index The cell index where this signal occurred
174 // Double_t signal The value of the signal (ionization)
183 if (TMath::Abs(signal)>2147483647.0) {
184 //PH 2147483647 is the max. integer
185 //PH This apparently is a problem which needs investigation
186 AliWarning(Form("Too big or too small signal value %f",signal));
187 signal = TMath::Sign((Double_t)2147483647,signal);
189 if(findex!=index || fmodule!=module)
190 Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d",
191 index,findex,module,fmodule);
192 fTsignal += signal; // Keep track of sum signal.
194 // for(i=0;i<fgksize;i++) if( track==fTrack[i] && hit==fHits[i] ){
195 for(i=0;i<fgksize;i++) if( track==fTrack[i] ){
196 fSignal[i] += signal;
199 //cout << "track="<<track<<endl;
200 if(flg){ // resort arrays.
201 for(i=1;i<fgksize;i++){
203 while(j>0 && fSignal[j]>fSignal[j-1]){
207 fTrack[j-1] = fTrack[j];
208 fHits[j-1] = fHits[j];
209 fSignal[j-1] = fSignal[j];
213 //cout << "#fTrack["<<j-1<<"]="<<fTrack[j-1]<< " fTrack["<<
214 // j<<"]="<<fTrack[j]<<endl;
219 } // end if added to existing and resorted array
221 // new entry add it in order.
222 // if this signal is <= smallest then don't add it.
223 if(signal <= fSignal[fgksize-1]) return;
224 for(i=fgksize-2;i>=0;i--){
225 if(signal > fSignal[i]){
226 fSignal[i+1] = fSignal[i];
227 fTrack[i+1] = fTrack[i];
228 fHits[i+1] = fHits[i];
230 fSignal[i+1] = signal;
233 return; // put it in the right place, now exit.
235 //cout << "$fTrack["<<i+1<<"]="<<fTrack[i+1]<< " fTrack["<<i<<"]="
236 //<<fTrack[i]<< " fHits["<<i+1<<"]="<<fHits[i+1]<< " fHits["<<i<<"]="
237 //<<fHits[i]<< " fSignal["<<i+1<<"]="<<fSignal[i+1]<< " fSignal["<<i
238 //<<"]="<<fSignal[i]<<endl;
239 } // end if; end for i
240 // Still haven't found the right place. Must be at top of list.
244 //cout << "$fTrack["<<0<<"]="<<fTrack[0]<<" fHits["<<0<<"]="<<fHits[0]
245 //<<" fSignal["<<0<<"]="<<fSignal[0]<<endl;
248 //______________________________________________________________________
249 void AliITSpListItem::AddNoise(Int_t module,Int_t index,Double_t noise){
250 // Adds noise to this existing list.
252 // Int_t module The module where this noise occurred
253 // Int_t index The cell index where this noise occurred
254 // Double_t noise The value of the noise.
260 if(findex!=index || fmodule!=module)
261 Warning("AddNoise","index=%d != findex=%d or module=%d != fmodule=%d",
262 index,findex,module,fmodule);
263 fNoise += noise; // Keep track of sum signal.
265 //______________________________________________________________________
266 void AliITSpListItem::AddSignalAfterElect(Int_t module,Int_t index,Double_t signal){
267 // Adds signal after electronics to this existing list.
269 // Int_t module The module where this noise occurred
270 // Int_t index The cell index where this noise occurred
271 // Double_t signal The value of the signal.
277 if(findex!=index || fmodule!=module)
278 Warning("AddSignalAfterElect","index=%d != findex=%d or module=%d "
279 "!= fmodule=%d",index,findex,module,fmodule);
280 fSignalAfterElect += signal; // Keep track of sum signal.
282 //______________________________________________________________________
283 void AliITSpListItem::Add(AliITSpListItem *pl){
284 // Adds the contents of pl to this
285 // pl could come from different module and index
287 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
296 for(i=0;i<pl->GetNsignals();i++){
297 sig = pl->GetSignal(i);
298 if( sig <= 0.0 ) break; // no more signals
299 AddSignal(pl->GetTrack(i),pl->GetHit(i),fmodule,findex,sig);
302 fTsignal += (pl->fTsignal - sigT);
303 fNoise += pl->fNoise;
306 //______________________________________________________________________
307 void AliITSpListItem::AddTo(Int_t fileIndex,AliITSpListItem *pl){
308 // Adds the contents of pl to this with track number off set given by
311 // Int_t fileIndex track number offset value
312 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
320 Int_t module = pl->GetModule();
321 Int_t index = pl->GetIndex();
322 for(i=0;i<pl->GetNsignals();i++){
323 sig = pl->GetSignal(i);
324 if( sig <= 0.0 ) break; // no more signals
325 trk = pl->GetTrack(i);
327 AddSignal(trk,pl->GetHit(i),module,index,sig);
329 fSignalAfterElect += (pl->fSignalAfterElect + pl->fNoise - fNoise);
333 //______________________________________________________________________
334 Int_t AliITSpListItem::ShiftIndex(Int_t in,Int_t trk) const {
335 // Shift an index number to occupy the upper four bits. No longer used.
337 // Int_t in The file number
338 // Int_t trk The track number
342 // Int_t The track number with the file number in the upper bits.
343 Int_t si = sizeof(Int_t) * 8;
344 UInt_t uin,utrk; // use UInt_t to avoid interger overflow-> goes negative.
348 for(Int_t i=0;i<si-4;i++) uin *= 2;
353 //______________________________________________________________________
354 void AliITSpListItem::Print(ostream *os) const {
355 //Standard output format for this class
357 // ostream *os The output stream
364 *os << fmodule <<","<<findex<<",";
365 *os << fgksize <<",";
366 for(i=0;i<fgksize;i++) *os << fTrack[i] <<",";
367 for(i=0;i<fgksize;i++) *os << fHits[i] <<",";
368 for(i=0;i<fgksize;i++) *os << fSignal[i] <<",";
369 *os << fTsignal <<","<< fNoise << "," << fSignalAfterElect;
371 //______________________________________________________________________
372 void AliITSpListItem::Read(istream *is){
373 // Standard output streaming function.
375 // istream *is The input stream
382 *is >> fmodule >> findex;
383 *is >> iss; // read in fgksize
384 for(i=0;i<fgksize&&i<iss;i++) *is >> fTrack[i];
385 for(i=0;i<fgksize&&i<iss;i++) *is >> fHits[i];
386 for(i=0;i<fgksize&&i<iss;i++) *is >> fSignal[i];
387 *is >> fTsignal >> fNoise >> fSignalAfterElect;
389 //______________________________________________________________________
390 ostream &operator<<(ostream &os,AliITSpListItem &source){
391 // Standard output streaming function.
393 // ostream &os The output stream
394 // AliITSpListItem &source The AliITSpListItem object to be written out.
398 // ostream The output stream
403 //______________________________________________________________________
404 istream &operator>>(istream &os,AliITSpListItem &source){
405 // Standard output streaming function.
407 // istream os The input stream
408 // AliITSpListItem &source The AliITSpListItem object to be inputted
412 // istream The input stream.