]>
Commit | Line | Data |
---|---|---|
3b868b75 | 1 | // $Header$ |
2 | ||
3 | #include "ITSScaledModule.h" | |
4 | ||
5 | #include <AliITSdigitSPD.h> | |
6 | #include <AliITSdigitSDD.h> | |
7 | #include <AliITSdigitSSD.h> | |
8 | ||
9 | using namespace Reve; | |
10 | using namespace Alieve; | |
11 | ||
3b868b75 | 12 | //______________________________________________________________________ |
13 | // DigitScaleInfo | |
14 | // | |
15 | ClassImp(DigitScaleInfo) | |
16 | ||
17 | DigitScaleInfo::DigitScaleInfo(): | |
18 | fScale(1), | |
19 | fStatType (ST_Average), | |
20 | fAutoUpdatePalette(kTRUE) | |
21 | { | |
22 | } | |
23 | ||
24 | void DigitScaleInfo::ScaleChanged(Int_t s) | |
25 | { | |
26 | fScale = s; | |
27 | Emit("ScaleChanged(Int_t)",fScale); | |
28 | } | |
29 | ||
30 | void DigitScaleInfo::StatTypeChanged(Int_t t) | |
31 | { | |
32 | fStatType = t; | |
33 | Emit("StatTypeChanged(Int_t)",fStatType); | |
34 | } | |
35 | ||
36 | //______________________________________________________________________ | |
37 | // DigitScaleInfo | |
38 | // | |
39 | ScaledDigit::ScaledDigit(): | |
40 | TObject(), | |
41 | N(0), | |
42 | sum(0), sqr_sum(0), | |
43 | min_i(-1), min_j(-1), max_i(-1), max_j(-1) | |
44 | { | |
45 | } | |
46 | ||
47 | ScaledDigit::ScaledDigit(Int_t di, Int_t dj): | |
48 | TObject(), | |
49 | N(0), | |
50 | sum(0), sqr_sum(0), | |
51 | min_i(di), min_j(dj), max_i(di), max_j(dj) | |
52 | { | |
53 | } | |
54 | ||
55 | void ScaledDigit::Dump() const | |
56 | { | |
57 | printf("N %d, sum %f, sqr_sum %f",N, sum, sqr_sum); | |
58 | } | |
59 | ||
60 | //______________________________________________________________________ | |
61 | // ITSScaledModule | |
62 | // | |
63 | ||
64 | ClassImp(ITSScaledModule) | |
65 | ||
03dfc4a7 | 66 | ITSScaledModule::ITSScaledModule(Int_t gid, ITSDigitsInfo* info, DigitScaleInfo* si): |
3b868b75 | 67 | ITSModule("ITSScaledModule", "ITSScaledModule"), |
68 | fNx(-1), | |
69 | fNz(-1), | |
70 | fNCx(-1), | |
03dfc4a7 | 71 | fNCz(-1), |
72 | fScaleInfo(si) | |
3b868b75 | 73 | { |
03dfc4a7 | 74 | si->IncRefCount(this); |
75 | si->Connect("ScaleChanged(Int_t)", "Alieve::ITSScaledModule", this,"LoadQuads()"); | |
76 | si->Connect("StatTypeChanged(Int_t)", "Alieve::ITSScaledModule", this,"SetQuadValues()"); | |
3b868b75 | 77 | SetOwnIds(kTRUE); |
78 | ||
79 | SetDigitsInfo(info); | |
80 | SetID(gid); | |
81 | } | |
82 | ||
83 | ITSScaledModule::~ITSScaledModule() | |
84 | { | |
03dfc4a7 | 85 | fScaleInfo->DecRefCount(); |
3b868b75 | 86 | } |
87 | ||
88 | /**************************************************************************/ | |
89 | ||
90 | void ITSScaledModule::LoadQuads() | |
91 | { | |
92 | // Here we still use 'z' for the name of axial coordinates. | |
93 | // The transforamtion matrix aplied rotates y -> z. | |
94 | // We need this as QuadSet offers optimized treatment for | |
95 | // quads in the x-y plane. | |
96 | ||
97 | TClonesArray *digits; | |
98 | Float_t x, z, zo, dpx, dpz; // orig cells size, pos | |
99 | Int_t i, j, ndigits; // orig cells idx | |
100 | Int_t c1, c2; // original coordinates | |
101 | ||
102 | Int_t id; | |
103 | map<Int_t, Int_t> dmap; | |
104 | map<Int_t, Int_t>::iterator miter; | |
105 | digits = fInfo->GetDigits(fID, fDetID); | |
106 | ndigits = digits->GetEntriesFast(); | |
107 | ||
108 | ScaledDigit* sd; | |
03dfc4a7 | 109 | Int_t scale = fScaleInfo->GetScale() -1; |
3b868b75 | 110 | switch(fDetID) |
111 | { | |
112 | case 0: | |
113 | { | |
114 | // SPD | |
115 | Reset(QT_RectangleXZFixedY, kFALSE, 32); | |
116 | ||
117 | fNCz = fInfo->fSPDScaleZ[scale]; | |
118 | fNCx = fInfo->fSPDScaleX[scale]; | |
119 | fNz = Int_t(fInfo->fSegSPD->Npz()/fNCz); | |
120 | fNx = Int_t(fInfo->fSegSPD->Npx()/fNCx); | |
121 | dpz = 2*fDz/fNz; | |
122 | dpx = 2*fDx/fNx; | |
123 | //printf("SPD orig cells (%d, %d) (%d, %d)\n", fInfo->fSegSPD->Npx(), fInfo->fSegSPD->Npz(), Nx, Nz); | |
124 | ||
125 | AliITSdigitSPD *od ; | |
126 | for (Int_t k=0; k<ndigits; ++k) | |
127 | { | |
128 | od = (AliITSdigitSPD*) digits->UncheckedAt(k); | |
129 | ||
130 | fInfo->GetSPDLocalZ(od->GetCoord1(),zo); | |
131 | c1 = od->GetCoord1(); c2 = od->GetCoord2(); | |
132 | i = Int_t((zo+fDz)/dpz); | |
133 | j = Int_t((od->GetCoord2()*fNx)/fInfo->fSegSPD->Npx()); | |
134 | id = j*fNx + i; | |
135 | ||
136 | miter = dmap.find(id); | |
137 | if(miter == dmap.end()) | |
138 | { | |
139 | dmap[id] = fPlex.Size(); | |
140 | z = dpz*(i) - fDz; | |
141 | x = dpx*(j) - fDx; | |
142 | AddQuad(x, z, dpx, dpz); | |
143 | sd = new ScaledDigit(c1, c2); | |
144 | QuadId(sd); | |
145 | } | |
146 | else | |
147 | { | |
148 | sd = dynamic_cast<ScaledDigit*>(GetId(miter->second)); | |
149 | if(c1 < sd->min_i) | |
150 | sd->min_i = c1; | |
151 | else if( c1 > sd->max_i) | |
152 | sd->max_i = c1; | |
153 | ||
154 | if(c2 < sd->min_j) | |
155 | sd->min_j = c2; | |
156 | else if( c2 > sd->max_j) | |
157 | sd->max_j = c2; | |
158 | } | |
159 | ||
160 | sd->N++; | |
161 | sd->sum += od->GetSignal(); | |
162 | sd->sqr_sum += od->GetSignal()*od->GetSignal(); | |
163 | } | |
164 | break; | |
165 | } | |
166 | case 1: | |
167 | { | |
168 | // SDD | |
169 | Reset(QT_RectangleXZFixedY, kFALSE, 32); | |
170 | ||
171 | fNCz = fInfo->fSDDScaleZ[scale]; | |
172 | fNCx = fInfo->fSDDScaleX[scale]; | |
173 | fNz = Int_t(fInfo->fSegSDD->Npz()/fNCz); | |
174 | fNx = Int_t(fInfo->fSegSDD->Npx()/fNCx); | |
175 | dpz = 2*fDz/fNz; | |
176 | dpx = 2*fDx/fNx; | |
177 | ||
178 | AliITSdigitSDD *od=0; | |
179 | for (Int_t k=0; k<ndigits; k++) { | |
180 | od=(AliITSdigitSDD*)digits->UncheckedAt(k); | |
181 | fInfo->fSegSDD->DetToLocal(od->GetCoord2(), od->GetCoord1(),x,z); | |
182 | z+= fDz; | |
183 | x+= fDx; | |
184 | i = Int_t(z/dpz); | |
185 | j = Int_t(x/dpx); | |
186 | //printf("Mod %d coord %d,%d out of %d,%d :: ORIG coord %d,%d out of %d,%d \n",fID, | |
187 | // i,j,Nz,Nx,od->GetCoord1(),od->GetCoord2(),fInfo->fSegSDD->Npz(),fInfo->fSegSDD->Npx()); | |
188 | ||
189 | id = j*fNx + i; | |
190 | c1 = od->GetCoord1(); c2 = od->GetCoord2(); | |
191 | ||
192 | miter = dmap.find(id); | |
193 | if(miter == dmap.end()) | |
194 | { | |
195 | dmap[id] = fPlex.Size(); | |
196 | z = dpz*(i) - fDz; | |
197 | x = dpx*(j) - fDx; | |
198 | AddQuad(x, z, dpx, dpz); | |
199 | sd = new ScaledDigit(od->GetCoord1(),od->GetCoord2()); | |
200 | QuadId(sd); | |
201 | } | |
202 | else | |
203 | { | |
204 | sd = dynamic_cast<ScaledDigit*>(GetId(miter->second)); | |
205 | if(c1 < sd->min_i) | |
206 | sd->min_i = c1; | |
207 | else if( c1 > sd->max_i) | |
208 | sd->max_i = c1; | |
209 | ||
210 | if(c2 < sd->min_j) | |
211 | sd->min_j = c2; | |
212 | else if( c2 > sd->max_j) | |
213 | sd->max_j = c2; | |
214 | } | |
215 | sd->N++; | |
216 | sd->sum += od->GetSignal(); | |
217 | sd->sqr_sum += od->GetSignal()*od->GetSignal(); | |
218 | } | |
219 | break; | |
220 | } | |
221 | case 2: | |
222 | { | |
223 | // SSD | |
224 | Reset(QT_LineXZFixedY, kFALSE, 32); | |
225 | ||
226 | AliITSsegmentationSSD* seg = fInfo->fSegSSD; | |
227 | Float_t ap, an; // positive/negative angles -> offsets | |
228 | seg->Angles(ap, an); | |
229 | ap = TMath::Tan(ap) * fDz; | |
230 | an = - TMath::Tan(an) * fDz; | |
231 | ||
232 | fNCx = fInfo->fSSDScale[scale]; | |
233 | fNz = 1; | |
234 | fNx = Int_t(fInfo->fSegSSD->Npx()/fNCx); | |
235 | dpz = 2*fDz/fNz; | |
236 | dpx = 2*fDx/fNx; | |
237 | ||
238 | AliITSdigitSSD *od=0; | |
239 | for (Int_t k=0; k<ndigits; k++) { | |
240 | od=(AliITSdigitSSD*)digits->UncheckedAt(k); | |
241 | if(od->GetCoord1() == 1) | |
242 | i = 1; // p side | |
243 | else | |
244 | i= -1; // n side | |
245 | j = Int_t(od->GetCoord2()/fNCx); | |
246 | c1 = od->GetCoord1(); c2 = od->GetCoord2(); | |
247 | id = j*i; | |
248 | ||
249 | miter = dmap.find(id); | |
250 | ScaledDigit* sd; | |
251 | if(miter == dmap.end()) | |
252 | { | |
253 | // printf("orig digit %d,%d scaled %d,%d \n",od->GetCoord1(),od->GetCoord2(),i,j); | |
254 | dmap[id] = fPlex.Size(); | |
255 | z = dpz*(i) - fDz; | |
256 | x = dpx*(j) - fDx; | |
257 | Float_t a = ( od->GetCoord1() == 1) ? ap : an; | |
258 | AddLine(x-a, -fDz, 2*a, 2*fDz); | |
259 | ||
260 | sd = new ScaledDigit(c1, c2); | |
261 | QuadId(sd); | |
262 | } | |
263 | else | |
264 | { | |
265 | sd = dynamic_cast<ScaledDigit*>(GetId(miter->second)); | |
266 | if(c1 < sd->min_i) | |
267 | sd->min_i = c1; | |
268 | else if( c1 > sd->max_i) | |
269 | sd->max_i = c1; | |
270 | ||
271 | if(c2 < sd->min_j) | |
272 | sd->min_j = c2; | |
273 | else if( c2 > sd->max_j) | |
274 | sd->max_j = c2; | |
275 | } | |
276 | sd->N++; | |
277 | sd->sum += od->GetSignal(); | |
278 | sd->sqr_sum += od->GetSignal()*od->GetSignal(); | |
279 | } // for digits | |
280 | break; | |
281 | } // end case 2 | |
282 | } // end switch | |
283 | ||
284 | SetQuadValues(); | |
285 | RefitPlex(); | |
286 | } | |
287 | ||
288 | /**************************************************************************/ | |
289 | ||
290 | void ITSScaledModule::SetQuadValues() | |
291 | { | |
292 | Int_t N = fPlex.Size(); | |
293 | for (Int_t i = 0 ; i< N; i++) | |
294 | { | |
295 | ScaledDigit* sd = dynamic_cast<ScaledDigit*>(GetId(i)); | |
296 | Int_t v = 0; | |
03dfc4a7 | 297 | switch(fScaleInfo->GetStatType()) { |
3b868b75 | 298 | case DigitScaleInfo::ST_Occup: v = sd->N; break; |
299 | case DigitScaleInfo::ST_Average: v = Int_t(sd->sum/(1.* sd->N)); break; | |
300 | case DigitScaleInfo::ST_Rms: v = Int_t(TMath::Sqrt(sd->sqr_sum)/(1.*sd->N)); break; | |
301 | } | |
302 | QuadBase* qb = GetQuad(i); | |
303 | qb->fValue = v; | |
304 | } | |
305 | } | |
306 | ||
307 | /**************************************************************************/ | |
308 | ||
309 | void ITSScaledModule::QuadSelected(Int_t idx) | |
310 | { | |
311 | // Override control-click from QuadSet | |
312 | printf("ITSScaledModule::QuadSelected "); Print(); | |
313 | ||
314 | QuadBase* qb = GetQuad(idx); | |
315 | TObject* obj = qb->fId.GetObject(); | |
316 | ScaledDigit* sd = dynamic_cast<ScaledDigit*>(obj); | |
317 | TClonesArray *digits = fInfo->GetDigits(fID, fDetID); | |
318 | Int_t ndigits = digits->GetEntriesFast(); | |
319 | ||
320 | printf("%d digits in cell scaleX = %d, scaleZ = %d \n", sd->N, fNCx, fNCz); | |
321 | ||
322 | Int_t il = 0; | |
323 | for(Int_t k=0; k<ndigits; k++) | |
324 | { | |
325 | AliITSdigit *d = (AliITSdigit*) digits->UncheckedAt(k); | |
326 | ||
327 | if(d->GetCoord1()>=sd->min_i && d->GetCoord1()<=sd->max_i && | |
328 | d->GetCoord2()>=sd->min_j && d->GetCoord2()<=sd->max_j) | |
329 | { | |
330 | printf("%3d, %3d: %3d", d->GetCoord1(), d->GetCoord2(), d->GetSignal()); | |
331 | printf(" | "); | |
332 | il++; | |
333 | if(il>5) { | |
334 | printf("\n"); | |
335 | il = 0; | |
336 | } | |
337 | } | |
338 | } | |
339 | if(il) printf("\n"); | |
340 | } |