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