1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 **************************************************************************/
21 #include <TObjArray.h>
25 #include "AliITSpList.h"
27 //______________________________________________________________________
29 ClassImp(AliITSpList);
30 //______________________________________________________________________
31 AliITSpList::AliITSpList(){
32 // Default constructor
38 //______________________________________________________________________
39 AliITSpList::AliITSpList(Int_t imax,Int_t jmax){
40 // Standard constructor
44 fa = new TObjArray(fNi*fNj); // elements are zeroed by
47 //______________________________________________________________________
48 AliITSpList::~AliITSpList(){
51 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
53 fa->AddAt(0,i); // zero content
60 //______________________________________________________________________
61 void AliITSpList::ClearMap(){
62 // Delete all AliITSpListItems and zero TObjArray.
64 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
66 fa->AddAt(0,i); // zero content
69 //______________________________________________________________________
70 void AliITSpList::DeleteHit(Int_t i,Int_t j){
71 // Delete a particular AliITSpListItems and zero TObjArray.
72 Int_t k = GetIndex(i,j);
76 fa->AddAt(0,k); // zero content
79 //______________________________________________________________________
80 AliITSpList& AliITSpList::operator=(const AliITSpList &source){
83 if(this == &source) return *this;
85 if(this->fa!=0){ // if this->fa exists delete it first.
86 for(Int_t i=0;i<GetMaxIndex();i++) if(fa->At(i)!=0){
88 fa->AddAt(0,i); // zero content
91 } // end if this->fa!=0
92 this->fNi = source.fNi;
93 this->fNj = source.fNj;
94 this->fa = new TObjArray(*(source.fa));
98 //______________________________________________________________________
99 AliITSpList::AliITSpList(AliITSpList &source){
104 //______________________________________________________________________
105 void AliITSpList::AddSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Int_t mod,
107 // Adds a Signal value to the TObjArray at i,j. Creates the AliITSpListItem
110 if(GetpListItem(i,j)==0){ // most create AliITSpListItem
111 fa->AddAt(new AliITSpListItem(trk,ht,mod,GetIndex(i,j),signal),
113 }else{ // AliITSpListItem exists, just add signal to it.
114 GetpListItem(i,j)->AddSignal(trk,ht,mod,GetIndex(i,j),signal);
117 //______________________________________________________________________
118 void AliITSpList::AddNoise(Int_t i,Int_t j,Int_t mod,Double_t noise){
119 // Adds a noise value to the TObjArray at i,j. Creates the AliITSpListItem
122 if(GetpListItem(i,j)==0){ // most create AliITSpListItem
123 fa->AddAt(new AliITSpListItem(mod,GetIndex(i,j),noise),
125 }else{ // AliITSpListItem exists, just add signal to it.
126 GetpListItem(i,j)->AddNoise(mod,GetIndex(i,j),noise);
129 //______________________________________________________________________
131 ClassImp(AliITSpListItem)
132 //______________________________________________________________________
133 AliITSpListItem::AliITSpListItem(){
134 // Default constructor
138 for(Int_t i=0;i<this->fkSize;i++){
139 this->fTrack[i] = -2;
141 this->fSignal[i] = 0.0;
146 //______________________________________________________________________
147 AliITSpListItem::AliITSpListItem(Int_t module,Int_t index,Double_t noise){
148 // Standard noise constructor
150 this->fmodule = module;
151 this->findex = index;
152 for(Int_t i=0;i<this->fkSize;i++){
153 this->fTrack[i] = -2;
154 this->fSignal[i] = 0.0;
157 this->fTsignal = 0.0;
158 this->fNoise = noise;
160 //______________________________________________________________________
161 AliITSpListItem::AliITSpListItem(Int_t track,Int_t hit,Int_t module,
162 Int_t index,Double_t signal){
163 // Standard signal constructor
165 this->fmodule = module;
166 this->findex = index;
167 this->fTrack[0] = track;
168 this->fHits[0] = hit;
169 this->fSignal[0] = signal;
170 for(Int_t i=1;i<this->fkSize;i++){
171 this->fTrack[i] = -2;
172 this->fSignal[i] = 0.0;
175 this->fTsignal = signal;
178 //______________________________________________________________________
179 AliITSpListItem::~AliITSpListItem(){
184 for(Int_t i=0;i<=this->GetNsignals();i++){
186 this->fSignal[i] = 0.0;
189 this->fTsignal = 0.0;
192 //______________________________________________________________________
193 AliITSpListItem& AliITSpListItem::operator=(const AliITSpListItem &source){
196 if(this == &source) return *this;
198 this->fmodule = source.fmodule;
199 this->findex = source.findex;
200 for(Int_t i=0;i<this->fkSize;i++){
201 this->fTrack[i] = source.fTrack[i];
202 this->fSignal[i] = source.fSignal[i];
203 this->fHits[i] = source.fHits[i];
205 this->fTsignal = source.fTsignal;
206 this->fNoise = source.fNoise;
210 //______________________________________________________________________
211 AliITSpListItem::AliITSpListItem(AliITSpListItem &source){
216 //______________________________________________________________________
217 void AliITSpListItem::AddSignal(Int_t track,Int_t hit,Int_t module,
218 Int_t index,Double_t signal){
219 // Adds this track number and sinal to the pList and orders them
224 if(findex!=index || fmodule!=module)
225 Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d",
226 index,findex,module,fmodule);
227 fTsignal += signal; // Keep track of sum signal.
228 if(signal<=fSignal[fkSize-1]) return; // smaller than smallest
229 for(i=0;i<fkSize;i++)if(track==fTrack[i] && hit ==fHits[i]){
230 fSignal[i] += signal;
233 if(flg){ // resort arrays. fkSize is small use Insertin sort.
234 for(i=1;i<fkSize;i++){
239 while(j>=0 && fSignal[i]>signal){
240 fTrack[j+1] = fTrack[j];
241 fHits[j+1] = fHits[j];
242 fSignal[j+1] = fSignal[j];
250 } // end if added to existing and resorted array
251 // new entry add it in order.
252 // if this signal is <= smallest then don't add it.
253 if(signal <= fSignal[fkSize-1]) return;
254 for(i=fkSize-2;i>=0;i--){
255 if(signal > fSignal[i]){
256 fSignal[i+1] = fSignal[i];
257 fTrack[i+1] = fTrack[i];
258 fHits[i+1] = fHits[i];
263 return; // put it in the right place, now exit.
265 } // end if; end for i
266 // Still haven't found the right place. Must be at top of list.
272 //______________________________________________________________________
273 void AliITSpListItem::AddNoise(Int_t module,Int_t index,Double_t noise){
274 // Addes noise to this existing list.
276 if(findex!=index || fmodule!=module)
277 Warning("AddSignal","index=%d != findex=%d or module=%d != fmodule=%d",
278 index,findex,module,fmodule);
279 fNoise += noise; // Keep track of sum signal.
281 //______________________________________________________________________
282 void AliITSpListItem::AddTo(Int_t fileIndex,AliITSpListItem *pl){
283 // Adds the contents of pl to this with track number off set given by
288 for(i=0;i<pl->GetNsignals()&&i<this->GetNsignals();i++){
289 trk = pl->GetTrack(i);
290 trk = pl->ShiftIndex(fileIndex,trk);
291 this->AddSignal(trk,pl->GetHit(i),pl->GetModule(),pl->GetIndex(),pl->GetSignal(i));
292 sig += pl->GetSignal(i);
294 this->fNoise += pl->fNoise;
297 //______________________________________________________________________
298 Int_t AliITSpListItem::ShiftIndex(Int_t in,Int_t trk){
299 // Shift an index number to occupy the upper four bits.
300 Int_t si = sizeof(Int_t) * 8;
301 UInt_t uin,utrk; // use UInt_t to avoid interger overflow-> goes negitive.
305 for(Int_t i=0;i<si-4;i++) uin *= 2;
310 //______________________________________________________________________
311 void AliITSpListItem::Print(ostream *os){
312 //Standard output format for this class
315 *os << fmodule <<","<<findex<<",";
317 for(i=0;i<fkSize;i++) *os << fTrack[i] <<",";
318 for(i=0;i<fkSize;i++) *os << fHits[i] <<",";
319 for(i=0;i<fkSize;i++) *os << fSignal[i] <<",";
320 *os << fTsignal <<","<< fNoise;
322 //______________________________________________________________________
323 void AliITSpListItem::Read(istream *is){
324 // Standard output streaming function.
327 *is >> fmodule >> findex;
328 *is >> iss; // read in fkSize
329 for(i=0;i<fkSize&&i<iss;i++) *is >> fTrack[i];
330 for(i=0;i<fkSize&&i<iss;i++) *is >> fHits[i];
331 for(i=0;i<fkSize&&i<iss;i++) *is >> fSignal[i];
332 *is >> fTsignal >> fNoise;
334 //______________________________________________________________________
335 ostream &operator<<(ostream &os,AliITSpListItem &source){
336 // Standard output streaming function.
341 //______________________________________________________________________
342 istream &operator>>(istream &os,AliITSpListItem &source){
343 // Standard output streaming function.