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 //////////////////////////////////////////////////////////////////////////
26 #include "AliMUONDisplay.h"
28 #include "AliMUONPoints.h"
29 #include "AliMUONGlobalTrigger.h"
30 #include "AliMUONHit.h"
31 #include "AliMUONDigit.h"
32 #include "AliMUONRawCluster.h"
33 #include "AliMUONTrack.h"
34 #include "AliMUONTrackParam.h"
35 #include "AliMUONGeometryTransformer.h"
36 #include "AliMUONSegmentation.h"
37 #include "AliMUONGeometrySegmentation.h"
38 #include "AliMUONConstants.h"
40 #include "AliMpDEIterator.h"
41 #include "AliMpSegFactory.h"
42 #include "AliMpSlatSegmentation.h"
43 #include "AliMpSlat.h"
44 #include "AliMpSectorSegmentation.h"
45 #include "AliMpSector.h"
46 #include "AliMpTriggerSegmentation.h"
47 #include "AliMpTrigger.h"
52 #include "AliHeader.h"
59 #include <TPaveLabel.h>
60 #include <TPaveText.h>
65 #include <TVirtualX.h>
67 #include <TGeometry.h>
68 #include <TMarker3DBox.h>
69 #include <TParticle.h>
70 #include <TPolyLine3D.h>
75 ClassImp(AliMUONDisplay)
78 //_____________________________________________________________________________
79 AliMUONDisplay::AliMUONDisplay()
87 fNextCathode = kFALSE;
91 //_____________________________________________________________________________
92 AliMUONDisplay::AliMUONDisplay(Int_t size, AliLoader * loader)
95 // Create an event display object.
96 // A canvas named "edisplay" is created with a vertical size in pixels
98 // A QUICK Overview of the Event Display functions
99 // ===============================================
101 // The event display can ve invoked by executing the macro "display.C"
102 // A canvas like in the picture below will appear.
104 // On the left side of the canvas, the following buttons appear:
105 // *Next* to move to the next event
106 // *Previous* to move to the previous event
108 // *Pick* Select this option to be able to point on a track with the
109 // mouse. Once on the track, use the right button to select
110 // an action. For example, select SetMarkerAttributes to
111 // change the marker type/color/size for the track.
112 // *Zoom* Select this option (default) if you want to zoom.
113 // To zoom, simply select the selected area with the left button.
114 // *UnZoom* To revert to the previous picture size.
116 // slider R On the left side, the vertical slider can be used to
117 // set the default picture size.
119 // When you are in Zoom mode, you can click on the black part of the canvas
120 // to select special options with the right mouse button.
123 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
124 // When you are on a track, select the menu item "InspectParticle"
125 // to display the current particle attributes.
127 // You can activate the Root browser by selecting the Inspect menu
128 // in the canvas tool bar menu. Then select "Start Browser"
129 // This will open a new canvas with the browser. At this point, you may want
130 // to display some histograms (from the Trees). Go to the "File" menu
131 // of the browser and click on "New canvas".
132 // In the browser, click on item "ROOT files" in the left pane.
133 // Click on galice.root.
135 // Click on TPC for example
136 // Click on any variable (eg TPC.fX) to histogram the variable.
138 // If you are lost, you can click on HELP in any Root canvas or browser.
141 <img src="gif/AliMUONDisplay.gif">
148 gAlice->SetDisplay(this);
150 // Initialize display default parameters
152 // Set front view by default
159 fDrawClusters = kTRUE;
161 fDrawTracks = kFALSE;
170 // Create display canvas
172 if (ysize < 100) ysize = 750;
173 Int_t xsize = Int_t(size*830./ysize);
174 fCanvas = new TCanvas("Canvas", "MUON Display",14,47,xsize,ysize);
175 fCanvas->ToggleEventStatus();
177 // Create main display pad
178 fPad = new TPad("viewpad", "MUON display",0.15,0,0.9,1);
181 fPad->SetFillColor(30);
182 fPad->SetBorderSize(2);
187 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
189 fColPad->SetFillColor(17);
190 fColPad->SetBorderSize(2);
195 // Create user interface control pad
199 // Create Range and mode pad
202 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
205 fTrigPad->SetFillColor(22);
206 fTrigPad->SetBorderSize(2);
207 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
208 fRangeSlider->SetObject(this);
209 char pickmode[] = "gAlice->Display()->SetPickMode()";
211 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
212 fPickButton->SetFillColor(38);
214 char zoommode[] = "gAlice->Display()->SetZoomMode()";
215 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
216 fZoomButton->SetFillColor(38);
218 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
219 fArcButton->SetFillColor(kGreen);
221 char butUnzoom[] = "gAlice->Display()->UnZoom()";
222 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
223 button->SetFillColor(38);
225 AppendPad(); // append display object as last object to force selection
228 fTrigPad->SetEditable(kFALSE);
229 fButtons->SetEditable(kFALSE);
231 fNextCathode = kFALSE;
233 // initialize container
235 fMUONData = new AliMUONData(fLoader,"MUON","MUON");
240 AliMUONDisplay::AliMUONDisplay(const AliMUONDisplay & display)
241 : AliDisplay(display)
243 // Protected copy constructor
245 AliFatal("Not implemented.");
250 //_____________________________________________________________________________
251 AliMUONDisplay::~AliMUONDisplay()
253 // Delete space point structure
254 if (fPoints) fPoints->Delete();
258 if (fPhits) fPhits->Delete();
262 if (fRpoints) fRpoints->Delete();
267 //_____________________________________________________________________________
268 void AliMUONDisplay::Clear(Option_t *)
270 // Delete graphics temporary objects
273 //_____________________________________________________________________________
274 void AliMUONDisplay::DisplayButtons()
276 // Create the user interface buttons
279 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
281 fButtons->SetFillColor(38);
282 fButtons->SetBorderSize(2);
285 // Int_t butcolor = 33;
286 Float_t dbutton = 0.08;
293 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
294 button = new TButton("Event +", but1, x0, y - dbutton, x1, y);
295 button->SetFillColor(38);
299 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
300 button = new TButton("Event -", but2, x0, y - dbutton, x1, y);
301 button->SetFillColor(38);
305 char but3[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(1)";
306 button = new TButton("Chamber +", but3, x0, y - dbutton, x1, y);
307 button->SetFillColor(38);
311 char but4[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(-1)";
312 button = new TButton("Chamber -", but4, x0, y - dbutton, x1, y);
313 button->SetFillColor(38);
317 char but5[] = "((AliMUONDisplay*)(gAlice->Display()))->SetChamberAndCathode(1,1)";
318 button = new TButton("Chamber 1", but5, x0, y - dbutton, x1, y);
319 button->SetFillColor(38);
323 char but6[] = "((AliMUONDisplay*)(gAlice->Display()))->NextCathode()";
324 button = new TButton("Cathode <>", but6, x0, y - dbutton, x1, y);
325 button->SetFillColor(38);
329 char but7[] = "((AliMUONDisplay*)(gAlice->Display()))->Trigger()";
330 button = new TButton("Trigger", but7, x0, y - dbutton, x1, y);
331 button->SetFillColor(38);
335 char but8[] = "((AliMUONDisplay*)(gAlice->Display()))->DrawReco()";
336 button = new TButton("Tracking", but8, x0, y - dbutton, x1, y);
337 button->SetFillColor(38);
341 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
342 diamond->SetFillColor(50);
343 diamond->SetTextAlign(22);
344 diamond->SetTextColor(5);
345 diamond->SetTextSize(0.11);
347 diamond->AddText(".. ");
348 diamond->AddText("ROOT");
349 diamond->AddText("MUON");
350 diamond->AddText("... ");
351 diamond->AddText(" ");
354 //_____________________________________________________________________________
355 void AliMUONDisplay::CreateColors() const
357 // Create the colors palette used to display clusters
372 new TColor(color,r,g,b);
382 new TColor(color,r,g,b);
392 new TColor(color,r,g,b);
402 new TColor(color,r,g,b);
412 new TColor(color,r,g,b);
419 //_____________________________________________________________________________
420 void AliMUONDisplay::DisplayColorScale()
422 // Display pulse height color scale
425 Float_t xlow, ylow, xup, yup, hs;
426 Float_t x1, y1, x2, y2;
430 TText *text = new TText(0,0,"");
431 text->SetTextFont(61);
432 text->SetTextSize(0.2);
433 text->SetTextAlign(22);
436 Int_t adcmax=4096; // default 12 bits ADC
442 //*-* draw colortable boxes
443 hs = (y2-y1)/Float_t(22);
447 ylow = y1 + hs*(Float_t(i));
448 yup = y1 + hs*(Float_t(i+1));
450 Double_t logscale=Double_t(i+1)*(TMath::Log(adcmax)/22);
451 Int_t scale=(Int_t)TMath::Exp(logscale);
452 sprintf(label,"%d",scale);
453 box = new TBox(xlow, ylow, xup, yup);
455 box->SetFillColor(color);
456 text->DrawText(xlow+0.7, 0.5*(ylow+yup),label);
460 //______________________________________________________________________________
461 Int_t AliMUONDisplay::DistancetoPrimitive(Int_t px, Int_t)
463 // Compute distance from point px,py to objects in event
465 gPad->SetCursor(kCross);
467 if (gPad == fTrigPad) return 9999;
469 const Int_t kBig = 9999;
471 Float_t xmin = gPad->GetX1();
472 Float_t xmax = gPad->GetX2();
473 Float_t dx = 0.02*(xmax - xmin);
474 Float_t x = gPad->AbsPixeltoX(px);
475 if (x < xmin+dx || x > xmax-dx) return dist;
477 if (fZoomMode) return 0;
481 //_____________________________________________________________________________
482 void AliMUONDisplay::Draw(Option_t *)
484 // Display current event
492 //_____________________________________________________________________________
493 void AliMUONDisplay::DrawChamber()
496 fDrawTracks = kFALSE;
498 DrawView(fTheta, fPhi, fPsi);
499 // Display the event number and title
504 //_____________________________________________________________________________
505 void AliMUONDisplay::DrawReco(Option_t *)
507 // Display current event
510 // print kinematics of generated particles
512 // Draw global view of muon system
514 DrawGlobalView(135, -50, -140);
516 // Display the event number and title
521 //_____________________________________________________________________________
522 void AliMUONDisplay::PrintKinematics()
524 AliRunLoader * runLoader;
525 TParticle *particle = new TParticle();
527 Float_t vertex[3], momentum[3];
530 runLoader = fLoader->GetRunLoader();
534 printf("****** Event # %d ******\n",runLoader->GetEventNumber());
535 runLoader->TreeK()->GetBranch("Particles")->SetAddress(&particle);
536 nPart = (Int_t)runLoader->TreeK()->GetEntries();
537 for(Int_t iPart = 0; iPart < nPart; iPart++) {
538 runLoader->TreeK()->GetEvent(iPart);
539 vertex[0] = particle->Vx();
540 vertex[1] = particle->Vy();
541 vertex[2] = particle->Vz();
542 momentum[0] = particle->Px();
543 momentum[1] = particle->Py();
544 momentum[2] = particle->Pz();
546 printf("===================================================\n");
547 printf(" Generated particle # %d \n",iPart);
548 printf(" name: %s \n",particle->GetName());
549 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
550 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
555 void AliMUONDisplay::DrawSegmentation()
557 // to be re-written for new seg
558 // Draw graphical representation of segmenatation
559 // Attention: still experimental code
562 // AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
563 // AliMUONChamber* iChamber;
565 // AliSegmentation* seg;
566 // iChamber = &(pMUON->Chamber(fChamber));
567 // seg=iChamber->SegmentationModel(icat);
569 // Float_t zpos=iChamber->Z();
570 // Float_t r=iChamber->ROuter();
572 // TMarker3DBox *marker;
574 // for (Int_t j=0; j<seg->Npy(); j++) {
576 // y0=j*seg->Dpy()-seg->Dpy()/2.;
577 // for (seg->FirstPad(0.,y0,0,300,0.);
581 // if (seg->ISector()==0) continue;
583 // seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
584 // Float_t dpx=seg->Dpx(seg->ISector())/2;
585 // Float_t dpy=seg->Dpy(seg->ISector())/2;
586 // marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
587 // marker->SetLineColor(seg->ISector()+1);
588 // marker->SetFillStyle(1001);
589 // marker->SetFillColor(0);
594 // for (Int_t j=0; j<250; j++) {
595 // Float_t x0=j*seg->Dpx();
596 // Float_t y0=TMath::Sqrt(r*r-x0*x0);
598 // for (seg->FirstPad(x0,0,0,0,y0);
602 // if (seg->ISector()==0) continue;
605 // seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
606 // Float_t dpx=seg->Dpx(seg->ISector())/2;
607 // Float_t dpy=seg->Dpy(seg->ISector())/2;
608 // marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
609 // marker->SetLineColor(seg->ISector()+1);
610 // marker->SetFillStyle(1001);
611 // marker->SetFillColor(0);
618 //_____________________________________________________________________________
619 void AliMUONDisplay::DrawClusters()
621 // Draw clusters for MUON chambers
623 Int_t ndigits, digit;
631 ndigits = points->GetEntriesFast();
632 for (digit=0;digit<ndigits;digit++){
633 pm = (AliMUONPoints*)points->UncheckedAt(digit);
637 for (Int_t im=0;im<3;im++) {
638 TMarker3DBox *marker=pm->GetMarker(im);
643 fClustersCuts += pm->GetN();
647 //_____________________________________________________________________________
648 void AliMUONDisplay::DrawHits()
650 // Draw hits for MUON chambers
654 Int_t ntracks, track;
661 ntracks = points->GetEntriesFast();
662 for (track=0;track<ntracks;track++) {
663 pm = (AliMUONPoints*)points->UncheckedAt(track);
666 fHitsCuts += pm->GetN();
671 //_____________________________________________________________________________
672 void AliMUONDisplay::DrawCoG()
674 // Draw hits for MUON chambers
675 if (!fDrawCoG) return;
676 if (fChamber > 10) return;
677 LoadCoG(fChamber,fCathode);
685 ncog = points->GetEntriesFast();
686 for (icog=0;icog<ncog;icog++) {
687 pm = (AliMUONPoints*)points->UncheckedAt(icog);
692 //_____________________________________________________________________________
693 void AliMUONDisplay::DrawTracks()
696 if (!fDrawTracks) return;
699 Int_t nTrack, iTrack;
705 nTrack = points->GetEntriesFast();
706 for ( iTrack = 0; iTrack < nTrack; iTrack++) {
707 pm = (TPolyLine3D*)points->UncheckedAt(iTrack);
712 //_____________________________________________________________________________
714 void AliMUONDisplay::DrawTitle(Option_t *option)
716 // Draw the event title
718 Float_t xmin = gPad->GetX1();
719 Float_t xmax = gPad->GetX2();
720 Float_t ymin = gPad->GetY1();
721 Float_t ymax = gPad->GetY2();
722 Float_t dx = xmax-xmin;
723 Float_t dy = ymax-ymin;
725 AliRunLoader * runLoader;
727 runLoader = fLoader->GetRunLoader();
732 if (strlen(option) == 0) {
733 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
734 // title->SetTextSize(0.023932);
735 title->SetTextSize(0.02);
736 title->SetBit(kCanDelete);
737 title->SetFillColor(42);
740 sprintf(ptitle, "Alice event:%d Run:%d Chamber:%d Cathode:%d",
741 runLoader->GetEventNumber(),
742 gAlice->GetHeader()->GetRun(),
745 title->AddText(ptitle);
746 Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast();
747 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
748 nparticles, fHitsCuts,fClustersCuts);
749 title->AddText(ptitle);
751 TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
752 label->SetBit(kCanDelete);
753 label->SetFillColor(42);
758 //_____________________________________________________________________________
759 void AliMUONDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
761 // Draw a view of MUON clusters
762 AliInfo(" Draw View");
764 gPad->SetCursor(kWatch);
765 // gPad->SetFillColor(39);
766 gPad->SetFillColor(1);
768 // gPad->SetFillColor(39);
769 gPad->SetFillColor(1);
773 TView *view = new TView(1);
775 Float_t range = fRrange*fRangeSlider->GetMaximum();
776 view->SetRange(-range,-range,-range,range, range, range);
777 // zoom back to full scale only if DrawView not called from NextCathode
786 Float_t xg1, xg2, yg1, yg2, zg1, zg2;
788 // Recovering the chamber
789 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
791 const AliMUONGeometryTransformer* kGeomTransformer
792 = pMUON->GetGeometryTransformer();
794 AliMUONSegmentation* segmentation = pMUON->GetSegmentation();
795 AliMpSegFactory segFactory;
796 // Mapping segmentation factory will be used only to create mapping
797 // segmentations if not present in the DE segmentations
799 // Display MUON Chamber Geometry
801 sprintf(nodeName,"MUON%d",100+fChamber);
802 printf(">>>> chamber is %d\n",fChamber);
806 for ( it.First(fChamber-1); ! it.IsDone(); it.Next() ) {
808 Int_t detElemId = it.CurrentDE();
809 AliMpSectorSegmentation * seg =
810 (AliMpSectorSegmentation *) segmentation->GetMpSegmentation(detElemId, 0);
811 const AliMpSector * sector = seg->GetSector();
813 // get sector measurements
814 TVector2 position = sector->Position();
815 TVector2 dimension = sector->Dimensions(); // half length
817 Float_t xlocal1 = position.Px(); // mm to cm
818 Float_t ylocal1 = position.Py();
819 Float_t xlocal2 = dimension.Px() * 2.;
820 Float_t ylocal2 = dimension.Px() * 2.;
822 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
823 kGeomTransformer->Local2Global(detElemId, xlocal2, ylocal2, 0, xg2, yg2, zg2);
826 TPolyLine3D* poly = new TPolyLine3D();
829 poly->SetPoint(nPoint++, xg1, yg1, 0.);
830 for (Float_t d = 0; d < TMath::Pi()/2.; d+= 0.01) {
831 Float_t x = xg1 + xg2 * TMath::Cos(d);
832 Float_t y = yg1 + yg2 * TMath::Sin(d);
833 poly->SetPoint(nPoint++, x, y, 0.);
835 poly->SetPoint(nPoint++, xg1, yg1, 0.);
837 poly->SetLineColor(2);
845 if(fChamber >4 && fChamber <11) {
847 for ( it.First(fChamber-1); ! it.IsDone(); it.Next() ) {
848 Int_t detElemId = it.CurrentDE();
849 if ( segmentation->HasDE(detElemId) ) {
850 AliMpSlatSegmentation * seg =
851 (AliMpSlatSegmentation *) segmentation->GetMpSegmentation(detElemId, 0);
853 // Create mapping segmentation if old trigger segmentation
854 // (not using mapping)
855 seg = (AliMpSlatSegmentation *)
856 segFactory.CreateMpSegmentation(detElemId, 0);
859 const AliMpSlat* slat = seg->Slat();
860 Float_t deltax = slat->DX();
861 Float_t deltay = slat->DY();
862 Float_t xlocal1 = -deltax;
863 Float_t ylocal1 = -deltay;
864 Float_t xlocal2 = +deltax;
865 Float_t ylocal2 = +deltay;
866 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
867 kGeomTransformer->Local2Global(detElemId, xlocal2, ylocal2, 0, xg2, yg2, zg2);
869 // drawing slat active volumes
870 Float_t xCenter = (xg1 + xg2)/2.;
871 Float_t yCenter = (yg1 + yg2)/2.;
873 TMarker3DBox* box = new TMarker3DBox(xCenter,yCenter,0,xlocal1,ylocal2,0,0,0);
875 box->SetFillStyle(0);
876 box->SetLineColor(2);
879 // drawing inner circle + disc
880 TPolyLine3D* poly = new TPolyLine3D();
881 TPolyLine3D* poly1 = new TPolyLine3D();
885 for (Float_t d = 0; d < 6.24; d+= 0.005) {
886 Double_t x = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Cos(d)/2.;
887 Double_t y = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Sin(d)/2.;
888 if (nPoint % 2 == 0) poly->SetPoint(nPoint++, 0., 0., 0.);
889 poly->SetPoint(nPoint++, x, y, 0.);
890 poly1->SetPoint(nPoint1++, x, y, 0.);
893 poly->SetLineColor(1);
895 poly1->SetLineColor(2);
902 /*-- Trigger Chambers ---------------------------------------*/
903 if(fChamber >10 && fChamber <15) {
905 for ( it.First(fChamber-1); ! it.IsDone(); it.Next() ) {
906 Int_t detElemId = it.CurrentDE();
907 AliMpTriggerSegmentation * seg
908 = (AliMpTriggerSegmentation *) segmentation->GetMpSegmentation(detElemId, 0);
910 // Create mapping segmentation if old trigger segmentation
911 // (not using mapping)
912 seg = (AliMpTriggerSegmentation *)
913 segFactory.CreateMpSegmentation(detElemId, 0);
916 const AliMpTrigger* slat = seg->Slat();
917 Float_t deltax = slat->DX();
918 Float_t deltay = slat->DY();
919 Float_t xlocal1 = -deltax;
920 Float_t ylocal1 = -deltay;
921 Float_t xlocal2 = +deltax;
922 Float_t ylocal2 = +deltay;
924 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
925 kGeomTransformer->Local2Global(detElemId, xlocal2, ylocal2, 0, xg2, yg2, zg2);
927 // drawing slat active volumes
928 Float_t xCenter = (xg1 + xg2)/2.;
929 Float_t yCenter = (yg1 + yg2)/2.;
931 TMarker3DBox* box = new TMarker3DBox(xCenter,yCenter,0,xlocal1,ylocal2,0,0,0);
933 box->SetFillStyle(0);
934 box->SetLineColor(4);
939 // Delete mapping segmentations created with factory
940 segFactory.DeleteSegmentations();
942 //add clusters to the pad
946 // DrawSegmentation();
947 // add itself to the list (must be last)
949 view->SetView(phi, theta, psi, iret);
952 //_____________________________________________________________________________
953 void AliMUONDisplay::DrawGlobalView(Float_t theta, Float_t phi, Float_t psi)
955 // Draw a view of muons chambers with tracks
957 gPad->SetCursor(kWatch);
958 // gPad->SetFillColor(39);
959 gPad->SetFillColor(1);
961 // gPad->SetFillColor(39);
962 gPad->SetFillColor(1);
966 TView *view = new TView(1);
968 Float_t range = fRrange*fRangeSlider->GetMaximum()*3.;
969 view->SetRange(-range,-range,-range,range,range,range);
971 // Display all MUON Chambers segmentation
974 sprintf(nodeName,"alice");
976 node1=gAlice->GetGeometry()->GetNode(nodeName);
977 if (node1) node1->Draw("same");
980 // Draw clusters for all chambers
981 Int_t chamberSave = fChamber;
982 for (fChamber = 1; fChamber <= 10; fChamber++){
985 fChamber = chamberSave;
986 // Draw reconstructed tracks
993 Float_t x0 = (-1+shift)/zoom;
994 Float_t y0 = (-1+shift)/zoom;
995 Float_t x1 = (1+shift)/zoom;
996 Float_t y1 = (1+shift)/zoom;
997 gPad->Range(x0,y0,x1,y1);
998 view->SetView(phi, theta, psi, iret);
1002 //______________________________________________________________________________
1003 void AliMUONDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
1005 // Execute action corresponding to the mouse event
1007 static Float_t x0, y0, x1, y1;
1009 static Int_t pxold, pyold;
1010 static Int_t px0, py0;
1011 static Int_t linedrawn;
1014 if (px == 0 && py == 0) { //when called by sliders
1015 if (event == kButton1Up) {
1020 if (!fZoomMode && gPad->GetView()) {
1021 gPad->GetView()->ExecuteRotateView(event, px, py);
1025 // something to zoom ?
1026 gPad->SetCursor(kCross);
1031 gVirtualX->SetLineColor(-1);
1032 gPad->TAttLine::Modify(); //Change line attributes only if necessary
1033 x0 = gPad->AbsPixeltoX(px);
1034 y0 = gPad->AbsPixeltoY(py);
1036 pxold = px; pyold = py;
1040 case kButton1Motion:
1041 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
1045 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
1049 gPad->GetCanvas()->FeedbackMode(kFALSE);
1050 if (px == px0) return;
1051 if (py == py0) return;
1052 x1 = gPad->AbsPixeltoX(px);
1053 y1 = gPad->AbsPixeltoY(py);
1055 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
1056 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
1057 gPad->Range(x0,y0,x1,y1);
1058 if (fZooms < AliMUONConstants::MaxZoom()-1) {
1060 fZoomX0[fZooms] = x0;
1061 fZoomY0[fZooms] = y0;
1062 fZoomX1[fZooms] = x1;
1063 fZoomY1[fZooms] = y1;
1065 gPad->Modified(kTRUE);
1070 //___________________________________________
1071 void AliMUONDisplay::LoadDigits(Int_t chamber, Int_t cathode)
1073 // Read digits info and store x,y,z info in arrays fPoints
1074 // Loop on all detectors
1076 if (chamber > 14) return;
1082 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1083 AliMUONGeometrySegmentation* segmentation2 = 0x0;
1085 GetMUONData()->SetTreeAddress("D");
1087 TClonesArray *muonDigits = GetMUONData()->Digits(chamber-1);
1088 if (muonDigits == 0) return;
1090 gAlice->ResetDigits();
1093 if (GetLoader()->TreeD()) {
1094 nent = (Int_t) GetLoader()->TreeD()->GetEntries();
1095 // gAlice->TreeD()->GetEvent(nent-2+cathode-1);
1096 GetMUONData()->GetDigits();
1099 Int_t ndigits = muonDigits->GetEntriesFast();
1100 if (ndigits == 0) return;
1101 if (fPoints == 0) fPoints = new TObjArray(ndigits);
1103 //segmentation2 = iChamber->SegmentationModel2(cathode);
1105 = pMUON->GetSegmentation()->GetModuleSegmentation(chamber-1, cathode-1);
1107 Float_t zpos = AliMUONConstants::DefaultChamberZ(chamber-1);
1110 AliMUONPoints *points = 0;
1111 TMarker3DBox *marker = 0;
1113 //loop over all digits and store their position
1116 Float_t adcmax = 1024; // default
1117 if (chamber<11) adcmax = 4096;
1119 for (Int_t digit = 0; digit < ndigits; digit++) {
1120 mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
1121 if (mdig->Cathode() != cathode-1) continue;
1124 // First get all needed parameters
1126 Int_t charge = mdig->Signal();
1127 Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
1128 Int_t color = 261+index;
1129 Int_t colorTrigger = 2;
1130 if (color > 282) color = 282;
1132 if (chamber > 10) { // trigger chamber
1134 Int_t sumCharge = 0;
1135 for (Int_t icharge = 0; icharge < 10; icharge++) {
1136 sumCharge = sumCharge+mdig->TrackCharge(icharge);
1138 Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10;
1139 if(sumCharge <= 10 || testCharge > 0) {
1140 colorTrigger = color;
1146 // get the center of the pad - add on x and y half of pad size
1147 Float_t xpad, ypad, zpad;
1151 Int_t detElemId = mdig->DetElemId();
1152 segmentation2->GetPadC(detElemId, mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
1153 isec = segmentation2->Sector(detElemId, mdig->PadX(), mdig->PadY());
1154 dpx = segmentation2->Dpx(detElemId, isec)/2;
1155 dpy = segmentation2->Dpy(detElemId, isec)/2;
1157 // segmentation->Dump();
1160 // Then set the objects
1162 points = new AliMUONPoints(npoints);
1163 fPoints->AddAt(points,digit);
1165 points->SetMarkerColor(colorTrigger);
1167 points->SetMarkerColor(color);
1169 points->SetMarkerStyle(21);
1170 points->SetMarkerSize(0.5);
1171 points->SetParticle(-1);
1172 points->SetHitIndex(-1);
1173 points->SetTrackIndex(-1);
1174 points->SetDigitIndex(digit);
1175 points->SetPoint(0,xpad,ypad,zpos);
1177 Int_t lineColor = (zpad-zpos > 0) ? 2:3;
1178 marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0);
1181 marker->SetLineColor(lineColor);
1182 marker->SetFillStyle(1001);
1183 marker->SetFillColor(color);
1184 marker->SetRefObject((TObject*)points);
1185 points->Set3DMarker(0, marker);
1188 //___________________________________________
1189 void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/)
1191 // Read raw clusters info and store x,y,z info in arrays fRpoints
1192 // Loop on all detectors
1194 if (chamber > 10) return;
1198 GetMUONData()->SetTreeAddress("RC");
1199 TClonesArray *muonRawClusters = GetMUONData()->RawClusters(chamber-1);
1201 if (muonRawClusters == 0) return;
1204 if (GetMUONData()->TreeR()) {
1205 nent=(Int_t) GetMUONData()->TreeR()->GetEntries();
1206 GetMUONData()->TreeR()->GetEvent(0);
1209 Int_t nrawcl = muonRawClusters->GetEntriesFast();
1210 if (nrawcl == 0) return;
1211 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
1213 Float_t zpos = AliMUONConstants::DefaultChamberZ(chamber-1);
1214 AliMUONRawCluster *mRaw;
1215 AliMUONPoints *points = 0;
1217 //loop over all raw clusters and store their position
1218 points = new AliMUONPoints(nrawcl);
1219 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
1220 mRaw = (AliMUONRawCluster*)muonRawClusters->UncheckedAt(iraw);
1221 points->SetMarkerColor(51);
1222 points->SetMarkerStyle(2);
1223 points->SetMarkerSize(1.);
1224 points->SetParticle(-1);
1225 points->SetHitIndex(-1);
1226 points->SetTrackIndex(-1);
1227 points->SetDigitIndex(-1);
1228 points->SetPoint(iraw,mRaw->GetX(0),mRaw->GetY(0),zpos);
1229 fRpoints->AddAt(points,iraw);
1230 // printf("%f and %f and %f\n",mRaw->GetX(0),mRaw->GetY(0),mRaw->GetZ(0));
1234 //___________________________________________
1235 void AliMUONDisplay::LoadTracks()
1238 AliMUONTrack* recTrack = 0;
1239 AliMUONTrackParam* trackParam = 0;
1240 TClonesArray * trackParamAtHit = 0;
1244 GetMUONData()->SetTreeAddress("RT");
1245 TClonesArray* recTracksArray = GetMUONData()->RecTracks();
1246 if (recTracksArray == NULL) return;
1247 GetMUONData()->GetRecTracks();
1249 Int_t nRecTracks = 0;
1251 nRecTracks = (Int_t) recTracksArray->GetEntriesFast();
1254 if (fRpoints == 0) fRpoints = new TObjArray(nRecTracks);
1256 for (Int_t iRecTracks = 0; iRecTracks < nRecTracks; iRecTracks++) {
1257 // reading info from tracks
1258 recTrack = (AliMUONTrack*) recTracksArray->At(iRecTracks);
1260 Int_t nTrackHits = recTrack->GetNTrackHits();
1262 if (nTrackHits == 0) continue;
1265 TPolyLine3D *points = new TPolyLine3D(nTrackHits+1);
1266 points->SetLineColor(6);
1267 points->SetLineWidth(1);
1268 fRpoints->AddAt(points,iRecTracks);
1274 trackParam = recTrack->GetTrackParamAtVertex();
1275 xRec = trackParam->GetNonBendingCoor();
1276 yRec = trackParam->GetBendingCoor();
1277 zRec = trackParam->GetZ();
1278 points->SetPoint(iPoint,xRec,yRec,zRec);
1281 for (Int_t iHit = 0; iHit < nTrackHits; iHit++){
1282 trackParamAtHit = recTrack->GetTrackParamAtHit();
1283 trackParam = (AliMUONTrackParam*) trackParamAtHit->At(iHit);
1284 xRec = trackParam->GetNonBendingCoor();
1285 yRec = trackParam->GetBendingCoor();
1286 zRec = trackParam->GetZ();
1287 points->SetPoint(iPoint,xRec,yRec,zRec);
1289 } // end loop rec. hits
1290 PrintTrack(iRecTracks,recTrack);
1291 } // end loop tracks
1296 void AliMUONDisplay::PrintTrack(Int_t iRecTracks, AliMUONTrack *recTrack)
1298 AliMUONTrackParam *trackParam;
1299 Float_t vertex[3], momentum[3];
1300 Float_t pYZ, bendingSlope, nonBendingSlope, chi2dof;
1303 trackParam = recTrack->GetTrackParamAtVertex();
1304 vertex[0] = trackParam->GetNonBendingCoor();
1305 vertex[1] = trackParam->GetBendingCoor();
1306 vertex[2] = trackParam->GetZ();
1307 pYZ = 1./TMath::Abs(trackParam->GetInverseBendingMomentum());
1308 bendingSlope = trackParam->GetBendingSlope();
1309 nonBendingSlope = trackParam->GetNonBendingSlope();
1310 momentum[2] = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);
1311 momentum[0] = momentum[2] * nonBendingSlope;
1312 momentum[1] = momentum[2] * bendingSlope;
1313 charge = Int_t(TMath::Sign(1.,trackParam->GetInverseBendingMomentum()));
1314 chi2dof = recTrack->GetFitFMin()/(2.0 * recTrack->GetNTrackHits() - 5.);
1316 printf("===================================================\n");
1317 printf(" Reconstructed track # %d \n",iRecTracks);
1318 printf(" charge: %d \n",charge);
1319 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
1320 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
1321 printf(" track chi2/dof: %f \n",chi2dof);
1325 //___________________________________________
1326 void AliMUONDisplay::LoadHits(Int_t chamber)
1328 // Read hits info and store x,y,z info in arrays fPhits
1329 // Loop on all detectors
1331 if (chamber > 14) return;
1338 Float_t zpos=AliMUONConstants::DefaultChamberZ(chamber-1);
1340 if (GetMUONData()->TreeH()) {
1341 GetMUONData()->SetTreeAddress("H");
1342 Int_t ntracks = (Int_t)GetMUONData()->TreeH()->GetEntries(); //skowron
1344 for (track = 0; track < ntracks; track++) {
1345 GetMUONData()->ResetHits();
1346 GetMUONData()->GetTrack(track);//skowron
1347 TClonesArray *muonHits = GetMUONData()->Hits();
1348 if (muonHits == 0) return;
1349 nthits += muonHits->GetEntriesFast();
1351 if (fPhits == 0) fPhits = new TObjArray(nthits);
1353 for (track=0; track<ntracks;track++) {
1354 GetMUONData()->ResetHits();
1355 GetMUONData()->GetTrack(track);//skowron
1356 TClonesArray *muonHits = GetMUONData()->Hits();
1357 if (muonHits == 0) return;
1358 Int_t nhits = muonHits->GetEntriesFast();
1359 if (nhits == 0) continue;
1361 AliMUONPoints *points = 0;
1363 for (Int_t hit=0;hit<nhits;hit++) {
1364 mHit = (AliMUONHit*)muonHits->UncheckedAt(hit);
1365 Int_t nch = mHit->Chamber(); // chamber number
1366 if (nch != chamber) continue;
1368 // Retrieve info and set the objects
1370 points = new AliMUONPoints(npoints);
1371 fPhits->AddAt(points,nhold+hit);
1372 points->SetMarkerColor(kRed);
1373 points->SetMarkerStyle(5);
1374 points->SetMarkerSize(1.);
1375 points->SetParticle(mHit->Track());
1376 points->SetHitIndex(hit);
1377 points->SetTrackIndex(track);
1378 points->SetDigitIndex(-1);
1379 points->SetPoint(0,mHit->X(),mHit->Y(),zpos);
1380 // printf("%f and %f and %f\n",mHit->X(),mHit->Y(),mHit->Z());
1387 //_____________________________________________________________________________
1388 void AliMUONDisplay::Paint(Option_t *)
1390 // Paint miscellaneous items
1393 //_____________________________________________________________________________
1394 void AliMUONDisplay::SetPickMode()
1396 // Set parameters for pick mode.
1400 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1401 fTrigPad->Modified();
1404 //_____________________________________________________________________________
1405 void AliMUONDisplay::SetZoomMode()
1407 // Set parameters for zoom mode
1410 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1411 fTrigPad->Modified();
1414 //_____________________________________________________________________________
1415 void AliMUONDisplay::NextChamber(Int_t delta)
1417 // to go from chamber to next chamber if delta = 1
1418 // or previous chamber otherwise
1420 if (fChamber < AliMUONConstants::NCh()) fChamber++;
1422 if (fChamber > 1) fChamber--;
1426 LoadDigits(fChamber, fCathode);
1430 //_____________________________________________________________________________
1431 void AliMUONDisplay::NextCathode()
1433 // to switch to other cathode plane
1436 if (fCathode == 1) {
1437 LoadDigits(fChamber, 2);
1439 LoadDigits(fChamber, 1);
1441 fNextCathode = kTRUE; // to keep the same zoom
1443 fNextCathode = kFALSE;
1444 TPad *pad = (TPad*)gPad->GetPadSave();
1445 pad->Range(fZoomX0[fZooms], fZoomY0[fZooms],
1446 fZoomX1[fZooms], fZoomY1[fZooms]);
1452 //_____________________________________________________________________________
1453 void AliMUONDisplay::Trigger()
1456 AliMUONGlobalTrigger* globalTrig;
1458 GetMUONData()->SetTreeAddress("GLT");
1459 GetMUONData()->GetTriggerD();
1461 globalTrig = (AliMUONGlobalTrigger*)GetMUONData()->GlobalTrigger()->UncheckedAt(0);
1462 if (globalTrig == 0) return;
1464 printf("===================================================\n");
1465 printf(" Global Trigger output Low pt High pt All\n");
1467 printf(" number of Single Plus :\t");
1468 printf("%i\t",globalTrig->SinglePlusLpt());
1469 printf("%i\t",globalTrig->SinglePlusHpt());
1470 printf("%i\t",globalTrig->SinglePlusApt());
1473 printf(" number of Single Minus :\t");
1474 printf("%i\t",globalTrig->SingleMinusLpt());
1475 printf("%i\t",globalTrig->SingleMinusHpt());
1476 printf("%i\t",globalTrig->SingleMinusApt());
1479 printf(" number of Single Undefined :\t");
1480 printf("%i\t",globalTrig->SingleUndefLpt());
1481 printf("%i\t",globalTrig->SingleUndefHpt());
1482 printf("%i\t",globalTrig->SingleUndefApt());
1485 printf(" number of UnlikeSign pair :\t");
1486 printf("%i\t",globalTrig->PairUnlikeLpt());
1487 printf("%i\t",globalTrig->PairUnlikeHpt());
1488 printf("%i\t",globalTrig->PairUnlikeApt());
1491 printf(" number of LikeSign pair :\t");
1492 printf("%i\t",globalTrig->PairLikeLpt());
1493 printf("%i\t",globalTrig->PairLikeHpt());
1494 printf("%i\t",globalTrig->PairLikeApt());
1496 printf("===================================================\n");
1500 // // returns Trigger Decision for current event
1501 // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(GetLoader(),1);
1503 // // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
1504 // AliMUONData* muonData = decision->GetMUONData();
1505 // muonData->SetTreeAddress("D");
1506 // decision->Trigger();
1508 //_____________________________________________________________________________
1509 void AliMUONDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1511 // Set chamber and cathode number
1517 LoadDigits(chamber,cathode);
1521 void AliMUONDisplay::SetEvent(Int_t newevent)
1524 gAlice->GetEvent(newevent);
1526 if (!gAlice->TreeD()) return;
1529 LoadDigits(fChamber,fCathode);
1533 //_____________________________________________________________________________
1534 void AliMUONDisplay::SetRange(Float_t rrange, Float_t zrange)
1536 // Set view range along R and Z
1545 //_____________________________________________________________________________
1546 void AliMUONDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1548 // change viewing angles for current event
1556 TView *view = gPad->GetView();
1557 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1562 //_____________________________________________________________________________
1563 void AliMUONDisplay::ShowNextEvent(Int_t delta)
1565 AliRunLoader * runLoader;
1567 runLoader = fLoader->GetRunLoader();
1571 // Display (current event_number + delta)
1572 // delta = 1 shown next event
1573 // delta = -1 show previous event
1575 //runLoader->CleanDetectors();
1576 //runLoader->CleanKinematics();
1577 Int_t currentEvent = runLoader->GetEventNumber();
1578 Int_t newEvent = currentEvent + delta;
1579 runLoader->GetEvent(newEvent);
1582 LoadDigits(fChamber, fCathode);
1587 //______________________________________________________________________________
1588 void AliMUONDisplay::UnZoom()
1591 if (fZooms <= 0) return;
1593 TPad *pad = (TPad*)gPad->GetPadSave();
1594 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1598 //_____________________________________________________________________________
1599 void AliMUONDisplay::ResetPoints()
1602 // Reset array of points
1610 //_____________________________________________________________________________
1611 void AliMUONDisplay::ResetPhits()
1614 // Reset array of points
1622 //_____________________________________________________________________________
1623 void AliMUONDisplay::ResetRpoints()
1626 // Reset array of points
1635 AliMUONDisplay & AliMUONDisplay::operator = (const AliMUONDisplay & rhs)
1637 // Protected assignement operator
1639 if (this == &rhs) return *this;
1641 AliFatal("Not implemented.");