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