]>
Commit | Line | Data |
---|---|---|
4c039060 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | ||
16 | /* | |
17 | $Log$ | |
18 | */ | |
19 | ||
ddae0931 | 20 | #include "AliRICHHitMap.h" |
21 | ||
22 | ClassImp(AliRICHHitMap) | |
23 | ClassImp(AliRICHHitMapA1) | |
24 | ||
f91473f6 | 25 | //const char* dummy=0; |
26 | ||
27 | ||
ddae0931 | 28 | AliRICHHitMapA1::AliRICHHitMapA1(AliRICHsegmentation *seg, TObjArray *dig) |
29 | { | |
30 | fSegmentation = seg; | |
31 | fNpx = fSegmentation->Npx(); | |
32 | fNpy = fSegmentation->Npy(); | |
33 | fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy; | |
34 | ||
35 | fHitMap = new Int_t[fMaxIndex]; | |
36 | fDigits = dig; | |
37 | fNdigits = fDigits->GetEntriesFast(); | |
38 | Clear(); | |
39 | } | |
40 | ||
41 | ||
42 | AliRICHHitMapA1::~AliRICHHitMapA1() | |
43 | { | |
44 | // if (fDigits) delete fDigits; | |
45 | if (fHitMap) delete[] fHitMap; | |
46 | } | |
47 | ||
f91473f6 | 48 | void AliRICHHitMapA1::Clear(Option_t *) |
ddae0931 | 49 | { |
50 | memset(fHitMap,0,sizeof(int)*fMaxIndex); | |
51 | } | |
52 | ||
53 | Int_t AliRICHHitMapA1::CheckedIndex(Int_t ix, Int_t iy) | |
54 | { | |
55 | Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy); | |
56 | if (index > fMaxIndex) { | |
57 | printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",ix,iy, fMaxIndex, index, fNpx, fNpy); | |
58 | return fMaxIndex-1; | |
59 | } else { | |
60 | return index; | |
61 | } | |
62 | } | |
63 | ||
64 | ||
65 | void AliRICHHitMapA1::FillHits() | |
66 | { | |
67 | Int_t ndigits = fDigits->GetEntriesFast(); | |
68 | printf("\n Filling hits into HitMap\n"); | |
69 | printf("FindRawClusters -- ndigits %d \n",ndigits); | |
70 | if (!ndigits) return; | |
71 | AliRICHdigit *dig; | |
72 | for (Int_t ndig=0; ndig<fNdigits; ndig++) { | |
73 | dig = (AliRICHdigit*)fDigits->UncheckedAt(ndig); | |
74 | SetHit(dig->fPadX,dig->fPadY,ndig); | |
75 | } | |
76 | } | |
77 | ||
78 | ||
79 | void AliRICHHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit) | |
80 | { | |
81 | // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1; | |
82 | fHitMap[CheckedIndex(ix, iy)]=idigit+1; | |
83 | } | |
84 | ||
85 | void AliRICHHitMapA1::DeleteHit(Int_t ix, Int_t iy) | |
86 | { | |
87 | // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0; | |
88 | fHitMap[CheckedIndex(ix, iy)]=0; | |
89 | } | |
90 | ||
91 | void AliRICHHitMapA1::FlagHit(Int_t ix, Int_t iy) | |
92 | { | |
93 | fHitMap[CheckedIndex(ix, iy)]= | |
94 | -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]); | |
95 | } | |
96 | ||
97 | Int_t AliRICHHitMapA1::GetHitIndex(Int_t ix, Int_t iy) | |
98 | { | |
99 | return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1; | |
100 | } | |
101 | ||
102 | TObject* AliRICHHitMapA1::GetHit(Int_t ix, Int_t iy) | |
103 | { | |
104 | Int_t index=GetHitIndex(ix,iy); | |
105 | // Force crash if index does not exist ! (Manu) | |
106 | return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy)); | |
107 | } | |
108 | ||
109 | Flag_t AliRICHHitMapA1::TestHit(Int_t ix, Int_t iy) | |
110 | { | |
111 | Int_t inf=fHitMap[CheckedIndex(ix, iy)]; | |
112 | if (inf < 0) { | |
113 | return used; | |
114 | } else if (inf == 0) { | |
115 | return empty; | |
116 | } else { | |
117 | return unused; | |
118 | } | |
119 | } | |
120 | ||
121 |