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 /// \class AliMUONDisplay
19 /// Create an event display object.
20 /// A canvas named "edisplay" is created with a vertical size in pixels \n
22 /// A QUICK Overview of the Event Display functions \n
23 /// =============================================== \n
25 /// The event display can ve invoked by executing the macro "display.C" \n
26 /// A canvas like in the picture below will appear.
28 /// On the left side of the canvas, the following buttons appear:
29 /// - *Next* to move to the next event
30 /// - *Previous* to move to the previous event
31 /// - *Pick* Select this option to be able to point on a track with the
32 /// mouse. Once on the track, use the right button to select
33 /// an action. For example, select SetMarkerAttributes to
34 /// change the marker type/color/size for the track.
35 /// - *Zoom* Select this option (default) if you want to zoom.
36 /// To zoom, simply select the selected area with the left button.
37 /// - *UnZoom* To revert to the previous picture size.
39 /// - slider R On the left side, the vertical slider can be used to
40 /// set the default picture size.
42 /// When you are in Zoom mode, you can click on the black part of the canvas
43 /// to select special options with the right mouse button.
45 /// When you are in pick mode, you can "Inspect" the object pointed by the mouse.
46 /// When you are on a track, select the menu item "InspectParticle"
47 /// to display the current particle attributes.
49 /// You can activate the Root browser by selecting the Inspect menu
50 /// in the canvas tool bar menu. Then select "Start Browser"
51 /// This will open a new canvas with the browser. At this point, you may want
52 /// to display some histograms (from the Trees). Go to the "File" menu
53 /// of the browser and click on "New canvas".
54 /// In the browser, click on item "ROOT files" in the left pane.
55 /// Click on galice.root.
57 /// Click on TPC for example
58 /// Click on any variable (eg TPC.fX) to histogram the variable.
60 /// If you are lost, you can click on HELP in any Root canvas or browser.
64 <img src="gif/AliMUONDisplay.gif">
68 #include "AliMUONDisplay.h"
70 #include "AliMUONPoints.h"
71 #include "AliMUONGlobalTrigger.h"
72 #include "AliMUONHit.h"
73 #include "AliMUONDigit.h"
74 #include "AliMUONRawCluster.h"
75 #include "AliMUONTrack.h"
76 #include "AliMUONTrackParam.h"
77 #include "AliMUONGeometryTransformer.h"
78 #include "AliMUONSegmentation.h"
79 #include "AliMUONGeometrySegmentation.h"
80 #include "AliMUONConstants.h"
81 #include "AliMUONTriggerSegmentationV2.h"
83 #include "AliMpDEIterator.h"
84 #include "AliMpSegFactory.h"
85 #include "AliMpSlatSegmentation.h"
86 #include "AliMpSlat.h"
87 #include "AliMpSectorSegmentation.h"
88 #include "AliMpSector.h"
89 #include "AliMpTriggerSegmentation.h"
90 #include "AliMpTrigger.h"
91 #include "AliMpStationType.h"
92 #include "AliMpDEManager.h"
97 #include "AliHeader.h"
104 #include <TPaveLabel.h>
105 #include <TPaveText.h>
106 #include <TDiamond.h>
110 #include <TVirtualX.h>
112 #include <TGeometry.h>
113 #include <TMarker3DBox.h>
114 #include <TParticle.h>
115 #include <TPolyLine3D.h>
119 ClassImp(AliMUONDisplay)
122 //_____________________________________________________________________________
123 AliMUONDisplay::AliMUONDisplay()
128 fDrawClusters(kTRUE),
140 /// Default constructor
143 //_____________________________________________________________________________
144 AliMUONDisplay::AliMUONDisplay(Int_t size, AliLoader * loader)
149 fDrawClusters(kTRUE),
157 fNextCathode(kFALSE),
162 /// Standard constructor to create an event display object.
166 gAlice->SetDisplay(this);
168 // Initialize display default parameters
171 // Set front view by default
180 // Create display canvas
182 if (ysize < 100) ysize = 750;
183 Int_t xsize = Int_t(size*830./ysize);
184 fCanvas = new TCanvas("Canvas", "MUON Display",14,47,xsize,ysize);
185 fCanvas->ToggleEventStatus();
187 // Create main display pad
188 fPad = new TPad("viewpad", "MUON display",0.15,0,0.9,1);
191 fPad->SetFillColor(30);
192 fPad->SetBorderSize(2);
197 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
199 fColPad->SetFillColor(17);
200 fColPad->SetBorderSize(2);
205 // Create user interface control pad
209 // Create Range and mode pad
212 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
215 fTrigPad->SetFillColor(22);
216 fTrigPad->SetBorderSize(2);
217 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
218 fRangeSlider->SetObject(this);
219 char pickmode[] = "gAlice->Display()->SetPickMode()";
221 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
222 fPickButton->SetFillColor(38);
224 char zoommode[] = "gAlice->Display()->SetZoomMode()";
225 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
226 fZoomButton->SetFillColor(38);
228 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
229 fArcButton->SetFillColor(kGreen);
231 char butUnzoom[] = "gAlice->Display()->UnZoom()";
232 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
233 button->SetFillColor(38);
235 AppendPad(); // append display object as last object to force selection
238 fTrigPad->SetEditable(kFALSE);
239 fButtons->SetEditable(kFALSE);
242 // initialize container
244 fMUONData = new AliMUONData(fLoader,"MUON","MUON");
249 //_____________________________________________________________________________
250 AliMUONDisplay::~AliMUONDisplay()
254 // Delete space point structure
255 if (fPoints) fPoints->Delete();
259 if (fPhits) fPhits->Delete();
263 if (fRpoints) fRpoints->Delete();
268 //_____________________________________________________________________________
269 void AliMUONDisplay::Clear(Option_t *)
271 /// Delete graphics temporary objects
274 //_____________________________________________________________________________
275 void AliMUONDisplay::DisplayButtons()
277 /// Create the user interface buttons
280 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
282 fButtons->SetFillColor(38);
283 fButtons->SetBorderSize(2);
286 // Int_t butcolor = 33;
287 Float_t dbutton = 0.08;
294 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
295 button = new TButton("Event +", but1, x0, y - dbutton, x1, y);
296 button->SetFillColor(38);
300 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
301 button = new TButton("Event -", but2, x0, y - dbutton, x1, y);
302 button->SetFillColor(38);
306 char but3[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(1)";
307 button = new TButton("Chamber +", but3, x0, y - dbutton, x1, y);
308 button->SetFillColor(38);
312 char but4[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(-1)";
313 button = new TButton("Chamber -", but4, x0, y - dbutton, x1, y);
314 button->SetFillColor(38);
318 char but5[] = "((AliMUONDisplay*)(gAlice->Display()))->SetChamberAndCathode(1,1)";
319 button = new TButton("Chamber 1", but5, x0, y - dbutton, x1, y);
320 button->SetFillColor(38);
324 char but6[] = "((AliMUONDisplay*)(gAlice->Display()))->NextCathode()";
325 button = new TButton("Cathode <>", but6, x0, y - dbutton, x1, y);
326 button->SetFillColor(38);
330 char but7[] = "((AliMUONDisplay*)(gAlice->Display()))->Trigger()";
331 button = new TButton("Trigger", but7, x0, y - dbutton, x1, y);
332 button->SetFillColor(38);
336 char but8[] = "((AliMUONDisplay*)(gAlice->Display()))->DrawReco()";
337 button = new TButton("Tracking", but8, x0, y - dbutton, x1, y);
338 button->SetFillColor(38);
342 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
343 diamond->SetFillColor(50);
344 diamond->SetTextAlign(22);
345 diamond->SetTextColor(5);
346 diamond->SetTextSize(0.11);
348 diamond->AddText(".. ");
349 diamond->AddText("ROOT");
350 diamond->AddText("MUON");
351 diamond->AddText("... ");
352 diamond->AddText(" ");
355 //_____________________________________________________________________________
356 void AliMUONDisplay::CreateColors() const
358 /// Create the colors palette used to display clusters
373 new TColor(color,r,g,b);
383 new TColor(color,r,g,b);
393 new TColor(color,r,g,b);
403 new TColor(color,r,g,b);
413 new TColor(color,r,g,b);
420 //_____________________________________________________________________________
421 void AliMUONDisplay::DisplayColorScale()
423 /// Display pulse height color scale
427 Float_t xlow, ylow, xup, yup, hs;
428 Float_t x1, y1, x2, y2;
432 TText *text = new TText(0,0,"");
433 text->SetTextFont(61);
434 text->SetTextSize(0.2);
435 text->SetTextAlign(22);
438 Int_t adcmax=4096; // default 12 bits ADC
444 //*-* draw colortable boxes
445 hs = (y2-y1)/Float_t(22);
449 ylow = y1 + hs*(Float_t(i));
450 yup = y1 + hs*(Float_t(i+1));
452 Double_t logscale=Double_t(i+1)*(TMath::Log(adcmax)/22);
453 Int_t scale=(Int_t)TMath::Exp(logscale);
454 sprintf(label,"%d",scale);
455 box = new TBox(xlow, ylow, xup, yup);
457 box->SetFillColor(color);
458 text->DrawText(xlow+0.7, 0.5*(ylow+yup),label);
462 //______________________________________________________________________________
463 Int_t AliMUONDisplay::DistancetoPrimitive(Int_t px, Int_t)
465 /// Compute distance from point px,py to objects in event
467 gPad->SetCursor(kCross);
469 if (gPad == fTrigPad) return 9999;
471 const Int_t kBig = 9999;
473 Float_t xmin = gPad->GetX1();
474 Float_t xmax = gPad->GetX2();
475 Float_t dx = 0.02*(xmax - xmin);
476 Float_t x = gPad->AbsPixeltoX(px);
477 if (x < xmin+dx || x > xmax-dx) return dist;
479 if (fZoomMode) return 0;
483 //_____________________________________________________________________________
484 void AliMUONDisplay::Draw(Option_t *)
486 /// Display current event
494 //_____________________________________________________________________________
495 void AliMUONDisplay::DrawChamber()
497 /// Display current event
499 fDrawTracks = kFALSE;
501 DrawView(fTheta, fPhi, fPsi);
502 // Display the event number and title
507 //_____________________________________________________________________________
508 void AliMUONDisplay::DrawReco(Option_t *)
510 /// Display current event
513 // print kinematics of generated particles
515 // Draw global view of muon system
517 DrawGlobalView(135, -50, -140);
519 // Display the event number and title
524 //_____________________________________________________________________________
525 void AliMUONDisplay::PrintKinematics()
527 /// Print kinematic tree
529 AliRunLoader * runLoader;
530 TParticle *particle = new TParticle();
532 Float_t vertex[3], momentum[3];
535 runLoader = fLoader->GetRunLoader();
539 printf("****** Event # %d ******\n",runLoader->GetEventNumber());
540 runLoader->TreeK()->GetBranch("Particles")->SetAddress(&particle);
541 nPart = (Int_t)runLoader->TreeK()->GetEntries();
542 for(Int_t iPart = 0; iPart < nPart; iPart++) {
543 runLoader->TreeK()->GetEvent(iPart);
544 vertex[0] = particle->Vx();
545 vertex[1] = particle->Vy();
546 vertex[2] = particle->Vz();
547 momentum[0] = particle->Px();
548 momentum[1] = particle->Py();
549 momentum[2] = particle->Pz();
551 printf("===================================================\n");
552 printf(" Generated particle # %d \n",iPart);
553 printf(" name: %s \n",particle->GetName());
554 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
555 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
560 //_____________________________________________________________________________
561 void AliMUONDisplay::DrawSegmentation()
563 /// \todo to be re-written for new seg
564 /// Draw graphical representation of segmenatation
565 /// Attention: still experimental code
568 // AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
569 // AliMUONChamber* iChamber;
571 // AliSegmentation* seg;
572 // iChamber = &(pMUON->Chamber(fChamber));
573 // seg=iChamber->SegmentationModel(icat);
575 // Float_t zpos=iChamber->Z();
576 // Float_t r=iChamber->ROuter();
578 // TMarker3DBox *marker;
580 // for (Int_t j=0; j<seg->Npy(); j++) {
582 // y0=j*seg->Dpy()-seg->Dpy()/2.;
583 // for (seg->FirstPad(0.,y0,0,300,0.);
587 // if (seg->ISector()==0) continue;
589 // seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
590 // Float_t dpx=seg->Dpx(seg->ISector())/2;
591 // Float_t dpy=seg->Dpy(seg->ISector())/2;
592 // marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
593 // marker->SetLineColor(seg->ISector()+1);
594 // marker->SetFillStyle(1001);
595 // marker->SetFillColor(0);
600 // for (Int_t j=0; j<250; j++) {
601 // Float_t x0=j*seg->Dpx();
602 // Float_t y0=TMath::Sqrt(r*r-x0*x0);
604 // for (seg->FirstPad(x0,0,0,0,y0);
608 // if (seg->ISector()==0) continue;
611 // seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
612 // Float_t dpx=seg->Dpx(seg->ISector())/2;
613 // Float_t dpy=seg->Dpy(seg->ISector())/2;
614 // marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
615 // marker->SetLineColor(seg->ISector()+1);
616 // marker->SetFillStyle(1001);
617 // marker->SetFillColor(0);
624 //_____________________________________________________________________________
625 void AliMUONDisplay::DrawClusters()
627 /// Draw clusters for MUON chambers
629 Int_t ndigits, digit;
637 ndigits = points->GetEntriesFast();
638 for (digit=0;digit<ndigits;digit++){
639 pm = (AliMUONPoints*)points->UncheckedAt(digit);
643 for (Int_t im=0;im<3;im++) {
644 TMarker3DBox *marker=pm->GetMarker(im);
649 fClustersCuts += pm->GetN();
653 //_____________________________________________________________________________
654 void AliMUONDisplay::DrawHits()
656 /// Draw hits for MUON chambers
660 Int_t ntracks, track;
667 ntracks = points->GetEntriesFast();
668 for (track=0;track<ntracks;track++) {
669 pm = (AliMUONPoints*)points->UncheckedAt(track);
672 fHitsCuts += pm->GetN();
677 //_____________________________________________________________________________
678 void AliMUONDisplay::DrawCoG()
680 /// Draw hits for MUON chambers
682 if (!fDrawCoG) return;
683 if (fChamber > 10) return;
684 LoadCoG(fChamber,fCathode);
692 ncog = points->GetEntriesFast();
693 for (icog=0;icog<ncog;icog++) {
694 pm = (AliMUONPoints*)points->UncheckedAt(icog);
699 //_____________________________________________________________________________
700 void AliMUONDisplay::DrawTracks()
704 if (!fDrawTracks) return;
707 Int_t nTrack, iTrack;
713 nTrack = points->GetEntriesFast();
714 for ( iTrack = 0; iTrack < nTrack; iTrack++) {
715 pm = (TPolyLine3D*)points->UncheckedAt(iTrack);
720 //_____________________________________________________________________________
722 void AliMUONDisplay::DrawTitle(Option_t *option)
724 /// Draw the event title
726 Float_t xmin = gPad->GetX1();
727 Float_t xmax = gPad->GetX2();
728 Float_t ymin = gPad->GetY1();
729 Float_t ymax = gPad->GetY2();
730 Float_t dx = xmax-xmin;
731 Float_t dy = ymax-ymin;
733 AliRunLoader * runLoader;
735 runLoader = fLoader->GetRunLoader();
740 if (strlen(option) == 0) {
741 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
742 // title->SetTextSize(0.023932);
743 title->SetTextSize(0.02);
744 title->SetBit(kCanDelete);
745 title->SetFillColor(42);
748 sprintf(ptitle, "Alice event:%d Run:%d Chamber:%d Cathode:%d",
749 runLoader->GetEventNumber(),
750 gAlice->GetHeader()->GetRun(),
753 title->AddText(ptitle);
754 Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast();
755 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
756 nparticles, fHitsCuts,fClustersCuts);
757 title->AddText(ptitle);
759 TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
760 label->SetBit(kCanDelete);
761 label->SetFillColor(42);
766 //_____________________________________________________________________________
767 void AliMUONDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
769 /// Draw a view of MUON clusters
771 AliInfo(" Draw View");
773 gPad->SetCursor(kWatch);
774 // gPad->SetFillColor(39);
775 gPad->SetFillColor(1);
777 // gPad->SetFillColor(39);
778 gPad->SetFillColor(1);
781 TView *view = new TView(1);
783 Float_t range = fRrange*fRangeSlider->GetMaximum();
784 view->SetRange(-range,-range,-range,range, range, range);
785 // zoom back to full scale only if DrawView not called from NextCathode
794 Float_t xg1, xg2, yg1, yg2, zg1, zg2;
796 // Recovering the chamber
797 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
799 const AliMUONGeometryTransformer* kGeomTransformer
800 = pMUON->GetGeometryTransformer();
802 AliMUONSegmentation* segmentation = pMUON->GetSegmentation();
803 AliMpSegFactory segFactory;
804 // Mapping segmentation factory will be used only to create mapping
805 // segmentations if not present in the DE segmentations
807 // Display MUON Chamber Geometry
809 sprintf(nodeName,"MUON%d",100+fChamber);
810 printf(">>>> chamber is %d\n",fChamber);
814 for ( it.First(fChamber-1); ! it.IsDone(); it.Next() ) {
816 Int_t detElemId = it.CurrentDE();
817 AliMpSectorSegmentation * seg =
818 (AliMpSectorSegmentation *) segmentation->GetMpSegmentation(detElemId, 0);
819 const AliMpSector * sector = seg->GetSector();
821 // get sector measurements
822 TVector2 position = sector->Position();
823 TVector2 dimension = sector->Dimensions(); // half length
825 Float_t xlocal1 = position.Px(); // FIXME: not really needed as it's 0 ?
826 Float_t ylocal1 = position.Py(); // FIXME: not really needed as it's 0 ?
827 Float_t xlocal2 = dimension.Px() * 2.;
828 Float_t ylocal2 = dimension.Px() * 2.;
830 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
831 kGeomTransformer->Local2Global(detElemId, xlocal2, ylocal2, 0, xg2, yg2, zg2);
834 TPolyLine3D* poly = new TPolyLine3D();
837 poly->SetPoint(nPoint++, xg1, yg1, 0.);
838 for (Float_t d = 0; d < TMath::Pi()/2.; d+= 0.01) {
839 Float_t x = xg1 + xg2 * TMath::Cos(d);
840 Float_t y = yg1 + yg2 * TMath::Sin(d);
841 poly->SetPoint(nPoint++, x, y, 0.);
843 poly->SetPoint(nPoint++, xg1, yg1, 0.);
845 poly->SetLineColor(2);
854 for ( it.First(fChamber-1); ! it.IsDone(); it.Next() )
856 Int_t detElemId = it.CurrentDE();
857 AliMpStationType stationType = AliMpDEManager::GetStationType(detElemId);
859 if ( segmentation->HasDE(detElemId) )
861 const AliMpVSegmentation* seg = segmentation->GetMpSegmentation(detElemId, 0);
863 // Create mapping segmentation if old trigger segmentation
864 // (not using mapping)
865 seg = segFactory.CreateMpSegmentation(detElemId, 0);
869 Float_t deltax = seg->Dimensions().X();
870 Float_t deltay = seg->Dimensions().Y();
871 Float_t xlocal1 = -deltax;
872 Float_t ylocal1 = -deltay;
873 Float_t xlocal2 = +deltax;
874 Float_t ylocal2 = +deltay;
875 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
876 kGeomTransformer->Local2Global(detElemId, xlocal2, ylocal2, 0, xg2, yg2, zg2);
878 // drawing slat active volumes
879 Float_t xCenter = (xg1 + xg2)/2.;
880 Float_t yCenter = (yg1 + yg2)/2.;
882 TMarker3DBox* box = new TMarker3DBox(xCenter,yCenter,0,xlocal1,ylocal2,0,0,0);
884 box->SetFillStyle(0);
885 box->SetLineColor( stationType == kStationTrigger ? 4 : 2);
888 if ( stationType == kStation345 )
890 // drawing inner circle + disc
891 TPolyLine3D* poly = new TPolyLine3D();
892 TPolyLine3D* poly1 = new TPolyLine3D();
896 for (Float_t d = 0; d < 6.24; d+= 0.005)
898 Double_t x = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Cos(d)/2.;
899 Double_t y = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Sin(d)/2.;
900 if (nPoint % 2 == 0) poly->SetPoint(nPoint++, 0., 0., 0.);
901 poly->SetPoint(nPoint++, x, y, 0.);
902 poly1->SetPoint(nPoint1++, x, y, 0.);
904 poly->SetLineColor(1);
906 poly1->SetLineColor(2);
914 // // Delete mapping segmentations created with factory
915 // segFactory.DeleteSegmentations();
917 //add clusters to the pad
921 // DrawSegmentation();
922 // add itself to the list (must be last)
924 view->SetView(phi, theta, psi, iret);
927 //_____________________________________________________________________________
928 void AliMUONDisplay::DrawGlobalView(Float_t theta, Float_t phi, Float_t psi)
930 /// Draw a view of muons chambers with tracks
932 gPad->SetCursor(kWatch);
933 // gPad->SetFillColor(39);
934 gPad->SetFillColor(1);
936 // gPad->SetFillColor(39);
937 gPad->SetFillColor(1);
941 TView *view = new TView(1);
943 Float_t range = fRrange*fRangeSlider->GetMaximum()*3.;
944 view->SetRange(-range,-range,-range,range,range,range);
946 // Display all MUON Chambers segmentation
949 sprintf(nodeName,"alice");
951 node1=gAlice->GetGeometry()->GetNode(nodeName);
952 if (node1) node1->Draw("same");
955 // Draw clusters for all chambers
956 Int_t chamberSave = fChamber;
957 for (fChamber = 1; fChamber <= 10; fChamber++){
960 fChamber = chamberSave;
961 // Draw reconstructed tracks
968 Float_t x0 = (-1+shift)/zoom;
969 Float_t y0 = (-1+shift)/zoom;
970 Float_t x1 = (1+shift)/zoom;
971 Float_t y1 = (1+shift)/zoom;
972 gPad->Range(x0,y0,x1,y1);
973 view->SetView(phi, theta, psi, iret);
977 //______________________________________________________________________________
978 void AliMUONDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
980 /// Execute action corresponding to the mouse event
982 static Float_t x0, y0, x1, y1;
984 static Int_t pxold, pyold;
985 static Int_t px0, py0;
986 static Int_t linedrawn;
989 if (px == 0 && py == 0) { //when called by sliders
990 if (event == kButton1Up) {
995 if (!fZoomMode && gPad->GetView()) {
996 gPad->GetView()->ExecuteRotateView(event, px, py);
1000 // something to zoom ?
1001 gPad->SetCursor(kCross);
1006 gVirtualX->SetLineColor(-1);
1007 gPad->TAttLine::Modify(); //Change line attributes only if necessary
1008 x0 = gPad->AbsPixeltoX(px);
1009 y0 = gPad->AbsPixeltoY(py);
1011 pxold = px; pyold = py;
1015 case kButton1Motion:
1016 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
1020 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
1024 gPad->GetCanvas()->FeedbackMode(kFALSE);
1025 if (px == px0) return;
1026 if (py == py0) return;
1027 x1 = gPad->AbsPixeltoX(px);
1028 y1 = gPad->AbsPixeltoY(py);
1030 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
1031 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
1032 gPad->Range(x0,y0,x1,y1);
1033 if (fZooms < AliMUONConstants::MaxZoom()-1) {
1035 fZoomX0[fZooms] = x0;
1036 fZoomY0[fZooms] = y0;
1037 fZoomX1[fZooms] = x1;
1038 fZoomY1[fZooms] = y1;
1040 gPad->Modified(kTRUE);
1045 //___________________________________________
1046 void AliMUONDisplay::LoadDigits(Int_t chamber, Int_t cathode)
1048 /// Read digits info and store x,y,z info in arrays fPoints.
1049 /// Loop on all detectors
1051 if (chamber > 14) return;
1057 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1059 GetMUONData()->SetTreeAddress("D");
1061 TClonesArray *muonDigits = GetMUONData()->Digits(chamber-1);
1062 if (muonDigits == 0) return;
1064 gAlice->ResetDigits();
1067 if (GetLoader()->TreeD()) {
1068 nent = (Int_t) GetLoader()->TreeD()->GetEntries();
1069 // gAlice->TreeD()->GetEvent(nent-2+cathode-1);
1070 GetMUONData()->GetDigits();
1073 Int_t ndigits = muonDigits->GetEntriesFast();
1074 if (ndigits == 0) return;
1075 if (fPoints == 0) fPoints = new TObjArray(ndigits);
1077 Float_t zpos = AliMUONConstants::DefaultChamberZ(chamber-1);
1080 AliMUONPoints *points = 0;
1081 TMarker3DBox *marker = 0;
1084 Float_t adcmax = 1024; // default
1085 if (chamber<11) adcmax = 4096;
1087 // check if trigger is using new or old segmentation
1089 AliMUONSegmentation* segmentation = pMUON->GetSegmentation();
1090 if ( segmentation->GetMpSegmentation(1100, cathode-1) ) old = false;
1092 if ( old && chamber > 10) {
1093 if (chamber > 10) printf(">>> old segmentation for trigger \n");
1094 else printf(">>> old segmentation for tracking \n");
1096 for (Int_t digit = 0; digit < ndigits; digit++) {
1097 mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
1098 if (mdig->Cathode() != cathode-1) continue;
1101 // First get all needed parameters
1103 Int_t charge = mdig->Signal();
1104 Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
1105 Int_t color = 261+index;
1106 Int_t colorTrigger = 2;
1107 if (color > 282) color = 282;
1109 if (chamber > 10) { // trigger chamber
1111 Int_t sumCharge = 0;
1112 for (Int_t icharge = 0; icharge < 10; icharge++) {
1113 sumCharge = sumCharge+mdig->TrackCharge(icharge);
1115 Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10;
1116 if(sumCharge <= 10 || testCharge > 0) {
1117 colorTrigger = color;
1123 // get the center of the pad - add on x and y half of pad size
1124 Float_t xpad, ypad, zpad;
1128 Int_t detElemId = mdig->DetElemId();
1129 AliMUONGeometrySegmentation* segmentation2
1130 = pMUON->GetSegmentation()->GetModuleSegmentationByDEId(detElemId, cathode-1);
1131 segmentation2->GetPadC(detElemId, mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
1132 isec = segmentation2->Sector(detElemId, mdig->PadX(), mdig->PadY());
1133 dpx = segmentation2->Dpx(detElemId, isec)/2;
1134 dpy = segmentation2->Dpy(detElemId, isec)/2;
1136 // Then set the objects
1137 points = new AliMUONPoints(npoints);
1138 fPoints->AddAt(points,digit);
1140 points->SetMarkerColor(colorTrigger);
1142 points->SetMarkerColor(color);
1144 points->SetMarkerStyle(21);
1145 points->SetMarkerSize(0.5);
1146 points->SetParticle(-1);
1147 points->SetHitIndex(-1);
1148 points->SetTrackIndex(-1);
1149 points->SetDigitIndex(digit);
1150 points->SetPoint(0,xpad,ypad,zpos);
1152 Int_t lineColor = (zpad-zpos > 0) ? 2:3;
1153 marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0);
1156 marker->SetLineColor(lineColor);
1157 marker->SetFillStyle(1001);
1158 marker->SetFillColor(color);
1159 marker->SetRefObject((TObject*)points);
1160 points->Set3DMarker(0, marker);
1161 } // end loop on digits
1164 if (chamber > 10) printf(">>> new segmentation for trigger \n");
1165 else printf(">>> new segmentation for tracking \n");
1167 const AliMUONGeometryTransformer* kGeomTransformer
1168 = pMUON->GetGeometryTransformer();
1170 //loop over all digits and store their position
1171 for (Int_t digit = 0; digit < ndigits; digit++) {
1172 mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
1173 if (mdig->Cathode() != cathode-1) continue;
1175 // get all needed parameters
1176 Int_t ix=mdig->PadX();
1177 Int_t iy=mdig->PadY();
1178 Int_t detElemId=mdig->DetElemId();
1179 Int_t charge = mdig->Signal();
1180 Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
1181 Int_t color = 261+index;
1182 Int_t colorTrigger = 2;
1183 if (color > 282) color = 282;
1185 const AliMpVSegmentation* seg =
1186 pMUON->GetSegmentation()->GetMpSegmentation(detElemId,cathode-1);
1188 AliMpPad pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
1190 if (chamber > 10) { // trigger chamber
1191 Int_t sumCharge = 0;
1192 Int_t n = mdig->Ntracks();
1193 for (Int_t icharge = 0; icharge < n; icharge++) {
1194 sumCharge = sumCharge+mdig->TrackCharge(icharge);
1196 assert(sumCharge==mdig->Signal());
1197 Int_t testCharge = sumCharge-(Int_t(sumCharge/n))*n;
1198 if(sumCharge <= n || testCharge > 0) {
1199 colorTrigger = color;
1205 // get the pad position and dimensions
1206 Float_t xlocal1 = pad.Position().X();
1207 Float_t ylocal1 = pad.Position().Y();
1208 Float_t xlocal2 = pad.Dimensions().X();
1209 Float_t ylocal2 = pad.Dimensions().Y();
1211 Float_t xg1, xg2, yg1, yg2, zg1;
1213 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
1214 // (no transformation for pad dimensions)
1218 // Then set the objects
1219 points = new AliMUONPoints(npoints);
1220 fPoints->AddAt(points,digit);
1222 points->SetMarkerColor(colorTrigger);
1224 points->SetMarkerColor(color);
1226 points->SetMarkerStyle(21);
1227 points->SetMarkerSize(0.5);
1228 points->SetParticle(-1);
1229 points->SetHitIndex(-1);
1230 points->SetTrackIndex(-1);
1231 points->SetDigitIndex(digit);
1232 points->SetPoint(0,xg1,yg1,zpos);
1234 Int_t lineColor = (zg1-zpos > 0) ? 2:3;
1235 marker=new TMarker3DBox(xg1,yg1,zpos,xg2,yg2,0,0,0);
1237 marker->SetLineColor(lineColor);
1238 marker->SetFillStyle(1001);
1239 marker->SetFillColor(color);
1240 marker->SetRefObject((TObject*)points);
1241 points->Set3DMarker(0, marker);
1243 } // end loop on digits
1244 } // end of new segmentation
1246 //___________________________________________
1247 void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/)
1249 /// Read raw clusters info and store x,y,z info in arrays fRpoints.
1250 /// Loop on all detectors
1252 if (chamber > 10) return;
1256 GetMUONData()->SetTreeAddress("RC");
1257 TClonesArray *muonRawClusters = GetMUONData()->RawClusters(chamber-1);
1259 if (muonRawClusters == 0) return;
1262 if (GetMUONData()->TreeR()) {
1263 nent=(Int_t) GetMUONData()->TreeR()->GetEntries();
1264 GetMUONData()->TreeR()->GetEvent(0);
1267 Int_t nrawcl = muonRawClusters->GetEntriesFast();
1268 if (nrawcl == 0) return;
1269 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
1271 Float_t zpos = AliMUONConstants::DefaultChamberZ(chamber-1);
1272 AliMUONRawCluster *mRaw;
1273 AliMUONPoints *points = 0;
1275 //loop over all raw clusters and store their position
1276 points = new AliMUONPoints(nrawcl);
1277 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
1278 mRaw = (AliMUONRawCluster*)muonRawClusters->UncheckedAt(iraw);
1279 points->SetMarkerColor(51);
1280 points->SetMarkerStyle(2);
1281 points->SetMarkerSize(1.);
1282 points->SetParticle(-1);
1283 points->SetHitIndex(-1);
1284 points->SetTrackIndex(-1);
1285 points->SetDigitIndex(-1);
1286 points->SetPoint(iraw,mRaw->GetX(0),mRaw->GetY(0),zpos);
1287 fRpoints->AddAt(points,iraw);
1288 // printf("%f and %f and %f\n",mRaw->GetX(0),mRaw->GetY(0),mRaw->GetZ(0));
1292 //___________________________________________
1293 void AliMUONDisplay::LoadTracks()
1297 AliMUONTrack* recTrack = 0;
1298 AliMUONTrackParam* trackParam = 0;
1299 TClonesArray * trackParamAtHit = 0;
1303 GetMUONData()->SetTreeAddress("RT");
1304 TClonesArray* recTracksArray = GetMUONData()->RecTracks();
1305 if (recTracksArray == NULL) return;
1306 GetMUONData()->GetRecTracks();
1308 Int_t nRecTracks = 0;
1310 nRecTracks = (Int_t) recTracksArray->GetEntriesFast();
1313 if (fRpoints == 0) fRpoints = new TObjArray(nRecTracks);
1315 for (Int_t iRecTracks = 0; iRecTracks < nRecTracks; iRecTracks++) {
1316 // reading info from tracks
1317 recTrack = (AliMUONTrack*) recTracksArray->At(iRecTracks);
1319 Int_t nTrackHits = recTrack->GetNTrackHits();
1321 if (nTrackHits == 0) continue;
1324 TPolyLine3D *points = new TPolyLine3D(nTrackHits+1);
1325 points->SetLineColor(6);
1326 points->SetLineWidth(1);
1327 fRpoints->AddAt(points,iRecTracks);
1333 trackParam = recTrack->GetTrackParamAtVertex();
1334 xRec = trackParam->GetNonBendingCoor();
1335 yRec = trackParam->GetBendingCoor();
1336 zRec = trackParam->GetZ();
1337 points->SetPoint(iPoint,xRec,yRec,zRec);
1340 for (Int_t iHit = 0; iHit < nTrackHits; iHit++){
1341 trackParamAtHit = recTrack->GetTrackParamAtHit();
1342 trackParam = (AliMUONTrackParam*) trackParamAtHit->At(iHit);
1343 xRec = trackParam->GetNonBendingCoor();
1344 yRec = trackParam->GetBendingCoor();
1345 zRec = trackParam->GetZ();
1346 points->SetPoint(iPoint,xRec,yRec,zRec);
1348 } // end loop rec. hits
1349 PrintTrack(iRecTracks,recTrack);
1350 } // end loop tracks
1355 //___________________________________________
1356 void AliMUONDisplay::PrintTrack(Int_t iRecTracks, AliMUONTrack *recTrack)
1358 /// Print reconstructed track
1360 AliMUONTrackParam *trackParam;
1361 Float_t vertex[3], momentum[3];
1362 Float_t pYZ, bendingSlope, nonBendingSlope, chi2dof;
1365 trackParam = recTrack->GetTrackParamAtVertex();
1366 vertex[0] = trackParam->GetNonBendingCoor();
1367 vertex[1] = trackParam->GetBendingCoor();
1368 vertex[2] = trackParam->GetZ();
1369 pYZ = 1./TMath::Abs(trackParam->GetInverseBendingMomentum());
1370 bendingSlope = trackParam->GetBendingSlope();
1371 nonBendingSlope = trackParam->GetNonBendingSlope();
1372 momentum[2] = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);
1373 momentum[0] = momentum[2] * nonBendingSlope;
1374 momentum[1] = momentum[2] * bendingSlope;
1375 charge = Int_t(TMath::Sign(1.,trackParam->GetInverseBendingMomentum()));
1376 chi2dof = recTrack->GetFitFMin()/(2.0 * recTrack->GetNTrackHits() - 5.);
1378 printf("===================================================\n");
1379 printf(" Reconstructed track # %d \n",iRecTracks);
1380 printf(" charge: %d \n",charge);
1381 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
1382 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
1383 printf(" track chi2/dof: %f \n",chi2dof);
1387 //___________________________________________
1388 void AliMUONDisplay::LoadHits(Int_t chamber)
1390 /// Read hits info and store x,y,z info in arrays fPhits.
1391 /// Loop on all detectors
1393 if (chamber > 14) return;
1400 Float_t zpos=AliMUONConstants::DefaultChamberZ(chamber-1);
1402 if (GetMUONData()->TreeH()) {
1403 GetMUONData()->SetTreeAddress("H");
1404 Int_t ntracks = (Int_t)GetMUONData()->TreeH()->GetEntries(); //skowron
1406 for (track = 0; track < ntracks; track++) {
1407 GetMUONData()->ResetHits();
1408 GetMUONData()->GetTrack(track);//skowron
1409 TClonesArray *muonHits = GetMUONData()->Hits();
1410 if (muonHits == 0) return;
1411 nthits += muonHits->GetEntriesFast();
1413 if (fPhits == 0) fPhits = new TObjArray(nthits);
1415 for (track=0; track<ntracks;track++) {
1416 GetMUONData()->ResetHits();
1417 GetMUONData()->GetTrack(track);//skowron
1418 TClonesArray *muonHits = GetMUONData()->Hits();
1419 if (muonHits == 0) return;
1420 Int_t nhits = muonHits->GetEntriesFast();
1421 if (nhits == 0) continue;
1423 AliMUONPoints *points = 0;
1425 for (Int_t hit=0;hit<nhits;hit++) {
1426 mHit = (AliMUONHit*)muonHits->UncheckedAt(hit);
1427 Int_t nch = mHit->Chamber(); // chamber number
1428 if (nch != chamber) continue;
1430 // Retrieve info and set the objects
1432 points = new AliMUONPoints(npoints);
1433 fPhits->AddAt(points,nhold+hit);
1434 points->SetMarkerColor(kRed);
1435 points->SetMarkerStyle(5);
1436 points->SetMarkerSize(1.);
1437 points->SetParticle(mHit->Track());
1438 points->SetHitIndex(hit);
1439 points->SetTrackIndex(track);
1440 points->SetDigitIndex(-1);
1441 points->SetPoint(0,mHit->X(),mHit->Y(),zpos);
1442 // printf("%f and %f and %f\n",mHit->X(),mHit->Y(),mHit->Z());
1449 //_____________________________________________________________________________
1450 void AliMUONDisplay::Paint(Option_t *)
1452 /// Paint miscellaneous items
1455 //_____________________________________________________________________________
1456 void AliMUONDisplay::SetPickMode()
1458 /// Set parameters for pick mode.
1462 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1463 fTrigPad->Modified();
1466 //_____________________________________________________________________________
1467 void AliMUONDisplay::SetZoomMode()
1469 /// Set parameters for zoom mode
1473 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1474 fTrigPad->Modified();
1477 //_____________________________________________________________________________
1478 void AliMUONDisplay::NextChamber(Int_t delta)
1480 /// To go from chamber to next chamber if delta = 1
1481 /// or previous chamber otherwise
1483 if (fChamber < AliMUONConstants::NCh()) fChamber++;
1485 if (fChamber > 1) fChamber--;
1489 LoadDigits(fChamber, fCathode);
1493 //_____________________________________________________________________________
1494 void AliMUONDisplay::NextCathode()
1496 /// To switch to other cathode plane
1500 if (fCathode == 1) {
1501 LoadDigits(fChamber, 2);
1503 LoadDigits(fChamber, 1);
1505 fNextCathode = kTRUE; // to keep the same zoom
1507 fNextCathode = kFALSE;
1508 TPad *pad = (TPad*)gPad->GetPadSave();
1509 pad->Range(fZoomX0[fZooms], fZoomY0[fZooms],
1510 fZoomX1[fZooms], fZoomY1[fZooms]);
1516 //_____________________________________________________________________________
1517 void AliMUONDisplay::Trigger()
1519 /// Print global trigger output
1521 AliMUONGlobalTrigger* globalTrig;
1523 GetMUONData()->SetTreeAddress("GLT");
1524 GetMUONData()->GetTriggerD();
1526 globalTrig = (AliMUONGlobalTrigger*)GetMUONData()->GlobalTrigger()->UncheckedAt(0);
1527 if (globalTrig == 0) return;
1529 globalTrig->Print("full");
1531 // // returns Trigger Decision for current event
1532 // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(GetLoader(),1);
1534 // // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
1535 // AliMUONData* muonData = decision->GetMUONData();
1536 // muonData->SetTreeAddress("D");
1537 // decision->Trigger();
1539 //_____________________________________________________________________________
1540 void AliMUONDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1542 /// Set chamber and cathode number
1549 LoadDigits(chamber,cathode);
1553 //_____________________________________________________________________________
1554 void AliMUONDisplay::SetEvent(Int_t newevent)
1558 gAlice->GetEvent(newevent);
1560 if (!gAlice->TreeD()) return;
1563 LoadDigits(fChamber,fCathode);
1567 //_____________________________________________________________________________
1568 void AliMUONDisplay::SetRange(Float_t rrange, Float_t zrange)
1570 /// Set view range along R and Z
1580 //_____________________________________________________________________________
1581 void AliMUONDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1583 /// Change viewing angles for current event
1591 TView *view = gPad->GetView();
1592 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1597 //_____________________________________________________________________________
1598 void AliMUONDisplay::ShowNextEvent(Int_t delta)
1600 /// Display (current event_number + delta)
1601 /// - delta = 1 shown next event
1602 /// - delta = -1 show previous event
1604 AliRunLoader * runLoader;
1606 runLoader = fLoader->GetRunLoader();
1611 //runLoader->CleanDetectors();
1612 //runLoader->CleanKinematics();
1613 Int_t currentEvent = runLoader->GetEventNumber();
1614 Int_t newEvent = currentEvent + delta;
1615 runLoader->GetEvent(newEvent);
1618 LoadDigits(fChamber, fCathode);
1623 //______________________________________________________________________________
1624 void AliMUONDisplay::UnZoom()
1628 if (fZooms <= 0) return;
1630 TPad *pad = (TPad*)gPad->GetPadSave();
1631 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1635 //_____________________________________________________________________________
1636 void AliMUONDisplay::ResetPoints()
1638 /// Reset array of points
1646 //_____________________________________________________________________________
1647 void AliMUONDisplay::ResetPhits()
1649 /// Reset array of points
1657 //_____________________________________________________________________________
1658 void AliMUONDisplay::ResetRpoints()
1660 /// Reset array of points