]>
Commit | Line | Data |
---|---|---|
1 | // $Id$ | |
2 | // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 | |
3 | ||
4 | /************************************************************************** | |
5 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * | |
6 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
7 | * full copyright notice. * | |
8 | **************************************************************************/ | |
9 | ||
10 | #include "AliEveITSModule.h" | |
11 | ||
12 | #include <AliITSgeomTGeo.h> | |
13 | #include <AliITSsegmentationSPD.h> | |
14 | #include <AliITSsegmentationSDD.h> | |
15 | #include <AliITSsegmentationSSD.h> | |
16 | ||
17 | #include <AliITSdigitSPD.h> | |
18 | #include <AliITSdigitSDD.h> | |
19 | #include <AliITSdigitSSD.h> | |
20 | ||
21 | #include <TStyle.h> | |
22 | ||
23 | ||
24 | //______________________________________________________________________________ | |
25 | // | |
26 | // Visualization of an ITS module. | |
27 | ||
28 | ClassImp(AliEveITSModule) | |
29 | ||
30 | Bool_t AliEveITSModule::fgStaticInitDone = kFALSE; | |
31 | ||
32 | TEveFrameBox* AliEveITSModule::fgSPDFrameBox = 0; | |
33 | TEveFrameBox* AliEveITSModule::fgSDDFrameBox = 0; | |
34 | TEveFrameBox* AliEveITSModule::fgSSDFrameBox = 0; | |
35 | ||
36 | TEveRGBAPalette* AliEveITSModule::fgSPDPalette = 0; | |
37 | TEveRGBAPalette* AliEveITSModule::fgSDDPalette = 0; | |
38 | TEveRGBAPalette* AliEveITSModule::fgSSDPalette = 0; | |
39 | ||
40 | /******************************************************************************/ | |
41 | ||
42 | AliEveITSModule::AliEveITSModule(const Text_t* n, const Text_t* t) : | |
43 | TEveQuadSet(n, t), | |
44 | fInfo(0), | |
45 | fID(-1), fDetID(-1), | |
46 | fLayer(-1), fLadder(-1), fDet(-1), | |
47 | fDx(0), fDz(0), fDy(0) | |
48 | { | |
49 | // Constructor. | |
50 | } | |
51 | ||
52 | AliEveITSModule::AliEveITSModule(Int_t gid, AliEveITSDigitsInfo* info) : | |
53 | TEveQuadSet(Form("ITS module %d", gid)), | |
54 | fInfo (0), | |
55 | fID(-1), fDetID(-1), | |
56 | fLayer(-1), fLadder(-1), fDet(-1), | |
57 | fDx(0), fDz(0), fDy(0) | |
58 | { | |
59 | // Constructor with module id and data-source. | |
60 | ||
61 | SetDigitsInfo(info); | |
62 | SetID(gid); | |
63 | } | |
64 | ||
65 | AliEveITSModule::~AliEveITSModule() | |
66 | { | |
67 | // Destructor. | |
68 | ||
69 | if(fInfo) fInfo->DecRefCount(); | |
70 | } | |
71 | ||
72 | /******************************************************************************/ | |
73 | ||
74 | void AliEveITSModule::InitStatics(AliEveITSDigitsInfo* info) | |
75 | { | |
76 | // Initialize static variables, | |
77 | ||
78 | if (fgStaticInitDone) return; | |
79 | fgStaticInitDone = kTRUE; | |
80 | ||
81 | { | |
82 | Float_t dx = info->fSegSPD->Dx()*0.00005; | |
83 | Float_t dz = 3.50; | |
84 | ||
85 | fgSPDFrameBox = new TEveFrameBox(); | |
86 | fgSPDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz); | |
87 | fgSPDFrameBox->SetFrameColor((Color_t) 31); | |
88 | fgSPDFrameBox->SetFrameFill(kTRUE); | |
89 | fgSPDFrameBox->IncRefCount(); | |
90 | fgSPDPalette = new TEveRGBAPalette(info->fSPDMinVal,info->fSPDMaxVal); | |
91 | fgSPDPalette->IncRefCount(); | |
92 | } | |
93 | ||
94 | { | |
95 | Float_t dx = info->fSegSDD->Dx()*0.0001; | |
96 | Float_t dz = info->fSegSDD->Dz()*0.00005; | |
97 | ||
98 | fgSDDFrameBox = new TEveFrameBox(); | |
99 | fgSDDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz); | |
100 | fgSDDFrameBox->SetFrameColor((Color_t) 32); | |
101 | fgSDDFrameBox->SetFrameFill(kTRUE); | |
102 | fgSDDFrameBox->IncRefCount(); | |
103 | fgSDDPalette = new TEveRGBAPalette(info->fSDDMinVal,info->fSDDMaxVal); | |
104 | fgSDDPalette->SetLimits(0, info->fSDDHighLim); // Set proper ADC range. | |
105 | fgSDDPalette->IncRefCount(); | |
106 | } | |
107 | ||
108 | { | |
109 | Float_t dx = info->fSegSSD->Dx()*0.00005; | |
110 | Float_t dz = info->fSegSSD->Dz()*0.00005; | |
111 | ||
112 | fgSSDFrameBox = new TEveFrameBox(); | |
113 | fgSSDFrameBox->SetAAQuadXZ(-dx, 0, -dz, 2*dx, 2*dz); | |
114 | fgSSDFrameBox->SetFrameColor((Color_t) 33); | |
115 | fgSSDFrameBox->SetFrameFill(kTRUE); | |
116 | fgSSDFrameBox->IncRefCount(); | |
117 | fgSSDPalette = new TEveRGBAPalette(info->fSSDMinVal,info->fSSDMaxVal); | |
118 | fgSSDPalette->SetLimits(0, info->fSSDHighLim); // Set proper ADC range. | |
119 | fgSSDPalette->IncRefCount(); | |
120 | } | |
121 | ||
122 | } | |
123 | ||
124 | /******************************************************************************/ | |
125 | ||
126 | void AliEveITSModule::SetDigitsInfo(AliEveITSDigitsInfo* info) | |
127 | { | |
128 | // Set data and geometry source. | |
129 | ||
130 | if (fInfo == info) return; | |
131 | if (fInfo) fInfo->DecRefCount(); | |
132 | fInfo = info; | |
133 | if (fInfo) fInfo->IncRefCount(); | |
134 | } | |
135 | ||
136 | /******************************************************************************/ | |
137 | ||
138 | void AliEveITSModule::SetID(Int_t gid, Bool_t trans) | |
139 | { | |
140 | // Set detector id. | |
141 | ||
142 | static const TEveException eH("AliEveITSModule::SetID "); | |
143 | ||
144 | if (fInfo == 0) | |
145 | throw(eH + "AliEveITSDigitsInfo not set."); | |
146 | ||
147 | Int_t firstSPD = AliITSgeomTGeo::GetModuleIndex(1,1,1); | |
148 | Int_t lastSSD = AliITSgeomTGeo::GetNModules() - 1; | |
149 | if (gid < firstSPD || gid > lastSSD) | |
150 | { | |
151 | throw(eH + Form("%d is not valid. ID range from %d to %d", gid, | |
152 | firstSPD, lastSSD )); | |
153 | } | |
154 | ||
155 | fID = gid; | |
156 | ||
157 | if (!fgStaticInitDone) { | |
158 | InitStatics(fInfo); | |
159 | ||
160 | fgSPDFrameBox->IncRefCount(this); | |
161 | fgSPDPalette->IncRefCount(); | |
162 | ||
163 | fgSDDFrameBox->IncRefCount(this); | |
164 | fgSDDPalette->IncRefCount(); | |
165 | ||
166 | fgSSDFrameBox->IncRefCount(this); | |
167 | fgSSDPalette->IncRefCount(); | |
168 | } | |
169 | ||
170 | AliITSgeomTGeo::GetModuleId(fID, fLayer, fLadder, fDet); | |
171 | TString strLadder = "Ladder"; | |
172 | TString strSensor = "Sensor"; | |
173 | TString symname; | |
174 | Int_t id, nsector, nstave, nladder, rest; | |
175 | ||
176 | if (fID <= (AliITSgeomTGeo::GetModuleIndex(3,1,1) - 1)) | |
177 | { | |
178 | // SPD | |
179 | ||
180 | SetFrame(fgSPDFrameBox); | |
181 | SetPalette(fgSPDPalette); | |
182 | ||
183 | symname += strLadder; | |
184 | if (fID < 80) | |
185 | { | |
186 | nsector = fID/8; | |
187 | rest = fID - 8*nsector; | |
188 | nstave = 1; | |
189 | } | |
190 | else | |
191 | { | |
192 | id = fID - 80; | |
193 | nsector = id/8; | |
194 | rest = id - 8*nsector; | |
195 | nstave = 1; | |
196 | } | |
197 | if (rest < 4) nstave = 0; | |
198 | rest -= 4*nstave; | |
199 | symname += rest; | |
200 | SetName(symname); | |
201 | fDetID = 0; | |
202 | fDx = fInfo->fSegSPD->Dx()*0.00005; | |
203 | fDz = 3.50; | |
204 | fDy = fInfo->fSegSPD->Dy()*0.00005; | |
205 | ||
206 | } | |
207 | else if (fID <= (AliITSgeomTGeo::GetModuleIndex(5,1,1) - 1)) | |
208 | { | |
209 | // SDD | |
210 | ||
211 | SetFrame(fgSDDFrameBox); | |
212 | SetPalette(fgSDDPalette); | |
213 | ||
214 | symname += strSensor; | |
215 | if (fID < 324) | |
216 | { | |
217 | id = fID - 240; | |
218 | nladder = id/6; | |
219 | rest = id - 6*nladder; | |
220 | } | |
221 | else | |
222 | { | |
223 | id = fID - 324; | |
224 | nladder = id/8; | |
225 | rest = id - 8*nladder; | |
226 | } | |
227 | symname += rest; | |
228 | SetName(symname); | |
229 | fDetID = 1; | |
230 | fDx = fInfo->fSegSDD->Dx()*0.0001; | |
231 | fDz = fInfo->fSegSDD->Dz()*0.00005; | |
232 | fDy = fInfo->fSegSDD->Dy()*0.00005; | |
233 | ||
234 | } | |
235 | else | |
236 | { | |
237 | // SSD | |
238 | ||
239 | SetFrame(fgSSDFrameBox); | |
240 | SetPalette(fgSSDPalette); | |
241 | ||
242 | symname += strSensor; | |
243 | if (fID < 1248) | |
244 | { | |
245 | id = fID - 500; | |
246 | nladder = id/22; | |
247 | rest = id - nladder*22; | |
248 | } | |
249 | else | |
250 | { | |
251 | id = fID - 1248; | |
252 | nladder = id/25; | |
253 | rest = id - nladder*25; | |
254 | } | |
255 | symname += rest; | |
256 | SetName(symname); | |
257 | fDetID = 2; | |
258 | fInfo->fSegSSD->SetLayer(fLayer); | |
259 | fDx = fInfo->fSegSSD->Dx()*0.00005; | |
260 | fDz = fInfo->fSegSSD->Dz()*0.00005; | |
261 | fDy = fInfo->fSegSSD->Dy()*0.00005; | |
262 | ||
263 | } | |
264 | ||
265 | LoadQuads(); | |
266 | ComputeBBox(); | |
267 | if (trans) | |
268 | SetTrans(); | |
269 | } | |
270 | ||
271 | void AliEveITSModule::LoadQuads() | |
272 | { | |
273 | // Read module data from source and create low-level objects for | |
274 | // visualization - called quads. | |
275 | ||
276 | TClonesArray *digits = fInfo->GetDigits(fID, fDetID); | |
277 | Int_t ndigits = digits ? digits->GetEntriesFast() : 0; | |
278 | ||
279 | Float_t x, z, dpx, dpz; | |
280 | Int_t i, j; | |
281 | ||
282 | switch(fDetID) | |
283 | { | |
284 | ||
285 | case 0: { // SPD | |
286 | AliITSsegmentationSPD* seg = fInfo->fSegSPD; | |
287 | ||
288 | Reset(kQT_RectangleXZFixedY, kFALSE, 32); | |
289 | ||
290 | for (Int_t k=0; k<ndigits; ++k) | |
291 | { | |
292 | AliITSdigit *d = (AliITSdigit*) digits->UncheckedAt(k); | |
293 | j = d->GetCoord1(); | |
294 | i = d->GetCoord2(); | |
295 | x = -0.5*seg->Dx() + i*seg->Dpx(0); | |
296 | x *= 0.0001; | |
297 | fInfo->GetSPDLocalZ(j, z); | |
298 | dpx = seg->Dpx(i)*0.0001; | |
299 | dpz = seg->Dpz(j)*0.0001; | |
300 | ||
301 | AddQuad(x, z, dpx, dpz); | |
302 | QuadValue(1); // In principle could have color based on number of neigbours | |
303 | QuadId(d); | |
304 | } | |
305 | break; | |
306 | } | |
307 | ||
308 | case 1: { // SDD | |
309 | AliITSsegmentationSDD *seg = fInfo->fSegSDD; | |
310 | ||
311 | Reset(kQT_RectangleXZFixedY, kFALSE, 32); | |
312 | ||
313 | for (Int_t k=0; k<ndigits; ++k) | |
314 | { | |
315 | AliITSdigit* d = (AliITSdigit*) digits->UncheckedAt(k); | |
316 | ||
317 | // if (d->GetSignal() > fgSDDThreshold) | |
318 | { | |
319 | j = d->GetCoord1(); | |
320 | i = d->GetCoord2(); | |
321 | seg->DetToLocal(i, j, x, z); | |
322 | dpx = seg->Dpx(i)*0.0001; | |
323 | dpz = seg->Dpz(j)*0.0001; | |
324 | ||
325 | AddQuad(x-2*dpx, z - dpz*0.5, 4*dpx, dpz); | |
326 | QuadValue(d->GetSignal()); | |
327 | QuadId(d); | |
328 | } | |
329 | } | |
330 | break; | |
331 | } | |
332 | ||
333 | case 2: { // SSD | |
334 | AliITSsegmentationSSD* seg = fInfo->fSegSSD; | |
335 | ||
336 | Reset(kQT_LineXZFixedY, kFALSE, 32); | |
337 | ||
338 | Float_t ap, an; // positive/negative angles -> offsets | |
339 | seg->Angles(ap, an); | |
340 | ap = TMath::Tan(ap) * fDz; | |
341 | an = - TMath::Tan(an) * fDz; | |
342 | ||
343 | for (Int_t k=0; k<ndigits; ++k) | |
344 | { | |
345 | AliITSdigit *d = (AliITSdigit*) digits->UncheckedAt(k); | |
346 | // if(d->GetSignal() > fgSSDThreshold) | |
347 | { | |
348 | j = d->GetCoord1(); | |
349 | i = d->GetCoord2(); | |
350 | seg->DetToLocal(i,j,x,z); | |
351 | ||
352 | Float_t a = ( d->GetCoord1() == 1) ? ap : an; | |
353 | ||
354 | AddLine(x-a, -fDz, 2*a, 2*fDz); | |
355 | QuadValue(d->GetSignal()); | |
356 | QuadId(d); | |
357 | // printf("%3d -> %3d -> %8x\n", d->GetSignal(), ci, fQuads.back().color); | |
358 | } | |
359 | } | |
360 | break; | |
361 | } | |
362 | ||
363 | } // end switch | |
364 | ||
365 | RefitPlex(); | |
366 | } | |
367 | ||
368 | /******************************************************************************/ | |
369 | ||
370 | void AliEveITSModule::SetTrans() | |
371 | { | |
372 | // Set transformation matrix based on module id (use geometry to | |
373 | // retrieve this information). | |
374 | ||
375 | fHMTrans.SetFrom(*AliITSgeomTGeo::GetMatrix(fID)); | |
376 | } | |
377 | ||
378 | /******************************************************************************/ | |
379 | ||
380 | void AliEveITSModule::DigitSelected(Int_t idx) | |
381 | { | |
382 | // Override secondary select (alt-click) from TEveQuadSet. | |
383 | ||
384 | DigitBase_t *qb = GetDigit(idx); | |
385 | TObject *obj = qb->fId.GetObject(); | |
386 | AliITSdigit *d = dynamic_cast<AliITSdigit*>(obj); | |
387 | printf("AliEveITSModule::QuadSelected "); Print(); | |
388 | printf(" idx=%d, value=%d, obj=0x%lx, digit=0x%lx\n", | |
389 | idx, qb->fValue, (ULong_t)obj, (ULong_t)d); | |
390 | if (d) | |
391 | printf(" coord1=%3d coord2=%3d signal=%d\n", | |
392 | d->GetCoord1(), d->GetCoord2(), d->GetSignal()); | |
393 | ||
394 | } | |
395 | ||
396 | /******************************************************************************/ | |
397 | ||
398 | void AliEveITSModule::Print(Option_t* ) const | |
399 | { | |
400 | // Print object summary information. | |
401 | ||
402 | printf("AliEveITSModule: ID %d, layer %d, ladder %d, det %d\n", | |
403 | fID, fLayer, fLadder, fDetID); | |
404 | } |