]>
Commit | Line | Data |
---|---|---|
4c039060 | 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 | /* | |
17 | $Log$ | |
084c1b4a | 18 | Revision 1.5 1999/09/29 09:24:29 fca |
19 | Introduction of the Copyright and cvs Log | |
20 | ||
4c039060 | 21 | */ |
22 | ||
ddae0931 | 23 | |
24 | ////////////////////////////////////////////////////////////////////////// | |
25 | // // | |
26 | // AliDisplay // | |
27 | // // | |
28 | // Utility class to display ALICE outline, tracks, hits,.. // | |
29 | // // | |
30 | ////////////////////////////////////////////////////////////////////////// | |
31 | ||
32 | #include <TROOT.h> | |
33 | #include <TTree.h> | |
34 | #include <TButton.h> | |
35 | #include <TColor.h> | |
36 | #include <TCanvas.h> | |
37 | #include <TView.h> | |
38 | #include <TText.h> | |
39 | #include <TPolyMarker3D.h> | |
40 | #include <TPolyMarker.h> | |
41 | #include <TPaveLabel.h> | |
42 | #include <TPaveText.h> | |
43 | #include <TList.h> | |
44 | #include <TDiamond.h> | |
45 | #include <TNode.h> | |
46 | #include <TArc.h> | |
47 | #include <TTUBE.h> | |
48 | #include <TSlider.h> | |
49 | #include <TSliderBox.h> | |
50 | #include <TGaxis.h> | |
084c1b4a | 51 | #include <TVirtualX.h> |
ddae0931 | 52 | #include <TMath.h> |
53 | #include <X3DBuffer.h> | |
54 | ||
55 | #include "AliRun.h" | |
56 | #include "AliDetector.h" | |
57 | #include "AliRICH.h" | |
58 | #include "AliRICHConst.h" | |
59 | #include "AliRICHdisplay.h" | |
60 | #include "AliRICHpoints.h" | |
61 | #include "TParticle.h" | |
62 | ||
63 | ||
64 | ClassImp(AliRICHdisplay) | |
65 | ||
66 | ||
67 | //____________________________________________________________________________ | |
68 | AliRICHdisplay::AliRICHdisplay() | |
69 | { | |
70 | fPoints = 0; | |
71 | fPhits = 0; | |
72 | fPCerenkovs = 0; | |
73 | fCanvas = 0; | |
74 | } | |
75 | ||
76 | //_____________________________________________________________________________ | |
77 | AliRICHdisplay::AliRICHdisplay(Int_t size) | |
78 | { | |
79 | // Create an event display object. | |
80 | // A canvas named "edisplay" is created with a vertical size in pixels | |
81 | // | |
82 | // A QUICK Overview of the Event Display functions | |
83 | // =============================================== | |
84 | // | |
85 | // The event display can ve invoked by executing the macro "display.C" | |
86 | // A canvas like in the picture below will appear. | |
87 | // | |
88 | // On the left side of the canvas, the following buttons appear: | |
89 | // *Next* to move to the next event | |
90 | // *Previous* to move to the previous event | |
91 | ||
92 | // *Pick* Select this option to be able to point on a track with the | |
93 | // mouse. Once on the track, use the right button to select | |
94 | // an action. For example, select SetMarkerAttributes to | |
95 | // change the marker type/color/size for the track. | |
96 | // *Zoom* Select this option (default) if you want to zoom. | |
97 | // To zoom, simply select the selected area with the left button. | |
98 | // *UnZoom* To revert to the previous picture size. | |
99 | // | |
100 | // slider R On the left side, the vertical slider can be used to | |
101 | // set the default picture size. | |
102 | // | |
103 | // When you are in Zoom mode, you can click on the black part of the canvas | |
104 | // to select special options with the right mouse button. | |
105 | ||
106 | // | |
107 | // When you are in pick mode, you can "Inspect" the object pointed by the mouse. | |
108 | // When you are on a track, select the menu item "InspectParticle" | |
109 | // to display the current particle attributes. | |
110 | // | |
111 | // You can activate the Root browser by selecting the Inspect menu | |
112 | // in the canvas tool bar menu. Then select "Start Browser" | |
113 | // This will open a new canvas with the browser. At this point, you may want | |
114 | // to display some histograms (from the Trees). Go to the "File" menu | |
115 | // of the browser and click on "New canvas". | |
116 | // In the browser, click on item "ROOT files" in the left pane. | |
117 | // Click on galice.root. | |
118 | // Click on TH | |
119 | // Click on TPC for example | |
120 | // Click on any variable (eg TPC.fX) to histogram the variable. | |
121 | // | |
122 | // If you are lost, you can click on HELP in any Root canvas or browser. | |
123 | //Begin_Html | |
124 | /* | |
125 | <img src="gif/aliRICHdisplay.gif"> | |
126 | */ | |
127 | //End_Html | |
128 | ||
129 | ||
130 | fPad = 0; | |
131 | ||
132 | gAlice->SetDisplay(this); | |
133 | ||
134 | // Initialize display default parameters | |
135 | SetRange(); | |
136 | ||
137 | // Set front view by default | |
138 | fTheta = 90; | |
139 | fPhi = 90; | |
140 | fPsi = 0; | |
141 | fChamber = 1; | |
142 | fCathode = 1; | |
143 | // fRzone = 1.e10; | |
144 | fDrawClusters = kTRUE; | |
145 | fZoomMode = 1; | |
146 | fZooms = 0; | |
147 | fClustersCuts = 0; | |
148 | fPoints = 0; | |
149 | fPCerenkovs = 0; | |
150 | fPhits = 0; | |
151 | // Create colors | |
152 | CreateColors(); | |
153 | // Create display canvas | |
154 | Int_t ysize = size; | |
155 | if (ysize < 100) ysize = 750; | |
156 | Int_t xsize = Int_t(size*830./ysize); | |
157 | fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize); | |
084c1b4a | 158 | fCanvas->SetEditable(kFALSE); |
ddae0931 | 159 | fCanvas->ToggleEventStatus(); |
160 | ||
161 | // Create main display pad | |
162 | fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1); | |
163 | fPad->Draw(); | |
164 | fPad->Modified(); | |
165 | fPad->SetFillColor(1); | |
166 | fPad->SetBorderSize(2); | |
167 | ||
168 | fCanvas->cd(); | |
169 | ||
170 | // Create colors pad | |
171 | fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1); | |
172 | fColPad->Draw(); | |
173 | fColPad->Modified(); | |
174 | fColPad->SetFillColor(19); | |
175 | fColPad->SetBorderSize(2); | |
176 | fColPad->cd(); | |
177 | DisplayColorScale(); | |
178 | ||
179 | fCanvas->cd(); | |
180 | ||
181 | // Create user interface control pad | |
182 | DisplayButtons(); | |
183 | fCanvas->cd(); | |
184 | ||
185 | // Create Range and mode pad | |
186 | Float_t dxtr = 0.15; | |
187 | Float_t dytr = 0.45; | |
188 | fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr); | |
189 | fTrigPad->Draw(); | |
190 | fTrigPad->cd(); | |
191 | fTrigPad->SetFillColor(22); | |
192 | fTrigPad->SetBorderSize(2); | |
193 | fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98); | |
194 | fRangeSlider->SetObject(this); | |
195 | char pickmode[] = "gAlice->Display()->SetPickMode()"; | |
196 | Float_t db = 0.09; | |
197 | fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db); | |
198 | fPickButton->SetFillColor(38); | |
199 | fPickButton->Draw(); | |
200 | char zoommode[] = "gAlice->Display()->SetZoomMode()"; | |
201 | fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db); | |
202 | fZoomButton->SetFillColor(38); | |
203 | fZoomButton->Draw(); | |
204 | fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db); | |
205 | fArcButton->SetFillColor(kGreen); | |
206 | fArcButton->Draw(); | |
207 | char butUnzoom[] = "gAlice->Display()->UnZoom()"; | |
208 | TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15); | |
209 | button->SetFillColor(38); | |
210 | button->Draw(); | |
211 | AppendPad(); // append display object as last object to force selection | |
212 | ||
213 | fCanvas->cd(); | |
214 | fCanvas->Update(); | |
215 | } | |
216 | ||
217 | ||
218 | //_____________________________________________________________________________ | |
219 | AliRICHdisplay::~AliRICHdisplay() | |
220 | { | |
221 | // Delete space point structure | |
222 | if (fPoints) fPoints->Delete(); | |
223 | delete fPoints; | |
224 | fPoints = 0; | |
225 | // | |
226 | if (fPhits) fPhits->Delete(); | |
227 | delete fPhits; | |
228 | fPhits = 0; | |
229 | // | |
230 | if (fPCerenkovs) fPCerenkovs->Delete(); | |
231 | delete fPCerenkovs; | |
232 | fPCerenkovs = 0; | |
233 | } | |
234 | ||
235 | //_____________________________________________________________________________ | |
236 | void AliRICHdisplay::Clear(Option_t *) | |
237 | { | |
238 | // Delete graphics temporary objects | |
239 | } | |
240 | ||
241 | //_____________________________________________________________________________ | |
242 | void AliRICHdisplay::DisplayButtons() | |
243 | { | |
244 | // Create the user interface buttons | |
245 | ||
246 | ||
247 | fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1); | |
248 | fButtons->Draw(); | |
249 | fButtons->SetFillColor(38); | |
250 | fButtons->SetBorderSize(2); | |
251 | fButtons->cd(); | |
252 | ||
253 | // Int_t butcolor = 33; | |
254 | Float_t dbutton = 0.08; | |
255 | Float_t y = 0.96; | |
256 | Float_t dy = 0.014; | |
257 | Float_t x0 = 0.05; | |
258 | Float_t x1 = 0.95; | |
259 | ||
260 | TButton *button; | |
261 | char but1[] = "gAlice->Display()->ShowNextEvent(1)"; | |
262 | button = new TButton("Next",but1,x0,y-dbutton,x1,y); | |
263 | button->SetFillColor(38); | |
264 | button->Draw(); | |
265 | ||
266 | y -= dbutton +dy; | |
267 | char but2[] = "gAlice->Display()->ShowNextEvent(-1)"; | |
268 | button = new TButton("Previous",but2,x0,y-dbutton,x1,y); | |
269 | button->SetFillColor(38); | |
270 | button->Draw(); | |
271 | ||
272 | // display logo | |
273 | TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22); | |
274 | diamond->SetFillColor(50); | |
275 | diamond->SetTextAlign(22); | |
276 | diamond->SetTextColor(5); | |
277 | diamond->SetTextSize(0.11); | |
278 | diamond->Draw(); | |
279 | diamond->AddText(".. "); | |
280 | diamond->AddText("ROOT"); | |
281 | diamond->AddText("RICH"); | |
282 | diamond->AddText("... "); | |
283 | diamond->AddText(" "); | |
284 | } | |
285 | ||
286 | //_____________________________________________________________________________ | |
287 | void AliRICHdisplay::CreateColors() | |
288 | { | |
289 | // Create the colors palette used to display clusters | |
290 | ||
291 | Int_t k,i; | |
292 | Int_t color; | |
293 | Float_t r,g,b; | |
294 | ||
295 | for (k=1;k<=5;k++) { | |
296 | switch(k) { | |
297 | case 1: | |
298 | for (i=1;i<=5;i++) { | |
299 | r=1.; | |
300 | g=i*0.2; | |
301 | b=0.; | |
302 | color=i; | |
303 | color=50+23-color; | |
304 | new TColor(color,r,g,b); | |
305 | } | |
306 | break; | |
307 | case 2: | |
308 | for (i=1;i<=4;i++) { | |
309 | r=1.1-i*0.2; | |
310 | g=1.; | |
311 | b=0.; | |
312 | color=i+5; | |
313 | color=50+23-color; | |
314 | new TColor(color,r,g,b); | |
315 | } | |
316 | break; | |
317 | case 3: | |
318 | for (i=1;i<=4;i++) { | |
319 | r=0.; | |
320 | g=1.; | |
321 | b=i*0.2+0.2; | |
322 | color=i+9; | |
323 | color=50+23-color; | |
324 | new TColor(color,r,g,b); | |
325 | } | |
326 | break; | |
327 | case 4: | |
328 | for (i=1;i<=4;i++) { | |
329 | r=0.; | |
330 | g=1.1-i*0.2; | |
331 | b=1.; | |
332 | color=i+13; | |
333 | color=50+23-color; | |
334 | new TColor(color,r,g,b); | |
335 | } | |
336 | break; | |
337 | case 5: | |
338 | for (i=1;i<=5;i++) { | |
339 | r=i*0.2; | |
340 | g=0.; | |
341 | b=1.; | |
342 | color=i+17; | |
343 | color=50+23-color; | |
344 | new TColor(color,r,g,b); | |
345 | } | |
346 | break; | |
347 | } | |
348 | ||
349 | } | |
350 | ||
351 | } | |
352 | ||
353 | //_____________________________________________________________________________ | |
354 | void AliRICHdisplay::DisplayColorScale() | |
355 | { | |
356 | ||
357 | Int_t i; | |
358 | Int_t color; | |
359 | Float_t xlow, ylow, xup, yup, hs; | |
360 | Float_t x1, y1, x2, y2; | |
361 | x1 = y1 = 0; | |
362 | x2 = y2 = 20; | |
363 | ||
364 | gPad->SetFillColor(0); | |
365 | gPad->Clear(); | |
366 | gPad->Range(x1,y1,x2,y2); | |
367 | TText *text = new TText(0,0,""); | |
368 | text->SetTextFont(61); | |
369 | text->SetTextSize(0.03); | |
370 | text->SetTextAlign(22); | |
371 | ||
372 | TBox *box; | |
373 | char label[8]; | |
374 | //*-* draw colortable boxes | |
375 | hs = (y2-y1)/Float_t(22); | |
376 | xlow=x1+1; | |
377 | xup=x2-9; | |
378 | for (i=0;i<22;i++) { | |
379 | ylow = y1 + hs*(Float_t(i)); | |
380 | yup = y1 + hs*(Float_t(i+1)); | |
381 | color = 51+i; | |
382 | Double_t logscale=Double_t(i+1)*(TMath::Log(adc_satm)/22); | |
383 | Int_t scale=(Int_t)TMath::Exp(logscale); | |
384 | sprintf(label,"%d",scale); | |
385 | box = new TBox(xlow, ylow, xup, yup); | |
386 | box->SetFillColor(color); | |
387 | box->Draw(); | |
388 | text->DrawText(xup+4, 0.5*(ylow+yup),label); | |
389 | } | |
390 | } | |
391 | ||
392 | //______________________________________________________________________________ | |
393 | Int_t AliRICHdisplay::DistancetoPrimitive(Int_t px, Int_t) | |
394 | { | |
395 | // Compute distance from point px,py to objects in event | |
396 | ||
397 | gPad->SetCursor(kCross); | |
398 | ||
399 | if (gPad == fTrigPad) return 9999; | |
400 | ||
401 | const Int_t big = 9999; | |
402 | Int_t dist = big; | |
403 | Float_t xmin = gPad->GetX1(); | |
404 | Float_t xmax = gPad->GetX2(); | |
405 | Float_t dx = 0.02*(xmax - xmin); | |
406 | Float_t x = gPad->AbsPixeltoX(px); | |
407 | if (x < xmin+dx || x > xmax-dx) return dist; | |
408 | ||
409 | if (fZoomMode) return 0; | |
410 | else return 7; | |
411 | } | |
412 | ||
413 | //_____________________________________________________________________________ | |
414 | void AliRICHdisplay::Draw(Option_t *) | |
415 | { | |
416 | // Display current event | |
417 | ||
418 | fPad->cd(); | |
419 | ||
420 | DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames | |
421 | ||
422 | // Display the event number and title | |
423 | fPad->cd(); | |
424 | DrawTitle(); | |
425 | } | |
426 | ||
427 | ||
428 | //_____________________________________________________________________________ | |
429 | ||
430 | void AliRICHdisplay::DrawCerenkovs() | |
431 | { | |
432 | // Draw cerenkovs hits for RICH chambers | |
433 | ||
434 | LoadCerenkovs(fChamber); | |
435 | printf("\nDrawCerenkovs\n"); | |
436 | ||
437 | Int_t ntracks, track; | |
438 | TObjArray *cpoints; | |
439 | AliRICHpoints *pm; | |
440 | ||
441 | fHitsCuts = 0; | |
442 | cpoints = fPCerenkovs; | |
443 | printf ("Cpoints: %p",cpoints); | |
444 | if (!cpoints) return; | |
445 | ntracks = cpoints->GetEntriesFast(); | |
446 | printf("DrawCerenkovs - ntracks %d \n",ntracks); | |
447 | for (track=0;track<ntracks;track++) { | |
448 | pm = (AliRICHpoints*)cpoints->UncheckedAt(track); | |
449 | if (!pm) continue; | |
450 | pm->Draw(); | |
451 | fHitsCuts += pm->GetN(); | |
452 | } | |
453 | } | |
454 | ||
455 | //_____________________________________________________________________________ | |
456 | void AliRICHdisplay::DrawClusters() | |
457 | { | |
458 | // Draw clusterss for RICH chambers | |
459 | ||
460 | Int_t ndigits, digit; | |
461 | TObjArray *points; | |
462 | AliRICHpoints *pm; | |
463 | ||
464 | fClustersCuts = 0; | |
465 | points = fPoints; | |
466 | if (!points) return; | |
467 | ndigits = points->GetEntriesFast(); | |
468 | printf("DrawClusters - ndigits %d \n",ndigits); | |
469 | for (digit=0;digit<ndigits;digit++){ | |
470 | pm = (AliRICHpoints*)points->UncheckedAt(digit); | |
471 | if (!pm) continue; | |
472 | pm->Draw(); | |
473 | fClustersCuts +=pm->GetN(); | |
474 | } | |
475 | } | |
476 | ||
477 | //_____________________________________________________________________________ | |
478 | void AliRICHdisplay::DrawHits() | |
479 | { | |
480 | // Draw hits for RICH chambers | |
481 | ||
482 | LoadHits(fChamber); | |
483 | ||
484 | Int_t ntracks, track; | |
485 | TObjArray *points; | |
486 | AliRICHpoints *pm; | |
487 | ||
488 | fHitsCuts = 0; | |
489 | points = Phits(); | |
490 | if (!points) return; | |
491 | ntracks = points->GetEntriesFast(); | |
492 | printf("DrawHits - ntracks %d \n",ntracks); | |
493 | for (track=0;track<ntracks;track++) { | |
494 | pm = (AliRICHpoints*)points->UncheckedAt(track); | |
495 | if (!pm) continue; | |
496 | pm->Draw(); | |
497 | fHitsCuts += pm->GetN(); | |
498 | } | |
499 | } | |
500 | ||
501 | ||
502 | //_____________________________________________________________________________ | |
503 | void AliRICHdisplay::DrawTitle(Option_t *option) | |
504 | { | |
505 | // Draw the event title | |
506 | ||
507 | Float_t xmin = gPad->GetX1(); | |
508 | Float_t xmax = gPad->GetX2(); | |
509 | Float_t ymin = gPad->GetY1(); | |
510 | Float_t ymax = gPad->GetY2(); | |
511 | Float_t dx = xmax-xmin; | |
512 | Float_t dy = ymax-ymin; | |
513 | ||
514 | if (strlen(option) == 0) { | |
515 | TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy); | |
516 | title->SetBit(kCanDelete); | |
517 | title->SetFillColor(42); | |
518 | title->Draw(); | |
519 | char ptitle[100]; | |
520 | sprintf(ptitle,"Alice event: %d, Run:%d",gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun()); | |
521 | title->AddText(ptitle); | |
522 | Int_t nparticles = gAlice->Particles()->GetEntriesFast(); | |
523 | sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",nparticles, fHitsCuts,fClustersCuts); | |
524 | title->AddText(ptitle); | |
525 | } else { | |
526 | TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option); | |
527 | label->SetBit(kCanDelete); | |
528 | label->SetFillColor(42); | |
529 | label->Draw(); | |
530 | } | |
531 | } | |
532 | ||
533 | //_____________________________________________________________________________ | |
534 | void AliRICHdisplay::DrawView(Float_t theta, Float_t phi, Float_t psi) | |
535 | { | |
536 | // Draw a view of RICH clusters | |
537 | ||
538 | gPad->SetCursor(kWatch); | |
539 | gPad->SetFillColor(1); | |
540 | gPad->Clear(); | |
541 | ||
542 | Int_t iret; | |
543 | TView *view = new TView(1); | |
544 | Float_t range = fRrange*fRangeSlider->GetMaximum(); | |
545 | view->SetRange(-range,-range,-range,range, range, range); | |
546 | fZoomX0[0] = -1; | |
547 | fZoomY0[0] = -1; | |
548 | fZoomX1[0] = 1; | |
549 | fZoomY1[0] = 1; | |
550 | fZooms = 0; | |
551 | ||
552 | //Display RICH Chamber Geometry | |
553 | gAlice->GetGeometry()->Draw("same"); | |
554 | ||
555 | //add clusters to the pad | |
556 | DrawClusters(); | |
557 | DrawHits(); | |
558 | DrawCerenkovs(); | |
559 | ||
560 | // add itself to the list (must be last) | |
561 | AppendPad(); | |
562 | ||
563 | view->SetView(phi, theta, psi, iret); | |
564 | } | |
565 | ||
566 | ||
567 | //______________________________________________________________________________ | |
568 | void AliRICHdisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py) | |
569 | { | |
570 | // Execute action corresponding to the mouse event | |
571 | ||
572 | static Float_t x0, y0, x1, y1; | |
573 | ||
574 | static Int_t pxold, pyold; | |
575 | static Int_t px0, py0; | |
576 | static Int_t linedrawn; | |
577 | Float_t temp; | |
578 | ||
579 | if (px == 0 && py == 0) { //when called by sliders | |
580 | if (event == kButton1Up) { | |
581 | Draw(); | |
582 | } | |
583 | return; | |
584 | } | |
585 | if (!fZoomMode && gPad->GetView()) { | |
586 | gPad->GetView()->ExecuteRotateView(event, px, py); | |
587 | return; | |
588 | } | |
589 | ||
590 | // something to zoom ? | |
591 | gPad->SetCursor(kCross); | |
592 | ||
593 | switch (event) { | |
594 | ||
595 | case kButton1Down: | |
084c1b4a | 596 | gVirtualX->SetLineColor(-1); |
ddae0931 | 597 | gPad->TAttLine::Modify(); //Change line attributes only if necessary |
598 | x0 = gPad->AbsPixeltoX(px); | |
599 | y0 = gPad->AbsPixeltoY(py); | |
600 | px0 = px; py0 = py; | |
601 | pxold = px; pyold = py; | |
602 | linedrawn = 0; | |
603 | return; | |
604 | ||
605 | case kButton1Motion: | |
084c1b4a | 606 | if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow); |
ddae0931 | 607 | pxold = px; |
608 | pyold = py; | |
609 | linedrawn = 1; | |
084c1b4a | 610 | gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow); |
ddae0931 | 611 | return; |
612 | ||
613 | case kButton1Up: | |
614 | gPad->GetCanvas()->FeedbackMode(kFALSE); | |
615 | if (px == px0) return; | |
616 | if (py == py0) return; | |
617 | x1 = gPad->AbsPixeltoX(px); | |
618 | y1 = gPad->AbsPixeltoY(py); | |
619 | ||
620 | if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;} | |
621 | if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;} | |
622 | gPad->Range(x0,y0,x1,y1); | |
623 | if (fZooms < kMAXZOOM-1) { | |
624 | fZooms++; | |
625 | fZoomX0[fZooms] = x0; | |
626 | fZoomY0[fZooms] = y0; | |
627 | fZoomX1[fZooms] = x1; | |
628 | fZoomY1[fZooms] = y1; | |
629 | } | |
630 | gPad->Modified(kTRUE); | |
631 | return; | |
632 | } | |
633 | ||
634 | } | |
635 | ||
636 | //___________________________________________ | |
637 | void AliRICHdisplay::LoadDigits() | |
638 | { | |
639 | // Read digits info and store x,y,z info in arrays fPoints | |
640 | // Loop on all detectors | |
641 | ||
642 | printf("Entering Load-digits"); | |
643 | ||
644 | ||
645 | ResetPoints(); | |
646 | AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH"); | |
647 | AliRICHchamber* iChamber; | |
648 | AliRICHsegmentation* segmentation; | |
649 | Int_t NallDigits=0; | |
c90dd3e2 | 650 | Int_t ich; |
ddae0931 | 651 | |
c90dd3e2 | 652 | for (ich=0; ich<7; ich++) { |
ddae0931 | 653 | TClonesArray *RICHdigits = RICH->DigitsAddress(ich); |
654 | if (RICHdigits == 0) continue; | |
655 | gAlice->ResetDigits(); | |
656 | gAlice->TreeD()->GetEvent(1); | |
657 | Int_t ndigits = RICHdigits->GetEntriesFast(); | |
658 | printf("Found %d digits in chamber %d \n",ndigits,ich); | |
659 | NallDigits+=ndigits; | |
660 | } | |
661 | if (fPoints == 0) fPoints = new TObjArray(NallDigits); | |
662 | Int_t counter=0; | |
c90dd3e2 | 663 | for (ich=0; ich<7; ich++) { |
ddae0931 | 664 | TClonesArray *RICHdigits = RICH->DigitsAddress(ich); |
665 | if (RICHdigits == 0) continue; | |
666 | gAlice->ResetDigits(); | |
667 | gAlice->TreeD()->GetEvent(1); | |
668 | Int_t ndigits = RICHdigits->GetEntriesFast(); | |
669 | printf("Found %d digits in chamber %d \n",ndigits,ich); | |
670 | if (ndigits == 0) continue; | |
671 | ||
672 | ||
673 | ||
674 | iChamber = &(RICH->Chamber(ich)); | |
675 | printf("LoadPoints - chamber %d \n",ich); | |
676 | segmentation=iChamber->GetSegmentationModel(1); | |
677 | Float_t dpx = segmentation->Dpx(); | |
678 | Float_t dpy = segmentation->Dpy(); | |
679 | printf("LoadPoints - dpx, dpy %f %f \n",dpx,dpy); | |
680 | AliRICHdigit *mdig; | |
681 | AliRICHpoints *points = 0; | |
682 | // | |
683 | //loop over all digits and store their position | |
684 | Int_t npoints=1; | |
685 | ||
686 | for (Int_t digit=0;digit<ndigits;digit++) { | |
687 | mdig = (AliRICHdigit*)RICHdigits->UncheckedAt(digit); | |
688 | points = new AliRICHpoints(npoints); | |
689 | fPoints->AddAt(points,counter); | |
690 | counter++; | |
691 | Int_t charge=mdig->fSignal; | |
692 | Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22)); | |
693 | Int_t color=51+index; | |
694 | if (color>72) color=72; | |
695 | points->SetMarkerColor(color); | |
696 | points->SetMarkerStyle(21); | |
697 | points->SetMarkerSize(0.5); | |
698 | // get the center of the pad - add on x and y half of pad size | |
699 | Float_t xpad, ypad; | |
700 | segmentation->GetPadCxy(mdig->fPadX, mdig->fPadY,xpad, ypad); | |
701 | printf("\n chamber x,y, %d %f %f ", ich, xpad, ypad); | |
702 | ||
703 | Float_t VecLoc[3]={xpad,0,ypad}; | |
704 | Float_t VecGlob[3]; | |
705 | iChamber->LocaltoGlobal(VecLoc,VecGlob); | |
706 | points->SetParticle(-1); | |
707 | points->SetHitIndex(-1); | |
708 | points->SetTrackIndex(-1); | |
709 | points->SetDigitIndex(digit); | |
710 | points->SetPoint(0,VecGlob[0],VecGlob[1],VecGlob[2]); | |
711 | } // loop over digits | |
712 | } // loop over chambers | |
713 | } | |
714 | ||
715 | ||
716 | //___________________________________________ | |
717 | void AliRICHdisplay::LoadHits(Int_t chamber) | |
718 | { | |
719 | // Read hits info and store x,y,z info in arrays fPhits | |
720 | // Loop on all detectors | |
721 | ||
722 | printf("Entering Load-hits"); | |
723 | ||
724 | fChamber=chamber; | |
725 | ResetPhits(); | |
726 | ||
727 | AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH"); | |
728 | AliRICHchamber* iChamber; | |
729 | ||
730 | iChamber = &(RICH->Chamber(chamber-1)); | |
731 | Float_t zpos=iChamber->ZPosition(); | |
732 | printf("LoadHits - zpos %f \n",zpos); | |
733 | ||
734 | Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries(); | |
735 | printf("ntracks %d\n",ntracks); | |
736 | Int_t ntrks = gAlice->GetNtrack(); | |
737 | printf("ntrks %d\n",ntrks); | |
738 | ||
739 | if (fPhits == 0) fPhits = new TObjArray(ntracks); | |
740 | TVector *xp = new TVector(1000); | |
741 | TVector *yp = new TVector(1000); | |
742 | TVector *zp = new TVector(1000); | |
743 | TVector *ptrk = new TVector(1000); | |
744 | TVector *phit = new TVector(1000); | |
745 | for (Int_t track=0; track<ntracks;track++) { | |
746 | gAlice->ResetHits(); | |
747 | gAlice->TreeH()->GetEvent(track); | |
748 | TClonesArray *RICHhits = RICH->Hits(); | |
749 | if (RICHhits == 0) return; | |
750 | Int_t nhits = RICHhits->GetEntriesFast(); | |
751 | if (nhits == 0) continue; | |
752 | AliRICHhit *mHit; | |
753 | AliRICHpoints *points = 0; | |
754 | Int_t npoints=0; | |
755 | for (Int_t hit=0;hit<nhits;hit++) { | |
756 | mHit = (AliRICHhit*)RICHhits->UncheckedAt(hit); | |
757 | (*xp)(npoints)=mHit->fX; | |
758 | (*yp)(npoints)=mHit->fY; | |
759 | (*zp)(npoints)=mHit->fZ; | |
760 | (*ptrk)(npoints)=Float_t(mHit->GetTrack()); | |
761 | (*phit)(npoints)=Float_t(hit); | |
762 | npoints++; | |
763 | } | |
764 | ||
765 | if (npoints == 0) continue; | |
766 | points = new AliRICHpoints(npoints); | |
767 | for (Int_t p=0;p<npoints;p++) { | |
768 | points->SetMarkerColor(kRed); | |
769 | points->SetMarkerStyle(5); | |
770 | points->SetMarkerSize(1.); | |
771 | points->SetParticle(Int_t((*ptrk)(p))); | |
772 | points->SetHitIndex(Int_t((*phit)(p))); | |
773 | points->SetTrackIndex(track); | |
774 | points->SetDigitIndex(-1); | |
775 | points->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p)); | |
776 | } | |
777 | xp->Zero(); | |
778 | yp->Zero(); | |
779 | ptrk->Zero(); | |
780 | phit->Zero(); | |
781 | fPhits->AddAt(points,track); | |
782 | } | |
783 | ||
784 | } | |
785 | ||
786 | //_____________________________________________________________________________ | |
787 | ||
788 | void AliRICHdisplay::LoadCerenkovs(Int_t chamber) | |
789 | { | |
790 | // Read cerenkov hits info and store x,y,z info in array fPCerenkovs | |
791 | // Loop on all detectors | |
792 | ||
793 | printf("Entering Load-Cerenkovs"); | |
794 | ||
795 | fChamber=chamber; | |
796 | ResetPCerenkovs(); | |
797 | ||
798 | AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH"); | |
799 | AliRICHchamber* iChamber; | |
800 | ||
801 | iChamber = &(RICH->Chamber(chamber-1)); | |
802 | Float_t zpos=iChamber->ZPosition(); | |
803 | printf("LoadCerenkovs - zpos %f \n",zpos); | |
804 | ||
805 | RICH->SetTreeAddress(); | |
806 | Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries(); | |
807 | printf("ntracks %d\n",ntracks); | |
808 | Int_t ntrks = gAlice->GetNtrack(); | |
809 | printf("ntrks %d\n",ntrks); | |
810 | ||
811 | if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks); | |
812 | TVector *xp = new TVector(1000); | |
813 | TVector *yp = new TVector(1000); | |
814 | TVector *zp = new TVector(1000); | |
815 | TVector *ptrk = new TVector(1000); | |
816 | TVector *phit = new TVector(1000); | |
817 | for (Int_t track=0; track<ntracks;track++) { | |
818 | gAlice->ResetHits(); | |
819 | gAlice->TreeH()->GetEvent(track); | |
820 | TClonesArray *RICHCerenkovs = RICH->Cerenkovs(); | |
821 | printf("RICHCerenkovs %p\n",RICHCerenkovs); | |
822 | if (RICHCerenkovs == 0) return; | |
823 | Int_t nhits = RICHCerenkovs->GetEntriesFast(); | |
824 | if (nhits == 0) continue; | |
825 | printf("nhits %d \n",nhits); | |
826 | AliRICHCerenkov *mCerenkov; | |
827 | AliRICHpoints *cpoints = 0; | |
828 | Int_t npoints=0; | |
829 | ||
830 | //Display Cerenkov hits in blue | |
831 | ||
832 | for (Int_t hit=0;hit<nhits;hit++) { | |
833 | mCerenkov = (AliRICHCerenkov*)RICHCerenkovs->UncheckedAt(hit); | |
834 | (*xp)(npoints)=mCerenkov->fX; | |
835 | (*yp)(npoints)=mCerenkov->fY; | |
836 | (*zp)(npoints)=mCerenkov->fZ; | |
837 | (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack()); | |
838 | (*phit)(npoints)=Float_t(hit); | |
839 | printf("track, trk %d %d\n",track,mCerenkov->GetTrack()); | |
840 | npoints++; | |
841 | } | |
842 | if (npoints == 0) continue; | |
843 | printf("npoints %d \n",npoints); | |
844 | cpoints = new AliRICHpoints(npoints); | |
845 | for (Int_t p=0;p<npoints;p++) { | |
846 | cpoints->SetMarkerColor(kBlue); | |
847 | cpoints->SetMarkerStyle(3); | |
848 | cpoints->SetMarkerSize(1.); | |
849 | cpoints->SetParticle(Int_t((*ptrk)(p))); | |
850 | Int_t index=cpoints->GetIndex(); | |
851 | printf("index %d \n",index); | |
852 | cpoints->SetHitIndex(Int_t((*phit)(p))); | |
853 | cpoints->SetTrackIndex(track); | |
854 | cpoints->SetDigitIndex(-1); | |
855 | cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p)); | |
856 | } | |
857 | xp->Zero(); | |
858 | yp->Zero(); | |
859 | ptrk->Zero(); | |
860 | phit->Zero(); | |
861 | fPCerenkovs->AddAt(cpoints,track); | |
862 | } | |
863 | } | |
864 | ||
865 | //_____________________________________________________________________________ | |
866 | void AliRICHdisplay::Paint(Option_t *) | |
867 | { | |
868 | // Paint miscellaneous items | |
869 | ||
870 | } | |
871 | ||
872 | //_____________________________________________________________________________ | |
873 | void AliRICHdisplay::SetPickMode() | |
874 | { | |
875 | fZoomMode = 0; | |
876 | ||
877 | fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC()); | |
878 | fTrigPad->Modified(); | |
879 | } | |
880 | ||
881 | //_____________________________________________________________________________ | |
882 | void AliRICHdisplay::SetZoomMode() | |
883 | { | |
884 | fZoomMode = 1; | |
885 | ||
886 | fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC()); | |
887 | fTrigPad->Modified(); | |
888 | } | |
889 | ||
890 | //_____________________________________________________________________________ | |
891 | void AliRICHdisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode) | |
892 | { | |
893 | // Set chamber and cathode number | |
894 | fChamber = chamber; | |
895 | fCathode = cathode; | |
896 | ||
897 | printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode); | |
898 | if (!fPad) return; | |
899 | fPad->Clear(); | |
900 | LoadDigits(); | |
901 | Draw(); | |
902 | } | |
903 | ||
904 | //_____________________________________________________________________________ | |
905 | void AliRICHdisplay::SetRange(Float_t rrange, Float_t zrange) | |
906 | { | |
907 | // Set view range along R and Z | |
908 | fRrange = rrange; | |
909 | fZrange = zrange; | |
910 | ||
911 | if (!fPad) return; | |
912 | fPad->Clear(); | |
913 | Draw(); | |
914 | } | |
915 | ||
916 | //_____________________________________________________________________________ | |
917 | void AliRICHdisplay::SetView(Float_t theta, Float_t phi, Float_t psi) | |
918 | { | |
919 | // change viewing angles for current event | |
920 | ||
921 | fPad->cd(); | |
922 | fPhi = phi; | |
923 | fTheta = theta; | |
924 | fPsi = psi; | |
925 | Int_t iret = 0; | |
926 | ||
927 | TView *view = gPad->GetView(); | |
928 | if (view) view->SetView(fPhi, fTheta, fPsi, iret); | |
929 | else Draw(); | |
930 | ||
931 | gPad->Modified(); | |
932 | } | |
933 | ||
934 | //_____________________________________________________________________________ | |
935 | void AliRICHdisplay::ShowNextEvent(Int_t delta) | |
936 | { | |
937 | // Display (current event_number+delta) | |
938 | // delta = 1 shown next event | |
939 | // delta = -1 show previous event | |
940 | ||
941 | if (delta) { | |
942 | gAlice->Clear(); | |
943 | Int_t current_event = gAlice->GetHeader()->GetEvent(); | |
944 | Int_t new_event = current_event + delta; | |
945 | gAlice->GetEvent(new_event); | |
946 | if (!gAlice->TreeD()) return; | |
947 | } | |
948 | LoadDigits(); | |
949 | DrawClusters(); | |
950 | fPad->cd(); | |
951 | Draw(); | |
952 | ||
953 | ||
954 | } | |
955 | ||
956 | //______________________________________________________________________________ | |
957 | void AliRICHdisplay::UnZoom() | |
958 | { | |
959 | if (fZooms <= 0) return; | |
960 | fZooms--; | |
961 | TPad *pad = (TPad*)gPad->GetPadSave(); | |
962 | pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]); | |
963 | pad->Modified(); | |
964 | } | |
965 | ||
966 | //_____________________________________________________________________________ | |
967 | void AliRICHdisplay::ResetPoints() | |
968 | { | |
969 | // | |
970 | // Reset array of points | |
971 | // | |
972 | if (fPoints) { | |
973 | fPoints->Delete(); | |
974 | delete fPoints; | |
975 | fPoints = 0; | |
976 | } | |
977 | } | |
978 | //_____________________________________________________________________________ | |
979 | void AliRICHdisplay::ResetPhits() | |
980 | { | |
981 | // | |
982 | // Reset array of points | |
983 | // | |
984 | if (fPhits) { | |
985 | fPhits->Delete(); | |
986 | delete fPhits; | |
987 | fPhits = 0; | |
988 | } | |
989 | } | |
990 | //_____________________________________________________________________________ | |
991 | void AliRICHdisplay::ResetPCerenkovs() | |
992 | { | |
993 | // | |
994 | // Reset array of points | |
995 | // | |
996 | if (fPCerenkovs) { | |
997 | fPCerenkovs->Delete(); | |
998 | delete fPCerenkovs; | |
999 | fPCerenkovs = 0; | |
1000 | } | |
1001 | } |