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