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