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