]>
Commit | Line | Data |
---|---|---|
237c933d | 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 | ||
20 | ||
21 | #include "AliRICHHitMapA1.h" | |
22 | #include "AliRICHSegmentation.h" | |
23 | #include "AliRICHDigit.h" | |
24 | ||
25 | #include <TObjArray.h> | |
26 | #include <TMath.h> | |
27 | ||
28 | ClassImp(AliRICHHitMapA1) | |
29 | ||
30 | ||
31 | AliRICHHitMapA1::AliRICHHitMapA1(AliRICHSegmentation *seg, TObjArray *dig) | |
32 | { | |
33 | ||
34 | // Constructor for AliRICHMapA1 | |
35 | ||
36 | fSegmentation = seg; | |
37 | fNpx = fSegmentation->Npx(); | |
38 | fNpy = fSegmentation->Npy(); | |
39 | fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy; | |
40 | ||
41 | fHitMap = new Int_t[fMaxIndex]; | |
42 | fDigits = dig; | |
43 | fNdigits = fDigits->GetEntriesFast(); | |
44 | Clear(); | |
45 | } | |
46 | ||
47 | ||
48 | AliRICHHitMapA1::~AliRICHHitMapA1() | |
49 | { | |
50 | // Destructor | |
51 | // if (fDigits) delete fDigits; | |
52 | if (fHitMap) delete[] fHitMap; | |
53 | } | |
54 | ||
55 | void AliRICHHitMapA1::Clear() | |
56 | { | |
57 | ||
58 | // Clear contents of hit map | |
59 | ||
60 | memset(fHitMap,0,sizeof(int)*fMaxIndex); | |
61 | } | |
62 | ||
63 | Int_t AliRICHHitMapA1::CheckedIndex(Int_t ix, Int_t iy) | |
64 | { | |
65 | ||
66 | // Check if index is valid | |
67 | ||
68 | Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy); | |
69 | if (index > fMaxIndex) { | |
70 | printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",ix,iy, fMaxIndex, index, fNpx, fNpy); | |
71 | return fMaxIndex-1; | |
72 | } else { | |
73 | return index; | |
74 | } | |
75 | } | |
76 | ||
77 | ||
78 | void AliRICHHitMapA1::FillHits() | |
79 | { | |
80 | ||
81 | // Fill hits into HitMap | |
82 | ||
83 | Int_t ndigits = fDigits->GetEntriesFast(); | |
84 | //printf("\n Filling hits into HitMap\n"); | |
85 | //printf("FindRawClusters -- ndigits %d \n",ndigits); | |
86 | if (!ndigits) return; | |
87 | AliRICHDigit *dig; | |
88 | for (Int_t ndig=0; ndig<fNdigits; ndig++) { | |
89 | dig = (AliRICHDigit*)fDigits->UncheckedAt(ndig); | |
90 | SetHit(dig->fPadX,dig->fPadY,ndig); | |
91 | } | |
92 | } | |
93 | ||
94 | ||
95 | void AliRICHHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit) | |
96 | { | |
97 | // | |
98 | // Set current hit | |
99 | // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1; | |
100 | fHitMap[CheckedIndex(ix, iy)]=idigit+1; | |
101 | } | |
102 | ||
103 | void AliRICHHitMapA1::DeleteHit(Int_t ix, Int_t iy) | |
104 | { | |
105 | // Delete hit | |
106 | // | |
107 | // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0; | |
108 | fHitMap[CheckedIndex(ix, iy)]=0; | |
109 | } | |
110 | ||
111 | void AliRICHHitMapA1::FlagHit(Int_t ix, Int_t iy) | |
112 | { | |
113 | // | |
114 | // Flag hit | |
115 | ||
116 | fHitMap[CheckedIndex(ix, iy)]= | |
117 | -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]); | |
118 | } | |
119 | ||
120 | Int_t AliRICHHitMapA1::GetHitIndex(Int_t ix, Int_t iy) | |
121 | { | |
122 | ||
123 | // Return hit coordinates from index | |
124 | ||
f8de6569 | 125 | //printf("ix:%d, iy:%d, index:%d\n",ix,iy,CheckedIndex(ix, iy)); |
237c933d | 126 | |
127 | return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1; | |
128 | ||
129 | } | |
130 | ||
131 | TObject* AliRICHHitMapA1::GetHit(Int_t ix, Int_t iy) | |
132 | { | |
133 | ||
134 | // Return index from coordinates | |
135 | ||
136 | Int_t index=GetHitIndex(ix,iy); | |
137 | // Force crash if index does not exist ! (Manu) | |
138 | return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy)); | |
139 | } | |
140 | ||
141 | FlagType AliRICHHitMapA1::TestHit(Int_t ix, Int_t iy) | |
142 | { | |
143 | ||
144 | // Is there a hit? | |
145 | ||
146 | Int_t inf=fHitMap[CheckedIndex(ix, iy)]; | |
147 | if (inf < 0) { | |
148 | return kUsed; | |
149 | } else if (inf == 0) { | |
150 | return kEmpty; | |
151 | } else { | |
152 | return kUnused; | |
153 | } | |
154 | } | |
155 | ||
156 |