]>
Commit | Line | Data |
---|---|---|
5289cf2f | 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 | ||
d19b6003 | 18 | // --------------------------- |
19 | // Class AliMUONDigitMapA1 | |
20 | // --------------------------- | |
21 | // Implements cluster Map as a 1-dim array | |
22 | // Author: Christian Finck | |
23 | ||
5289cf2f | 24 | #include "AliMUONDigitMapA1.h" |
25 | #include "AliMUONDigit.h" | |
d3ea2ca8 | 26 | |
5289cf2f | 27 | #include "AliLog.h" |
28 | ||
d3ea2ca8 | 29 | #include <TObjArray.h> |
30 | #include <TMath.h> | |
31 | ||
5289cf2f | 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 | { | |
d19b6003 | 42 | /// Default constructor |
5289cf2f | 43 | |
44 | } | |
45 | //________________________________________________________________________________ | |
d3ea2ca8 | 46 | AliMUONDigitMapA1::AliMUONDigitMapA1(Int_t idDE, Int_t npx, Int_t npy ) |
5289cf2f | 47 | { |
d19b6003 | 48 | /// Standard constructor |
5289cf2f | 49 | |
5289cf2f | 50 | fIdDE = idDE; |
d3ea2ca8 | 51 | fNpx = npx; |
52 | fNpy = npy; | |
5289cf2f | 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 | { | |
d19b6003 | 63 | /// Protected copy constructor |
5289cf2f | 64 | |
65 | AliFatal("Not implemented."); | |
66 | } | |
67 | //_________________________________ | |
68 | AliMUONDigitMapA1::~AliMUONDigitMapA1() | |
69 | { | |
d19b6003 | 70 | /// Destructor |
5289cf2f | 71 | if (fHitMap) delete[] fHitMap; |
72 | } | |
73 | //______________________________________ | |
74 | void AliMUONDigitMapA1::Clear(const char *) | |
75 | { | |
d19b6003 | 76 | /// Clear hitmap |
5289cf2f | 77 | memset(fHitMap,0,sizeof(int)*fMaxIndex); |
78 | } | |
79 | ||
80 | //_________________________________________________________ | |
81 | Int_t AliMUONDigitMapA1::CheckedIndex(Int_t ix, Int_t iy) const | |
82 | { | |
d19b6003 | 83 | /// Return checked indices ix, iy |
5289cf2f | 84 | Int_t index = iy * fNpx + ix; |
b133692e | 85 | if ( index < 0 || index >= fMaxIndex ) { |
5289cf2f | 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 | { | |
d19b6003 | 96 | /// Fill hits from digits list |
5289cf2f | 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 | { | |
d19b6003 | 109 | /// Assign digit to hit cell ix,iy |
5289cf2f | 110 | |
111 | fHitMap[CheckedIndex(ix, iy)] = idigit + 1; | |
112 | } | |
113 | //_______________________________________________ | |
114 | void AliMUONDigitMapA1::DeleteHit(Int_t ix, Int_t iy) | |
115 | { | |
d19b6003 | 116 | /// Delete hit at cell ix,iy |
5289cf2f | 117 | |
118 | fHitMap[CheckedIndex(ix, iy)]=0; | |
119 | } | |
120 | //_____________________________________________ | |
121 | void AliMUONDigitMapA1::FlagHit(Int_t ix, Int_t iy) | |
122 | { | |
d19b6003 | 123 | /// Flag hit as used |
5289cf2f | 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 | { | |
d19b6003 | 130 | /// Get absolute value of contents of hit cell ix,iy |
5289cf2f | 131 | return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1; |
132 | } | |
133 | //_______________________________________________________ | |
134 | TObject* AliMUONDigitMapA1::GetHit(Int_t ix, Int_t iy) const | |
135 | { | |
d19b6003 | 136 | /// Get pointer to object at hit cell ix, iy |
137 | /// Force crash if index does not exist ! (Manu) | |
5289cf2f | 138 | Int_t index = GetHitIndex(ix,iy); |
139 | return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy)); | |
140 | } | |
141 | //_________________________________________________ | |
85fec35d | 142 | FlagType AliMUONDigitMapA1::TestHit(Int_t ix, Int_t iy) const |
5289cf2f | 143 | { |
d19b6003 | 144 | /// Check if hit cell is empty, used or unused |
145 | ||
5289cf2f | 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 | { | |
d19b6003 | 161 | /// Protected assignement operator |
5289cf2f | 162 | |
163 | if (this == &rhs) return *this; | |
164 | ||
165 | AliFatal( "Not implemented."); | |
166 | ||
167 | return *this; | |
168 | } |