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 **************************************************************************/
15 #include <TObjArray.h>
16 #include "AliITSMapA1.h"
17 #include "AliITSsegmentation.h"
18 #include "AliITSdigit.h"
20 ////////////////////////////////////////////////////////////////////////
21 // Map Class for ITS. Implementation A1. In this implementation, the //
22 // 2 dimensional (iz,ix) map is filled with integers values. For each //
23 // cell a corresponding TObject, a hit, can also be stored. //
24 // The detector geometry is accessed via the that detectors //
25 // segmentation class and stored here for conveniance. //
26 ////////////////////////////////////////////////////////////////////////
29 //______________________________________________________________________
30 AliITSMapA1::AliITSMapA1():
40 // default constructor
43 //______________________________________________________________________
44 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg):
56 fNpz = fSegmentation->Npz();
57 fNpx = fSegmentation->Npx();
58 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
59 fHitMap = new Int_t[fMaxIndex];
62 //______________________________________________________________________
63 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj):
75 fNpz = fSegmentation->Npz();
76 fNpx = fSegmentation->Npx();
77 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
78 fHitMap = new Int_t[fMaxIndex];
79 if(fObjects) fNobjects = fObjects->GetEntriesFast();
82 //______________________________________________________________________
83 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj, Int_t thr):
95 fNpz = fSegmentation->Npz();
96 fNpx = fSegmentation->Npx();
97 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
98 fHitMap = new Int_t[fMaxIndex];
99 if(fObjects) fNobjects = fObjects->GetEntriesFast();
102 //______________________________________________________________________
103 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj, TArrayI thr):
110 fMapThresholdArr(thr),
115 fNpz = fSegmentation->Npz();
116 fNpx = fSegmentation->Npx();
117 fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector
118 fHitMap = new Int_t[fMaxIndex];
119 if(fObjects) fNobjects = fObjects->GetEntriesFast();
123 //______________________________________________________________________
124 AliITSMapA1::~AliITSMapA1(){
127 if(fHitMap) delete[] fHitMap;
129 //_________________________________________________________________________
130 AliITSMapA1& AliITSMapA1::operator=(const AliITSMapA1 &source) {
131 // Assignment operator
133 this->~AliITSMapA1();
134 new(this) AliITSMapA1(source);
137 //______________________________________________________________________
138 AliITSMapA1::AliITSMapA1(const AliITSMapA1 &source) : AliITSMap(source),
139 fSegmentation(source.fSegmentation),
142 fObjects(source.fObjects),
143 fNobjects(source.fNobjects),
144 fMaxIndex(source.fMaxIndex),
145 fMapThresholdArr(source.fMapThresholdArr),
146 fHitMap(source.fHitMap),
147 fMapThreshold(source.fMapThreshold){
151 //______________________________________________________________________
152 void AliITSMapA1::ClearMap(){
155 memset(fHitMap,0,sizeof(int)*fMaxIndex);
157 //______________________________________________________________________
158 void AliITSMapA1::SetArray(TObjArray *obj){
159 // set array of objects
162 if (fObjects) fNobjects = fObjects->GetEntriesFast();
164 //______________________________________________________________________
165 Int_t AliITSMapA1::CheckedIndex(Int_t iz, Int_t ix) const {
166 //check boundaries and return an index in array
167 Int_t index=fNpx*iz+ix;
169 //if (index > fMaxIndex) {
170 if (index > fMaxIndex || index < 0) {
171 printf("\n \n \n Try to read/write outside array !!!!"
172 " \n \n %d %d %d %d %d %d \n",iz,ix,fMaxIndex,index,fNpz,fNpx);
177 } // end if index>max or < 0
179 //______________________________________________________________________
180 void AliITSMapA1::FillMap(){
181 // fill array with digits indices
183 Int_t ndigits = fObjects->GetEntriesFast();
184 if (!ndigits) return;
187 for (Int_t ndig=0; ndig<ndigits; ndig++) {
188 dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
189 if(dig->GetSignal() > fMapThreshold) {
190 SetHit(dig->GetCoord1(),dig->GetCoord2(),ndig);
191 } // end if fSignal > fMapthreshold
194 //______________________________________________________________________
195 void AliITSMapA1::FillMap2(){
196 // fill array with digits indices
198 Int_t ndigits = fObjects->GetEntriesFast();
199 if (!ndigits) return;
202 for (Int_t ndig=0; ndig<ndigits; ndig++) {
203 dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
204 if(dig->GetSignal() > fMapThresholdArr[dig->GetCoord1()]) {
205 SetHit(dig->GetCoord1(),dig->GetCoord2(),ndig);
206 } // end if fSignal > fMapthreshold
210 //______________________________________________________________________
211 void AliITSMapA1::SetHit(Int_t iz, Int_t ix, Int_t idigit){
212 // set the digit index at a certain position in array
214 fHitMap[CheckedIndex(iz, ix)]=idigit+1;
216 //______________________________________________________________________
217 void AliITSMapA1::DeleteHit(Int_t iz, Int_t ix){
218 // delete an entry in array
220 fHitMap[CheckedIndex(iz, ix)]=0;
222 //______________________________________________________________________
223 void AliITSMapA1::FlagHit(Int_t iz, Int_t ix){
224 // flag an entry in array
226 fHitMap[CheckedIndex(iz, ix)] = -TMath::Abs(fHitMap[CheckedIndex(iz, ix)]);
228 //______________________________________________________________________
229 Int_t AliITSMapA1::GetHitIndex(Int_t iz, Int_t ix) const {
230 // return the digit index from a specific entry in array
232 return TMath::Abs(fHitMap[CheckedIndex(iz, ix)])-1;
234 //______________________________________________________________________
235 TObject* AliITSMapA1::GetHit(Int_t iz, Int_t ix) const {
236 // return the pointer to the digit
238 Int_t index=GetHitIndex(iz,ix);
239 // Force crash if index does not exist !
240 return (index <0) ? 0 : fObjects->UncheckedAt(GetHitIndex(iz,ix));
242 //______________________________________________________________________
243 Double_t AliITSMapA1::GetSignal(Int_t iz, Int_t ix) const{
247 AliITSdigit *dig = (AliITSdigit*)GetHit(iz,ix);
248 if(dig) signal=(Double_t)dig->GetSignal();
252 //______________________________________________________________________
253 FlagType AliITSMapA1::TestHit(Int_t iz, Int_t ix) {
254 // check whether the digit has already been flagged
256 if (CheckedIndex(iz, ix) < 0) return kEmpty;
257 Int_t inf=fHitMap[CheckedIndex(iz, ix)];
260 } else if (inf == 0) {