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"
62 #include "AliMpSectorSegmentation.h"
63 #include "AliMpSector.h"
65 #include "AliMUONGeometrySegmentation.h"
66 #include "AliMUONChamber.h"
67 #include "AliMUONConstants.h"
70 // to manage the same zoom on both cathodes
74 ClassImp(AliMUONDisplay)
77 //_____________________________________________________________________________
78 AliMUONDisplay::AliMUONDisplay()
86 fNextCathode = kFALSE;
90 //_____________________________________________________________________________
91 AliMUONDisplay::AliMUONDisplay(Int_t size, AliLoader * loader)
94 // Create an event display object.
95 // A canvas named "edisplay" is created with a vertical size in pixels
97 // A QUICK Overview of the Event Display functions
98 // ===============================================
100 // The event display can ve invoked by executing the macro "display.C"
101 // A canvas like in the picture below will appear.
103 // On the left side of the canvas, the following buttons appear:
104 // *Next* to move to the next event
105 // *Previous* to move to the previous event
107 // *Pick* Select this option to be able to point on a track with the
108 // mouse. Once on the track, use the right button to select
109 // an action. For example, select SetMarkerAttributes to
110 // change the marker type/color/size for the track.
111 // *Zoom* Select this option (default) if you want to zoom.
112 // To zoom, simply select the selected area with the left button.
113 // *UnZoom* To revert to the previous picture size.
115 // slider R On the left side, the vertical slider can be used to
116 // set the default picture size.
118 // When you are in Zoom mode, you can click on the black part of the canvas
119 // to select special options with the right mouse button.
122 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
123 // When you are on a track, select the menu item "InspectParticle"
124 // to display the current particle attributes.
126 // You can activate the Root browser by selecting the Inspect menu
127 // in the canvas tool bar menu. Then select "Start Browser"
128 // This will open a new canvas with the browser. At this point, you may want
129 // to display some histograms (from the Trees). Go to the "File" menu
130 // of the browser and click on "New canvas".
131 // In the browser, click on item "ROOT files" in the left pane.
132 // Click on galice.root.
134 // Click on TPC for example
135 // Click on any variable (eg TPC.fX) to histogram the variable.
137 // If you are lost, you can click on HELP in any Root canvas or browser.
140 <img src="gif/AliMUONDisplay.gif">
147 gAlice->SetDisplay(this);
149 // Initialize display default parameters
151 // Set front view by default
158 fDrawClusters = kTRUE;
160 fDrawTracks = kFALSE;
169 // Create display canvas
171 if (ysize < 100) ysize = 750;
172 Int_t xsize = Int_t(size*830./ysize);
173 fCanvas = new TCanvas("Canvas", "MUON Display",14,47,xsize,ysize);
174 fCanvas->ToggleEventStatus();
176 // Create main display pad
177 fPad = new TPad("viewpad", "MUON display",0.15,0,0.9,1);
180 fPad->SetFillColor(30);
181 fPad->SetBorderSize(2);
186 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
188 fColPad->SetFillColor(17);
189 fColPad->SetBorderSize(2);
194 // Create user interface control pad
198 // Create Range and mode pad
201 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
204 fTrigPad->SetFillColor(22);
205 fTrigPad->SetBorderSize(2);
206 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
207 fRangeSlider->SetObject(this);
208 char pickmode[] = "gAlice->Display()->SetPickMode()";
210 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
211 fPickButton->SetFillColor(38);
213 char zoommode[] = "gAlice->Display()->SetZoomMode()";
214 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
215 fZoomButton->SetFillColor(38);
217 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
218 fArcButton->SetFillColor(kGreen);
220 char butUnzoom[] = "gAlice->Display()->UnZoom()";
221 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
222 button->SetFillColor(38);
224 AppendPad(); // append display object as last object to force selection
227 fTrigPad->SetEditable(kFALSE);
228 fButtons->SetEditable(kFALSE);
230 fNextCathode = kFALSE;
232 // initialize container
234 fMUONData = new AliMUONData(fLoader,"MUON","MUON");
239 AliMUONDisplay::AliMUONDisplay(const AliMUONDisplay & display)
240 : AliDisplay(display)
242 // Protected copy constructor
244 AliFatal("Not implemented.");
249 //_____________________________________________________________________________
250 AliMUONDisplay::~AliMUONDisplay()
252 // Delete space point structure
253 if (fPoints) fPoints->Delete();
257 if (fPhits) fPhits->Delete();
261 if (fRpoints) fRpoints->Delete();
266 //_____________________________________________________________________________
267 void AliMUONDisplay::Clear(Option_t *)
269 // Delete graphics temporary objects
272 //_____________________________________________________________________________
273 void AliMUONDisplay::DisplayButtons()
275 // Create the user interface buttons
278 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
280 fButtons->SetFillColor(38);
281 fButtons->SetBorderSize(2);
284 // Int_t butcolor = 33;
285 Float_t dbutton = 0.08;
292 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
293 button = new TButton("Event +", but1, x0, y - dbutton, x1, y);
294 button->SetFillColor(38);
298 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
299 button = new TButton("Event -", but2, x0, y - dbutton, x1, y);
300 button->SetFillColor(38);
304 char but3[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(1)";
305 button = new TButton("Chamber +", but3, x0, y - dbutton, x1, y);
306 button->SetFillColor(38);
310 char but4[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(-1)";
311 button = new TButton("Chamber -", but4, x0, y - dbutton, x1, y);
312 button->SetFillColor(38);
316 char but5[] = "((AliMUONDisplay*)(gAlice->Display()))->SetChamberAndCathode(1,1)";
317 button = new TButton("Chamber 1", but5, x0, y - dbutton, x1, y);
318 button->SetFillColor(38);
322 char but6[] = "((AliMUONDisplay*)(gAlice->Display()))->NextCathode()";
323 button = new TButton("Cathode <>", but6, x0, y - dbutton, x1, y);
324 button->SetFillColor(38);
328 char but7[] = "((AliMUONDisplay*)(gAlice->Display()))->Trigger()";
329 button = new TButton("Trigger", but7, x0, y - dbutton, x1, y);
330 button->SetFillColor(38);
334 char but8[] = "((AliMUONDisplay*)(gAlice->Display()))->DrawReco()";
335 button = new TButton("Tracking", but8, x0, y - dbutton, x1, y);
336 button->SetFillColor(38);
340 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
341 diamond->SetFillColor(50);
342 diamond->SetTextAlign(22);
343 diamond->SetTextColor(5);
344 diamond->SetTextSize(0.11);
346 diamond->AddText(".. ");
347 diamond->AddText("ROOT");
348 diamond->AddText("MUON");
349 diamond->AddText("... ");
350 diamond->AddText(" ");
353 //_____________________________________________________________________________
354 void AliMUONDisplay::CreateColors() const
356 // Create the colors palette used to display clusters
371 new TColor(color,r,g,b);
381 new TColor(color,r,g,b);
391 new TColor(color,r,g,b);
401 new TColor(color,r,g,b);
411 new TColor(color,r,g,b);
418 //_____________________________________________________________________________
419 void AliMUONDisplay::DisplayColorScale()
421 // Display pulse height color scale
424 Float_t xlow, ylow, xup, yup, hs;
425 Float_t x1, y1, x2, y2;
429 TText *text = new TText(0,0,"");
430 text->SetTextFont(61);
431 text->SetTextSize(0.2);
432 text->SetTextAlign(22);
435 Int_t adcmax=4096; // default 12 bits ADC
441 //*-* draw colortable boxes
442 hs = (y2-y1)/Float_t(22);
446 ylow = y1 + hs*(Float_t(i));
447 yup = y1 + hs*(Float_t(i+1));
449 Double_t logscale=Double_t(i+1)*(TMath::Log(adcmax)/22);
450 Int_t scale=(Int_t)TMath::Exp(logscale);
451 sprintf(label,"%d",scale);
452 box = new TBox(xlow, ylow, xup, yup);
454 box->SetFillColor(color);
455 text->DrawText(xlow+0.7, 0.5*(ylow+yup),label);
459 //______________________________________________________________________________
460 Int_t AliMUONDisplay::DistancetoPrimitive(Int_t px, Int_t)
462 // Compute distance from point px,py to objects in event
464 gPad->SetCursor(kCross);
466 if (gPad == fTrigPad) return 9999;
468 const Int_t kBig = 9999;
470 Float_t xmin = gPad->GetX1();
471 Float_t xmax = gPad->GetX2();
472 Float_t dx = 0.02*(xmax - xmin);
473 Float_t x = gPad->AbsPixeltoX(px);
474 if (x < xmin+dx || x > xmax-dx) return dist;
476 if (fZoomMode) return 0;
480 //_____________________________________________________________________________
481 void AliMUONDisplay::Draw(Option_t *)
483 // Display current event
491 //_____________________________________________________________________________
492 void AliMUONDisplay::DrawChamber()
495 fDrawTracks = kFALSE;
497 DrawView(fTheta, fPhi, fPsi);
498 // Display the event number and title
503 //_____________________________________________________________________________
504 void AliMUONDisplay::DrawReco(Option_t *)
506 // Display current event
509 // print kinematics of generated particles
511 // Draw global view of muon system
513 DrawGlobalView(135, -50, -140);
515 // Display the event number and title
520 //_____________________________________________________________________________
521 void AliMUONDisplay::PrintKinematics()
523 AliRunLoader * runLoader;
524 TParticle *particle = new TParticle();
526 Float_t vertex[3], momentum[3];
529 runLoader = fLoader->GetRunLoader();
533 printf("****** Event # %d ******\n",runLoader->GetEventNumber());
534 runLoader->TreeK()->GetBranch("Particles")->SetAddress(&particle);
535 nPart = (Int_t)runLoader->TreeK()->GetEntries();
536 for(Int_t iPart = 0; iPart < nPart; iPart++) {
537 runLoader->TreeK()->GetEvent(iPart);
538 vertex[0] = particle->Vx();
539 vertex[1] = particle->Vy();
540 vertex[2] = particle->Vz();
541 momentum[0] = particle->Px();
542 momentum[1] = particle->Py();
543 momentum[2] = particle->Pz();
545 printf("===================================================\n");
546 printf(" Generated particle # %d \n",iPart);
547 printf(" name: %s \n",particle->GetName());
548 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
549 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
554 void AliMUONDisplay::DrawSegmentation()
556 // to be re-written for new seg
557 // Draw graphical representation of segmenatation
558 // Attention: still experimental code
561 // AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
562 // AliMUONChamber* iChamber;
564 // AliSegmentation* seg;
565 // iChamber = &(pMUON->Chamber(fChamber));
566 // seg=iChamber->SegmentationModel(icat);
568 // Float_t zpos=iChamber->Z();
569 // Float_t r=iChamber->ROuter();
571 // TMarker3DBox *marker;
573 // for (Int_t j=0; j<seg->Npy(); j++) {
575 // y0=j*seg->Dpy()-seg->Dpy()/2.;
576 // for (seg->FirstPad(0.,y0,0,300,0.);
580 // if (seg->ISector()==0) continue;
582 // seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
583 // Float_t dpx=seg->Dpx(seg->ISector())/2;
584 // Float_t dpy=seg->Dpy(seg->ISector())/2;
585 // marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
586 // marker->SetLineColor(seg->ISector()+1);
587 // marker->SetFillStyle(1001);
588 // marker->SetFillColor(0);
593 // for (Int_t j=0; j<250; j++) {
594 // Float_t x0=j*seg->Dpx();
595 // Float_t y0=TMath::Sqrt(r*r-x0*x0);
597 // for (seg->FirstPad(x0,0,0,0,y0);
601 // if (seg->ISector()==0) continue;
604 // seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
605 // Float_t dpx=seg->Dpx(seg->ISector())/2;
606 // Float_t dpy=seg->Dpy(seg->ISector())/2;
607 // marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
608 // marker->SetLineColor(seg->ISector()+1);
609 // marker->SetFillStyle(1001);
610 // marker->SetFillColor(0);
617 //_____________________________________________________________________________
618 void AliMUONDisplay::DrawClusters()
620 // Draw clusters for MUON chambers
622 Int_t ndigits, digit;
630 ndigits = points->GetEntriesFast();
631 for (digit=0;digit<ndigits;digit++){
632 pm = (AliMUONPoints*)points->UncheckedAt(digit);
636 for (Int_t im=0;im<3;im++) {
637 TMarker3DBox *marker=pm->GetMarker(im);
642 fClustersCuts += pm->GetN();
646 //_____________________________________________________________________________
647 void AliMUONDisplay::DrawHits()
649 // Draw hits for MUON chambers
653 Int_t ntracks, track;
660 ntracks = points->GetEntriesFast();
661 for (track=0;track<ntracks;track++) {
662 pm = (AliMUONPoints*)points->UncheckedAt(track);
665 fHitsCuts += pm->GetN();
670 //_____________________________________________________________________________
671 void AliMUONDisplay::DrawCoG()
673 // Draw hits for MUON chambers
674 if (!fDrawCoG) return;
675 if (fChamber > 10) return;
676 LoadCoG(fChamber,fCathode);
684 ncog = points->GetEntriesFast();
685 for (icog=0;icog<ncog;icog++) {
686 pm = (AliMUONPoints*)points->UncheckedAt(icog);
691 //_____________________________________________________________________________
692 void AliMUONDisplay::DrawTracks()
695 if (!fDrawTracks) return;
698 Int_t nTrack, iTrack;
704 nTrack = points->GetEntriesFast();
705 for ( iTrack = 0; iTrack < nTrack; iTrack++) {
706 pm = (TPolyLine3D*)points->UncheckedAt(iTrack);
711 //_____________________________________________________________________________
713 void AliMUONDisplay::DrawTitle(Option_t *option)
715 // Draw the event title
717 Float_t xmin = gPad->GetX1();
718 Float_t xmax = gPad->GetX2();
719 Float_t ymin = gPad->GetY1();
720 Float_t ymax = gPad->GetY2();
721 Float_t dx = xmax-xmin;
722 Float_t dy = ymax-ymin;
724 AliRunLoader * runLoader;
726 runLoader = fLoader->GetRunLoader();
731 if (strlen(option) == 0) {
732 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
733 // title->SetTextSize(0.023932);
734 title->SetTextSize(0.02);
735 title->SetBit(kCanDelete);
736 title->SetFillColor(42);
739 sprintf(ptitle, "Alice event:%d Run:%d Chamber:%d Cathode:%d",
740 runLoader->GetEventNumber(),
741 gAlice->GetHeader()->GetRun(),
744 title->AddText(ptitle);
745 Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast();
746 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
747 nparticles, fHitsCuts,fClustersCuts);
748 title->AddText(ptitle);
750 TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
751 label->SetBit(kCanDelete);
752 label->SetFillColor(42);
757 //_____________________________________________________________________________
758 void AliMUONDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
760 // Draw a view of MUON clusters
761 AliInfo(" Draw View");
763 gPad->SetCursor(kWatch);
764 // gPad->SetFillColor(39);
765 gPad->SetFillColor(1);
767 // gPad->SetFillColor(39);
768 gPad->SetFillColor(1);
772 TView *view = new TView(1);
774 Float_t range = fRrange*fRangeSlider->GetMaximum();
775 view->SetRange(-range,-range,-range,range, range, range);
776 // zoom back to full scale only if DrawView not called from NextCathode
785 Float_t xg1, xg2, yg1, yg2, zg1, zg2;
787 // Recovering the chamber
788 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
789 AliMUONChamber* iChamber;
790 iChamber = &(pMUON->Chamber(fChamber-1));
792 // Display MUON Chamber Geometry
794 sprintf(nodeName,"MUON%d",100+fChamber);
795 printf(">>>> chamber is %d\n",fChamber);
798 for(Int_t id = 0; id < 4; id++) {
800 Int_t detElemId = fChamber*100+id;
801 // if ( AliMUONSegmentationManager::IsValidDetElemId(detElemId) ) {
802 AliMpSectorSegmentation* seg =
803 (AliMpSectorSegmentation *) AliMUONSegmentationManager::Segmentation(detElemId, kBendingPlane);
804 const AliMpSector* sector = seg->GetSector();
806 // get sector measurements
807 TVector2 position = sector->Position();
808 TVector2 dimension = sector->Dimensions(); // half length
810 Float_t xlocal1 = position.Px(); // mm to cm
811 Float_t ylocal1 = position.Py();
812 Float_t xlocal2 = dimension.Px() * 2.;
813 Float_t ylocal2 = dimension.Px() * 2.;
815 iChamber->GetGeometry()->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
816 iChamber->GetGeometry()->Local2Global(detElemId, xlocal2, ylocal2, 0, xg2, yg2, zg2);
819 TPolyLine3D* poly = new TPolyLine3D();
822 poly->SetPoint(nPoint++, xg1, yg1, 0.);
823 for (Float_t d = 0; d < TMath::Pi()/2.; d+= 0.01) {
824 Float_t x = xg1 + xg2 * TMath::Cos(d);
825 Float_t y = yg1 + yg2 * TMath::Sin(d);
826 poly->SetPoint(nPoint++, x, y, 0.);
828 poly->SetPoint(nPoint++, xg1, yg1, 0.);
830 poly->SetLineColor(2);
838 if(fChamber >4 && fChamber <11) {
840 for(id=0; id<26; id++) {
841 Int_t detElemId = fChamber*100+id;
842 if ( AliMUONSegmentationManager::IsValidDetElemId(detElemId) ) {
843 AliMpSlatSegmentation * seg =
844 (AliMpSlatSegmentation *) AliMUONSegmentationManager::Segmentation(detElemId, kBendingPlane);
845 const AliMpSlat* slat = seg->Slat();
846 Float_t deltax = slat->DX();
847 Float_t deltay = slat->DY();
848 Float_t xlocal1 = -deltax;
849 Float_t ylocal1 = -deltay;
850 Float_t xlocal2 = +deltax;
851 Float_t ylocal2 = +deltay;
852 iChamber->GetGeometry()->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
853 iChamber->GetGeometry()->Local2Global(detElemId, xlocal2, ylocal2, 0, xg2, yg2, zg2);
855 // drawing slat active volumes
856 Float_t xCenter = (xg1 + xg2)/2.;
857 Float_t yCenter = (yg1 + yg2)/2.;
859 TMarker3DBox* box = new TMarker3DBox(xCenter,yCenter,0,xlocal1,ylocal2,0,0,0);
861 box->SetFillStyle(0);
862 box->SetLineColor(2);
865 // drawing inner circle + disc
866 TPolyLine3D* poly = new TPolyLine3D();
867 TPolyLine3D* poly1 = new TPolyLine3D();
871 for (Float_t d = 0; d < 6.24; d+= 0.005) {
872 Double_t x = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Cos(d)/2.;
873 Double_t y = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Sin(d)/2.;
874 if (nPoint % 2 == 0) poly->SetPoint(nPoint++, 0., 0., 0.);
875 poly->SetPoint(nPoint++, x, y, 0.);
876 poly1->SetPoint(nPoint1++, x, y, 0.);
879 poly->SetLineColor(1);
881 poly1->SetLineColor(2);
886 //add clusters to the pad
890 // DrawSegmentation();
891 // add itself to the list (must be last)
893 view->SetView(phi, theta, psi, iret);
896 //_____________________________________________________________________________
897 void AliMUONDisplay::DrawGlobalView(Float_t theta, Float_t phi, Float_t psi)
899 // Draw a view of muons chambers with tracks
901 gPad->SetCursor(kWatch);
902 // gPad->SetFillColor(39);
903 gPad->SetFillColor(1);
905 // gPad->SetFillColor(39);
906 gPad->SetFillColor(1);
910 TView *view = new TView(1);
912 Float_t range = fRrange*fRangeSlider->GetMaximum()*3.;
913 view->SetRange(-range,-range,-range,range,range,range);
915 // Display all MUON Chambers segmentation
918 sprintf(nodeName,"alice");
920 node1=gAlice->GetGeometry()->GetNode(nodeName);
921 if (node1) node1->Draw("same");
924 // Draw clusters for all chambers
925 Int_t chamberSave = fChamber;
926 for (fChamber = 1; fChamber <= 10; fChamber++){
929 fChamber = chamberSave;
930 // Draw reconstructed tracks
937 Float_t x0 = (-1+shift)/zoom;
938 Float_t y0 = (-1+shift)/zoom;
939 Float_t x1 = (1+shift)/zoom;
940 Float_t y1 = (1+shift)/zoom;
941 gPad->Range(x0,y0,x1,y1);
942 view->SetView(phi, theta, psi, iret);
946 //______________________________________________________________________________
947 void AliMUONDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
949 // Execute action corresponding to the mouse event
951 static Float_t x0, y0, x1, y1;
953 static Int_t pxold, pyold;
954 static Int_t px0, py0;
955 static Int_t linedrawn;
958 if (px == 0 && py == 0) { //when called by sliders
959 if (event == kButton1Up) {
964 if (!fZoomMode && gPad->GetView()) {
965 gPad->GetView()->ExecuteRotateView(event, px, py);
969 // something to zoom ?
970 gPad->SetCursor(kCross);
975 gVirtualX->SetLineColor(-1);
976 gPad->TAttLine::Modify(); //Change line attributes only if necessary
977 x0 = gPad->AbsPixeltoX(px);
978 y0 = gPad->AbsPixeltoY(py);
980 pxold = px; pyold = py;
985 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
989 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
993 gPad->GetCanvas()->FeedbackMode(kFALSE);
994 if (px == px0) return;
995 if (py == py0) return;
996 x1 = gPad->AbsPixeltoX(px);
997 y1 = gPad->AbsPixeltoY(py);
999 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
1000 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
1001 gPad->Range(x0,y0,x1,y1);
1002 if (fZooms < AliMUONConstants::MaxZoom()-1) {
1004 fZoomX0[fZooms] = x0;
1005 fZoomY0[fZooms] = y0;
1006 fZoomX1[fZooms] = x1;
1007 fZoomY1[fZooms] = y1;
1009 gPad->Modified(kTRUE);
1014 //___________________________________________
1015 void AliMUONDisplay::LoadDigits(Int_t chamber, Int_t cathode)
1017 // Read digits info and store x,y,z info in arrays fPoints
1018 // Loop on all detectors
1020 if (chamber > 14) return;
1026 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1027 AliMUONChamber* iChamber;
1028 AliMUONGeometrySegmentation* segmentation2 = 0x0;
1030 GetMUONData()->SetTreeAddress("D");
1032 TClonesArray *muonDigits = GetMUONData()->Digits(chamber-1);
1033 if (muonDigits == 0) return;
1035 gAlice->ResetDigits();
1038 if (GetLoader()->TreeD()) {
1039 nent = (Int_t) GetLoader()->TreeD()->GetEntries();
1040 // gAlice->TreeD()->GetEvent(nent-2+cathode-1);
1041 GetMUONData()->GetDigits();
1044 Int_t ndigits = muonDigits->GetEntriesFast();
1045 if (ndigits == 0) return;
1046 if (fPoints == 0) fPoints = new TObjArray(ndigits);
1048 iChamber = &(pMUON->Chamber(chamber-1));
1050 segmentation2 = iChamber->SegmentationModel2(cathode);
1052 Float_t zpos = iChamber->Z();
1055 AliMUONPoints *points = 0;
1056 TMarker3DBox *marker = 0;
1058 //loop over all digits and store their position
1061 Float_t adcmax = 1024; // default
1062 if (chamber<11) adcmax = 4096;
1064 for (Int_t digit = 0; digit < ndigits; digit++) {
1065 mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
1066 if (mdig->Cathode() != cathode-1) continue;
1069 // First get all needed parameters
1071 Int_t charge = mdig->Signal();
1072 Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
1073 Int_t color = 261+index;
1074 Int_t colorTrigger = 2;
1075 if (color > 282) color = 282;
1077 if (chamber > 10) { // trigger chamber
1079 Int_t sumCharge = 0;
1080 for (Int_t icharge = 0; icharge < 10; icharge++) {
1081 sumCharge = sumCharge+mdig->TrackCharge(icharge);
1083 Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10;
1084 if(sumCharge <= 10 || testCharge > 0) {
1085 colorTrigger = color;
1091 // get the center of the pad - add on x and y half of pad size
1092 Float_t xpad, ypad, zpad;
1096 Int_t detElemId = mdig->DetElemId();
1097 segmentation2->GetPadC(detElemId, mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
1098 isec = segmentation2->Sector(detElemId, mdig->PadX(), mdig->PadY());
1099 dpx = segmentation2->Dpx(detElemId, isec)/2;
1100 dpy = segmentation2->Dpy(detElemId, isec)/2;
1102 // segmentation->Dump();
1105 // Then set the objects
1107 points = new AliMUONPoints(npoints);
1108 fPoints->AddAt(points,digit);
1110 points->SetMarkerColor(colorTrigger);
1112 points->SetMarkerColor(color);
1114 points->SetMarkerStyle(21);
1115 points->SetMarkerSize(0.5);
1116 points->SetParticle(-1);
1117 points->SetHitIndex(-1);
1118 points->SetTrackIndex(-1);
1119 points->SetDigitIndex(digit);
1120 points->SetPoint(0,xpad,ypad,zpos);
1122 Int_t lineColor = (zpad-zpos > 0) ? 2:3;
1123 marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0);
1126 marker->SetLineColor(lineColor);
1127 marker->SetFillStyle(1001);
1128 marker->SetFillColor(color);
1129 marker->SetRefObject((TObject*)points);
1130 points->Set3DMarker(0, marker);
1133 //___________________________________________
1134 void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/)
1136 // Read raw clusters info and store x,y,z info in arrays fRpoints
1137 // Loop on all detectors
1139 if (chamber > 10) return;
1143 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1144 AliMUONChamber* iChamber;
1146 GetMUONData()->SetTreeAddress("RC");
1147 TClonesArray *muonRawClusters = GetMUONData()->RawClusters(chamber-1);
1149 if (muonRawClusters == 0) return;
1152 if (GetMUONData()->TreeR()) {
1153 nent=(Int_t) GetMUONData()->TreeR()->GetEntries();
1154 GetMUONData()->TreeR()->GetEvent(0);
1157 Int_t nrawcl = muonRawClusters->GetEntriesFast();
1158 if (nrawcl == 0) return;
1159 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
1161 iChamber = &(pMUON->Chamber(chamber-1));
1162 Float_t zpos=iChamber->Z();
1163 AliMUONRawCluster *mRaw;
1164 AliMUONPoints *points = 0;
1166 //loop over all raw clusters and store their position
1167 points = new AliMUONPoints(nrawcl);
1168 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
1169 mRaw = (AliMUONRawCluster*)muonRawClusters->UncheckedAt(iraw);
1170 points->SetMarkerColor(51);
1171 points->SetMarkerStyle(2);
1172 points->SetMarkerSize(1.);
1173 points->SetParticle(-1);
1174 points->SetHitIndex(-1);
1175 points->SetTrackIndex(-1);
1176 points->SetDigitIndex(-1);
1177 points->SetPoint(iraw,mRaw->GetX(0),mRaw->GetY(0),zpos);
1178 fRpoints->AddAt(points,iraw);
1179 // printf("%f and %f and %f\n",mRaw->GetX(0),mRaw->GetY(0),mRaw->GetZ(0));
1183 //___________________________________________
1184 void AliMUONDisplay::LoadTracks()
1187 AliMUONTrack* recTrack = 0;
1188 AliMUONTrackParam* trackParam = 0;
1189 TClonesArray * trackParamAtHit = 0;
1193 GetMUONData()->SetTreeAddress("RT");
1194 TClonesArray* recTracksArray = GetMUONData()->RecTracks();
1195 if (recTracksArray == NULL) return;
1196 GetMUONData()->GetRecTracks();
1198 Int_t nRecTracks = 0;
1200 nRecTracks = (Int_t) recTracksArray->GetEntriesFast();
1203 if (fRpoints == 0) fRpoints = new TObjArray(nRecTracks);
1205 for (Int_t iRecTracks = 0; iRecTracks < nRecTracks; iRecTracks++) {
1206 // reading info from tracks
1207 recTrack = (AliMUONTrack*) recTracksArray->At(iRecTracks);
1209 Int_t nTrackHits = recTrack->GetNTrackHits();
1211 if (nTrackHits == 0) continue;
1214 TPolyLine3D *points = new TPolyLine3D(nTrackHits+1);
1215 points->SetLineColor(6);
1216 points->SetLineWidth(1);
1217 fRpoints->AddAt(points,iRecTracks);
1223 trackParam = recTrack->GetTrackParamAtVertex();
1224 xRec = trackParam->GetNonBendingCoor();
1225 yRec = trackParam->GetBendingCoor();
1226 zRec = trackParam->GetZ();
1227 points->SetPoint(iPoint,xRec,yRec,zRec);
1230 for (Int_t iHit = 0; iHit < nTrackHits; iHit++){
1231 trackParamAtHit = recTrack->GetTrackParamAtHit();
1232 trackParam = (AliMUONTrackParam*) trackParamAtHit->At(iHit);
1233 xRec = trackParam->GetNonBendingCoor();
1234 yRec = trackParam->GetBendingCoor();
1235 zRec = trackParam->GetZ();
1236 points->SetPoint(iPoint,xRec,yRec,zRec);
1238 } // end loop rec. hits
1239 PrintTrack(iRecTracks,recTrack);
1240 } // end loop tracks
1245 void AliMUONDisplay::PrintTrack(Int_t iRecTracks, AliMUONTrack *recTrack)
1247 AliMUONTrackParam *trackParam;
1248 Float_t vertex[3], momentum[3];
1249 Float_t pYZ, bendingSlope, nonBendingSlope, chi2dof;
1252 trackParam = recTrack->GetTrackParamAtVertex();
1253 vertex[0] = trackParam->GetNonBendingCoor();
1254 vertex[1] = trackParam->GetBendingCoor();
1255 vertex[2] = trackParam->GetZ();
1256 pYZ = 1./TMath::Abs(trackParam->GetInverseBendingMomentum());
1257 bendingSlope = trackParam->GetBendingSlope();
1258 nonBendingSlope = trackParam->GetNonBendingSlope();
1259 momentum[2] = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);
1260 momentum[0] = momentum[2] * nonBendingSlope;
1261 momentum[1] = momentum[2] * bendingSlope;
1262 charge = Int_t(TMath::Sign(1.,trackParam->GetInverseBendingMomentum()));
1263 chi2dof = recTrack->GetFitFMin()/(2.0 * recTrack->GetNTrackHits() - 5.);
1265 printf("===================================================\n");
1266 printf(" Reconstructed track # %d \n",iRecTracks);
1267 printf(" charge: %d \n",charge);
1268 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
1269 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
1270 printf(" track chi2/dof: %f \n",chi2dof);
1274 //___________________________________________
1275 void AliMUONDisplay::LoadHits(Int_t chamber)
1277 // Read hits info and store x,y,z info in arrays fPhits
1278 // Loop on all detectors
1280 if (chamber > 14) return;
1287 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1288 AliMUONChamber* iChamber;
1290 iChamber = &(pMUON->Chamber(chamber-1));
1291 Float_t zpos=iChamber->Z();
1294 if (GetMUONData()->TreeH()) {
1295 GetMUONData()->SetTreeAddress("H");
1296 Int_t ntracks = (Int_t)GetMUONData()->TreeH()->GetEntries(); //skowron
1298 for (track = 0; track < ntracks; track++) {
1299 GetMUONData()->ResetHits();
1300 GetMUONData()->GetTrack(track);//skowron
1301 TClonesArray *muonHits = GetMUONData()->Hits();
1302 if (muonHits == 0) return;
1303 nthits += muonHits->GetEntriesFast();
1305 if (fPhits == 0) fPhits = new TObjArray(nthits);
1307 for (track=0; track<ntracks;track++) {
1308 GetMUONData()->ResetHits();
1309 GetMUONData()->GetTrack(track);//skowron
1310 TClonesArray *muonHits = GetMUONData()->Hits();
1311 if (muonHits == 0) return;
1312 Int_t nhits = muonHits->GetEntriesFast();
1313 if (nhits == 0) continue;
1315 AliMUONPoints *points = 0;
1317 for (Int_t hit=0;hit<nhits;hit++) {
1318 mHit = (AliMUONHit*)muonHits->UncheckedAt(hit);
1319 Int_t nch = mHit->Chamber(); // chamber number
1320 if (nch != chamber) continue;
1322 // Retrieve info and set the objects
1324 points = new AliMUONPoints(npoints);
1325 fPhits->AddAt(points,nhold+hit);
1326 points->SetMarkerColor(kRed);
1327 points->SetMarkerStyle(5);
1328 points->SetMarkerSize(1.);
1329 points->SetParticle(mHit->Track());
1330 points->SetHitIndex(hit);
1331 points->SetTrackIndex(track);
1332 points->SetDigitIndex(-1);
1333 points->SetPoint(0,mHit->X(),mHit->Y(),zpos);
1334 // printf("%f and %f and %f\n",mHit->X(),mHit->Y(),mHit->Z());
1341 //_____________________________________________________________________________
1342 void AliMUONDisplay::Paint(Option_t *)
1344 // Paint miscellaneous items
1347 //_____________________________________________________________________________
1348 void AliMUONDisplay::SetPickMode()
1350 // Set parameters for pick mode.
1354 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1355 fTrigPad->Modified();
1358 //_____________________________________________________________________________
1359 void AliMUONDisplay::SetZoomMode()
1361 // Set parameters for zoom mode
1364 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1365 fTrigPad->Modified();
1368 //_____________________________________________________________________________
1369 void AliMUONDisplay::NextChamber(Int_t delta)
1371 // to go from chamber to next chamber if delta = 1
1372 // or previous chamber otherwise
1374 if (fChamber < AliMUONConstants::NCh()) fChamber++;
1376 if (fChamber > 1) fChamber--;
1380 LoadDigits(fChamber, fCathode);
1384 //_____________________________________________________________________________
1385 void AliMUONDisplay::NextCathode()
1387 // to switch to other cathode plane
1390 if (fCathode == 1) {
1391 LoadDigits(fChamber, 2);
1393 LoadDigits(fChamber, 1);
1395 fNextCathode = kTRUE; // to keep the same zoom
1397 fNextCathode = kFALSE;
1398 TPad *pad = (TPad*)gPad->GetPadSave();
1399 pad->Range(fZoomX0[fZooms], fZoomY0[fZooms],
1400 fZoomX1[fZooms], fZoomY1[fZooms]);
1406 //_____________________________________________________________________________
1407 void AliMUONDisplay::Trigger()
1410 AliMUONGlobalTrigger* globalTrig;
1412 GetMUONData()->SetTreeAddress("GLT");
1413 GetMUONData()->GetTriggerD();
1415 globalTrig = (AliMUONGlobalTrigger*)GetMUONData()->GlobalTrigger()->UncheckedAt(0);
1416 if (globalTrig == 0) return;
1418 printf("===================================================\n");
1419 printf(" Global Trigger output Low pt High pt All\n");
1421 printf(" number of Single Plus :\t");
1422 printf("%i\t",globalTrig->SinglePlusLpt());
1423 printf("%i\t",globalTrig->SinglePlusHpt());
1424 printf("%i\t",globalTrig->SinglePlusApt());
1427 printf(" number of Single Minus :\t");
1428 printf("%i\t",globalTrig->SingleMinusLpt());
1429 printf("%i\t",globalTrig->SingleMinusHpt());
1430 printf("%i\t",globalTrig->SingleMinusApt());
1433 printf(" number of Single Undefined :\t");
1434 printf("%i\t",globalTrig->SingleUndefLpt());
1435 printf("%i\t",globalTrig->SingleUndefHpt());
1436 printf("%i\t",globalTrig->SingleUndefApt());
1439 printf(" number of UnlikeSign pair :\t");
1440 printf("%i\t",globalTrig->PairUnlikeLpt());
1441 printf("%i\t",globalTrig->PairUnlikeHpt());
1442 printf("%i\t",globalTrig->PairUnlikeApt());
1445 printf(" number of LikeSign pair :\t");
1446 printf("%i\t",globalTrig->PairLikeLpt());
1447 printf("%i\t",globalTrig->PairLikeHpt());
1448 printf("%i\t",globalTrig->PairLikeApt());
1450 printf("===================================================\n");
1454 // // returns Trigger Decision for current event
1455 // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(GetLoader(),1);
1457 // // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
1458 // AliMUONData* muonData = decision->GetMUONData();
1459 // muonData->SetTreeAddress("D");
1460 // decision->Trigger();
1462 //_____________________________________________________________________________
1463 void AliMUONDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1465 // Set chamber and cathode number
1471 LoadDigits(chamber,cathode);
1475 void AliMUONDisplay::SetEvent(Int_t newevent)
1478 gAlice->GetEvent(newevent);
1480 if (!gAlice->TreeD()) return;
1483 LoadDigits(fChamber,fCathode);
1487 //_____________________________________________________________________________
1488 void AliMUONDisplay::SetRange(Float_t rrange, Float_t zrange)
1490 // Set view range along R and Z
1499 //_____________________________________________________________________________
1500 void AliMUONDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1502 // change viewing angles for current event
1510 TView *view = gPad->GetView();
1511 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1516 //_____________________________________________________________________________
1517 void AliMUONDisplay::ShowNextEvent(Int_t delta)
1519 AliRunLoader * runLoader;
1521 runLoader = fLoader->GetRunLoader();
1525 // Display (current event_number + delta)
1526 // delta = 1 shown next event
1527 // delta = -1 show previous event
1529 //runLoader->CleanDetectors();
1530 //runLoader->CleanKinematics();
1531 Int_t currentEvent = runLoader->GetEventNumber();
1532 Int_t newEvent = currentEvent + delta;
1533 runLoader->GetEvent(newEvent);
1536 LoadDigits(fChamber, fCathode);
1541 //______________________________________________________________________________
1542 void AliMUONDisplay::UnZoom()
1545 if (fZooms <= 0) return;
1547 TPad *pad = (TPad*)gPad->GetPadSave();
1548 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1552 //_____________________________________________________________________________
1553 void AliMUONDisplay::ResetPoints()
1556 // Reset array of points
1564 //_____________________________________________________________________________
1565 void AliMUONDisplay::ResetPhits()
1568 // Reset array of points
1576 //_____________________________________________________________________________
1577 void AliMUONDisplay::ResetRpoints()
1580 // Reset array of points
1589 AliMUONDisplay & AliMUONDisplay::operator = (const AliMUONDisplay & rhs)
1591 // Protected assignement operator
1593 if (this == &rhs) return *this;
1595 AliFatal("Not implemented.");