]>
Commit | Line | Data |
---|---|---|
a897a37a | 1 | #include "AliMUONHitMap.h" |
2 | ClassImp(AliMUONHitMap) | |
3 | ClassImp(AliMUONHitMapA1) | |
4 | ||
5 | AliMUONHitMapA1::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(); | |
15 | Clear(); | |
16 | } | |
17 | ||
18 | ||
19 | AliMUONHitMapA1::~AliMUONHitMapA1() | |
20 | { | |
21 | // if (fDigits) delete fDigits; | |
22 | if (fHitMap) delete[] fHitMap; | |
23 | } | |
24 | ||
25 | void AliMUONHitMapA1::Clear() | |
26 | { | |
27 | memset(fHitMap,0,sizeof(int)*fMaxIndex); | |
28 | } | |
29 | ||
30 | Int_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 | ||
42 | void 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 | ||
56 | void 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 | ||
62 | void 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 | ||
68 | void AliMUONHitMapA1::FlagHit(Int_t ix, Int_t iy) | |
69 | { | |
70 | fHitMap[CheckedIndex(ix, iy)]= | |
71 | -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]); | |
72 | } | |
73 | ||
74 | Int_t AliMUONHitMapA1::GetHitIndex(Int_t ix, Int_t iy) | |
75 | { | |
76 | return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1; | |
77 | } | |
78 | ||
79 | TObject* 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 | ||
86 | Flag_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 |