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