1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //////////////////////////////////////////////////////////////////////////
22 // Utility class to display ALICE outline, tracks, hits,.. //
24 //////////////////////////////////////////////////////////////////////////
31 #include <TPaveLabel.h>
32 #include <TPaveText.h>
37 #include <TVirtualX.h>
39 #include <TGeometry.h>
40 #include <TMarker3DBox.h>
41 #include <TParticle.h>
42 #include <TPolyLine3D.h>
45 #include "AliMUONDisplay.h"
48 #include "AliMUONPoints.h"
49 #include "AliMUONGlobalTrigger.h"
50 #include "AliHeader.h"
52 #include "AliMUONHit.h"
53 #include "AliMUONDigit.h"
54 #include "AliMUONRawCluster.h"
55 #include "AliMUONTrack.h"
56 #include "AliMUONTrackParam.h"
58 #include "AliMUONSegmentationManager.h"
59 #include "AliMUONGeometryModule.h"
60 #include "AliMpSlatSegmentation.h"
61 #include "AliMpSlat.h"
64 #include "AliMUONGeometrySegmentation.h"
65 #include "AliMUONChamber.h"
66 #include "AliMUONConstants.h"
69 // to manage the same zoom on both cathodes
73 ClassImp(AliMUONDisplay)
76 //_____________________________________________________________________________
77 AliMUONDisplay::AliMUONDisplay()
85 fNextCathode = kFALSE;
89 //_____________________________________________________________________________
90 AliMUONDisplay::AliMUONDisplay(Int_t size, AliLoader * loader)
93 // Create an event display object.
94 // A canvas named "edisplay" is created with a vertical size in pixels
96 // A QUICK Overview of the Event Display functions
97 // ===============================================
99 // The event display can ve invoked by executing the macro "display.C"
100 // A canvas like in the picture below will appear.
102 // On the left side of the canvas, the following buttons appear:
103 // *Next* to move to the next event
104 // *Previous* to move to the previous event
106 // *Pick* Select this option to be able to point on a track with the
107 // mouse. Once on the track, use the right button to select
108 // an action. For example, select SetMarkerAttributes to
109 // change the marker type/color/size for the track.
110 // *Zoom* Select this option (default) if you want to zoom.
111 // To zoom, simply select the selected area with the left button.
112 // *UnZoom* To revert to the previous picture size.
114 // slider R On the left side, the vertical slider can be used to
115 // set the default picture size.
117 // When you are in Zoom mode, you can click on the black part of the canvas
118 // to select special options with the right mouse button.
121 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
122 // When you are on a track, select the menu item "InspectParticle"
123 // to display the current particle attributes.
125 // You can activate the Root browser by selecting the Inspect menu
126 // in the canvas tool bar menu. Then select "Start Browser"
127 // This will open a new canvas with the browser. At this point, you may want
128 // to display some histograms (from the Trees). Go to the "File" menu
129 // of the browser and click on "New canvas".
130 // In the browser, click on item "ROOT files" in the left pane.
131 // Click on galice.root.
133 // Click on TPC for example
134 // Click on any variable (eg TPC.fX) to histogram the variable.
136 // If you are lost, you can click on HELP in any Root canvas or browser.
139 <img src="gif/AliMUONDisplay.gif">
146 gAlice->SetDisplay(this);
148 // Initialize display default parameters
150 // Set front view by default
157 fDrawClusters = kTRUE;
159 fDrawTracks = kFALSE;
168 // Create display canvas
170 if (ysize < 100) ysize = 750;
171 Int_t xsize = Int_t(size*830./ysize);
172 fCanvas = new TCanvas("Canvas", "MUON Display",14,47,xsize,ysize);
173 fCanvas->ToggleEventStatus();
175 // Create main display pad
176 fPad = new TPad("viewpad", "MUON display",0.15,0,0.9,1);
179 fPad->SetFillColor(30);
180 fPad->SetBorderSize(2);
185 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
187 fColPad->SetFillColor(17);
188 fColPad->SetBorderSize(2);
193 // Create user interface control pad
197 // Create Range and mode pad
200 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
203 fTrigPad->SetFillColor(22);
204 fTrigPad->SetBorderSize(2);
205 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
206 fRangeSlider->SetObject(this);
207 char pickmode[] = "gAlice->Display()->SetPickMode()";
209 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
210 fPickButton->SetFillColor(38);
212 char zoommode[] = "gAlice->Display()->SetZoomMode()";
213 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
214 fZoomButton->SetFillColor(38);
216 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
217 fArcButton->SetFillColor(kGreen);
219 char butUnzoom[] = "gAlice->Display()->UnZoom()";
220 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
221 button->SetFillColor(38);
223 AppendPad(); // append display object as last object to force selection
226 fTrigPad->SetEditable(kFALSE);
227 fButtons->SetEditable(kFALSE);
229 fNextCathode = kFALSE;
231 // initialize container
233 fMUONData = new AliMUONData(fLoader,"MUON","MUON");
238 AliMUONDisplay::AliMUONDisplay(const AliMUONDisplay & display)
239 : AliDisplay(display)
241 // Protected copy constructor
243 AliFatal("Not implemented.");
248 //_____________________________________________________________________________
249 AliMUONDisplay::~AliMUONDisplay()
251 // Delete space point structure
252 if (fPoints) fPoints->Delete();
256 if (fPhits) fPhits->Delete();
260 if (fRpoints) fRpoints->Delete();
265 //_____________________________________________________________________________
266 void AliMUONDisplay::Clear(Option_t *)
268 // Delete graphics temporary objects
271 //_____________________________________________________________________________
272 void AliMUONDisplay::DisplayButtons()
274 // Create the user interface buttons
277 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
279 fButtons->SetFillColor(38);
280 fButtons->SetBorderSize(2);
283 // Int_t butcolor = 33;
284 Float_t dbutton = 0.08;
291 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
292 button = new TButton("Event +", but1, x0, y - dbutton, x1, y);
293 button->SetFillColor(38);
297 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
298 button = new TButton("Event -", but2, x0, y - dbutton, x1, y);
299 button->SetFillColor(38);
303 char but3[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(1)";
304 button = new TButton("Chamber +", but3, x0, y - dbutton, x1, y);
305 button->SetFillColor(38);
309 char but4[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(-1)";
310 button = new TButton("Chamber -", but4, x0, y - dbutton, x1, y);
311 button->SetFillColor(38);
315 char but5[] = "((AliMUONDisplay*)(gAlice->Display()))->SetChamberAndCathode(1,1)";
316 button = new TButton("Chamber 1", but5, x0, y - dbutton, x1, y);
317 button->SetFillColor(38);
321 char but6[] = "((AliMUONDisplay*)(gAlice->Display()))->NextCathode()";
322 button = new TButton("Cathode <>", but6, x0, y - dbutton, x1, y);
323 button->SetFillColor(38);
327 char but7[] = "((AliMUONDisplay*)(gAlice->Display()))->Trigger()";
328 button = new TButton("Trigger", but7, x0, y - dbutton, x1, y);
329 button->SetFillColor(38);
333 char but8[] = "((AliMUONDisplay*)(gAlice->Display()))->DrawReco()";
334 button = new TButton("Tracking", but8, x0, y - dbutton, x1, y);
335 button->SetFillColor(38);
339 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
340 diamond->SetFillColor(50);
341 diamond->SetTextAlign(22);
342 diamond->SetTextColor(5);
343 diamond->SetTextSize(0.11);
345 diamond->AddText(".. ");
346 diamond->AddText("ROOT");
347 diamond->AddText("MUON");
348 diamond->AddText("... ");
349 diamond->AddText(" ");
352 //_____________________________________________________________________________
353 void AliMUONDisplay::CreateColors() const
355 // Create the colors palette used to display clusters
370 new TColor(color,r,g,b);
380 new TColor(color,r,g,b);
390 new TColor(color,r,g,b);
400 new TColor(color,r,g,b);
410 new TColor(color,r,g,b);
417 //_____________________________________________________________________________
418 void AliMUONDisplay::DisplayColorScale()
420 // Display pulse height color scale
423 Float_t xlow, ylow, xup, yup, hs;
424 Float_t x1, y1, x2, y2;
428 TText *text = new TText(0,0,"");
429 text->SetTextFont(61);
430 text->SetTextSize(0.2);
431 text->SetTextAlign(22);
434 Int_t adcmax=4096; // default 12 bits ADC
440 //*-* draw colortable boxes
441 hs = (y2-y1)/Float_t(22);
445 ylow = y1 + hs*(Float_t(i));
446 yup = y1 + hs*(Float_t(i+1));
448 Double_t logscale=Double_t(i+1)*(TMath::Log(adcmax)/22);
449 Int_t scale=(Int_t)TMath::Exp(logscale);
450 sprintf(label,"%d",scale);
451 box = new TBox(xlow, ylow, xup, yup);
453 box->SetFillColor(color);
454 text->DrawText(xlow+0.7, 0.5*(ylow+yup),label);
458 //______________________________________________________________________________
459 Int_t AliMUONDisplay::DistancetoPrimitive(Int_t px, Int_t)
461 // Compute distance from point px,py to objects in event
463 gPad->SetCursor(kCross);
465 if (gPad == fTrigPad) return 9999;
467 const Int_t kBig = 9999;
469 Float_t xmin = gPad->GetX1();
470 Float_t xmax = gPad->GetX2();
471 Float_t dx = 0.02*(xmax - xmin);
472 Float_t x = gPad->AbsPixeltoX(px);
473 if (x < xmin+dx || x > xmax-dx) return dist;
475 if (fZoomMode) return 0;
479 //_____________________________________________________________________________
480 void AliMUONDisplay::Draw(Option_t *)
482 // Display current event
490 //_____________________________________________________________________________
491 void AliMUONDisplay::DrawChamber()
494 fDrawTracks = kFALSE;
496 DrawView(fTheta, fPhi, fPsi);
497 // Display the event number and title
502 //_____________________________________________________________________________
503 void AliMUONDisplay::DrawReco(Option_t *)
505 // Display current event
508 // print kinematics of generated particles
510 // Draw global view of muon system
512 DrawGlobalView(135, -50, -140);
514 // Display the event number and title
519 //_____________________________________________________________________________
520 void AliMUONDisplay::PrintKinematics()
522 AliRunLoader * runLoader;
523 TParticle *particle = new TParticle();
525 Float_t vertex[3], momentum[3];
528 runLoader = fLoader->GetRunLoader();
532 printf("****** Event # %d ******\n",runLoader->GetEventNumber());
533 runLoader->TreeK()->GetBranch("Particles")->SetAddress(&particle);
534 nPart = (Int_t)runLoader->TreeK()->GetEntries();
535 for(Int_t iPart = 0; iPart < nPart; iPart++) {
536 runLoader->TreeK()->GetEvent(iPart);
537 vertex[0] = particle->Vx();
538 vertex[1] = particle->Vy();
539 vertex[2] = particle->Vz();
540 momentum[0] = particle->Px();
541 momentum[1] = particle->Py();
542 momentum[2] = particle->Pz();
544 printf("===================================================\n");
545 printf(" Generated particle # %d \n",iPart);
546 printf(" name: %s \n",particle->GetName());
547 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
548 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
553 void AliMUONDisplay::DrawSegmentation()
555 // to be re-written for new seg
556 // Draw graphical representation of segmenatation
557 // Attention: still experimental code
560 // AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
561 // AliMUONChamber* iChamber;
563 // AliSegmentation* seg;
564 // iChamber = &(pMUON->Chamber(fChamber));
565 // seg=iChamber->SegmentationModel(icat);
567 // Float_t zpos=iChamber->Z();
568 // Float_t r=iChamber->ROuter();
570 // TMarker3DBox *marker;
572 // for (Int_t j=0; j<seg->Npy(); j++) {
574 // y0=j*seg->Dpy()-seg->Dpy()/2.;
575 // for (seg->FirstPad(0.,y0,0,300,0.);
579 // if (seg->ISector()==0) continue;
581 // seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
582 // Float_t dpx=seg->Dpx(seg->ISector())/2;
583 // Float_t dpy=seg->Dpy(seg->ISector())/2;
584 // marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
585 // marker->SetLineColor(seg->ISector()+1);
586 // marker->SetFillStyle(1001);
587 // marker->SetFillColor(0);
592 // for (Int_t j=0; j<250; j++) {
593 // Float_t x0=j*seg->Dpx();
594 // Float_t y0=TMath::Sqrt(r*r-x0*x0);
596 // for (seg->FirstPad(x0,0,0,0,y0);
600 // if (seg->ISector()==0) continue;
603 // seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
604 // Float_t dpx=seg->Dpx(seg->ISector())/2;
605 // Float_t dpy=seg->Dpy(seg->ISector())/2;
606 // marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
607 // marker->SetLineColor(seg->ISector()+1);
608 // marker->SetFillStyle(1001);
609 // marker->SetFillColor(0);
616 //_____________________________________________________________________________
617 void AliMUONDisplay::DrawClusters()
619 // Draw clusters for MUON chambers
621 Int_t ndigits, digit;
629 ndigits = points->GetEntriesFast();
630 for (digit=0;digit<ndigits;digit++){
631 pm = (AliMUONPoints*)points->UncheckedAt(digit);
635 for (Int_t im=0;im<3;im++) {
636 TMarker3DBox *marker=pm->GetMarker(im);
641 fClustersCuts += pm->GetN();
645 //_____________________________________________________________________________
646 void AliMUONDisplay::DrawHits()
648 // Draw hits for MUON chambers
652 Int_t ntracks, track;
659 ntracks = points->GetEntriesFast();
660 for (track=0;track<ntracks;track++) {
661 pm = (AliMUONPoints*)points->UncheckedAt(track);
664 fHitsCuts += pm->GetN();
669 //_____________________________________________________________________________
670 void AliMUONDisplay::DrawCoG()
672 // Draw hits for MUON chambers
673 if (!fDrawCoG) return;
674 if (fChamber > 10) return;
675 LoadCoG(fChamber,fCathode);
683 ncog = points->GetEntriesFast();
684 for (icog=0;icog<ncog;icog++) {
685 pm = (AliMUONPoints*)points->UncheckedAt(icog);
690 //_____________________________________________________________________________
691 void AliMUONDisplay::DrawTracks()
694 if (!fDrawTracks) return;
697 Int_t nTrack, iTrack;
703 nTrack = points->GetEntriesFast();
704 for ( iTrack = 0; iTrack < nTrack; iTrack++) {
705 pm = (TPolyLine3D*)points->UncheckedAt(iTrack);
710 //_____________________________________________________________________________
712 void AliMUONDisplay::DrawTitle(Option_t *option)
714 // Draw the event title
716 Float_t xmin = gPad->GetX1();
717 Float_t xmax = gPad->GetX2();
718 Float_t ymin = gPad->GetY1();
719 Float_t ymax = gPad->GetY2();
720 Float_t dx = xmax-xmin;
721 Float_t dy = ymax-ymin;
723 AliRunLoader * runLoader;
725 runLoader = fLoader->GetRunLoader();
730 if (strlen(option) == 0) {
731 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
732 // title->SetTextSize(0.023932);
733 title->SetTextSize(0.02);
734 title->SetBit(kCanDelete);
735 title->SetFillColor(42);
738 sprintf(ptitle, "Alice event:%d Run:%d Chamber:%d Cathode:%d",
739 runLoader->GetEventNumber(),
740 gAlice->GetHeader()->GetRun(),
743 title->AddText(ptitle);
744 Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast();
745 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
746 nparticles, fHitsCuts,fClustersCuts);
747 title->AddText(ptitle);
749 TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
750 label->SetBit(kCanDelete);
751 label->SetFillColor(42);
756 //_____________________________________________________________________________
757 void AliMUONDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
759 // Draw a view of MUON clusters
760 AliInfo(" Draw View");
762 gPad->SetCursor(kWatch);
763 // gPad->SetFillColor(39);
764 gPad->SetFillColor(1);
766 // gPad->SetFillColor(39);
767 gPad->SetFillColor(1);
771 TView *view = new TView(1);
773 Float_t range = fRrange*fRangeSlider->GetMaximum();
774 view->SetRange(-range,-range,-range,range, range, range);
775 // zoom back to full scale only if DrawView not called from NextCathode
783 // Recovering the chamber
784 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
785 AliMUONChamber* iChamber;
786 iChamber = &(pMUON->Chamber(fChamber-1));
788 // Display MUON Chamber Geometry
790 sprintf(nodeName,"MUON%d",100+fChamber);
791 printf(">>>> chamber is %d\n",fChamber);
794 // drawing inner circle
795 TPolyLine3D* poly1 = new TPolyLine3D();
797 for (Float_t d = 0; d < 6.3; d+= 0.1) {
798 Double_t x = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Cos(d)/2.;
799 Double_t y = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Sin(d)/2.;
800 poly1->SetPoint(nPoint++, x, y, 0.);
802 poly1->SetLineColor(2);
805 // drawing outer circle
806 TPolyLine3D* poly2 = new TPolyLine3D();
808 for (Float_t d = 0; d < 6.3; d+= 0.1) {
809 Double_t x = AliMUONConstants::Dmax((fChamber-1)/2) * TMath::Cos(d)/2.;
810 Double_t y = AliMUONConstants::Dmax((fChamber-1)/2) * TMath::Sin(d)/2.;
811 poly2->SetPoint(nPoint++, x, y, 0.);
813 poly2->SetLineColor(2);
818 if(fChamber >4 && fChamber <11) {
820 for(id=0; id<26; id++) {
821 Int_t detElemId = fChamber*100+id;
822 if ( AliMUONSegmentationManager::IsValidDetElemId(detElemId) ) {
823 AliMpSlatSegmentation * seg =
824 (AliMpSlatSegmentation *) AliMUONSegmentationManager::Segmentation(detElemId, kBendingPlane);
825 const AliMpSlat * slat = seg->Slat();
826 Float_t deltax = slat->DX()/10.;
827 Float_t deltay = slat->DY()/10.;
828 Float_t xlocal1 = -deltax;
829 Float_t ylocal1 = -deltay;
830 Float_t xlocal2 = +deltax;
831 Float_t ylocal2 = +deltay;
832 Float_t xg1, xg2, yg1, yg2, zg1, zg2;
833 iChamber->GetGeometry()->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
834 iChamber->GetGeometry()->Local2Global(detElemId, xlocal2, ylocal2, 0, xg2, yg2, zg2);
836 // drawing slat active volumes
837 Float_t xCenter = (xg1 + xg2)/2.;
838 Float_t yCenter = (yg1 + yg2)/2.;
840 TMarker3DBox* box = new TMarker3DBox(xCenter,yCenter,0,xlocal1,ylocal2,0,0,0);
842 box->SetFillStyle(0);
843 box->SetLineColor(2);
846 // drawing inner circle + disc
847 TPolyLine3D* poly = new TPolyLine3D();
848 TPolyLine3D* poly1 = new TPolyLine3D();
852 for (Float_t d = 0; d < 6.24; d+= 0.005) {
853 Double_t x = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Cos(d)/2.;
854 Double_t y = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Sin(d)/2.;
855 if (nPoint % 2 == 0) poly->SetPoint(nPoint++, 0., 0., 0.);
856 poly->SetPoint(nPoint++, x, y, 0.);
857 poly1->SetPoint(nPoint1++, x, y, 0.);
860 poly->SetLineColor(1);
862 poly1->SetLineColor(2);
867 //add clusters to the pad
871 // DrawSegmentation();
872 // add itself to the list (must be last)
874 view->SetView(phi, theta, psi, iret);
877 //_____________________________________________________________________________
878 void AliMUONDisplay::DrawGlobalView(Float_t theta, Float_t phi, Float_t psi)
880 // Draw a view of muons chambers with tracks
882 gPad->SetCursor(kWatch);
883 // gPad->SetFillColor(39);
884 gPad->SetFillColor(1);
886 // gPad->SetFillColor(39);
887 gPad->SetFillColor(1);
891 TView *view = new TView(1);
893 Float_t range = fRrange*fRangeSlider->GetMaximum()*3.;
894 view->SetRange(-range,-range,-range,range,range,range);
896 // Display all MUON Chambers segmentation
899 sprintf(nodeName,"alice");
901 node1=gAlice->GetGeometry()->GetNode(nodeName);
902 if (node1) node1->Draw("same");
905 // Draw clusters for all chambers
906 Int_t chamberSave = fChamber;
907 for (fChamber = 1; fChamber <= 10; fChamber++){
910 fChamber = chamberSave;
911 // Draw reconstructed tracks
918 Float_t x0 = (-1+shift)/zoom;
919 Float_t y0 = (-1+shift)/zoom;
920 Float_t x1 = (1+shift)/zoom;
921 Float_t y1 = (1+shift)/zoom;
922 gPad->Range(x0,y0,x1,y1);
923 view->SetView(phi, theta, psi, iret);
927 //______________________________________________________________________________
928 void AliMUONDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
930 // Execute action corresponding to the mouse event
932 static Float_t x0, y0, x1, y1;
934 static Int_t pxold, pyold;
935 static Int_t px0, py0;
936 static Int_t linedrawn;
939 if (px == 0 && py == 0) { //when called by sliders
940 if (event == kButton1Up) {
945 if (!fZoomMode && gPad->GetView()) {
946 gPad->GetView()->ExecuteRotateView(event, px, py);
950 // something to zoom ?
951 gPad->SetCursor(kCross);
956 gVirtualX->SetLineColor(-1);
957 gPad->TAttLine::Modify(); //Change line attributes only if necessary
958 x0 = gPad->AbsPixeltoX(px);
959 y0 = gPad->AbsPixeltoY(py);
961 pxold = px; pyold = py;
966 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
970 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
974 gPad->GetCanvas()->FeedbackMode(kFALSE);
975 if (px == px0) return;
976 if (py == py0) return;
977 x1 = gPad->AbsPixeltoX(px);
978 y1 = gPad->AbsPixeltoY(py);
980 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
981 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
982 gPad->Range(x0,y0,x1,y1);
983 if (fZooms < AliMUONConstants::MaxZoom()-1) {
985 fZoomX0[fZooms] = x0;
986 fZoomY0[fZooms] = y0;
987 fZoomX1[fZooms] = x1;
988 fZoomY1[fZooms] = y1;
990 gPad->Modified(kTRUE);
995 //___________________________________________
996 void AliMUONDisplay::LoadDigits(Int_t chamber, Int_t cathode)
998 // Read digits info and store x,y,z info in arrays fPoints
999 // Loop on all detectors
1001 if (chamber > 14) return;
1007 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1008 AliMUONChamber* iChamber;
1009 AliMUONGeometrySegmentation* segmentation2 = 0x0;
1011 GetMUONData()->SetTreeAddress("D");
1013 TClonesArray *muonDigits = GetMUONData()->Digits(chamber-1);
1014 if (muonDigits == 0) return;
1016 gAlice->ResetDigits();
1019 if (GetLoader()->TreeD()) {
1020 nent = (Int_t) GetLoader()->TreeD()->GetEntries();
1021 // gAlice->TreeD()->GetEvent(nent-2+cathode-1);
1022 GetMUONData()->GetDigits();
1025 Int_t ndigits = muonDigits->GetEntriesFast();
1026 if (ndigits == 0) return;
1027 if (fPoints == 0) fPoints = new TObjArray(ndigits);
1029 iChamber = &(pMUON->Chamber(chamber-1));
1031 segmentation2 = iChamber->SegmentationModel2(cathode);
1033 Float_t zpos = iChamber->Z();
1036 AliMUONPoints *points = 0;
1037 TMarker3DBox *marker = 0;
1039 //loop over all digits and store their position
1042 Float_t adcmax = 1024; // default
1043 if (chamber<11) adcmax = 4096;
1045 for (Int_t digit = 0; digit < ndigits; digit++) {
1046 mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
1047 if (mdig->Cathode() != cathode-1) continue;
1050 // First get all needed parameters
1052 Int_t charge = mdig->Signal();
1053 Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
1054 Int_t color = 261+index;
1055 Int_t colorTrigger = 2;
1056 if (color > 282) color = 282;
1058 if (chamber > 10) { // trigger chamber
1060 Int_t sumCharge = 0;
1061 for (Int_t icharge = 0; icharge < 10; icharge++) {
1062 sumCharge = sumCharge+mdig->TrackCharge(icharge);
1064 Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10;
1065 if(sumCharge <= 10 || testCharge > 0) {
1066 colorTrigger = color;
1072 // get the center of the pad - add on x and y half of pad size
1073 Float_t xpad, ypad, zpad;
1077 Int_t detElemId = mdig->DetElemId();
1078 segmentation2->GetPadC(detElemId, mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
1079 isec = segmentation2->Sector(detElemId, mdig->PadX(), mdig->PadY());
1080 dpx = segmentation2->Dpx(detElemId, isec)/2;
1081 dpy = segmentation2->Dpy(detElemId, isec)/2;
1083 // segmentation->Dump();
1086 // Then set the objects
1088 points = new AliMUONPoints(npoints);
1089 fPoints->AddAt(points,digit);
1091 points->SetMarkerColor(colorTrigger);
1093 points->SetMarkerColor(color);
1095 points->SetMarkerStyle(21);
1096 points->SetMarkerSize(0.5);
1097 points->SetParticle(-1);
1098 points->SetHitIndex(-1);
1099 points->SetTrackIndex(-1);
1100 points->SetDigitIndex(digit);
1101 points->SetPoint(0,xpad,ypad,zpos);
1103 Int_t lineColor = (zpad-zpos > 0) ? 2:3;
1104 marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0);
1107 marker->SetLineColor(lineColor);
1108 marker->SetFillStyle(1001);
1109 marker->SetFillColor(color);
1110 marker->SetRefObject((TObject*)points);
1111 points->Set3DMarker(0, marker);
1114 //___________________________________________
1115 void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/)
1117 // Read raw clusters info and store x,y,z info in arrays fRpoints
1118 // Loop on all detectors
1120 if (chamber > 10) return;
1124 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1125 AliMUONChamber* iChamber;
1127 GetMUONData()->SetTreeAddress("RC");
1128 TClonesArray *muonRawClusters = GetMUONData()->RawClusters(chamber-1);
1130 if (muonRawClusters == 0) return;
1133 if (GetMUONData()->TreeR()) {
1134 nent=(Int_t) GetMUONData()->TreeR()->GetEntries();
1135 GetMUONData()->TreeR()->GetEvent(0);
1138 Int_t nrawcl = muonRawClusters->GetEntriesFast();
1139 if (nrawcl == 0) return;
1140 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
1142 iChamber = &(pMUON->Chamber(chamber-1));
1143 Float_t zpos=iChamber->Z();
1144 AliMUONRawCluster *mRaw;
1145 AliMUONPoints *points = 0;
1147 //loop over all raw clusters and store their position
1148 points = new AliMUONPoints(nrawcl);
1149 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
1150 mRaw = (AliMUONRawCluster*)muonRawClusters->UncheckedAt(iraw);
1151 points->SetMarkerColor(51);
1152 points->SetMarkerStyle(2);
1153 points->SetMarkerSize(1.);
1154 points->SetParticle(-1);
1155 points->SetHitIndex(-1);
1156 points->SetTrackIndex(-1);
1157 points->SetDigitIndex(-1);
1158 points->SetPoint(iraw,mRaw->GetX(0),mRaw->GetY(0),zpos);
1159 fRpoints->AddAt(points,iraw);
1160 // printf("%f and %f and %f\n",mRaw->GetX(0),mRaw->GetY(0),mRaw->GetZ(0));
1164 //___________________________________________
1165 void AliMUONDisplay::LoadTracks()
1168 AliMUONTrack* recTrack = 0;
1169 AliMUONTrackParam* trackParam = 0;
1170 TClonesArray * trackParamAtHit = 0;
1174 GetMUONData()->SetTreeAddress("RT");
1175 TClonesArray* recTracksArray = GetMUONData()->RecTracks();
1176 if (recTracksArray == NULL) return;
1177 GetMUONData()->GetRecTracks();
1179 Int_t nRecTracks = 0;
1181 nRecTracks = (Int_t) recTracksArray->GetEntriesFast();
1184 if (fRpoints == 0) fRpoints = new TObjArray(nRecTracks);
1186 for (Int_t iRecTracks = 0; iRecTracks < nRecTracks; iRecTracks++) {
1187 // reading info from tracks
1188 recTrack = (AliMUONTrack*) recTracksArray->At(iRecTracks);
1190 Int_t nTrackHits = recTrack->GetNTrackHits();
1192 if (nTrackHits == 0) continue;
1195 TPolyLine3D *points = new TPolyLine3D(nTrackHits+1);
1196 points->SetLineColor(6);
1197 points->SetLineWidth(1);
1198 fRpoints->AddAt(points,iRecTracks);
1204 trackParam = recTrack->GetTrackParamAtVertex();
1205 xRec = trackParam->GetNonBendingCoor();
1206 yRec = trackParam->GetBendingCoor();
1207 zRec = trackParam->GetZ();
1208 points->SetPoint(iPoint,xRec,yRec,zRec);
1211 for (Int_t iHit = 0; iHit < nTrackHits; iHit++){
1212 trackParamAtHit = recTrack->GetTrackParamAtHit();
1213 trackParam = (AliMUONTrackParam*) trackParamAtHit->At(iHit);
1214 xRec = trackParam->GetNonBendingCoor();
1215 yRec = trackParam->GetBendingCoor();
1216 zRec = trackParam->GetZ();
1217 points->SetPoint(iPoint,xRec,yRec,zRec);
1219 } // end loop rec. hits
1220 PrintTrack(iRecTracks,recTrack);
1221 } // end loop tracks
1226 void AliMUONDisplay::PrintTrack(Int_t iRecTracks, AliMUONTrack *recTrack)
1228 AliMUONTrackParam *trackParam;
1229 Float_t vertex[3], momentum[3];
1230 Float_t pYZ, bendingSlope, nonBendingSlope, chi2dof;
1233 trackParam = recTrack->GetTrackParamAtVertex();
1234 vertex[0] = trackParam->GetNonBendingCoor();
1235 vertex[1] = trackParam->GetBendingCoor();
1236 vertex[2] = trackParam->GetZ();
1237 pYZ = 1./TMath::Abs(trackParam->GetInverseBendingMomentum());
1238 bendingSlope = trackParam->GetBendingSlope();
1239 nonBendingSlope = trackParam->GetNonBendingSlope();
1240 momentum[2] = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);
1241 momentum[0] = momentum[2] * nonBendingSlope;
1242 momentum[1] = momentum[2] * bendingSlope;
1243 charge = Int_t(TMath::Sign(1.,trackParam->GetInverseBendingMomentum()));
1244 chi2dof = recTrack->GetFitFMin()/(2.0 * recTrack->GetNTrackHits() - 5.);
1246 printf("===================================================\n");
1247 printf(" Reconstructed track # %d \n",iRecTracks);
1248 printf(" charge: %d \n",charge);
1249 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
1250 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
1251 printf(" track chi2/dof: %f \n",chi2dof);
1255 //___________________________________________
1256 void AliMUONDisplay::LoadHits(Int_t chamber)
1258 // Read hits info and store x,y,z info in arrays fPhits
1259 // Loop on all detectors
1261 if (chamber > 14) return;
1268 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1269 AliMUONChamber* iChamber;
1271 iChamber = &(pMUON->Chamber(chamber-1));
1272 Float_t zpos=iChamber->Z();
1275 if (GetMUONData()->TreeH()) {
1276 GetMUONData()->SetTreeAddress("H");
1277 Int_t ntracks = (Int_t)GetMUONData()->TreeH()->GetEntries(); //skowron
1279 for (track = 0; track < ntracks; track++) {
1280 GetMUONData()->ResetHits();
1281 GetMUONData()->GetTrack(track);//skowron
1282 TClonesArray *muonHits = GetMUONData()->Hits();
1283 if (muonHits == 0) return;
1284 nthits += muonHits->GetEntriesFast();
1286 if (fPhits == 0) fPhits = new TObjArray(nthits);
1288 for (track=0; track<ntracks;track++) {
1289 GetMUONData()->ResetHits();
1290 GetMUONData()->GetTrack(track);//skowron
1291 TClonesArray *muonHits = GetMUONData()->Hits();
1292 if (muonHits == 0) return;
1293 Int_t nhits = muonHits->GetEntriesFast();
1294 if (nhits == 0) continue;
1296 AliMUONPoints *points = 0;
1298 for (Int_t hit=0;hit<nhits;hit++) {
1299 mHit = (AliMUONHit*)muonHits->UncheckedAt(hit);
1300 Int_t nch = mHit->Chamber(); // chamber number
1301 if (nch != chamber) continue;
1303 // Retrieve info and set the objects
1305 points = new AliMUONPoints(npoints);
1306 fPhits->AddAt(points,nhold+hit);
1307 points->SetMarkerColor(kRed);
1308 points->SetMarkerStyle(5);
1309 points->SetMarkerSize(1.);
1310 points->SetParticle(mHit->Track());
1311 points->SetHitIndex(hit);
1312 points->SetTrackIndex(track);
1313 points->SetDigitIndex(-1);
1314 points->SetPoint(0,mHit->X(),mHit->Y(),zpos);
1315 // printf("%f and %f and %f\n",mHit->X(),mHit->Y(),mHit->Z());
1322 //_____________________________________________________________________________
1323 void AliMUONDisplay::Paint(Option_t *)
1325 // Paint miscellaneous items
1328 //_____________________________________________________________________________
1329 void AliMUONDisplay::SetPickMode()
1331 // Set parameters for pick mode.
1335 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1336 fTrigPad->Modified();
1339 //_____________________________________________________________________________
1340 void AliMUONDisplay::SetZoomMode()
1342 // Set parameters for zoom mode
1345 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1346 fTrigPad->Modified();
1349 //_____________________________________________________________________________
1350 void AliMUONDisplay::NextChamber(Int_t delta)
1352 // to go from chamber to next chamber if delta = 1
1353 // or previous chamber otherwise
1355 if (fChamber < AliMUONConstants::NCh()) fChamber++;
1357 if (fChamber > 1) fChamber--;
1361 LoadDigits(fChamber, fCathode);
1365 //_____________________________________________________________________________
1366 void AliMUONDisplay::NextCathode()
1368 // to switch to other cathode plane
1371 if (fCathode == 1) {
1372 LoadDigits(fChamber, 2);
1374 LoadDigits(fChamber, 1);
1376 fNextCathode = kTRUE; // to keep the same zoom
1378 fNextCathode = kFALSE;
1379 TPad *pad = (TPad*)gPad->GetPadSave();
1380 pad->Range(fZoomX0[fZooms], fZoomY0[fZooms],
1381 fZoomX1[fZooms], fZoomY1[fZooms]);
1387 //_____________________________________________________________________________
1388 void AliMUONDisplay::Trigger()
1391 AliMUONGlobalTrigger* globalTrig;
1393 GetMUONData()->SetTreeAddress("GLT");
1394 GetMUONData()->GetTriggerD();
1396 globalTrig = (AliMUONGlobalTrigger*)GetMUONData()->GlobalTrigger()->UncheckedAt(0);
1397 if (globalTrig == 0) return;
1399 printf("===================================================\n");
1400 printf(" Global Trigger output Low pt High pt All\n");
1402 printf(" number of Single Plus :\t");
1403 printf("%i\t",globalTrig->SinglePlusLpt());
1404 printf("%i\t",globalTrig->SinglePlusHpt());
1405 printf("%i\t",globalTrig->SinglePlusApt());
1408 printf(" number of Single Minus :\t");
1409 printf("%i\t",globalTrig->SingleMinusLpt());
1410 printf("%i\t",globalTrig->SingleMinusHpt());
1411 printf("%i\t",globalTrig->SingleMinusApt());
1414 printf(" number of Single Undefined :\t");
1415 printf("%i\t",globalTrig->SingleUndefLpt());
1416 printf("%i\t",globalTrig->SingleUndefHpt());
1417 printf("%i\t",globalTrig->SingleUndefApt());
1420 printf(" number of UnlikeSign pair :\t");
1421 printf("%i\t",globalTrig->PairUnlikeLpt());
1422 printf("%i\t",globalTrig->PairUnlikeHpt());
1423 printf("%i\t",globalTrig->PairUnlikeApt());
1426 printf(" number of LikeSign pair :\t");
1427 printf("%i\t",globalTrig->PairLikeLpt());
1428 printf("%i\t",globalTrig->PairLikeHpt());
1429 printf("%i\t",globalTrig->PairLikeApt());
1431 printf("===================================================\n");
1435 // // returns Trigger Decision for current event
1436 // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(GetLoader(),1);
1438 // // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
1439 // AliMUONData* muonData = decision->GetMUONData();
1440 // muonData->SetTreeAddress("D");
1441 // decision->Trigger();
1443 //_____________________________________________________________________________
1444 void AliMUONDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1446 // Set chamber and cathode number
1452 LoadDigits(chamber,cathode);
1456 void AliMUONDisplay::SetEvent(Int_t newevent)
1459 gAlice->GetEvent(newevent);
1461 if (!gAlice->TreeD()) return;
1464 LoadDigits(fChamber,fCathode);
1468 //_____________________________________________________________________________
1469 void AliMUONDisplay::SetRange(Float_t rrange, Float_t zrange)
1471 // Set view range along R and Z
1480 //_____________________________________________________________________________
1481 void AliMUONDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1483 // change viewing angles for current event
1491 TView *view = gPad->GetView();
1492 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1497 //_____________________________________________________________________________
1498 void AliMUONDisplay::ShowNextEvent(Int_t delta)
1500 AliRunLoader * runLoader;
1502 runLoader = fLoader->GetRunLoader();
1506 // Display (current event_number + delta)
1507 // delta = 1 shown next event
1508 // delta = -1 show previous event
1510 //runLoader->CleanDetectors();
1511 //runLoader->CleanKinematics();
1512 Int_t currentEvent = runLoader->GetEventNumber();
1513 Int_t newEvent = currentEvent + delta;
1514 runLoader->GetEvent(newEvent);
1517 LoadDigits(fChamber, fCathode);
1522 //______________________________________________________________________________
1523 void AliMUONDisplay::UnZoom()
1526 if (fZooms <= 0) return;
1528 TPad *pad = (TPad*)gPad->GetPadSave();
1529 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1533 //_____________________________________________________________________________
1534 void AliMUONDisplay::ResetPoints()
1537 // Reset array of points
1545 //_____________________________________________________________________________
1546 void AliMUONDisplay::ResetPhits()
1549 // Reset array of points
1557 //_____________________________________________________________________________
1558 void AliMUONDisplay::ResetRpoints()
1561 // Reset array of points
1570 AliMUONDisplay & AliMUONDisplay::operator = (const AliMUONDisplay & rhs)
1572 // Protected assignement operator
1574 if (this == &rhs) return *this;
1576 AliFatal("Not implemented.");