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