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 **************************************************************************/
17 #include "AliITSMapA1.h"
18 #include "AliITSsegmentation.h"
19 #include "AliITSresponse.h"
20 #include "AliITSdigit.h"
22 #include <TObjArray.h>
28 AliITSMapA1::AliITSMapA1()
30 // default constructor
42 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg)
46 fNpz=fSegmentation->Npz();
47 fNpx=fSegmentation->Npx();
48 fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
50 fHitMap = new Int_t[fMaxIndex];
57 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj)
62 fNpz=fSegmentation->Npz();
63 fNpx=fSegmentation->Npx();
64 fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
66 fHitMap = new Int_t[fMaxIndex];
68 if (fObjects) fNobjects = fObjects->GetEntriesFast();
73 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj, Int_t thr)
78 fNpz=fSegmentation->Npz();
79 fNpx=fSegmentation->Npx();
80 fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
82 fHitMap = new Int_t[fMaxIndex];
84 if (fObjects) fNobjects = fObjects->GetEntriesFast();
90 AliITSMapA1::~AliITSMapA1()
93 if (fHitMap) delete[] fHitMap;
96 //__________________________________________________________________________
97 AliITSMapA1::AliITSMapA1(const AliITSMapA1 &source){
99 if(&source == this) return;
100 this->fNpx = source.fNpx;
101 this->fNpz = source.fNpz;
102 this->fObjects = source.fObjects;
103 this->fNobjects = source.fNobjects;
104 this->fMaxIndex = source.fMaxIndex;
105 this->fHitMap = source.fHitMap;
106 this->fMapThreshold = source.fMapThreshold;
110 //_________________________________________________________________________
112 AliITSMapA1::operator=(const AliITSMapA1 &source) {
113 // Assignment operator
114 if(&source == this) return *this;
115 this->fNpx = source.fNpx;
116 this->fNpz = source.fNpz;
117 this->fObjects = source.fObjects;
118 this->fNobjects = source.fNobjects;
119 this->fMaxIndex = source.fMaxIndex;
120 this->fHitMap = source.fHitMap;
121 this->fMapThreshold = source.fMapThreshold;
125 void AliITSMapA1::ClearMap()
128 memset(fHitMap,0,sizeof(int)*fMaxIndex);
131 void AliITSMapA1::SetArray(TObjArray *obj)
133 // set array of objects
135 if (fObjects) fNobjects = fObjects->GetEntriesFast();
139 Int_t AliITSMapA1::CheckedIndex(Int_t iz, Int_t ix)
141 //check boundaries and return an index in array
142 Int_t index=fNpx*iz+ix;
144 //if (index > fMaxIndex) {
145 if (index > fMaxIndex || index < 0) {
146 printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d \n",iz,ix, fMaxIndex, index, fNpz, fNpx);
155 void AliITSMapA1::FillMap()
157 // fill array with digits indices
159 //printf("fMapThreshold %d\n",fMapThreshold);
160 Int_t ndigits = fObjects->GetEntriesFast();
161 if (!ndigits) return;
164 for (Int_t ndig=0; ndig<ndigits; ndig++) {
165 dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
166 if(dig->fSignal > fMapThreshold) {
167 SetHit(dig->fCoord1,dig->fCoord2,ndig);
173 void AliITSMapA1::SetHit(Int_t iz, Int_t ix, Int_t idigit)
175 // set the digit index at a certain position in array
176 fHitMap[CheckedIndex(iz, ix)]=idigit+1;
179 void AliITSMapA1::DeleteHit(Int_t iz, Int_t ix)
181 // delete an entry in array
182 fHitMap[CheckedIndex(iz, ix)]=0;
185 void AliITSMapA1::FlagHit(Int_t iz, Int_t ix)
187 // flag an entry in array
188 fHitMap[CheckedIndex(iz, ix)]=
189 -TMath::Abs(fHitMap[CheckedIndex(iz, ix)]);
193 Int_t AliITSMapA1::GetHitIndex(Int_t iz, Int_t ix)
195 // return the digit index from a specific entry in array
196 return TMath::Abs(fHitMap[CheckedIndex(iz, ix)])-1;
199 TObject* AliITSMapA1::GetHit(Int_t iz, Int_t ix)
201 // return the pointer to the digit
202 Int_t index=GetHitIndex(iz,ix);
203 // Force crash if index does not exist !
204 return (index <0) ? 0 : fObjects->UncheckedAt(GetHitIndex(iz,ix));
207 Double_t AliITSMapA1::GetSignal(Int_t iz, Int_t ix)
211 AliITSdigit *dig = (AliITSdigit*)GetHit(iz,ix);
212 if(dig) signal=(Double_t)dig->fSignal;
218 FlagType AliITSMapA1::TestHit(Int_t iz, Int_t ix)
220 // check whether the digit has already been flagged
222 if (CheckedIndex(iz, ix) < 0) return kEmpty;
223 Int_t inf=fHitMap[CheckedIndex(iz, ix)];
226 } else if (inf == 0) {