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