]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICHDisplay.cxx
More debug info
[u/mrichter/AliRoot.git] / RICH / AliRICHDisplay.cxx
CommitLineData
8278a469 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
8278a469 16
17//////////////////////////////////////////////////////////////////////////
18// //
19// AliDisplay //
20// //
21// Utility class to display ALICE outline, tracks, hits,.. //
22// //
23//////////////////////////////////////////////////////////////////////////
24
25#include <TROOT.h>
26#include <TTree.h>
27#include <TButton.h>
28#include <TColor.h>
29#include <TCanvas.h>
30#include <TView.h>
31#include <TText.h>
32#include <TPolyMarker3D.h>
488e98ba 33#include <TAtt3D.h>
34#include <TAttLine.h>
8278a469 35#include <TPolyMarker.h>
36#include <TPaveLabel.h>
37#include <TPaveText.h>
38#include <TList.h>
39#include <TDiamond.h>
40#include <TNode.h>
41#include <TArc.h>
42#include <TTUBE.h>
43#include <TSlider.h>
94de3818 44#include <TGeometry.h>
8278a469 45#include <TSliderBox.h>
46#include <TGaxis.h>
47#include <TVirtualX.h>
48#include <TMath.h>
49#include <TRandom.h>
50#include <X3DBuffer.h>
237c933d 51#include <TParticle.h>
53fd478b 52#include "AliRICHChamber.h"
8278a469 53#include "AliRun.h"
54#include "AliPDG.h"
55#include "AliDetector.h"
56#include "AliRICH.h"
8278a469 57#include "AliRICHDisplay.h"
58#include "AliRICHPoints.h"
9e1a0ddb 59#include "AliHeader.h"
8278a469 60
5d12ce38 61#include "AliMC.h"
8278a469 62
63ClassImp(AliRICHDisplay)
64
65
66//____________________________________________________________________________
67AliRICHDisplay::AliRICHDisplay()
68{
237c933d 69
70// default constructor
2685bf00 71 fColPad = 0;
8278a469 72 fPoints = 0;
73 fPhits = 0;
74 fPCerenkovs = 0;
75 fCanvas = 0;
76 fRpoints = 0;
77 fRecpoints = 0;
78}
79
80//_____________________________________________________________________________
81AliRICHDisplay::AliRICHDisplay(Int_t size)
82{
8278a469 83
84 fPad = 0;
85
86 gAlice->SetDisplay(this);
87
88 // Initialize display default parameters
89 SetRange();
90
91 // Set front view by default
192b81a6 92 fTheta = 90; //inclined HMPID
93 fPhi = 30; //inclined HMPID
94 //fTheta = 90; //normal HMPID
95 //fPhi = 90; //normal HMPID
8278a469 96 fPsi = 0;
97 fChamber = 1;
98 fCathode = 1;
99 // fRzone = 1.e10;
100 fDrawClusters = kTRUE;
101 fDrawCoG = kTRUE;
102 fDrawRecHits = kTRUE;
103 fZoomMode = 1;
104 fZooms = 0;
105 fClustersCuts = 0;
106 fPoints = 0;
107 fPCerenkovs = 0;
108 fPhits = 0;
109 fRpoints = 0;
110 fRecpoints = 0;
111 // Create colors
112 CreateColors();
113 // Create display canvas
114 Int_t ysize = size;
115 if (ysize < 100) ysize = 750;
116 Int_t xsize = Int_t(size*830./ysize);
117 fCanvas = new TCanvas("Canvas", "RICH Clusters Display",14,47,xsize,ysize);
118 fCanvas->ToggleEventStatus();
119
120 // Create main display pad
121 fPad = new TPad("viewpad", "RICH display",0.15,0,0.9,1);
122 fPad->Draw();
123 fPad->Modified();
124 fPad->SetFillColor(1);
125 fPad->SetBorderSize(2);
126
127 fCanvas->cd();
128
129 // Create colors pad
130 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
131 fColPad->Draw();
132 fColPad->Modified();
133 fColPad->SetFillColor(19);
134 fColPad->SetBorderSize(2);
135 fColPad->cd();
136 DisplayColorScale();
137
138 fCanvas->cd();
139
140 // Create user interface control pad
141 DisplayButtons();
142 fCanvas->cd();
143
144 // Create Range and mode pad
145 Float_t dxtr = 0.15;
146 Float_t dytr = 0.45;
147 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
8278a469 148 fTrigPad->Draw();
149 fTrigPad->cd();
150 fTrigPad->SetFillColor(22);
151 fTrigPad->SetBorderSize(2);
152 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
153 fRangeSlider->SetObject(this);
154 char pickmode[] = "gAlice->Display()->SetPickMode()";
155 Float_t db = 0.09;
156 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
157 fPickButton->SetFillColor(38);
158 fPickButton->Draw();
159 char zoommode[] = "gAlice->Display()->SetZoomMode()";
160 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
161 fZoomButton->SetFillColor(38);
162 fZoomButton->Draw();
163 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
164 fArcButton->SetFillColor(kGreen);
165 fArcButton->Draw();
166 char butUnzoom[] = "gAlice->Display()->UnZoom()";
167 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
168 button->SetFillColor(38);
169 button->Draw();
170 AppendPad(); // append display object as last object to force selection
171
9f0fdec5 172 fTrigPad->SetEditable(kFALSE);
173 fButtons->SetEditable(kFALSE);
8278a469 174 fCanvas->cd();
175 fCanvas->Update();
176}
177
178
179//_____________________________________________________________________________
180AliRICHDisplay::~AliRICHDisplay()
181{
182 // Delete space point structure
183 if (fPoints) fPoints->Delete();
184 delete fPoints;
185 fPoints = 0;
186 //
187 if (fPhits) fPhits->Delete();
188 delete fPhits;
189 fPhits = 0;
190 //
191 if (fRpoints) fRpoints->Delete();
192 delete fRpoints;
193 fRpoints = 0;
194 //
195 if (fRecpoints) fRecpoints->Delete();
196 delete fRecpoints;
197 fRecpoints = 0;
198 //
199 if (fPCerenkovs) fPCerenkovs->Delete();
200 delete fPCerenkovs;
201 fPCerenkovs = 0;
202}
203
204//_____________________________________________________________________________
205void AliRICHDisplay::Clear(Option_t *)
206{
207// Delete graphics temporary objects
208}
209
210//_____________________________________________________________________________
211void AliRICHDisplay::DisplayButtons()
212{
213// Create the user interface buttons
214
215
216 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
8278a469 217 fButtons->Draw();
218 fButtons->SetFillColor(38);
219 fButtons->SetBorderSize(2);
220 fButtons->cd();
221
222 // Int_t butcolor = 33;
223 Float_t dbutton = 0.08;
224 Float_t y = 0.96;
225 Float_t dy = 0.014;
226 Float_t x0 = 0.05;
227 Float_t x1 = 0.95;
228
229 TButton *button;
230 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
231 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
232 button->SetFillColor(38);
233 button->Draw();
234
235 y -= dbutton +dy;
236 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
237 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
238 button->SetFillColor(38);
239 button->Draw();
240
241 y -= dbutton +dy;
242 char but7[] = "gAlice->Display()->DrawViewGL()";
243 button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
244 button->SetFillColor(38);
245 button->Draw();
246
247 y -= dbutton +dy;
248 char but8[] = "gAlice->Display()->DrawViewX3D()";
249 button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
250 button->SetFillColor(38);
251 button->Draw();
252
253 // display logo
254 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
255 diamond->SetFillColor(50);
256 diamond->SetTextAlign(22);
257 diamond->SetTextColor(5);
258 diamond->SetTextSize(0.11);
259 diamond->Draw();
260 diamond->AddText(".. ");
261 diamond->AddText("ROOT");
262 diamond->AddText("RICH");
263 diamond->AddText("... ");
264 diamond->AddText(" ");
265}
266
267//_____________________________________________________________________________
268void AliRICHDisplay::CreateColors()
269{
270// Create the colors palette used to display clusters
271
272 Int_t k,i;
273 Int_t color;
274 Float_t r,g,b;
275
276 for (k=1;k<=5;k++) {
277 switch(k) {
278 case 1:
279 for (i=1;i<=5;i++) {
280 r=1.;
281 g=i*0.2;
282 b=0.;
283 color=i;
284 color=700+23-color;
285 new TColor(color,r,g,b);
286 }
287 break;
288 case 2:
289 for (i=1;i<=4;i++) {
290 r=1.1-i*0.2;
291 g=1.;
292 b=0.;
293 color=i+5;
294 color=700+23-color;
295 new TColor(color,r,g,b);
296 }
297 break;
298 case 3:
299 for (i=1;i<=4;i++) {
300 r=0.;
301 g=1.;
302 b=i*0.2+0.2;
303 color=i+9;
304 color=700+23-color;
305 new TColor(color,r,g,b);
306 }
307 break;
308 case 4:
309 for (i=1;i<=4;i++) {
310 r=0.;
311 g=1.1-i*0.2;
312 b=1.;
313 color=i+13;
314 color=700+23-color;
315 new TColor(color,r,g,b);
316 }
317 break;
318 case 5:
319 for (i=1;i<=5;i++) {
320 r=i*0.2;
321 g=0.;
322 b=1.;
323 color=i+17;
324 color=700+23-color;
325 new TColor(color,r,g,b);
326 }
327 break;
328 }
329 }
330}
331
332//_____________________________________________________________________________
333void AliRICHDisplay::DisplayColorScale()
334{
237c933d 335
336// Draw the color scale in the RICH display canvas
8278a469 337
338 Int_t i;
339 Int_t color;
340 Float_t xlow, ylow, xup, yup, hs;
341 Float_t x1, y1, x2, y2;
342 x1 = y1 = 0;
343 x2 = y2 = 20;
344
345 gPad->SetFillColor(0);
346 gPad->Clear();
347 gPad->Range(x1,y1,x2,y2);
348 TText *text = new TText(0,0,"");
349 text->SetTextFont(61);
731293a6 350 text->SetTextSize(0.2);
8278a469 351 text->SetTextAlign(22);
352
353 TBox *box;
354 char label[8];
355//*-* draw colortable boxes
356 hs = (y2-y1)/Float_t(22);
357 xlow=x1+1;
358 xup=x2-9;
359 for (i=0;i<22;i++) {
360 ylow = y1 + hs*(Float_t(i));
361 yup = y1 + hs*(Float_t(i+1));
362 color = 701+i;
a277aaca 363 Double_t logscale=Double_t(i+1)*(TMath::Log(kadc_satm)/22);
8278a469 364 Int_t scale=(Int_t)TMath::Exp(logscale);
365 sprintf(label,"%d",scale);
366 box = new TBox(xlow, ylow, xup, yup);
367 box->SetFillColor(color);
368 box->Draw();
369 text->DrawText(xup+4, 0.5*(ylow+yup),label);
370 }
371}
372
373//______________________________________________________________________________
374Int_t AliRICHDisplay::DistancetoPrimitive(Int_t px, Int_t)
375{
376// Compute distance from point px,py to objects in event
377
378 gPad->SetCursor(kCross);
379
380 if (gPad == fTrigPad) return 9999;
381
237c933d 382 const Int_t kBig = 9999;
383 Int_t dist = kBig;
8278a469 384 Float_t xmin = gPad->GetX1();
385 Float_t xmax = gPad->GetX2();
386 Float_t dx = 0.02*(xmax - xmin);
387 Float_t x = gPad->AbsPixeltoX(px);
388 if (x < xmin+dx || x > xmax-dx) return dist;
389 if (fZoomMode) return 0;
390 else return 7;
391}
392
393//_____________________________________________________________________________
394void AliRICHDisplay::Draw(Option_t *)
395{
396// Display current event
397
398 fPad->cd();
399
400 DrawView(fTheta, fPhi, fPsi); // see how to draw PGON+inner frames
401
402 // Display the event number and title
403 fPad->cd();
404 DrawTitle();
405}
406
407//_____________________________________________________________________________
408void AliRICHDisplay::DrawCoG()
409{
410// Draw hits for RICH chambers
411
412 if (!fDrawCoG) return;
413 ResetRpoints();
237c933d 414 for (Int_t chamber=0;chamber<kNCH;chamber++) {
8278a469 415 LoadCoG(chamber,1);
416 }
417
418 Int_t ncog, icog;
419 TObjArray *points;
420 AliRICHPoints *pm;
421 points = fRpoints;
422 if (!points) return;
423 ncog = points->GetEntriesFast();
424 for (icog=0; icog < ncog; icog++) {
425 pm = (AliRICHPoints*)points->UncheckedAt(icog);
426 if (!pm) continue;
427 pm->Draw();
428 }
429}
430
431void AliRICHDisplay::DrawRecHits()
432{
433// Draw rec hits for RICH chambers
434
435 if (!fDrawRecHits) return;
436 //ResetRecpoints();
237c933d 437 for (Int_t chamber=0;chamber<kNCH;chamber++) {
8278a469 438 LoadRecHits(chamber,1);
439 }
440
441 Int_t nrec, irec;
442 TObjArray *points;
443 AliRICHPoints *pm;
444 points = fRecpoints;
445 if (!points) return;
446 nrec = points->GetEntriesFast();
e524e1a0 447 //printf("Nrec %d\n",nrec);
8278a469 448 for (irec=0; irec < nrec; irec++) {
449 pm = (AliRICHPoints*)points->UncheckedAt(irec);
450 if (!pm) continue;
451 pm->Draw();
452 }
453}
454
455//_____________________________________________________________________________
456
457void AliRICHDisplay::DrawCerenkovs()
458{
459// Draw cerenkovs hits for RICH chambers
460
461 LoadCerenkovs(fChamber);
462 //printf("\nDrawCerenkovs\n");
463
464 Int_t ntracks, track;
465 TObjArray *cpoints;
466 AliRICHPoints *pm;
467
468 fHitsCuts = 0;
469 cpoints = fPCerenkovs;
470 //printf ("Cpoints: %p",cpoints);
471 if (!cpoints) return;
472 ntracks = cpoints->GetEntriesFast();
473 //printf("DrawCerenkovs - ntracks %d \n",ntracks);
474 for (track=0;track<ntracks;track++) {
475 pm = (AliRICHPoints*)cpoints->UncheckedAt(track);
476 if (!pm) continue;
477 pm->Draw();
478 fHitsCuts += pm->GetN();
479 }
480}
481
482//_____________________________________________________________________________
483
484void AliRICHDisplay::DrawClusters()
485{
486// Draw clusterss for RICH chambers
487
488 Int_t ndigits, digit;
489 TObjArray *points;
490 AliRICHPoints *pm;
491
492 fClustersCuts = 0;
493 points = fPoints;
494 if (!points) return;
495 ndigits = points->GetEntriesFast();
496 for (digit=0;digit<ndigits;digit++){
497 pm = (AliRICHPoints*)points->UncheckedAt(digit);
498 if (!pm) continue;
499 pm->Draw();
500 Float_t *pxyz;
501 pxyz=pm->GetP();
502 for (Int_t im=0;im<3;im++) {
503 TMarker3DBox *marker=pm->GetMarker(im);
504 if (marker)
505 marker->Draw();
506 }
507 fClustersCuts +=pm->GetN();
508 }
509}
510
511//_____________________________________________________________________________
512void AliRICHDisplay::DrawHits()
513{
514// Draw hits for RICH chambers
515
516 LoadHits(fChamber);
517
518 Int_t ntracks, track;
519 TObjArray *points;
520 AliRICHPoints *pm;
521
522 fHitsCuts = 0;
523 points = Phits();
524 if (!fPhits) return;
525// ntracks = points->GetEntriesFast();
526 ntracks = fPhits->GetEntriesFast();
527
528 //printf("DrawHits - ntracks %d \n",ntracks);
529 for (track=0;track<ntracks;track++) {
530 pm = (AliRICHPoints*)fPhits->UncheckedAt(track);
531 if (!pm) continue;
532 pm->Draw();
533 fHitsCuts += pm->GetN();
534 }
535}
536
537
538//_____________________________________________________________________________
539void AliRICHDisplay::DrawTitle(Option_t *option)
540{
541// Draw the event title
542
543 Float_t xmin = gPad->GetX1();
544 Float_t xmax = gPad->GetX2();
545 Float_t ymin = gPad->GetY1();
546 Float_t ymax = gPad->GetY2();
547 Float_t dx = xmax-xmin;
548 Float_t dy = ymax-ymin;
549
550 if (strlen(option) == 0) {
551 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
552 title->SetBit(kCanDelete);
553 title->SetFillColor(42);
554 title->Draw();
555 char ptitle[100];
556 sprintf(ptitle,"Alice event: %d, Run:%d",
557 gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
558 title->AddText(ptitle);
5d12ce38 559 Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast();
8278a469 560 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
561 nparticles, fHitsCuts,fClustersCuts);
562 title->AddText(ptitle);
563 } else {
564 TPaveLabel *label =
565 new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
566 label->SetBit(kCanDelete);
567 label->SetFillColor(42);
568 label->Draw();
569 }
570}
571
572//_____________________________________________________________________________
573void AliRICHDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
574{
575// Draw a view of RICH clusters
576
577 gPad->SetCursor(kWatch);
578 gPad->SetFillColor(1);
579 gPad->Clear();
580
581 Int_t iret;
582 TView *view = new TView(1);
583 Float_t range = fRrange*fRangeSlider->GetMaximum();
584 view->SetRange(-range,-range,-range,range, range, range);
585 fZoomX0[0] = -1;
586 fZoomY0[0] = -1;
587 fZoomX1[0] = 1;
588 fZoomY1[0] = 1;
589 fZooms = 0;
590
591 //Display RICH Chamber Geometry
592 gAlice->GetGeometry()->Draw("same");
593
594 //add clusters to the pad
595 DrawClusters();
0339e982 596 DrawHits();
731293a6 597 //DrawCerenkovs();
e524e1a0 598 if (gAlice->TreeR())
599 {
600 //printf("Calling DrawCoG\n");
0339e982 601 DrawCoG();
e524e1a0 602 //printf("Calling DrawRecHits\n");
0339e982 603 DrawRecHits();
e524e1a0 604 }
8278a469 605 /*for (Int_t i=0;i<7;i++)
606 LoadRecHits(i,1);*/
607
608 // add itself to the list (must be last)
609 AppendPad();
610
611 view->SetView(phi, theta, psi, iret);
612}
613
614//______________________________________________________________________________
615void AliRICHDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
616{
617// Execute action corresponding to the mouse event
618
619 static Float_t x0, y0, x1, y1;
620
621 static Int_t pxold, pyold;
622 static Int_t px0, py0;
623 static Int_t linedrawn;
624 Float_t temp;
625
626 if (px == 0 && py == 0) { //when called by sliders
627 if (event == kButton1Up) {
64ee71e7 628 printf("Drawing event %d\n",event);
629 Draw();
8278a469 630 }
631 return;
632 }
633 if (!fZoomMode && gPad->GetView()) {
634 gPad->GetView()->ExecuteRotateView(event, px, py);
635 return;
636 }
637
638 // something to zoom ?
639 gPad->SetCursor(kCross);
640
641 switch (event) {
642
643 case kButton1Down:
644 gVirtualX->SetLineColor(-1);
645 gPad->TAttLine::Modify(); //Change line attributes only if necessary
646 x0 = gPad->AbsPixeltoX(px);
647 y0 = gPad->AbsPixeltoY(py);
648 px0 = px; py0 = py;
649 pxold = px; pyold = py;
650 linedrawn = 0;
651 return;
652
653 case kButton1Motion:
654 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
655 pxold = px;
656 pyold = py;
657 linedrawn = 1;
658 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
659 return;
660
661 case kButton1Up:
662 gPad->GetCanvas()->FeedbackMode(kFALSE);
663 if (px == px0) return;
664 if (py == py0) return;
665 x1 = gPad->AbsPixeltoX(px);
666 y1 = gPad->AbsPixeltoY(py);
667
668 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
669 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
670 gPad->Range(x0,y0,x1,y1);
671 if (fZooms < kMAXZOOM-1) {
672 fZooms++;
673 fZoomX0[fZooms] = x0;
674 fZoomY0[fZooms] = y0;
675 fZoomX1[fZooms] = x1;
676 fZoomY1[fZooms] = y1;
677 }
678 gPad->Modified(kTRUE);
679 return;
680 }
681
682}
683//___________________________________________
684void AliRICHDisplay::LoadCoG(Int_t chamber, Int_t cathode)
685{
686// Read raw clusters info and store x,y,z info in arrays fRpoints
687// Loop on all detectors
688
aed240d4 689 if (chamber > 7) return;
8278a469 690
237c933d 691 AliRICH *pRICH = (AliRICH*)gAlice->GetModule("RICH");
8278a469 692 AliRICHChamber* iChamber;
693
aed240d4 694 TClonesArray *pRICHrawclust = pRICH->Clusters(chamber);
237c933d 695 if (pRICHrawclust == 0) return;
8278a469 696
aed240d4 697 pRICH->ResetClusters();
8278a469 698
699
700 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
701 gAlice->TreeR()->GetEvent(nent-1+cathode-1);
237c933d 702 Int_t nrawcl = pRICHrawclust->GetEntriesFast();
e524e1a0 703 //printf ("nrawcl:%d\n",nrawcl);
8278a469 704 if (nrawcl == 0) return;
705 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
706
84365c70 707 iChamber = pRICH->C(chamber);
aed240d4 708 AliRICHcluster *mRaw;
8278a469 709 AliRICHPoints *points = 0;
710 //
711 //loop over all raw clusters and store their position
712 points = new AliRICHPoints(nrawcl);
713 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
aed240d4 714 mRaw = (AliRICHcluster*)pRICHrawclust->UncheckedAt(iraw);
8278a469 715 fRpoints->AddAt(points,iraw);
716 points->SetMarkerColor(3);
717 points->SetMarkerStyle(3);
718 points->SetMarkerSize(1.);
719 points->SetParticle(-1);
720 points->SetHitIndex(-1);
721 points->SetTrackIndex(-1);
722 points->SetDigitIndex(-1);
aed240d4 723 Float_t vectorLoc[3]={mRaw->X(),5,mRaw->Y()};
237c933d 724 Float_t vectorGlob[3];
725 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
726 points->SetPoint(iraw,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
8278a469 727 }
aed240d4 728}//LoadCoG()
8278a469 729//___________________________________________
730void AliRICHDisplay::LoadRecHits(Int_t chamber, Int_t cathode)
731{
c712cb2f 732 chamber++;cathode++;
8278a469 733}
734//___________________________________________
735void AliRICHDisplay::LoadDigits()
736{
737// Read digits info and store x,y,z info in arrays fPoints
738// Loop on all detectors
739
740 ResetPoints();
237c933d 741 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
8278a469 742 AliRICHChamber* iChamber;
a2f7eaf6 743 AliSegmentation* segmentation;
237c933d 744 Int_t nAllDigits=0;
8278a469 745 Int_t ich;
50755e99 746
e524e1a0 747 //printf("Entering LoadDigits\n");
50755e99 748
749 if (gAlice->TreeD())
750 {
8278a469 751
aed240d4 752 for (ich=1; ich<=kNCH; ich++) {
753 TClonesArray *pRICHdigits = pRICH->Digits(ich);
50755e99 754 if (pRICHdigits == 0) continue;
755 gAlice->ResetDigits();
e524e1a0 756 gAlice->TreeD()->GetEvent(0);
50755e99 757 Int_t ndigits = pRICHdigits->GetEntriesFast();
50755e99 758 nAllDigits+=ndigits;
759 }
8278a469 760
50755e99 761 if (fPoints == 0) fPoints = new TObjArray(nAllDigits);
762 Int_t counter=0;
aed240d4 763 for (ich=1; ich<=kNCH; ich++) {
764 TClonesArray *pRICHdigits = pRICH->Digits(ich);
50755e99 765 if (pRICHdigits == 0) continue;
766 gAlice->ResetDigits();
e524e1a0 767 gAlice->TreeD()->GetEvent(0);
50755e99 768 Int_t ndigits = pRICHdigits->GetEntriesFast();
769 if (ndigits == 0) continue;
84365c70 770 iChamber = pRICH->C(ich);
771 Float_t dpx = AliRICHParam::PadSizeX();
772 Float_t dpy = AliRICHParam::PadSizeY();
50755e99 773
50755e99 774
aed240d4 775 AliRICHdigit *mdig;
50755e99 776 AliRICHPoints *points = 0;
777 TMarker3DBox *marker = 0;
778 //
779 //loop over all digits and store their position
780 Int_t npoints=1;
781
782 for (Int_t digit=0;digit<ndigits;digit++) {
aed240d4 783 mdig = (AliRICHdigit*)pRICHdigits->UncheckedAt(digit);
8278a469 784 points = new AliRICHPoints(npoints);
785 fPoints->AddAt(points,counter);
786 counter++;
aed240d4 787 Int_t charge=(Int_t)mdig->Q();
a277aaca 788 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(kadc_satm)/22));
8278a469 789 Int_t color=701+index;
790 if (color>722) color=722;
791 points->SetMarkerColor(color);
792 points->SetMarkerStyle(21);
793 points->SetMarkerSize(0.5);
a2f7eaf6 794 Float_t xpad, ypad, zpad;
aed240d4 795 segmentation->GetPadC(mdig->X(), mdig->Y(),xpad, ypad, zpad);
64ee71e7 796 Float_t vectorLoc[3]={xpad,5,ypad};
237c933d 797 Float_t vectorGlob[3];
798 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
8278a469 799 points->SetParticle(-1);
800 points->SetHitIndex(-1);
801 points->SetTrackIndex(-1);
802 points->SetDigitIndex(digit);
237c933d 803 points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
64ee71e7 804 //printf("Y position (digit): %f\n", vectorGlob[1]);
8278a469 805
aed240d4 806 segmentation->GetPadC(mdig->X(), mdig->Y(), xpad, ypad, zpad);
8278a469 807 Float_t theta = iChamber->GetRotMatrix()->GetTheta();
808 Float_t phi = iChamber->GetRotMatrix()->GetPhi();
237c933d 809 marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
8278a469 810 dpy/2,0,dpx/2,theta,phi);
811 marker->SetLineColor(2);
812 marker->SetFillStyle(1001);
813 marker->SetFillColor(color);
814 marker->SetRefObject((TObject*)points);
815 points->Set3DMarker(0, marker);
50755e99 816 } // loop over digits
817 } // loop over chambers
818 } //if TreeD
aed240d4 819}//LoadDigits();
820//__________________________________________________________________________________________________
8278a469 821void AliRICHDisplay::LoadHits(Int_t chamber)
822{
823// Read hits info and store x,y,z info in arrays fPhits
824// Loop on all detectors
825
826
827 fChamber=chamber;
828 ResetPhits();
829
237c933d 830 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
8278a469 831 AliRICHChamber* iChamber;
832
84365c70 833 iChamber = pRICH->C(chamber-1);
88cb7938 834 Int_t ntracks = (Int_t)pRICH->TreeH()->GetEntries();
8278a469 835 Int_t track;
836
837 if (fPhits == 0) fPhits = new TObjArray(ntracks);
838 //TVector *xp = new TVector(1000);
839 //TVector *yp = new TVector(1000);
840 //TVector *zp = new TVector(1000);
841 //TVector *ptrk = new TVector(1000);
842 //TVector *phit = new TVector(1000);
237c933d 843 Int_t nAllHits=0;
8278a469 844 for (track=0; track<ntracks;track++) {
845 gAlice->ResetHits();
88cb7938 846 pRICH->TreeH()->GetEvent(track);
237c933d 847 TClonesArray *pRICHhits = pRICH->Hits();
848 if (pRICHhits == 0) return;
849 Int_t nhits = pRICHhits->GetEntriesFast();
850 nAllHits+=nhits;
8278a469 851 }
852
237c933d 853 fPhits = new TObjArray(nAllHits);
8278a469 854
855 Int_t npoints=0;
856 for (track=0; track<ntracks;track++) {
857 gAlice->ResetHits();
88cb7938 858 pRICH->TreeH()->GetEvent(track);
237c933d 859 TClonesArray *pRICHhits = pRICH->Hits();
860 if (pRICHhits == 0) return;
861 Int_t nhits = pRICHhits->GetEntriesFast();
8278a469 862 if (nhits == 0) continue;
853634d3 863 AliRICHhit *mHit;
8278a469 864 AliRICHPoints *points = 0;
865 for (Int_t hit=0;hit<nhits;hit++) {
866 points = new AliRICHPoints(1);
867 fPhits->AddAt(points,npoints);
853634d3 868 mHit = (AliRICHhit*)pRICHhits->UncheckedAt(hit);
5d12ce38 869 TParticle *current = (TParticle*)gAlice->GetMCApp()->Particle(mHit->Track());
8278a469 870 if (current->GetPdgCode() == 50000050) {
871 points->SetMarkerColor(kBlue);
872 } else if (current->GetPdgCode() == 50000051) {
873 points->SetMarkerColor(kYellow);
874 } else {
875 points->SetMarkerColor(kRed);
876 }
877 points->SetMarkerStyle(5);
878 points->SetMarkerSize(1.);
94de3818 879 points->SetParticle(mHit->Track());
8278a469 880 points->SetHitIndex(hit);
0976a54b 881 points->SetTrackIndex(track);
8278a469 882 points->SetDigitIndex(-1);
0339e982 883 points->SetPoint(0,mHit->X(), mHit->Y(), mHit->Z());
8278a469 884 npoints++;
885 }
886 }
aed240d4 887}//LoadHits()
888//__________________________________________________________________________________________________
8278a469 889void AliRICHDisplay::LoadCerenkovs(Int_t chamber)
890{
891// Read cerenkov hits info and store x,y,z info in array fPCerenkovs
892// Loop on all detectors
84365c70 893 chamber++;
8278a469 894}
895
896//_____________________________________________________________________________
897void AliRICHDisplay::Paint(Option_t *)
898{
899// Paint miscellaneous items
900
901}
902
903//_____________________________________________________________________________
904void AliRICHDisplay::SetPickMode()
905{
237c933d 906
907// Toggle pick mode
908
8278a469 909 fZoomMode = 0;
910
911 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
912 fTrigPad->Modified();
913}
914
915//_____________________________________________________________________________
916void AliRICHDisplay::SetZoomMode()
917{
237c933d 918
919// Toggle Zoom mode
920
8278a469 921 fZoomMode = 1;
922
923 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
924 fTrigPad->Modified();
925}
926
927//_____________________________________________________________________________
928void AliRICHDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
929{
930// Set chamber and cathode number
931 fChamber = chamber;
932 fCathode = cathode;
933
e524e1a0 934 //printf("SetChamberAndCathode - fChamber fCathode %d %d\n",fChamber,fCathode);
8278a469 935 if (!fPad) return;
936 fPad->Clear();
937 LoadDigits();
938 Draw();
939}
940
941//_____________________________________________________________________________
942void AliRICHDisplay::SetRange(Float_t rrange, Float_t zrange)
943{
944// Set view range along R and Z
945 fRrange = rrange;
946 fZrange = zrange;
947
948 if (!fPad) return;
949 fPad->Clear();
950 Draw();
951}
952
953//_____________________________________________________________________________
954void AliRICHDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
955{
956// change viewing angles for current event
957
958 fPad->cd();
959 fPhi = phi;
960 fTheta = theta;
961 fPsi = psi;
962 Int_t iret = 0;
963
964 TView *view = gPad->GetView();
965 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
966 else Draw();
967
968 gPad->Modified();
969}
970
971//_____________________________________________________________________________
972void AliRICHDisplay::ShowNextEvent(Int_t delta)
973{
974// Display (current event_number+delta)
975// delta = 1 shown next event
976// delta = -1 show previous event
977
978 if (delta) {
979 gAlice->Clear();
237c933d 980 Int_t currentEvent = gAlice->GetHeader()->GetEvent();
981 Int_t newEvent = currentEvent + delta;
982 gAlice->GetEvent(newEvent);
8278a469 983 if (!gAlice->TreeD()) return;
984 }
985 LoadDigits();
986 DrawClusters();
987 fPad->cd();
988 Draw();
989
990
991}
992
993//______________________________________________________________________________
994void AliRICHDisplay::UnZoom()
995{
237c933d 996
997// Return to previous zoom factor
998
8278a469 999 if (fZooms <= 0) return;
1000 fZooms--;
1001 TPad *pad = (TPad*)gPad->GetPadSave();
1002 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1003 pad->Modified();
1004}
1005
1006//_____________________________________________________________________________
1007void AliRICHDisplay::ResetPoints()
1008{
1009 //
1010 // Reset array of points
1011 //
1012 if (fPoints) {
1013 fPoints->Delete();
1014 delete fPoints;
1015 fPoints = 0;
1016 }
1017}
1018//_____________________________________________________________________________
1019void AliRICHDisplay::ResetRpoints()
1020{
1021 //
1022 // Reset array of points
1023 //
1024 if (fRpoints) {
1025 fRpoints->Delete();
1026 delete fRpoints;
1027 fRpoints = 0;
1028 }
1029}
1030//_____________________________________________________________________________
1031void AliRICHDisplay::ResetRecpoints()
1032{
1033 //
1034 // Reset array of points
1035 //
1036 if (fRecpoints) {
1037 fRecpoints->Delete();
1038 delete fRecpoints;
1039 fRecpoints = 0;
1040 }
1041}
1042//_____________________________________________________________________________
1043void AliRICHDisplay::ResetPhits()
1044{
1045 //
1046 // Reset array of points
1047 //
1048 if (fPhits) {
1049 fPhits->Delete();
1050 delete fPhits;
1051 fPhits = 0;
1052 }
1053}
1054//_____________________________________________________________________________
1055void AliRICHDisplay::ResetPCerenkovs()
1056{
1057 //
1058 // Reset array of points
1059 //
1060 if (fPCerenkovs) {
1061 fPCerenkovs->Delete();
1062 delete fPCerenkovs;
1063 fPCerenkovs = 0;
1064 }
1065}
1066
1067//_____________________________________________________________________________
1068
1069void AliRICHDisplay::DrawViewGL()
1070{
1071// Draw current view using OPENGL
1072
1073 TPad *pad = (TPad*)gPad->GetPadSave();
1074 pad->cd();
1075 TView *view = pad->GetView();
1076 if (!view) return;
1077 pad->x3d("OPENGL");
1078}
1079
1080//_____________________________________________________________________________
1081void AliRICHDisplay::DrawViewX3D()
1082{
1083// Draw current view using X3D
1084
1085 TPad *pad = (TPad*)gPad->GetPadSave();
1086 pad->cd();
1087 TView *view = pad->GetView();
1088 if (!view) return;
1089 pad->x3d();
1090}