Remove warnings on SunOS
[u/mrichter/AliRoot.git] / RICH / AliRICHHitMap.cxx
CommitLineData
ddae0931 1#include "AliRICHHitMap.h"
2
3ClassImp(AliRICHHitMap)
4ClassImp(AliRICHHitMapA1)
5
f91473f6 6 //const char* dummy=0;
7
8
ddae0931 9AliRICHHitMapA1::AliRICHHitMapA1(AliRICHsegmentation *seg, TObjArray *dig)
10{
11 fSegmentation = seg;
12 fNpx = fSegmentation->Npx();
13 fNpy = fSegmentation->Npy();
14 fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy;
15
16 fHitMap = new Int_t[fMaxIndex];
17 fDigits = dig;
18 fNdigits = fDigits->GetEntriesFast();
19 Clear();
20}
21
22
23AliRICHHitMapA1::~AliRICHHitMapA1()
24{
25// if (fDigits) delete fDigits;
26 if (fHitMap) delete[] fHitMap;
27}
28
f91473f6 29void AliRICHHitMapA1::Clear(Option_t *)
ddae0931 30{
31 memset(fHitMap,0,sizeof(int)*fMaxIndex);
32}
33
34Int_t AliRICHHitMapA1::CheckedIndex(Int_t ix, Int_t iy)
35{
36 Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy);
37 if (index > fMaxIndex) {
38 printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",ix,iy, fMaxIndex, index, fNpx, fNpy);
39 return fMaxIndex-1;
40 } else {
41 return index;
42 }
43}
44
45
46void AliRICHHitMapA1::FillHits()
47{
48 Int_t ndigits = fDigits->GetEntriesFast();
49 printf("\n Filling hits into HitMap\n");
50 printf("FindRawClusters -- ndigits %d \n",ndigits);
51 if (!ndigits) return;
52 AliRICHdigit *dig;
53 for (Int_t ndig=0; ndig<fNdigits; ndig++) {
54 dig = (AliRICHdigit*)fDigits->UncheckedAt(ndig);
55 SetHit(dig->fPadX,dig->fPadY,ndig);
56 }
57}
58
59
60void AliRICHHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
61{
62// fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1;
63 fHitMap[CheckedIndex(ix, iy)]=idigit+1;
64}
65
66void AliRICHHitMapA1::DeleteHit(Int_t ix, Int_t iy)
67{
68// fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0;
69 fHitMap[CheckedIndex(ix, iy)]=0;
70}
71
72void AliRICHHitMapA1::FlagHit(Int_t ix, Int_t iy)
73{
74 fHitMap[CheckedIndex(ix, iy)]=
75 -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
76}
77
78Int_t AliRICHHitMapA1::GetHitIndex(Int_t ix, Int_t iy)
79{
80 return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
81}
82
83TObject* AliRICHHitMapA1::GetHit(Int_t ix, Int_t iy)
84{
85 Int_t index=GetHitIndex(ix,iy);
86 // Force crash if index does not exist ! (Manu)
87 return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy));
88}
89
90Flag_t AliRICHHitMapA1::TestHit(Int_t ix, Int_t iy)
91{
92 Int_t inf=fHitMap[CheckedIndex(ix, iy)];
93 if (inf < 0) {
94 return used;
95 } else if (inf == 0) {
96 return empty;
97 } else {
98 return unused;
99 }
100}
101
102