]>
Commit | Line | Data |
---|---|---|
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 | /* $Id$ */ | |
17 | ||
18 | // --------------------------- | |
19 | // Class AliMUONDigitMapA1 | |
20 | // --------------------------- | |
21 | // Implements cluster Map as a 1-dim array | |
22 | // Author: Christian Finck | |
23 | ||
24 | #include "AliMUONDigitMapA1.h" | |
25 | #include "AliMUONDigit.h" | |
26 | ||
27 | #include "AliLog.h" | |
28 | ||
29 | #include <TObjArray.h> | |
30 | #include <TMath.h> | |
31 | ||
32 | ClassImp(AliMUONDigitMapA1) | |
33 | ||
34 | AliMUONDigitMapA1::AliMUONDigitMapA1() | |
35 | : fIdDE(0), | |
36 | fNpx(0), | |
37 | fNpy(0), | |
38 | fDigits(0), | |
39 | fMaxIndex(0), | |
40 | fHitMap(0) | |
41 | { | |
42 | /// Default constructor | |
43 | ||
44 | } | |
45 | //________________________________________________________________________________ | |
46 | AliMUONDigitMapA1::AliMUONDigitMapA1(Int_t idDE, Int_t npx, Int_t npy ) | |
47 | { | |
48 | /// Standard constructor | |
49 | ||
50 | fIdDE = idDE; | |
51 | fNpx = npx; | |
52 | fNpy = npy; | |
53 | fMaxIndex = fNpx * fNpy + fNpx ; | |
54 | ||
55 | fHitMap = new Int_t[fMaxIndex]; | |
56 | Clear(); | |
57 | ||
58 | } | |
59 | //______________________________________________________________ | |
60 | AliMUONDigitMapA1::AliMUONDigitMapA1(const AliMUONDigitMapA1& hitMap) | |
61 | : TObject(hitMap) | |
62 | { | |
63 | /// Protected copy constructor | |
64 | ||
65 | AliFatal("Not implemented."); | |
66 | } | |
67 | //_________________________________ | |
68 | AliMUONDigitMapA1::~AliMUONDigitMapA1() | |
69 | { | |
70 | /// Destructor | |
71 | if (fHitMap) delete[] fHitMap; | |
72 | } | |
73 | //______________________________________ | |
74 | void AliMUONDigitMapA1::Clear(const char *) | |
75 | { | |
76 | /// Clear hitmap | |
77 | memset(fHitMap,0,sizeof(int)*fMaxIndex); | |
78 | } | |
79 | ||
80 | //_________________________________________________________ | |
81 | Int_t AliMUONDigitMapA1::CheckedIndex(Int_t ix, Int_t iy) const | |
82 | { | |
83 | /// Return checked indices ix, iy | |
84 | Int_t index = iy * fNpx + ix; | |
85 | if ( index < 0 || index >= fMaxIndex ) { | |
86 | AliWarning(Form("index outside array idDE %d ix %d iy %d MaxIndex %d index %d Npx %d Npy %d", | |
87 | fIdDE, ix,iy, fMaxIndex, index, fNpx, fNpy)); | |
88 | return fMaxIndex-1; | |
89 | } else { | |
90 | return index; | |
91 | } | |
92 | } | |
93 | //_____________________________ | |
94 | void AliMUONDigitMapA1::FillHits(TObjArray* digits) | |
95 | { | |
96 | /// Fill hits from digits list | |
97 | fDigits = digits; | |
98 | Int_t ndigits = fDigits->GetEntriesFast(); | |
99 | if (!ndigits) return; | |
100 | AliMUONDigit *dig; | |
101 | for (Int_t ndig = 0; ndig < ndigits; ndig++) { | |
102 | dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig); | |
103 | SetHit(dig->PadX(),dig->PadY(),ndig); | |
104 | } | |
105 | } | |
106 | //___________________________________________________________ | |
107 | void AliMUONDigitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit) | |
108 | { | |
109 | /// Assign digit to hit cell ix,iy | |
110 | ||
111 | fHitMap[CheckedIndex(ix, iy)] = idigit + 1; | |
112 | } | |
113 | //_______________________________________________ | |
114 | void AliMUONDigitMapA1::DeleteHit(Int_t ix, Int_t iy) | |
115 | { | |
116 | /// Delete hit at cell ix,iy | |
117 | ||
118 | fHitMap[CheckedIndex(ix, iy)]=0; | |
119 | } | |
120 | //_____________________________________________ | |
121 | void AliMUONDigitMapA1::FlagHit(Int_t ix, Int_t iy) | |
122 | { | |
123 | /// Flag hit as used | |
124 | fHitMap[CheckedIndex(ix, iy)]= | |
125 | -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]); | |
126 | } | |
127 | //________________________________________________________ | |
128 | Int_t AliMUONDigitMapA1::GetHitIndex(Int_t ix, Int_t iy) const | |
129 | { | |
130 | /// Get absolute value of contents of hit cell ix,iy | |
131 | return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1; | |
132 | } | |
133 | //_______________________________________________________ | |
134 | TObject* AliMUONDigitMapA1::GetHit(Int_t ix, Int_t iy) const | |
135 | { | |
136 | /// Get pointer to object at hit cell ix, iy | |
137 | /// Force crash if index does not exist ! (Manu) | |
138 | Int_t index = GetHitIndex(ix,iy); | |
139 | return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy)); | |
140 | } | |
141 | //_________________________________________________ | |
142 | FlagType AliMUONDigitMapA1::TestHit(Int_t ix, Int_t iy) const | |
143 | { | |
144 | /// Check if hit cell is empty, used or unused | |
145 | ||
146 | Int_t index = CheckedIndex(ix, iy); | |
147 | if (index<0 || index >= fMaxIndex) return kEmpty; | |
148 | ||
149 | Int_t inf = fHitMap[index]; | |
150 | if (inf < 0) { | |
151 | return kUsed; | |
152 | } else if (inf == 0) { | |
153 | return kEmpty; | |
154 | } else { | |
155 | return kUnused; | |
156 | } | |
157 | } | |
158 | //________________________________________________________________________ | |
159 | AliMUONDigitMapA1 & AliMUONDigitMapA1::operator = (const AliMUONDigitMapA1 & rhs) | |
160 | { | |
161 | /// Protected assignement operator | |
162 | ||
163 | if (this == &rhs) return *this; | |
164 | ||
165 | AliFatal( "Not implemented."); | |
166 | ||
167 | return *this; | |
168 | } |