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(AliITSsegmentation *seg)
32 fNpz=fSegmentation->Npz();
33 fNpx=fSegmentation->Npx();
34 fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
36 fHitMap = new Int_t[fMaxIndex];
41 AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj)
45 fNpz=fSegmentation->Npz();
46 fNpx=fSegmentation->Npx();
47 fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
49 fHitMap = new Int_t[fMaxIndex];
51 if (fObjects) fNobjects = fObjects->GetEntriesFast();
56 AliITSMapA1::~AliITSMapA1()
59 if (fHitMap) delete[] fHitMap;
62 //__________________________________________________________________________
63 AliITSMapA1::AliITSMapA1(const AliITSMapA1 &source){
65 if(&source == this) return;
66 this->fNpx = source.fNpx;
67 this->fNpz = source.fNpz;
68 this->fObjects = source.fObjects;
69 this->fNobjects = source.fNobjects;
70 this->fMaxIndex = source.fMaxIndex;
71 this->fHitMap = source.fHitMap;
75 //_________________________________________________________________________
77 AliITSMapA1::operator=(const AliITSMapA1 &source) {
78 // Assignment operator
79 if(&source == this) return *this;
80 this->fNpx = source.fNpx;
81 this->fNpz = source.fNpz;
82 this->fObjects = source.fObjects;
83 this->fNobjects = source.fNobjects;
84 this->fMaxIndex = source.fMaxIndex;
85 this->fHitMap = source.fHitMap;
89 void AliITSMapA1::ClearMap()
92 memset(fHitMap,0,sizeof(int)*fMaxIndex);
95 void AliITSMapA1::SetArray(TObjArray *obj)
97 // set array of objects
99 if (fObjects) fNobjects = fObjects->GetEntriesFast();
103 Int_t AliITSMapA1::CheckedIndex(Int_t iz, Int_t ix)
105 //check boundaries and return an index in array
106 Int_t index=fNpx*iz+ix;
107 if (index > fMaxIndex) {
108 printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",iz,ix, fMaxIndex, index, fNpz, fNpx);
117 void AliITSMapA1::FillMap()
119 // fill array with digits indices
120 Int_t ndigits = fObjects->GetEntriesFast();
121 if (!ndigits) return;
124 for (Int_t ndig=0; ndig<ndigits; ndig++) {
125 dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
126 SetHit(dig->fCoord1,dig->fCoord2,ndig);
131 void AliITSMapA1::SetHit(Int_t iz, Int_t ix, Int_t idigit)
133 // set the digit index at a certain position in array
134 fHitMap[CheckedIndex(iz, ix)]=idigit+1;
137 void AliITSMapA1::DeleteHit(Int_t iz, Int_t ix)
139 // delete an entry in array
140 fHitMap[CheckedIndex(iz, ix)]=0;
143 void AliITSMapA1::FlagHit(Int_t iz, Int_t ix)
145 // flag an entry in array
146 fHitMap[CheckedIndex(iz, ix)]=
147 -TMath::Abs(fHitMap[CheckedIndex(iz, ix)]);
150 Int_t AliITSMapA1::GetHitIndex(Int_t iz, Int_t ix)
152 // return the digit index from a specific entry in array
153 if (fHitMap[CheckedIndex(iz, ix)]) return TMath::Abs(fHitMap[CheckedIndex(iz, ix)])-1;
157 TObject* AliITSMapA1::GetHit(Int_t iz, Int_t ix)
159 // return the pointer to the digit
160 Int_t index=GetHitIndex(iz,ix);
161 // Force crash if index does not exist !
162 return (index <0) ? 0 : fObjects->UncheckedAt(GetHitIndex(iz,ix));
165 Double_t AliITSMapA1::GetSignal(Int_t iz, Int_t ix)
168 AliITSdigit *dig = (AliITSdigit*)GetHit(iz,ix);
169 return (Double_t)dig->fSignal;
173 FlagType AliITSMapA1::TestHit(Int_t iz, Int_t ix)
175 // check whether the digit has already been flagged
176 Int_t inf=fHitMap[CheckedIndex(iz, ix)];
179 } else if (inf == 0) {