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