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