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),
36 // Default constructor
42 // A zeroed/empty AliITSpListItem class.
44 for(Int_t i=0;i<this->fgksize;i++){
47 this->fSignal[i] = 0.0;
50 //______________________________________________________________________
51 AliITSpListItem::AliITSpListItem(Int_t module,Int_t index,Double_t noise):
56 fSignalAfterElect(0.0),
58 // Standard noise constructor
60 // Int_t module The module where this noise occurred
61 // Int_t index The cell index where this noise occurred
62 // Double_t noise The value of the noise.
66 // A setup and noise filled AliITSpListItem class.
68 for(Int_t i=0;i<this->fgksize;i++){
70 this->fSignal[i] = 0.0;
74 //______________________________________________________________________
75 AliITSpListItem::AliITSpListItem(Int_t track,Int_t hit,Int_t module,
76 Int_t index,Double_t signal):
81 fSignalAfterElect(0.0),
83 // Standard signal constructor
85 // Int_t track The track number which produced this signal
86 // Int_t hit The hit number which produced this signal
87 // Int_t module The module where this signal occurred
88 // Int_t index The cell index where this signal occurred
89 // Double_t signal The value of the signal (ionization)
93 // A setup and signal filled AliITSpListItem class.
95 this->fTrack[0] = track;
97 this->fSignal[0] = signal;
98 for(Int_t i=1;i<this->fgksize;i++){
100 this->fSignal[i] = 0.0;
105 //______________________________________________________________________
106 void AliITSpListItem::Build(Int_t module,Int_t index,Double_t noise){
107 // this method resets all the data members and initializes the
108 // object as in the constructor which has the same arguments
113 fSignalAfterElect = 0.;
115 for(Int_t i=0;i<this->fgksize;i++){
116 this->fTrack[i] = -2;
117 this->fSignal[i] = 0.0;
122 //______________________________________________________________________
123 void AliITSpListItem::Build(Int_t track,Int_t hit,Int_t module,Int_t index,Double_t signal){
124 // this method resets all the data members and initializes the
125 // object as in the constructor which has the same arguments
130 fSignalAfterElect = 0.;
132 this->fTrack[0] = track;
133 this->fHits[0] = hit;
134 this->fSignal[0] = signal;
135 for(Int_t i=1;i<this->fgksize;i++){
136 this->fTrack[i] = -2;
137 this->fSignal[i] = 0.0;
142 //______________________________________________________________________
143 void AliITSpListItem::Build(const AliITSpListItem &source){
144 // this method resets all the data members and initializes the
145 // object as in the constructor which has the same arguments
146 fmodule = source.fmodule;
147 findex = source.findex;
148 fTsignal = source.fTsignal;
149 fNoise = source.fNoise;
150 fSignalAfterElect = source.fSignalAfterElect;
151 fUsed = source.fUsed;
152 for(Int_t i=0;i<this->fgksize;i++){
153 this->fTrack[i] = source.fTrack[i];
154 this->fSignal[i] = source.fSignal[i];
155 this->fHits[i] = source.fHits[i];
159 //______________________________________________________________________
160 AliITSpListItem::~AliITSpListItem(){
167 // A properly destroyed AliITSpListItem class.
170 //______________________________________________________________________
171 AliITSpListItem& AliITSpListItem::operator=(const AliITSpListItem &source){
174 // AliITSpListItem &source A AliITSpListItem Object
178 // A copied AliITSpListItem object
179 this->~AliITSpListItem();
180 new(this) AliITSpListItem(source);
184 //______________________________________________________________________
185 AliITSpListItem::AliITSpListItem(const AliITSpListItem &source) :
187 fmodule(source.fmodule),
188 findex(source.findex),
189 fTsignal(source.fTsignal),
190 fNoise(source.fNoise),
191 fSignalAfterElect(source.fSignalAfterElect),
195 // AliITSpListItem &source A AliITSpListItem Object
199 // A copied AliITSpListItem object
201 for(Int_t i=0;i<this->fgksize;i++){
202 this->fTrack[i] = source.fTrack[i];
203 this->fSignal[i] = source.fSignal[i];
204 this->fHits[i] = source.fHits[i];
208 //______________________________________________________________________
209 void AliITSpListItem::AddSignal(Int_t track,Int_t hit,Int_t module,
210 Int_t index,Double_t signal){
211 // Adds this track number and signal to the pList and orders them
213 // Int_t track The track number which produced this signal
214 // Int_t hit The hit number which produced this signal
215 // Int_t module The module where this signal occurred
216 // Int_t index The cell index where this signal occurred
217 // Double_t signal The value of the signal (ionization)
226 if (TMath::Abs(signal)>2147483647.0) {
227 //PH 2147483647 is the max. integer
228 //PH This apparently is a problem which needs investigation
229 AliWarning(Form("Too big or too small signal value %f",signal));
230 signal = TMath::Sign((Double_t)2147483647,signal);
232 if(findex!=index || fmodule!=module)
233 Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d",
234 index,findex,module,fmodule);
235 fTsignal += signal; // Keep track of sum signal.
237 // for(i=0;i<fgksize;i++) if( track==fTrack[i] && hit==fHits[i] ){
238 for(i=0;i<fgksize;i++) if( track==fTrack[i] ){
239 fSignal[i] += signal;
242 //cout << "track="<<track<<endl;
243 if(flg){ // resort arrays.
244 for(i=1;i<fgksize;i++){
246 while(j>0 && fSignal[j]>fSignal[j-1]){
250 fTrack[j-1] = fTrack[j];
251 fHits[j-1] = fHits[j];
252 fSignal[j-1] = fSignal[j];
256 //cout << "#fTrack["<<j-1<<"]="<<fTrack[j-1]<< " fTrack["<<
257 // j<<"]="<<fTrack[j]<<endl;
262 } // end if added to existing and resorted array
264 // new entry add it in order.
265 // if this signal is <= smallest then don't add it.
266 if(signal <= fSignal[fgksize-1]) return;
267 for(i=fgksize-2;i>=0;i--){
268 if(signal > fSignal[i]){
269 fSignal[i+1] = fSignal[i];
270 fTrack[i+1] = fTrack[i];
271 fHits[i+1] = fHits[i];
273 fSignal[i+1] = signal;
276 return; // put it in the right place, now exit.
278 //cout << "$fTrack["<<i+1<<"]="<<fTrack[i+1]<< " fTrack["<<i<<"]="
279 //<<fTrack[i]<< " fHits["<<i+1<<"]="<<fHits[i+1]<< " fHits["<<i<<"]="
280 //<<fHits[i]<< " fSignal["<<i+1<<"]="<<fSignal[i+1]<< " fSignal["<<i
281 //<<"]="<<fSignal[i]<<endl;
282 } // end if; end for i
283 // Still haven't found the right place. Must be at top of list.
287 //cout << "$fTrack["<<0<<"]="<<fTrack[0]<<" fHits["<<0<<"]="<<fHits[0]
288 //<<" fSignal["<<0<<"]="<<fSignal[0]<<endl;
291 //______________________________________________________________________
292 void AliITSpListItem::AddNoise(Int_t module,Int_t index,Double_t noise){
293 // Adds noise to this existing list.
295 // Int_t module The module where this noise occurred
296 // Int_t index The cell index where this noise occurred
297 // Double_t noise The value of the noise.
303 if(findex!=index || fmodule!=module)
304 Warning("AddNoise","index=%d != findex=%d or module=%d != fmodule=%d",
305 index,findex,module,fmodule);
306 fNoise += noise; // Keep track of sum signal.
308 //______________________________________________________________________
309 void AliITSpListItem::AddSignalAfterElect(Int_t module,Int_t index,Double_t signal){
310 // Adds signal after electronics to this existing list.
312 // Int_t module The module where this noise occurred
313 // Int_t index The cell index where this noise occurred
314 // Double_t signal The value of the signal.
320 if(findex!=index || fmodule!=module)
321 Warning("AddSignalAfterElect","index=%d != findex=%d or module=%d "
322 "!= fmodule=%d",index,findex,module,fmodule);
323 fSignalAfterElect += signal; // Keep track of sum signal.
325 //______________________________________________________________________
326 void AliITSpListItem::Add(AliITSpListItem *pl){
327 // Adds the contents of pl to this
328 // pl could come from different module and index
330 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
339 for(i=0;i<pl->GetNsignals();i++){
340 sig = pl->GetSignal(i);
341 if( sig <= 0.0 ) break; // no more signals
342 AddSignal(pl->GetTrack(i),pl->GetHit(i),fmodule,findex,sig);
345 fTsignal += (pl->fTsignal - sigT);
346 fNoise += pl->fNoise;
349 //______________________________________________________________________
350 void AliITSpListItem::AddTo(Int_t fileIndex,AliITSpListItem *pl){
351 // Adds the contents of pl to this with track number off set given by
354 // Int_t fileIndex track number offset value
355 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
363 Int_t module = pl->GetModule();
364 Int_t index = pl->GetIndex();
365 for(i=0;i<pl->GetNsignals();i++){
366 sig = pl->GetSignal(i);
367 if( sig <= 0.0 ) break; // no more signals
368 trk = pl->GetTrack(i);
370 AddSignal(trk,pl->GetHit(i),module,index,sig);
372 fSignalAfterElect += (pl->fSignalAfterElect + pl->fNoise - fNoise);
376 //______________________________________________________________________
377 Int_t AliITSpListItem::ShiftIndex(Int_t in,Int_t trk) const {
378 // Shift an index number to occupy the upper four bits. No longer used.
380 // Int_t in The file number
381 // Int_t trk The track number
385 // Int_t The track number with the file number in the upper bits.
386 Int_t si = sizeof(Int_t) * 8;
387 UInt_t uin,utrk; // use UInt_t to avoid interger overflow-> goes negative.
391 for(Int_t i=0;i<si-4;i++) uin *= 2;
396 //______________________________________________________________________
397 void AliITSpListItem::Print(ostream *os) const {
398 //Standard output format for this class
400 // ostream *os The output stream
407 *os << fmodule <<","<<findex<<",";
408 *os << fgksize <<",";
409 for(i=0;i<fgksize;i++) *os << fTrack[i] <<",";
410 for(i=0;i<fgksize;i++) *os << fHits[i] <<",";
411 for(i=0;i<fgksize;i++) *os << fSignal[i] <<",";
412 *os << fTsignal <<","<< fNoise << "," << fSignalAfterElect;
414 //______________________________________________________________________
415 void AliITSpListItem::Read(istream *is){
416 // Standard output streaming function.
418 // istream *is The input stream
425 *is >> fmodule >> findex;
426 *is >> iss; // read in fgksize
427 for(i=0;i<fgksize&&i<iss;i++) *is >> fTrack[i];
428 for(i=0;i<fgksize&&i<iss;i++) *is >> fHits[i];
429 for(i=0;i<fgksize&&i<iss;i++) *is >> fSignal[i];
430 *is >> fTsignal >> fNoise >> fSignalAfterElect;
432 //______________________________________________________________________
433 ostream &operator<<(ostream &os,AliITSpListItem &source){
434 // Standard output streaming function.
436 // ostream &os The output stream
437 // AliITSpListItem &source The AliITSpListItem object to be written out.
441 // ostream The output stream
446 //______________________________________________________________________
447 istream &operator>>(istream &os,AliITSpListItem &source){
448 // Standard output streaming function.
450 // istream os The input stream
451 // AliITSpListItem &source The AliITSpListItem object to be inputted
455 // istream The input stream.