]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSpListItem.cxx
Correct the number of buspatches for station 1 & 2 and for R2 & R3 type slat (Christian)
[u/mrichter/AliRoot.git] / ITS / AliITSpListItem.cxx
CommitLineData
fb4e90e0 1/**************************************************************************
2 * Copyright(c) 1998-2004, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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//************************************************************************
25ClassImp(AliITSpListItem)
26//______________________________________________________________________
27AliITSpListItem::AliITSpListItem(){
28 // Default constructor
29 // Inputs:
30 // none.
31 // Outputs:
32 // none.
33 // Return:
34 // A zeroed/empty AliITSpListItem class.
35
36 fmodule = -1;
37 findex = -1;
38 for(Int_t i=0;i<this->fgksize;i++){
39 this->fTrack[i] = -2;
40 this->fHits[i] = -1;
41 this->fSignal[i] = 0.0;
42 } // end if i
43 fTsignal = 0.0;
44 fNoise = 0.0;
45 fSignalAfterElect = 0.0;
46}
47//______________________________________________________________________
48AliITSpListItem::AliITSpListItem(Int_t module,Int_t index,Double_t noise){
49 // Standard noise constructor
50 // Inputs:
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.
54 // Outputs:
55 // none.
56 // Return:
57 // A setup and noise filled AliITSpListItem class.
58
59 this->fmodule = module;
60 this->findex = index;
61 for(Int_t i=0;i<this->fgksize;i++){
62 this->fTrack[i] = -2;
63 this->fSignal[i] = 0.0;
64 this->fHits[i] = -1;
65 } // end if i
66 this->fTsignal = 0.0;
67 this->fSignalAfterElect = 0.0;
68 this->fNoise = noise;
69}
70//______________________________________________________________________
71AliITSpListItem::AliITSpListItem(Int_t track,Int_t hit,Int_t module,
72 Int_t index,Double_t signal){
73 // Standard signal constructor
74 // Inputs:
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)
80 // Outputs:
81 // none.
82 // Return:
83 // A setup and signal filled AliITSpListItem class.
84
85 this->fmodule = module;
86 this->findex = index;
87 this->fTrack[0] = track;
88 this->fHits[0] = hit;
89 this->fSignal[0] = signal;
90 for(Int_t i=1;i<this->fgksize;i++){
91 this->fTrack[i] = -2;
92 this->fSignal[i] = 0.0;
93 this->fHits[i] = -1;
94 } // end if i
95 this->fTsignal = signal;
96 this->fNoise = 0.0;
97 this->fSignalAfterElect = 0.0;
98}
99//______________________________________________________________________
100AliITSpListItem::~AliITSpListItem(){
101 // Destructor
102 // Inputs:
103 // none.
104 // Outputs:
105 // none.
106 // Return:
107 // A properly destroyed AliITSpListItem class.
108
109}
110//______________________________________________________________________
111AliITSpListItem& AliITSpListItem::operator=(const AliITSpListItem &source){
112 // = operator
113 // Inputs:
114 // AliITSpListItem &source A AliITSpListItem Object
115 // Outputs:
116 // none.
117 // Return:
118 // A copied AliITSpListItem object
119 Int_t i;
120
121 if(this == &source) return *this;
122
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];
129 } // end if i
130 this->fTsignal = source.fTsignal;
131 this->fNoise = source.fNoise;
132 this->fSignalAfterElect = source.fSignalAfterElect;
133 /*
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]<<",";
140 cout << endl;
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]<<",";
147 cout << endl;
148 */
149 return *this;
150}
151//______________________________________________________________________
152AliITSpListItem::AliITSpListItem(AliITSpListItem &source) : TObject(source){
153 // Copy operator
154 // Inputs:
155 // AliITSpListItem &source A AliITSpListItem Object
156 // Outputs:
157 // none.
158 // Return:
159 // A copied AliITSpListItem object
160
161 *this = source;
162}
163//______________________________________________________________________
164void 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
167 // Inputs:
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)
173 // Outputs:
174 // none.
175 // Return:
176 // none.
177 Int_t i,j,trk,hts;
178 Double_t sig;
179 Bool_t flg=kFALSE;
180
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.
185
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;
189 flg = kTRUE;
190 } // end for i & if.
191 //cout << "track="<<track<<endl;
192 if(flg){ // resort arrays.
193 for(i=1;i<fgksize;i++){
194 j = i;
195 while(j>0 && fSignal[j]>fSignal[j-1]){
196 trk = fTrack[j-1];
197 hts = fHits[j-1];
198 sig = fSignal[j-1];
199 fTrack[j-1] = fTrack[j];
200 fHits[j-1] = fHits[j];
201 fSignal[j-1] = fSignal[j];
202 fTrack[j] = trk;
203 fHits[j] = hts;
204 fSignal[j] = sig;
205 //cout << "#fTrack["<<j-1<<"]="<<fTrack[j-1]<< " fTrack["<<
206 // j<<"]="<<fTrack[j]<<endl;
207 j--;
208 } // end while
209 } // end if i
210 return;
211 } // end if added to existing and resorted array
212
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];
221 }else{
222 fSignal[i+1] = signal;
223 fTrack[i+1] = track;
224 fHits[i+1] = hit;
225 return; // put it in the right place, now exit.
226 } // end if
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.
233 fSignal[0] = signal;
234 fTrack[0] = track;
235 fHits[0] = hit;
236 //cout << "$fTrack["<<0<<"]="<<fTrack[0]<<" fHits["<<0<<"]="<<fHits[0]
237 //<<" fSignal["<<0<<"]="<<fSignal[0]<<endl;
238 return;
239}
240//______________________________________________________________________
241void AliITSpListItem::AddNoise(Int_t module,Int_t index,Double_t noise){
242 // Adds noise to this existing list.
243 // Inputs:
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.
247 // Outputs:
248 // none.
249 // Return:
250 // none.
251
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.
256}
257//______________________________________________________________________
258void AliITSpListItem::AddSignalAfterElect(Int_t module,Int_t index,Double_t signal){
259 // Adds signal after electronics to this existing list.
260 // Inputs:
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.
264 // Outputs:
265 // none.
266 // Return:
267 // none.
268
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.
273}
274//______________________________________________________________________
275void AliITSpListItem::Add(AliITSpListItem *pl){
276 // Adds the contents of pl to this
277 // pl could come from different module and index
278 // Inputs:
279 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
280 // Outputs:
281 // none.
282 // Return:
283 // none.
284 Int_t i;
285 Double_t sig = 0.0;
286 Double_t sigT = 0.0;
287
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);
292 sigT += sig;
293 } // end for i
294 fTsignal += (pl->fTsignal - sigT);
295 fNoise += pl->fNoise;
296 return;
297}
298//______________________________________________________________________
299void AliITSpListItem::AddTo(Int_t fileIndex,AliITSpListItem *pl){
300 // Adds the contents of pl to this with track number off set given by
301 // fileIndex.
302 // Inputs:
303 // Int_t fileIndex track number offset value
304 // AliITSpListItem *pl an AliITSpListItem to be added to this class.
305 // Outputs:
306 // none.
307 // Return:
308 // none.
309 Int_t i,trk;
310 Double_t sig = 0.0;
311
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);
318 trk += fileIndex;
319 AddSignal(trk,pl->GetHit(i),module,index,sig);
320 } // end for i
321 fSignalAfterElect += (pl->fSignalAfterElect + pl->fNoise - fNoise);
322 fNoise = pl->fNoise;
323 return;
324}
325//______________________________________________________________________
326Int_t AliITSpListItem::ShiftIndex(Int_t in,Int_t trk) const {
327 // Shift an index number to occupy the upper four bits. No longer used.
328 // Inputs:
329 // Int_t in The file number
330 // Int_t trk The track number
331 // Outputs:
332 // none.
333 // Return:
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.
337
338 uin = in;
339 utrk = trk;
340 for(Int_t i=0;i<si-4;i++) uin *= 2;
341 uin += utrk;
342 in = uin;
343 return in;
344}
345//______________________________________________________________________
346void AliITSpListItem::Print(ostream *os) const {
347 //Standard output format for this class
348 // Inputs:
349 // ostream *os The output stream
350 // Outputs:
351 // none.
352 // Return:
353 // none.
354 Int_t i;
355
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;
362}
363//______________________________________________________________________
364void AliITSpListItem::Read(istream *is){
365 // Standard output streaming function.
366 // Inputs:
367 // istream *is The input stream
368 // Outputs:
369 // none.
370 // Return:
371 // none.
372 Int_t i,iss;
373
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;
380}
381//______________________________________________________________________
382ostream &operator<<(ostream &os,AliITSpListItem &source){
383 // Standard output streaming function.
384 // Inputs:
385 // ostream &os The output stream
386 // AliITSpListItem &source The AliITSpListItem object to be written out.
387 // Outputs:
388 // none.
389 // Return:
390 // ostream The output stream
391
392 source.Print(&os);
393 return os;
394}
395//______________________________________________________________________
396istream &operator>>(istream &os,AliITSpListItem &source){
397 // Standard output streaming function.
398 // Inputs:
399 // istream os The input stream
400 // AliITSpListItem &source The AliITSpListItem object to be inputted
401 // Outputs:
402 // none.
403 // Return:
404 // istream The input stream.
405
406 source.Read(&os);
407 return os;
408}