New RICH code J.Barbosa, A.Morsch, D.DiBari
[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;
628
629 for (Int_t ich=0; ich<7; ich++) {
630 TClonesArray *RICHdigits = RICH->DigitsAddress(ich);
631 if (RICHdigits == 0) continue;
632 gAlice->ResetDigits();
633 gAlice->TreeD()->GetEvent(1);
634 Int_t ndigits = RICHdigits->GetEntriesFast();
635 printf("Found %d digits in chamber %d \n",ndigits,ich);
636 NallDigits+=ndigits;
637 }
638 if (fPoints == 0) fPoints = new TObjArray(NallDigits);
639 Int_t counter=0;
640 for (Int_t ich=0; ich<7; ich++) {
641 TClonesArray *RICHdigits = RICH->DigitsAddress(ich);
642 if (RICHdigits == 0) continue;
643 gAlice->ResetDigits();
644 gAlice->TreeD()->GetEvent(1);
645 Int_t ndigits = RICHdigits->GetEntriesFast();
646 printf("Found %d digits in chamber %d \n",ndigits,ich);
647 if (ndigits == 0) continue;
648
649
650
651 iChamber = &(RICH->Chamber(ich));
652 printf("LoadPoints - chamber %d \n",ich);
653 segmentation=iChamber->GetSegmentationModel(1);
654 Float_t dpx = segmentation->Dpx();
655 Float_t dpy = segmentation->Dpy();
656 printf("LoadPoints - dpx, dpy %f %f \n",dpx,dpy);
657 AliRICHdigit *mdig;
658 AliRICHpoints *points = 0;
659 //
660 //loop over all digits and store their position
661 Int_t npoints=1;
662
663 for (Int_t digit=0;digit<ndigits;digit++) {
664 mdig = (AliRICHdigit*)RICHdigits->UncheckedAt(digit);
665 points = new AliRICHpoints(npoints);
666 fPoints->AddAt(points,counter);
667 counter++;
668 Int_t charge=mdig->fSignal;
669 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
670 Int_t color=51+index;
671 if (color>72) color=72;
672 points->SetMarkerColor(color);
673 points->SetMarkerStyle(21);
674 points->SetMarkerSize(0.5);
675 // get the center of the pad - add on x and y half of pad size
676 Float_t xpad, ypad;
677 segmentation->GetPadCxy(mdig->fPadX, mdig->fPadY,xpad, ypad);
678 printf("\n chamber x,y, %d %f %f ", ich, xpad, ypad);
679
680 Float_t VecLoc[3]={xpad,0,ypad};
681 Float_t VecGlob[3];
682 iChamber->LocaltoGlobal(VecLoc,VecGlob);
683 points->SetParticle(-1);
684 points->SetHitIndex(-1);
685 points->SetTrackIndex(-1);
686 points->SetDigitIndex(digit);
687 points->SetPoint(0,VecGlob[0],VecGlob[1],VecGlob[2]);
688 } // loop over digits
689 } // loop over chambers
690}
691
692
693//___________________________________________
694void AliRICHdisplay::LoadHits(Int_t chamber)
695{
696// Read hits info and store x,y,z info in arrays fPhits
697// Loop on all detectors
698
699 printf("Entering Load-hits");
700
701 fChamber=chamber;
702 ResetPhits();
703
704 AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH");
705 AliRICHchamber* iChamber;
706
707 iChamber = &(RICH->Chamber(chamber-1));
708 Float_t zpos=iChamber->ZPosition();
709 printf("LoadHits - zpos %f \n",zpos);
710
711 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
712 printf("ntracks %d\n",ntracks);
713 Int_t ntrks = gAlice->GetNtrack();
714 printf("ntrks %d\n",ntrks);
715
716 if (fPhits == 0) fPhits = new TObjArray(ntracks);
717 TVector *xp = new TVector(1000);
718 TVector *yp = new TVector(1000);
719 TVector *zp = new TVector(1000);
720 TVector *ptrk = new TVector(1000);
721 TVector *phit = new TVector(1000);
722 for (Int_t track=0; track<ntracks;track++) {
723 gAlice->ResetHits();
724 gAlice->TreeH()->GetEvent(track);
725 TClonesArray *RICHhits = RICH->Hits();
726 if (RICHhits == 0) return;
727 Int_t nhits = RICHhits->GetEntriesFast();
728 if (nhits == 0) continue;
729 AliRICHhit *mHit;
730 AliRICHpoints *points = 0;
731 Int_t npoints=0;
732 for (Int_t hit=0;hit<nhits;hit++) {
733 mHit = (AliRICHhit*)RICHhits->UncheckedAt(hit);
734 (*xp)(npoints)=mHit->fX;
735 (*yp)(npoints)=mHit->fY;
736 (*zp)(npoints)=mHit->fZ;
737 (*ptrk)(npoints)=Float_t(mHit->GetTrack());
738 (*phit)(npoints)=Float_t(hit);
739 npoints++;
740 }
741
742 if (npoints == 0) continue;
743 points = new AliRICHpoints(npoints);
744 for (Int_t p=0;p<npoints;p++) {
745 points->SetMarkerColor(kRed);
746 points->SetMarkerStyle(5);
747 points->SetMarkerSize(1.);
748 points->SetParticle(Int_t((*ptrk)(p)));
749 points->SetHitIndex(Int_t((*phit)(p)));
750 points->SetTrackIndex(track);
751 points->SetDigitIndex(-1);
752 points->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
753 }
754 xp->Zero();
755 yp->Zero();
756 ptrk->Zero();
757 phit->Zero();
758 fPhits->AddAt(points,track);
759 }
760
761}
762
763//_____________________________________________________________________________
764
765void AliRICHdisplay::LoadCerenkovs(Int_t chamber)
766{
767// Read cerenkov hits info and store x,y,z info in array fPCerenkovs
768// Loop on all detectors
769
770 printf("Entering Load-Cerenkovs");
771
772 fChamber=chamber;
773 ResetPCerenkovs();
774
775 AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH");
776 AliRICHchamber* iChamber;
777
778 iChamber = &(RICH->Chamber(chamber-1));
779 Float_t zpos=iChamber->ZPosition();
780 printf("LoadCerenkovs - zpos %f \n",zpos);
781
782 RICH->SetTreeAddress();
783 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
784 printf("ntracks %d\n",ntracks);
785 Int_t ntrks = gAlice->GetNtrack();
786 printf("ntrks %d\n",ntrks);
787
788 if (fPCerenkovs == 0) fPCerenkovs = new TObjArray(ntracks);
789 TVector *xp = new TVector(1000);
790 TVector *yp = new TVector(1000);
791 TVector *zp = new TVector(1000);
792 TVector *ptrk = new TVector(1000);
793 TVector *phit = new TVector(1000);
794 for (Int_t track=0; track<ntracks;track++) {
795 gAlice->ResetHits();
796 gAlice->TreeH()->GetEvent(track);
797 TClonesArray *RICHCerenkovs = RICH->Cerenkovs();
798 printf("RICHCerenkovs %p\n",RICHCerenkovs);
799 if (RICHCerenkovs == 0) return;
800 Int_t nhits = RICHCerenkovs->GetEntriesFast();
801 if (nhits == 0) continue;
802 printf("nhits %d \n",nhits);
803 AliRICHCerenkov *mCerenkov;
804 AliRICHpoints *cpoints = 0;
805 Int_t npoints=0;
806
807//Display Cerenkov hits in blue
808
809 for (Int_t hit=0;hit<nhits;hit++) {
810 mCerenkov = (AliRICHCerenkov*)RICHCerenkovs->UncheckedAt(hit);
811 (*xp)(npoints)=mCerenkov->fX;
812 (*yp)(npoints)=mCerenkov->fY;
813 (*zp)(npoints)=mCerenkov->fZ;
814 (*ptrk)(npoints)=Float_t(mCerenkov->GetTrack());
815 (*phit)(npoints)=Float_t(hit);
816 printf("track, trk %d %d\n",track,mCerenkov->GetTrack());
817 npoints++;
818 }
819 if (npoints == 0) continue;
820 printf("npoints %d \n",npoints);
821 cpoints = new AliRICHpoints(npoints);
822 for (Int_t p=0;p<npoints;p++) {
823 cpoints->SetMarkerColor(kBlue);
824 cpoints->SetMarkerStyle(3);
825 cpoints->SetMarkerSize(1.);
826 cpoints->SetParticle(Int_t((*ptrk)(p)));
827 Int_t index=cpoints->GetIndex();
828 printf("index %d \n",index);
829 cpoints->SetHitIndex(Int_t((*phit)(p)));
830 cpoints->SetTrackIndex(track);
831 cpoints->SetDigitIndex(-1);
832 cpoints->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
833 }
834 xp->Zero();
835 yp->Zero();
836 ptrk->Zero();
837 phit->Zero();
838 fPCerenkovs->AddAt(cpoints,track);
839 }
840}
841
842//_____________________________________________________________________________
843void AliRICHdisplay::Paint(Option_t *)
844{
845// Paint miscellaneous items
846
847}
848
849//_____________________________________________________________________________
850void AliRICHdisplay::SetPickMode()
851{
852 fZoomMode = 0;
853
854 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
855 fTrigPad->Modified();
856}
857
858//_____________________________________________________________________________
859void AliRICHdisplay::SetZoomMode()
860{
861 fZoomMode = 1;
862
863 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
864 fTrigPad->Modified();
865}
866
867//_____________________________________________________________________________
868void AliRICHdisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
869{
870// Set chamber and cathode number
871 fChamber = chamber;
872 fCathode = cathode;
873
874 printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
875 if (!fPad) return;
876 fPad->Clear();
877 LoadDigits();
878 Draw();
879}
880
881//_____________________________________________________________________________
882void AliRICHdisplay::SetRange(Float_t rrange, Float_t zrange)
883{
884// Set view range along R and Z
885 fRrange = rrange;
886 fZrange = zrange;
887
888 if (!fPad) return;
889 fPad->Clear();
890 Draw();
891}
892
893//_____________________________________________________________________________
894void AliRICHdisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
895{
896// change viewing angles for current event
897
898 fPad->cd();
899 fPhi = phi;
900 fTheta = theta;
901 fPsi = psi;
902 Int_t iret = 0;
903
904 TView *view = gPad->GetView();
905 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
906 else Draw();
907
908 gPad->Modified();
909}
910
911//_____________________________________________________________________________
912void AliRICHdisplay::ShowNextEvent(Int_t delta)
913{
914// Display (current event_number+delta)
915// delta = 1 shown next event
916// delta = -1 show previous event
917
918 if (delta) {
919 gAlice->Clear();
920 Int_t current_event = gAlice->GetHeader()->GetEvent();
921 Int_t new_event = current_event + delta;
922 gAlice->GetEvent(new_event);
923 if (!gAlice->TreeD()) return;
924 }
925 LoadDigits();
926 DrawClusters();
927 fPad->cd();
928 Draw();
929
930
931}
932
933//______________________________________________________________________________
934void AliRICHdisplay::UnZoom()
935{
936 if (fZooms <= 0) return;
937 fZooms--;
938 TPad *pad = (TPad*)gPad->GetPadSave();
939 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
940 pad->Modified();
941}
942
943//_____________________________________________________________________________
944void AliRICHdisplay::ResetPoints()
945{
946 //
947 // Reset array of points
948 //
949 if (fPoints) {
950 fPoints->Delete();
951 delete fPoints;
952 fPoints = 0;
953 }
954}
955//_____________________________________________________________________________
956void AliRICHdisplay::ResetPhits()
957{
958 //
959 // Reset array of points
960 //
961 if (fPhits) {
962 fPhits->Delete();
963 delete fPhits;
964 fPhits = 0;
965 }
966}
967//_____________________________________________________________________________
968void AliRICHdisplay::ResetPCerenkovs()
969{
970 //
971 // Reset array of points
972 //
973 if (fPCerenkovs) {
974 fPCerenkovs->Delete();
975 delete fPCerenkovs;
976 fPCerenkovs = 0;
977 }
978}