]>
Commit | Line | Data |
---|---|---|
a9e2aefa | 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 | Revision 1.1.2.2 2000/06/12 07:58:06 morsch | |
19 | include TMath.h | |
20 | ||
21 | Revision 1.1.2.1 2000/06/09 22:01:09 morsch | |
22 | Code from AliMUONHitMap.h | |
23 | Most coding rule violations corrected. | |
24 | ||
25 | */ | |
26 | ||
27 | #include "AliMUONHitMapA1.h" | |
28 | #include "AliMUONSegmentation.h" | |
29 | #include "AliMUONResponse.h" | |
30 | #include "AliMUONDigit.h" | |
31 | ||
32 | #include <TObjArray.h> | |
33 | #include <TMath.h> | |
34 | ||
35 | ClassImp(AliMUONHitMapA1) | |
36 | ||
37 | ||
38 | AliMUONHitMapA1::AliMUONHitMapA1(AliMUONSegmentation *seg, TObjArray *dig) | |
39 | { | |
40 | // Constructor | |
41 | fSegmentation = seg; | |
42 | fNpx = fSegmentation->Npx(); | |
43 | fNpy = fSegmentation->Npy(); | |
44 | fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy; | |
45 | ||
46 | fHitMap = new Int_t[fMaxIndex]; | |
47 | fDigits = dig; | |
48 | fNdigits = fDigits->GetEntriesFast(); | |
49 | Clear(); | |
50 | } | |
51 | ||
52 | AliMUONHitMapA1::AliMUONHitMapA1(const AliMUONHitMapA1 & hitMap) | |
53 | { | |
54 | // Dummy copy constructor | |
55 | ; | |
56 | } | |
57 | ||
58 | ||
59 | AliMUONHitMapA1::~AliMUONHitMapA1() | |
60 | { | |
61 | // Destructor | |
62 | // if (fDigits) delete fDigits; | |
63 | if (fHitMap) delete[] fHitMap; | |
64 | } | |
65 | ||
66 | void AliMUONHitMapA1::Clear() | |
67 | { | |
68 | // Clear hitmap | |
69 | memset(fHitMap,0,sizeof(int)*fMaxIndex); | |
70 | } | |
71 | ||
72 | Int_t AliMUONHitMapA1::CheckedIndex(Int_t ix, Int_t iy) | |
73 | { | |
74 | // Return checked indices ix, iy | |
75 | Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy); | |
76 | if (index > fMaxIndex) { | |
77 | printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",ix,iy, fMaxIndex, index, fNpx, fNpy); | |
78 | return fMaxIndex-1; | |
79 | } else { | |
80 | return index; | |
81 | } | |
82 | } | |
83 | ||
84 | ||
85 | void AliMUONHitMapA1::FillHits() | |
86 | { | |
87 | // Fill hits from digits list | |
88 | Int_t ndigits = fDigits->GetEntriesFast(); | |
89 | //printf("\n Filling hits into HitMap\n"); | |
90 | //printf("FindRawClusters -- ndigits %d \n",ndigits); | |
91 | if (!ndigits) return; | |
92 | AliMUONDigit *dig; | |
93 | for (Int_t ndig=0; ndig<fNdigits; ndig++) { | |
94 | dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig); | |
95 | SetHit(dig->fPadX,dig->fPadY,ndig); | |
96 | } | |
97 | } | |
98 | ||
99 | ||
100 | void AliMUONHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit) | |
101 | { | |
102 | // Assign digit to hit cell ix,iy | |
103 | // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1; | |
104 | fHitMap[CheckedIndex(ix, iy)]=idigit+1; | |
105 | } | |
106 | ||
107 | void AliMUONHitMapA1::DeleteHit(Int_t ix, Int_t iy) | |
108 | { | |
109 | // Delete hit at cell ix,iy | |
110 | // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0; | |
111 | fHitMap[CheckedIndex(ix, iy)]=0; | |
112 | } | |
113 | ||
114 | void AliMUONHitMapA1::FlagHit(Int_t ix, Int_t iy) | |
115 | { | |
116 | // Flag hit as used | |
117 | fHitMap[CheckedIndex(ix, iy)]= | |
118 | -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]); | |
119 | } | |
120 | ||
121 | Int_t AliMUONHitMapA1::GetHitIndex(Int_t ix, Int_t iy) | |
122 | { | |
123 | // Get absolute value of contents of hit cell ix,iy | |
124 | return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1; | |
125 | } | |
126 | ||
127 | TObject* AliMUONHitMapA1::GetHit(Int_t ix, Int_t iy) | |
128 | { | |
129 | // Get pointer to object at hit cell ix, iy | |
130 | // Force crash if index does not exist ! (Manu) | |
131 | Int_t index=GetHitIndex(ix,iy); | |
132 | return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy)); | |
133 | } | |
134 | ||
135 | FlagType AliMUONHitMapA1::TestHit(Int_t ix, Int_t iy) | |
136 | { | |
137 | // Check if hit cell is empty, used or unused | |
138 | // | |
139 | Int_t inf=fHitMap[CheckedIndex(ix, iy)]; | |
140 | if (inf < 0) { | |
141 | return kUsed; | |
142 | } else if (inf == 0) { | |
143 | return kEmpty; | |
144 | } else { | |
145 | return kUnused; | |
146 | } | |
147 | } | |
148 | ||
149 | AliMUONHitMapA1 & AliMUONHitMapA1::operator = (const AliMUONHitMapA1 & rhs) | |
150 | { | |
151 | // Dummy assignment operator | |
152 | return *this; | |
153 | } | |
154 | ||
155 |