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