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>
16 #include "AliITSpListItem.h"
17 // ************************************************************************
18 // the data member "fa" of the AliITSpList class
19 // is a TObjectArray of AliITSpListItem objects
20 // each AliITSpListItem object contains information related to
21 // the digitization such signal, noise, module number,...
22 // plus some info related to the simulation (hits/track)
23 // in order to allow efficiency studies
24 //************************************************************************
25 ClassImp(AliITSpListItem)
26 //______________________________________________________________________
27 AliITSpListItem::AliITSpListItem(){
28 // Default constructor
34 // A zeroed/empty AliITSpListItem class.
38 for(Int_t i=0;i<this->fgksize;i++){
41 this->fSignal[i] = 0.0;
45 fSignalAfterElect = 0.0;
47 //______________________________________________________________________
48 AliITSpListItem::AliITSpListItem(Int_t module,Int_t index,Double_t noise){
49 // Standard noise constructor
51 // Int_t module The module where this noise occurred
52 // Int_t index The cell index where this noise occurred
53 // Double_t noise The value of the noise.
57 // A setup and noise filled AliITSpListItem class.
59 this->fmodule = module;
61 for(Int_t i=0;i<this->fgksize;i++){
63 this->fSignal[i] = 0.0;
67 this->fSignalAfterElect = 0.0;
70 //______________________________________________________________________
71 AliITSpListItem::AliITSpListItem(Int_t track,Int_t hit,Int_t module,
72 Int_t index,Double_t signal){
73 // Standard signal constructor
75 // Int_t track The track number which produced this signal
76 // Int_t hit The hit number which produced this signal
77 // Int_t module The module where this signal occurred
78 // Int_t index The cell index where this signal occurred
79 // Double_t signal The value of the signal (ionization)
83 // A setup and signal filled AliITSpListItem class.
85 this->fmodule = module;
87 this->fTrack[0] = track;
89 this->fSignal[0] = signal;
90 for(Int_t i=1;i<this->fgksize;i++){
92 this->fSignal[i] = 0.0;
95 this->fTsignal = signal;
97 this->fSignalAfterElect = 0.0;
99 //______________________________________________________________________
100 AliITSpListItem::~AliITSpListItem(){
107 // A properly destroyed AliITSpListItem class.
110 //______________________________________________________________________
111 AliITSpListItem& AliITSpListItem::operator=(const AliITSpListItem &source){
114 // AliITSpListItem &source A AliITSpListItem Object
118 // A copied AliITSpListItem object
121 if(this == &source) return *this;
123 this->fmodule = source.fmodule;
124 this->findex = source.findex;
125 for(i=0;i<this->fgksize;i++){
126 this->fTrack[i] = source.fTrack[i];
127 this->fSignal[i] = source.fSignal[i];
128 this->fHits[i] = source.fHits[i];
130 this->fTsignal = source.fTsignal;
131 this->fNoise = source.fNoise;
132 this->fSignalAfterElect = source.fSignalAfterElect;
134 cout <<"this fTrack[0-9]=";
135 for(i=0;i<this->fgksize;i++) cout <<this->fTrack[i]<<",";
136 cout <<" fHits[0-9]=";
137 for(i=0;i<this->fgksize;i++) cout <<this->fHits[i]<<",";
138 cout <<" fSignal[0-9]=";
139 for(i=0;i<this->fgksize;i++) cout <<this->fSignal[i]<<",";
141 cout <<"source fTrack[0-9]=";
142 for(i=0;i<this->fgksize;i++) cout <<source.fTrack[i]<<",";
143 cout <<" fHits[0-9]=";
144 for(i=0;i<this->fgksize;i++) cout <<source.fHits[i]<<",";
145 cout <<" fSignal[0-9]=";
146 for(i=0;i<this->fgksize;i++) cout <<source.fSignal[i]<<",";
151 //______________________________________________________________________
152 AliITSpListItem::AliITSpListItem(AliITSpListItem &source) : TObject(source){
155 // AliITSpListItem &source A AliITSpListItem Object
159 // A copied AliITSpListItem object
163 //______________________________________________________________________
164 void AliITSpListItem::AddSignal(Int_t track,Int_t hit,Int_t module,
165 Int_t index,Double_t signal){
166 // Adds this track number and signal to the pList and orders them
168 // Int_t track The track number which produced this signal
169 // Int_t hit The hit number which produced this signal
170 // Int_t module The module where this signal occurred
171 // Int_t index The cell index where this signal occurred
172 // Double_t signal The value of the signal (ionization)
181 if(findex!=index || fmodule!=module)
182 Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d",
183 index,findex,module,fmodule);
184 fTsignal += signal; // Keep track of sum signal.
186 // for(i=0;i<fgksize;i++) if( track==fTrack[i] && hit==fHits[i] ){
187 for(i=0;i<fgksize;i++) if( track==fTrack[i] ){
188 fSignal[i] += signal;
191 //cout << "track="<<track<<endl;
192 if(flg){ // resort arrays.
193 for(i=1;i<fgksize;i++){
195 while(j>0 && fSignal[j]>fSignal[j-1]){
199 fTrack[j-1] = fTrack[j];
200 fHits[j-1] = fHits[j];
201 fSignal[j-1] = fSignal[j];
205 //cout << "#fTrack["<<j-1<<"]="<<fTrack[j-1]<< " fTrack["<<
206 // j<<"]="<<fTrack[j]<<endl;
211 } // end if added to existing and resorted array
213 // new entry add it in order.
214 // if this signal is <= smallest then don't add it.
215 if(signal <= fSignal[fgksize-1]) return;
216 for(i=fgksize-2;i>=0;i--){
217 if(signal > fSignal[i]){
218 fSignal[i+1] = fSignal[i];
219 fTrack[i+1] = fTrack[i];
220 fHits[i+1] = fHits[i];
222 fSignal[i+1] = signal;
225 return; // put it in the right place, now exit.
227 //cout << "$fTrack["<<i+1<<"]="<<fTrack[i+1]<< " fTrack["<<i<<"]="
228 //<<fTrack[i]<< " fHits["<<i+1<<"]="<<fHits[i+1]<< " fHits["<<i<<"]="
229 //<<fHits[i]<< " fSignal["<<i+1<<"]="<<fSignal[i+1]<< " fSignal["<<i
230 //<<"]="<<fSignal[i]<<endl;
231 } // end if; end for i
232 // Still haven't found the right place. Must be at top of list.
236 //cout << "$fTrack["<<0<<"]="<<fTrack[0]<<" fHits["<<0<<"]="<<fHits[0]
237 //<<" fSignal["<<0<<"]="<<fSignal[0]<<endl;
240 //______________________________________________________________________
241 void AliITSpListItem::AddNoise(Int_t module,Int_t index,Double_t noise){
242 // Adds noise to this existing list.
244 // Int_t module The module where this noise occurred
245 // Int_t index The cell index where this noise occurred
246 // Double_t noise The value of the noise.
252 if(findex!=index || fmodule!=module)
253 Warning("AddNoise","index=%d != findex=%d or module=%d != fmodule=%d",
254 index,findex,module,fmodule);
255 fNoise += noise; // Keep track of sum signal.
257 //______________________________________________________________________
258 void AliITSpListItem::AddSignalAfterElect(Int_t module,Int_t index,Double_t signal){
259 // Adds signal after electronics to this existing list.
261 // Int_t module The module where this noise occurred
262 // Int_t index The cell index where this noise occurred
263 // Double_t signal The value of the signal.
269 if(findex!=index || fmodule!=module)
270 Warning("AddSignalAfterElect","index=%d != findex=%d or module=%d "
271 "!= fmodule=%d",index,findex,module,fmodule);
272 fSignalAfterElect += signal; // Keep track of sum signal.
274 //______________________________________________________________________
275 void AliITSpListItem::Add(AliITSpListItem *pl){
276 // Adds the contents of pl to this
277 // pl could come from different module and index
279 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
288 for(i=0;i<pl->GetNsignals();i++){
289 sig = pl->GetSignal(i);
290 if( sig <= 0.0 ) break; // no more signals
291 AddSignal(pl->GetTrack(i),pl->GetHit(i),fmodule,findex,sig);
294 fTsignal += (pl->fTsignal - sigT);
295 fNoise += pl->fNoise;
298 //______________________________________________________________________
299 void AliITSpListItem::AddTo(Int_t fileIndex,AliITSpListItem *pl){
300 // Adds the contents of pl to this with track number off set given by
303 // Int_t fileIndex track number offset value
304 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
312 Int_t module = pl->GetModule();
313 Int_t index = pl->GetIndex();
314 for(i=0;i<pl->GetNsignals();i++){
315 sig = pl->GetSignal(i);
316 if( sig <= 0.0 ) break; // no more signals
317 trk = pl->GetTrack(i);
319 AddSignal(trk,pl->GetHit(i),module,index,sig);
321 fSignalAfterElect += (pl->fSignalAfterElect + pl->fNoise - fNoise);
325 //______________________________________________________________________
326 Int_t AliITSpListItem::ShiftIndex(Int_t in,Int_t trk) const {
327 // Shift an index number to occupy the upper four bits. No longer used.
329 // Int_t in The file number
330 // Int_t trk The track number
334 // Int_t The track number with the file number in the upper bits.
335 Int_t si = sizeof(Int_t) * 8;
336 UInt_t uin,utrk; // use UInt_t to avoid interger overflow-> goes negative.
340 for(Int_t i=0;i<si-4;i++) uin *= 2;
345 //______________________________________________________________________
346 void AliITSpListItem::Print(ostream *os) const {
347 //Standard output format for this class
349 // ostream *os The output stream
356 *os << fmodule <<","<<findex<<",";
357 *os << fgksize <<",";
358 for(i=0;i<fgksize;i++) *os << fTrack[i] <<",";
359 for(i=0;i<fgksize;i++) *os << fHits[i] <<",";
360 for(i=0;i<fgksize;i++) *os << fSignal[i] <<",";
361 *os << fTsignal <<","<< fNoise << "," << fSignalAfterElect;
363 //______________________________________________________________________
364 void AliITSpListItem::Read(istream *is){
365 // Standard output streaming function.
367 // istream *is The input stream
374 *is >> fmodule >> findex;
375 *is >> iss; // read in fgksize
376 for(i=0;i<fgksize&&i<iss;i++) *is >> fTrack[i];
377 for(i=0;i<fgksize&&i<iss;i++) *is >> fHits[i];
378 for(i=0;i<fgksize&&i<iss;i++) *is >> fSignal[i];
379 *is >> fTsignal >> fNoise >> fSignalAfterElect;
381 //______________________________________________________________________
382 ostream &operator<<(ostream &os,AliITSpListItem &source){
383 // Standard output streaming function.
385 // ostream &os The output stream
386 // AliITSpListItem &source The AliITSpListItem object to be written out.
390 // ostream The output stream
395 //______________________________________________________________________
396 istream &operator>>(istream &os,AliITSpListItem &source){
397 // Standard output streaming function.
399 // istream os The input stream
400 // AliITSpListItem &source The AliITSpListItem object to be inputted
404 // istream The input stream.