]>
Commit | Line | Data |
---|---|---|
e8189707 | 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 | **************************************************************************/ | |
766e3066 | 15 | #include <TObjArray.h> |
e8189707 | 16 | #include "AliITSMapA1.h" |
17 | #include "AliITSsegmentation.h" | |
e8189707 | 18 | #include "AliITSdigit.h" |
19 | ||
766e3066 | 20 | //////////////////////////////////////////////////////////////////////// |
21 | // Map Class for ITS. Implementation A1. In this implementation, the // | |
22 | // 2 dimensional (iz,ix) map is filled with integers values. For each // | |
23 | // cell a corresponding TObject, a hit, can also be stored. // | |
24 | // The detector geometry is accessed via the that detectors // | |
25 | // segmentation class and stored here for conveniance. // | |
26 | //////////////////////////////////////////////////////////////////////// | |
e8189707 | 27 | |
28 | ClassImp(AliITSMapA1) | |
766e3066 | 29 | //______________________________________________________________________ |
30 | AliITSMapA1::AliITSMapA1(){ | |
31 | // default constructor | |
32 | ||
33 | fSegmentation = 0; | |
34 | fNpz = 0; | |
35 | fNpx = 0; | |
36 | fMaxIndex = 0; | |
37 | fHitMap = 0; | |
38 | fObjects = 0; | |
39 | fNobjects = 0; | |
40 | fMapThreshold = 0; | |
f45f6658 | 41 | fMapThresholdArr = 0; |
766e3066 | 42 | } |
43 | //______________________________________________________________________ | |
44 | AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg){ | |
45 | //constructor | |
46 | ||
47 | fSegmentation = seg; | |
48 | fNpz = fSegmentation->Npz(); | |
49 | fNpx = fSegmentation->Npx(); | |
50 | fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector | |
51 | fHitMap = new Int_t[fMaxIndex]; | |
52 | fObjects = 0; | |
53 | fNobjects = 0; | |
54 | fMapThreshold = 0; | |
f45f6658 | 55 | fMapThresholdArr = 0; |
766e3066 | 56 | ClearMap(); |
57 | } | |
58 | //______________________________________________________________________ | |
59 | AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj){ | |
60 | //constructor | |
61 | ||
62 | fNobjects = 0; | |
63 | fSegmentation = seg; | |
64 | fNpz = fSegmentation->Npz(); | |
65 | fNpx = fSegmentation->Npx(); | |
66 | fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector | |
67 | fHitMap = new Int_t[fMaxIndex]; | |
68 | fObjects = obj; | |
69 | if(fObjects) fNobjects = fObjects->GetEntriesFast(); | |
70 | fMapThreshold = 0; | |
f45f6658 | 71 | fMapThresholdArr = 0; |
766e3066 | 72 | ClearMap(); |
73 | } | |
74 | //______________________________________________________________________ | |
75 | AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj, Int_t thr){ | |
76 | //constructor | |
77 | ||
78 | fNobjects = 0; | |
79 | fSegmentation = seg; | |
80 | fNpz = fSegmentation->Npz(); | |
81 | fNpx = fSegmentation->Npx(); | |
82 | fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector | |
83 | fHitMap = new Int_t[fMaxIndex]; | |
84 | fObjects = obj; | |
85 | if(fObjects) fNobjects = fObjects->GetEntriesFast(); | |
86 | fMapThreshold = thr; | |
87 | ClearMap(); | |
88 | } | |
f45f6658 | 89 | //______________________________________________________________________ |
90 | AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj, TArrayI thr){ | |
91 | //constructor | |
92 | ||
93 | fNobjects = 0; | |
94 | fSegmentation = seg; | |
95 | fNpz = fSegmentation->Npz(); | |
96 | fNpx = fSegmentation->Npx(); | |
97 | fMaxIndex = fNpz*fNpx+fNpx; // 2 halves of detector | |
98 | fHitMap = new Int_t[fMaxIndex]; | |
99 | fObjects = obj; | |
100 | if(fObjects) fNobjects = fObjects->GetEntriesFast(); | |
101 | fMapThreshold = 0; | |
102 | fMapThresholdArr = thr; | |
103 | ClearMap(); | |
104 | } | |
105 | ||
766e3066 | 106 | //______________________________________________________________________ |
107 | AliITSMapA1::~AliITSMapA1(){ | |
108 | //destructor | |
109 | ||
110 | if(fHitMap) delete[] fHitMap; | |
e8189707 | 111 | } |
e8189707 | 112 | //_________________________________________________________________________ |
766e3066 | 113 | AliITSMapA1& AliITSMapA1::operator=(const AliITSMapA1 &source) { |
114 | // Assignment operator | |
e8189707 | 115 | |
766e3066 | 116 | if(&source == this) return *this; |
117 | ||
118 | this->fNpx = source.fNpx; | |
119 | this->fNpz = source.fNpz; | |
120 | this->fObjects = source.fObjects; | |
121 | this->fNobjects = source.fNobjects; | |
122 | this->fMaxIndex = source.fMaxIndex; | |
123 | this->fHitMap = source.fHitMap; | |
124 | this->fMapThreshold = source.fMapThreshold; | |
f45f6658 | 125 | this->fMapThresholdArr = source.fMapThresholdArr; |
766e3066 | 126 | return *this; |
e8189707 | 127 | } |
766e3066 | 128 | //______________________________________________________________________ |
ac74f489 | 129 | AliITSMapA1::AliITSMapA1(const AliITSMapA1 &source) : AliITSMap(source){ |
766e3066 | 130 | // Copy Constructor |
131 | ||
132 | *this = source; | |
e8189707 | 133 | } |
766e3066 | 134 | //______________________________________________________________________ |
135 | void AliITSMapA1::ClearMap(){ | |
136 | //clear array | |
e8189707 | 137 | |
766e3066 | 138 | memset(fHitMap,0,sizeof(int)*fMaxIndex); |
139 | } | |
140 | //______________________________________________________________________ | |
141 | void AliITSMapA1::SetArray(TObjArray *obj){ | |
142 | // set array of objects | |
e8189707 | 143 | |
766e3066 | 144 | fObjects = obj; |
145 | if (fObjects) fNobjects = fObjects->GetEntriesFast(); | |
e8189707 | 146 | } |
766e3066 | 147 | //______________________________________________________________________ |
fb4e90e0 | 148 | Int_t AliITSMapA1::CheckedIndex(Int_t iz, Int_t ix) const { |
766e3066 | 149 | //check boundaries and return an index in array |
150 | Int_t index=fNpx*iz+ix; | |
e8189707 | 151 | |
766e3066 | 152 | //if (index > fMaxIndex) { |
153 | if (index > fMaxIndex || index < 0) { | |
154 | printf("\n \n \n Try to read/write outside array !!!!" | |
155 | " \n \n %d %d %d %d %d %d \n",iz,ix,fMaxIndex,index,fNpz,fNpx); | |
156 | // force crash | |
157 | return -1; | |
158 | } else { | |
159 | return index; | |
160 | } // end if index>max or < 0 | |
161 | } | |
162 | //______________________________________________________________________ | |
163 | void AliITSMapA1::FillMap(){ | |
164 | // fill array with digits indices | |
e8189707 | 165 | |
766e3066 | 166 | Int_t ndigits = fObjects->GetEntriesFast(); |
167 | if (!ndigits) return; | |
96f414e9 | 168 | |
766e3066 | 169 | AliITSdigit *dig; |
170 | for (Int_t ndig=0; ndig<ndigits; ndig++) { | |
171 | dig = (AliITSdigit*)fObjects->UncheckedAt(ndig); | |
ecee53fc | 172 | if(dig->GetSignal() > fMapThreshold) { |
173 | SetHit(dig->GetCoord1(),dig->GetCoord2(),ndig); | |
766e3066 | 174 | } // end if fSignal > fMapthreshold |
175 | } // end for ndig | |
e8189707 | 176 | } |
f45f6658 | 177 | //______________________________________________________________________ |
178 | void AliITSMapA1::FillMap2(){ | |
179 | // fill array with digits indices | |
180 | ||
181 | Int_t ndigits = fObjects->GetEntriesFast(); | |
182 | if (!ndigits) return; | |
183 | ||
184 | AliITSdigit *dig; | |
185 | for (Int_t ndig=0; ndig<ndigits; ndig++) { | |
186 | dig = (AliITSdigit*)fObjects->UncheckedAt(ndig); | |
187 | if(dig->GetSignal() > fMapThresholdArr[dig->GetCoord1()]) { | |
188 | SetHit(dig->GetCoord1(),dig->GetCoord2(),ndig); | |
189 | } // end if fSignal > fMapthreshold | |
190 | } // end for ndig | |
191 | } | |
192 | ||
766e3066 | 193 | //______________________________________________________________________ |
194 | void AliITSMapA1::SetHit(Int_t iz, Int_t ix, Int_t idigit){ | |
195 | // set the digit index at a certain position in array | |
e8189707 | 196 | |
766e3066 | 197 | fHitMap[CheckedIndex(iz, ix)]=idigit+1; |
e8189707 | 198 | } |
766e3066 | 199 | //______________________________________________________________________ |
200 | void AliITSMapA1::DeleteHit(Int_t iz, Int_t ix){ | |
201 | // delete an entry in array | |
e8189707 | 202 | |
766e3066 | 203 | fHitMap[CheckedIndex(iz, ix)]=0; |
e8189707 | 204 | } |
766e3066 | 205 | //______________________________________________________________________ |
206 | void AliITSMapA1::FlagHit(Int_t iz, Int_t ix){ | |
207 | // flag an entry in array | |
e8189707 | 208 | |
766e3066 | 209 | fHitMap[CheckedIndex(iz, ix)] = -TMath::Abs(fHitMap[CheckedIndex(iz, ix)]); |
e8189707 | 210 | } |
766e3066 | 211 | //______________________________________________________________________ |
fb4e90e0 | 212 | Int_t AliITSMapA1::GetHitIndex(Int_t iz, Int_t ix) const { |
766e3066 | 213 | // return the digit index from a specific entry in array |
e8189707 | 214 | |
766e3066 | 215 | return TMath::Abs(fHitMap[CheckedIndex(iz, ix)])-1; |
e8189707 | 216 | } |
766e3066 | 217 | //______________________________________________________________________ |
590d15ee | 218 | TObject* AliITSMapA1::GetHit(Int_t iz, Int_t ix) const { |
766e3066 | 219 | // return the pointer to the digit |
e8189707 | 220 | |
766e3066 | 221 | Int_t index=GetHitIndex(iz,ix); |
222 | // Force crash if index does not exist ! | |
223 | return (index <0) ? 0 : fObjects->UncheckedAt(GetHitIndex(iz,ix)); | |
e8189707 | 224 | } |
766e3066 | 225 | //______________________________________________________________________ |
590d15ee | 226 | Double_t AliITSMapA1::GetSignal(Int_t iz, Int_t ix) const{ |
766e3066 | 227 | // get a pad signal |
228 | Double_t signal; | |
e8189707 | 229 | |
766e3066 | 230 | AliITSdigit *dig = (AliITSdigit*)GetHit(iz,ix); |
ecee53fc | 231 | if(dig) signal=(Double_t)dig->GetSignal(); |
766e3066 | 232 | else signal=0.; |
233 | return signal; | |
e8189707 | 234 | } |
766e3066 | 235 | //______________________________________________________________________ |
590d15ee | 236 | FlagType AliITSMapA1::TestHit(Int_t iz, Int_t ix) { |
766e3066 | 237 | // check whether the digit has already been flagged |
e8189707 | 238 | |
766e3066 | 239 | if (CheckedIndex(iz, ix) < 0) return kEmpty; |
240 | Int_t inf=fHitMap[CheckedIndex(iz, ix)]; | |
241 | if (inf < 0) { | |
242 | return kUsed; | |
243 | } else if (inf == 0) { | |
244 | return kEmpty; | |
245 | } else { | |
246 | return kUnused; | |
247 | } // end if inf | |
e8189707 | 248 | } |
766e3066 | 249 |