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>
44 #include "AliMUONDisplay.h"
47 #include "AliMUONPoints.h"
48 #include "AliMUONGlobalTrigger.h"
49 #include "AliHeader.h"
51 #include "AliMUONHit.h"
52 #include "AliMUONDigit.h"
53 #include "AliMUONRawCluster.h"
54 #include "AliMUONTrack.h"
55 #include "AliMUONTrackParam.h"
57 #include "AliMUONGeometrySegmentation.h"
58 #include "AliSegmentation.h"
59 #include "AliMUONChamber.h"
60 #include "AliMUONConstants.h"
63 // to manage the same zoom on both cathodes
67 ClassImp(AliMUONDisplay)
70 //_____________________________________________________________________________
71 AliMUONDisplay::AliMUONDisplay()
79 fNextCathode = kFALSE;
83 //_____________________________________________________________________________
84 AliMUONDisplay::AliMUONDisplay(Int_t size, AliLoader * loader)
87 // Create an event display object.
88 // A canvas named "edisplay" is created with a vertical size in pixels
90 // A QUICK Overview of the Event Display functions
91 // ===============================================
93 // The event display can ve invoked by executing the macro "display.C"
94 // A canvas like in the picture below will appear.
96 // On the left side of the canvas, the following buttons appear:
97 // *Next* to move to the next event
98 // *Previous* to move to the previous event
100 // *Pick* Select this option to be able to point on a track with the
101 // mouse. Once on the track, use the right button to select
102 // an action. For example, select SetMarkerAttributes to
103 // change the marker type/color/size for the track.
104 // *Zoom* Select this option (default) if you want to zoom.
105 // To zoom, simply select the selected area with the left button.
106 // *UnZoom* To revert to the previous picture size.
108 // slider R On the left side, the vertical slider can be used to
109 // set the default picture size.
111 // When you are in Zoom mode, you can click on the black part of the canvas
112 // to select special options with the right mouse button.
115 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
116 // When you are on a track, select the menu item "InspectParticle"
117 // to display the current particle attributes.
119 // You can activate the Root browser by selecting the Inspect menu
120 // in the canvas tool bar menu. Then select "Start Browser"
121 // This will open a new canvas with the browser. At this point, you may want
122 // to display some histograms (from the Trees). Go to the "File" menu
123 // of the browser and click on "New canvas".
124 // In the browser, click on item "ROOT files" in the left pane.
125 // Click on galice.root.
127 // Click on TPC for example
128 // Click on any variable (eg TPC.fX) to histogram the variable.
130 // If you are lost, you can click on HELP in any Root canvas or browser.
133 <img src="gif/AliMUONDisplay.gif">
140 gAlice->SetDisplay(this);
142 // Initialize display default parameters
144 // Set front view by default
151 fDrawClusters = kTRUE;
153 fDrawTracks = kFALSE;
162 // Create display canvas
164 if (ysize < 100) ysize = 750;
165 Int_t xsize = Int_t(size*830./ysize);
166 fCanvas = new TCanvas("Canvas", "MUON Display",14,47,xsize,ysize);
167 fCanvas->ToggleEventStatus();
169 // Create main display pad
170 fPad = new TPad("viewpad", "MUON display",0.15,0,0.9,1);
173 fPad->SetFillColor(30);
174 fPad->SetBorderSize(2);
179 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
181 fColPad->SetFillColor(17);
182 fColPad->SetBorderSize(2);
187 // Create user interface control pad
191 // Create Range and mode pad
194 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
197 fTrigPad->SetFillColor(22);
198 fTrigPad->SetBorderSize(2);
199 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
200 fRangeSlider->SetObject(this);
201 char pickmode[] = "gAlice->Display()->SetPickMode()";
203 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
204 fPickButton->SetFillColor(38);
206 char zoommode[] = "gAlice->Display()->SetZoomMode()";
207 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
208 fZoomButton->SetFillColor(38);
210 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
211 fArcButton->SetFillColor(kGreen);
213 char butUnzoom[] = "gAlice->Display()->UnZoom()";
214 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
215 button->SetFillColor(38);
217 AppendPad(); // append display object as last object to force selection
220 fTrigPad->SetEditable(kFALSE);
221 fButtons->SetEditable(kFALSE);
223 fNextCathode = kFALSE;
225 // initialize container
227 fMUONData = new AliMUONData(fLoader,"MUON","MUON");
232 AliMUONDisplay::AliMUONDisplay(const AliMUONDisplay & display)
233 : AliDisplay(display)
235 // Protected copy constructor
237 AliFatal("Not implemented.");
242 //_____________________________________________________________________________
243 AliMUONDisplay::~AliMUONDisplay()
245 // Delete space point structure
246 if (fPoints) fPoints->Delete();
250 if (fPhits) fPhits->Delete();
254 if (fRpoints) fRpoints->Delete();
259 //_____________________________________________________________________________
260 void AliMUONDisplay::Clear(Option_t *)
262 // Delete graphics temporary objects
265 //_____________________________________________________________________________
266 void AliMUONDisplay::DisplayButtons()
268 // Create the user interface buttons
271 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
273 fButtons->SetFillColor(38);
274 fButtons->SetBorderSize(2);
277 // Int_t butcolor = 33;
278 Float_t dbutton = 0.08;
285 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
286 button = new TButton("Event +", but1, x0, y - dbutton, x1, y);
287 button->SetFillColor(38);
291 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
292 button = new TButton("Event -", but2, x0, y - dbutton, x1, y);
293 button->SetFillColor(38);
297 char but3[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(1)";
298 button = new TButton("Chamber +", but3, x0, y - dbutton, x1, y);
299 button->SetFillColor(38);
303 char but4[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(-1)";
304 button = new TButton("Chamber -", but4, x0, y - dbutton, x1, y);
305 button->SetFillColor(38);
309 char but5[] = "((AliMUONDisplay*)(gAlice->Display()))->SetChamberAndCathode(1,1)";
310 button = new TButton("Chamber 1", but5, x0, y - dbutton, x1, y);
311 button->SetFillColor(38);
315 char but6[] = "((AliMUONDisplay*)(gAlice->Display()))->NextCathode()";
316 button = new TButton("Cathode <>", but6, x0, y - dbutton, x1, y);
317 button->SetFillColor(38);
321 char but7[] = "((AliMUONDisplay*)(gAlice->Display()))->Trigger()";
322 button = new TButton("Trigger", but7, x0, y - dbutton, x1, y);
323 button->SetFillColor(38);
327 char but8[] = "((AliMUONDisplay*)(gAlice->Display()))->DrawReco()";
328 button = new TButton("Tracking", but8, x0, y - dbutton, x1, y);
329 button->SetFillColor(38);
333 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
334 diamond->SetFillColor(50);
335 diamond->SetTextAlign(22);
336 diamond->SetTextColor(5);
337 diamond->SetTextSize(0.11);
339 diamond->AddText(".. ");
340 diamond->AddText("ROOT");
341 diamond->AddText("MUON");
342 diamond->AddText("... ");
343 diamond->AddText(" ");
346 //_____________________________________________________________________________
347 void AliMUONDisplay::CreateColors() const
349 // Create the colors palette used to display clusters
364 new TColor(color,r,g,b);
374 new TColor(color,r,g,b);
384 new TColor(color,r,g,b);
394 new TColor(color,r,g,b);
404 new TColor(color,r,g,b);
411 //_____________________________________________________________________________
412 void AliMUONDisplay::DisplayColorScale()
414 // Display pulse height color scale
417 Float_t xlow, ylow, xup, yup, hs;
418 Float_t x1, y1, x2, y2;
422 TText *text = new TText(0,0,"");
423 text->SetTextFont(61);
424 text->SetTextSize(0.2);
425 text->SetTextAlign(22);
428 Int_t adcmax=4096; // default 12 bits ADC
434 //*-* draw colortable boxes
435 hs = (y2-y1)/Float_t(22);
439 ylow = y1 + hs*(Float_t(i));
440 yup = y1 + hs*(Float_t(i+1));
442 Double_t logscale=Double_t(i+1)*(TMath::Log(adcmax)/22);
443 Int_t scale=(Int_t)TMath::Exp(logscale);
444 sprintf(label,"%d",scale);
445 box = new TBox(xlow, ylow, xup, yup);
447 box->SetFillColor(color);
448 text->DrawText(xlow+0.7, 0.5*(ylow+yup),label);
452 //______________________________________________________________________________
453 Int_t AliMUONDisplay::DistancetoPrimitive(Int_t px, Int_t)
455 // Compute distance from point px,py to objects in event
457 gPad->SetCursor(kCross);
459 if (gPad == fTrigPad) return 9999;
461 const Int_t kBig = 9999;
463 Float_t xmin = gPad->GetX1();
464 Float_t xmax = gPad->GetX2();
465 Float_t dx = 0.02*(xmax - xmin);
466 Float_t x = gPad->AbsPixeltoX(px);
467 if (x < xmin+dx || x > xmax-dx) return dist;
469 if (fZoomMode) return 0;
473 //_____________________________________________________________________________
474 void AliMUONDisplay::Draw(Option_t *)
476 // Display current event
484 //_____________________________________________________________________________
485 void AliMUONDisplay::DrawChamber()
488 fDrawTracks = kFALSE;
490 DrawView(fTheta, fPhi, fPsi);
491 // Display the event number and title
496 //_____________________________________________________________________________
497 void AliMUONDisplay::DrawReco(Option_t *)
499 // Display current event
502 // print kinematics of generated particles
504 // Draw global view of muon system
506 DrawGlobalView(135, -50, -140);
508 // Display the event number and title
513 //_____________________________________________________________________________
514 void AliMUONDisplay::PrintKinematics()
516 AliRunLoader * runLoader;
517 TParticle *particle = new TParticle();
519 Float_t vertex[3], momentum[3];
522 runLoader = fLoader->GetRunLoader();
526 printf("****** Event # %d ******\n",runLoader->GetEventNumber());
527 runLoader->TreeK()->GetBranch("Particles")->SetAddress(&particle);
528 nPart = (Int_t)runLoader->TreeK()->GetEntries();
529 for(Int_t iPart = 0; iPart < nPart; iPart++) {
530 runLoader->TreeK()->GetEvent(iPart);
531 vertex[0] = particle->Vx();
532 vertex[1] = particle->Vy();
533 vertex[2] = particle->Vz();
534 momentum[0] = particle->Px();
535 momentum[1] = particle->Py();
536 momentum[2] = particle->Pz();
538 printf("===================================================\n");
539 printf(" Generated particle # %d \n",iPart);
540 printf(" name: %s \n",particle->GetName());
541 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
542 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
547 void AliMUONDisplay::DrawSegmentation()
549 // Draw graphical representation of segmenatation
550 // Attention: still experimental code
553 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
554 AliMUONChamber* iChamber;
556 AliSegmentation* seg;
557 iChamber = &(pMUON->Chamber(fChamber));
558 seg=iChamber->SegmentationModel(icat);
560 Float_t zpos=iChamber->Z();
561 Float_t r=iChamber->ROuter();
563 TMarker3DBox *marker;
565 for (Int_t j=0; j<seg->Npy(); j++) {
567 y0=j*seg->Dpy()-seg->Dpy()/2.;
568 for (seg->FirstPad(0.,y0,0,300,0.);
572 if (seg->ISector()==0) continue;
574 seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
575 Float_t dpx=seg->Dpx(seg->ISector())/2;
576 Float_t dpy=seg->Dpy(seg->ISector())/2;
577 marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
578 marker->SetLineColor(seg->ISector()+1);
579 marker->SetFillStyle(1001);
580 marker->SetFillColor(0);
585 for (Int_t j=0; j<250; j++) {
586 Float_t x0=j*seg->Dpx();
587 Float_t y0=TMath::Sqrt(r*r-x0*x0);
589 for (seg->FirstPad(x0,0,0,0,y0);
593 if (seg->ISector()==0) continue;
596 seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
597 Float_t dpx=seg->Dpx(seg->ISector())/2;
598 Float_t dpy=seg->Dpy(seg->ISector())/2;
599 marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
600 marker->SetLineColor(seg->ISector()+1);
601 marker->SetFillStyle(1001);
602 marker->SetFillColor(0);
609 //_____________________________________________________________________________
610 void AliMUONDisplay::DrawClusters()
612 // Draw clusters for MUON chambers
614 Int_t ndigits, digit;
622 ndigits = points->GetEntriesFast();
623 for (digit=0;digit<ndigits;digit++){
624 pm = (AliMUONPoints*)points->UncheckedAt(digit);
628 for (Int_t im=0;im<3;im++) {
629 TMarker3DBox *marker=pm->GetMarker(im);
634 fClustersCuts +=pm->GetN();
638 //_____________________________________________________________________________
639 void AliMUONDisplay::DrawHits()
641 // Draw hits for MUON chambers
645 Int_t ntracks, track;
652 ntracks = points->GetEntriesFast();
653 for (track=0;track<ntracks;track++) {
654 pm = (AliMUONPoints*)points->UncheckedAt(track);
657 fHitsCuts += pm->GetN();
662 //_____________________________________________________________________________
663 void AliMUONDisplay::DrawCoG()
665 // Draw hits for MUON chambers
666 if (!fDrawCoG) return;
667 if (fChamber > 10) return;
668 LoadCoG(fChamber,fCathode);
676 ncog = points->GetEntriesFast();
677 for (icog=0;icog<ncog;icog++) {
678 pm = (AliMUONPoints*)points->UncheckedAt(icog);
683 //_____________________________________________________________________________
684 void AliMUONDisplay::DrawTracks()
687 if (!fDrawTracks) return;
690 Int_t nTrack, iTrack;
696 nTrack = points->GetEntriesFast();
697 for ( iTrack = 0; iTrack < nTrack; iTrack++) {
698 pm = (TPolyLine3D*)points->UncheckedAt(iTrack);
703 //_____________________________________________________________________________
705 void AliMUONDisplay::DrawTitle(Option_t *option)
707 // Draw the event title
709 Float_t xmin = gPad->GetX1();
710 Float_t xmax = gPad->GetX2();
711 Float_t ymin = gPad->GetY1();
712 Float_t ymax = gPad->GetY2();
713 Float_t dx = xmax-xmin;
714 Float_t dy = ymax-ymin;
716 AliRunLoader * runLoader;
718 runLoader = fLoader->GetRunLoader();
723 if (strlen(option) == 0) {
724 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
725 // title->SetTextSize(0.023932);
726 title->SetTextSize(0.02);
727 title->SetBit(kCanDelete);
728 title->SetFillColor(42);
731 sprintf(ptitle, "Alice event:%d Run:%d Chamber:%d Cathode:%d",
732 runLoader->GetEventNumber(),
733 gAlice->GetHeader()->GetRun(),
736 title->AddText(ptitle);
737 Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast();
738 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
739 nparticles, fHitsCuts,fClustersCuts);
740 title->AddText(ptitle);
742 TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
743 label->SetBit(kCanDelete);
744 label->SetFillColor(42);
749 //_____________________________________________________________________________
750 void AliMUONDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
752 // Draw a view of MUON clusters
753 AliInfo(" Draw View");
755 gPad->SetCursor(kWatch);
756 // gPad->SetFillColor(39);
757 gPad->SetFillColor(1);
759 // gPad->SetFillColor(39);
760 gPad->SetFillColor(1);
764 TView *view = new TView(1);
766 Float_t range = fRrange*fRangeSlider->GetMaximum();
767 view->SetRange(-range,-range,-range,range, range, range);
768 // zoom back to full scale only if DrawView not called from NextCathode
777 // Display MUON Chamber Geometry
779 sprintf(nodeName,"MUON%d",100+fChamber);
781 TNode *node1=gAlice->GetGeometry()->GetNode(nodeName);
782 if (node1) node1->Draw("same");
783 //add clusters to the pad
787 // DrawSegmentation();
788 // add itself to the list (must be last)
790 view->SetView(phi, theta, psi, iret);
793 //_____________________________________________________________________________
794 void AliMUONDisplay::DrawGlobalView(Float_t theta, Float_t phi, Float_t psi)
796 // Draw a view of muons chambers with tracks
798 gPad->SetCursor(kWatch);
799 // gPad->SetFillColor(39);
800 gPad->SetFillColor(1);
802 // gPad->SetFillColor(39);
803 gPad->SetFillColor(1);
807 TView *view = new TView(1);
809 Float_t range = fRrange*fRangeSlider->GetMaximum()*3.;
810 view->SetRange(-range,-range,-range,range,range,range);
812 // Display all MUON Chambers segmentation
815 sprintf(nodeName,"alice");
817 node1=gAlice->GetGeometry()->GetNode(nodeName);
818 if (node1) node1->Draw("same");
821 // Draw clusters for all chambers
822 Int_t chamberSave = fChamber;
823 for (fChamber = 1; fChamber <= 10; fChamber++){
826 fChamber = chamberSave;
827 // Draw reconstructed tracks
834 Float_t x0 = (-1+shift)/zoom;
835 Float_t y0 = (-1+shift)/zoom;
836 Float_t x1 = (1+shift)/zoom;
837 Float_t y1 = (1+shift)/zoom;
838 gPad->Range(x0,y0,x1,y1);
839 view->SetView(phi, theta, psi, iret);
843 //______________________________________________________________________________
844 void AliMUONDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
846 // Execute action corresponding to the mouse event
848 static Float_t x0, y0, x1, y1;
850 static Int_t pxold, pyold;
851 static Int_t px0, py0;
852 static Int_t linedrawn;
855 if (px == 0 && py == 0) { //when called by sliders
856 if (event == kButton1Up) {
861 if (!fZoomMode && gPad->GetView()) {
862 gPad->GetView()->ExecuteRotateView(event, px, py);
866 // something to zoom ?
867 gPad->SetCursor(kCross);
872 gVirtualX->SetLineColor(-1);
873 gPad->TAttLine::Modify(); //Change line attributes only if necessary
874 x0 = gPad->AbsPixeltoX(px);
875 y0 = gPad->AbsPixeltoY(py);
877 pxold = px; pyold = py;
882 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
886 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
890 gPad->GetCanvas()->FeedbackMode(kFALSE);
891 if (px == px0) return;
892 if (py == py0) return;
893 x1 = gPad->AbsPixeltoX(px);
894 y1 = gPad->AbsPixeltoY(py);
896 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
897 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
898 gPad->Range(x0,y0,x1,y1);
899 if (fZooms < AliMUONConstants::MaxZoom()-1) {
901 fZoomX0[fZooms] = x0;
902 fZoomY0[fZooms] = y0;
903 fZoomX1[fZooms] = x1;
904 fZoomY1[fZooms] = y1;
906 gPad->Modified(kTRUE);
911 //___________________________________________
912 void AliMUONDisplay::LoadDigits(Int_t chamber, Int_t cathode)
914 // Read digits info and store x,y,z info in arrays fPoints
915 // Loop on all detectors
917 if (chamber > 14) return;
923 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
924 AliMUONChamber* iChamber;
925 AliSegmentation* segmentation = 0x0;
926 AliMUONGeometrySegmentation* segmentation2 = 0x0;
928 GetMUONData()->SetTreeAddress("D");
930 TClonesArray *muonDigits = GetMUONData()->Digits(chamber-1);
931 if (muonDigits == 0) return;
933 gAlice->ResetDigits();
936 if (GetLoader()->TreeD()) {
937 nent = (Int_t) GetLoader()->TreeD()->GetEntries();
938 // gAlice->TreeD()->GetEvent(nent-2+cathode-1);
939 GetMUONData()->GetCathode(cathode-1);
942 Int_t ndigits = muonDigits->GetEntriesFast();
943 if (ndigits == 0) return;
944 if (fPoints == 0) fPoints = new TObjArray(ndigits);
946 iChamber = &(pMUON->Chamber(chamber-1));
948 if (pMUON->WhichSegmentation()==1)
949 segmentation = iChamber->SegmentationModel(cathode);
951 segmentation2 = iChamber->SegmentationModel2(cathode);
953 Float_t zpos = iChamber->Z();
956 AliMUONPoints *points = 0;
957 TMarker3DBox *marker = 0;
959 //loop over all digits and store their position
962 Float_t adcmax = 1024; // default
963 if (chamber<11) adcmax = 4096;
965 for (Int_t digit = 0; digit < ndigits; digit++) {
966 mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
967 if (mdig->Cathode() != cathode-1) continue;
970 // First get all needed parameters
972 Int_t charge = mdig->Signal();
973 Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
974 Int_t color = 261+index;
975 Int_t colorTrigger = 2;
976 if (color > 282) color = 282;
978 if (chamber > 10) { // trigger chamber
981 for (Int_t icharge = 0; icharge < 10; icharge++) {
982 sumCharge = sumCharge+mdig->TrackCharge(icharge);
984 Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10;
985 if(sumCharge <= 10 || testCharge > 0) {
986 colorTrigger = color;
992 // get the center of the pad - add on x and y half of pad size
993 Float_t xpad, ypad, zpad;
997 if (pMUON->WhichSegmentation()==1) {
998 segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
999 isec = segmentation->Sector(mdig->PadX(), mdig->PadY());
1000 dpx = segmentation->Dpx(isec)/2;
1001 dpy = segmentation->Dpy(isec)/2;
1003 Int_t detElemId = mdig->DetElemId();
1004 segmentation2->GetPadC(detElemId, mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
1005 isec = segmentation2->Sector(detElemId, mdig->PadX(), mdig->PadY());
1006 dpx = segmentation2->Dpx(detElemId, isec)/2;
1007 dpy = segmentation2->Dpy(detElemId, isec)/2;
1010 // segmentation->Dump();
1013 // Then set the objects
1015 points = new AliMUONPoints(npoints);
1016 fPoints->AddAt(points,digit);
1018 points->SetMarkerColor(colorTrigger);
1020 points->SetMarkerColor(color);
1022 points->SetMarkerStyle(21);
1023 points->SetMarkerSize(0.5);
1024 points->SetParticle(-1);
1025 points->SetHitIndex(-1);
1026 points->SetTrackIndex(-1);
1027 points->SetDigitIndex(digit);
1028 points->SetPoint(0,xpad,ypad,zpos);
1030 Int_t lineColor = (zpad-zpos > 0) ? 2:3;
1031 marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0);
1034 marker->SetLineColor(lineColor);
1035 marker->SetFillStyle(1001);
1036 marker->SetFillColor(color);
1037 marker->SetRefObject((TObject*)points);
1038 points->Set3DMarker(0, marker);
1041 //___________________________________________
1042 void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/)
1044 // Read raw clusters info and store x,y,z info in arrays fRpoints
1045 // Loop on all detectors
1047 if (chamber > 10) return;
1051 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1052 AliMUONChamber* iChamber;
1054 GetMUONData()->SetTreeAddress("RC");
1055 TClonesArray *muonRawClusters = GetMUONData()->RawClusters(chamber-1);
1057 if (muonRawClusters == 0) return;
1060 if (GetMUONData()->TreeR()) {
1061 nent=(Int_t) GetMUONData()->TreeR()->GetEntries();
1062 GetMUONData()->TreeR()->GetEvent(0);
1065 Int_t nrawcl = muonRawClusters->GetEntriesFast();
1066 if (nrawcl == 0) return;
1067 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
1069 iChamber = &(pMUON->Chamber(chamber-1));
1070 Float_t zpos=iChamber->Z();
1071 AliMUONRawCluster *mRaw;
1072 AliMUONPoints *points = 0;
1074 //loop over all raw clusters and store their position
1075 points = new AliMUONPoints(nrawcl);
1076 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
1077 mRaw = (AliMUONRawCluster*)muonRawClusters->UncheckedAt(iraw);
1078 points->SetMarkerColor(51);
1079 points->SetMarkerStyle(2);
1080 points->SetMarkerSize(1.);
1081 points->SetParticle(-1);
1082 points->SetHitIndex(-1);
1083 points->SetTrackIndex(-1);
1084 points->SetDigitIndex(-1);
1085 points->SetPoint(iraw,mRaw->GetX(0),mRaw->GetY(0),zpos);
1086 fRpoints->AddAt(points,iraw);
1087 // printf("%f and %f and %f\n",mRaw->GetX(0),mRaw->GetY(0),mRaw->GetZ(0));
1091 //___________________________________________
1092 void AliMUONDisplay::LoadTracks()
1095 AliMUONTrack* recTrack = 0;
1096 AliMUONTrackParam* trackParam = 0;
1097 TClonesArray * trackParamAtHit = 0;
1101 GetMUONData()->SetTreeAddress("RT");
1102 TClonesArray* recTracksArray = GetMUONData()->RecTracks();
1103 if (recTracksArray == NULL) return;
1104 GetMUONData()->GetRecTracks();
1106 Int_t nRecTracks = 0;
1108 nRecTracks = (Int_t) recTracksArray->GetEntriesFast();
1111 if (fRpoints == 0) fRpoints = new TObjArray(nRecTracks);
1113 for (Int_t iRecTracks = 0; iRecTracks < nRecTracks; iRecTracks++) {
1114 // reading info from tracks
1115 recTrack = (AliMUONTrack*) recTracksArray->At(iRecTracks);
1117 Int_t nTrackHits = recTrack->GetNTrackHits();
1119 if (nTrackHits == 0) continue;
1122 TPolyLine3D *points = new TPolyLine3D(nTrackHits+1);
1123 points->SetLineColor(6);
1124 points->SetLineWidth(1);
1125 fRpoints->AddAt(points,iRecTracks);
1131 trackParam = recTrack->GetTrackParamAtVertex();
1132 xRec = trackParam->GetNonBendingCoor();
1133 yRec = trackParam->GetBendingCoor();
1134 zRec = trackParam->GetZ();
1135 points->SetPoint(iPoint,xRec,yRec,zRec);
1138 for (Int_t iHit = 0; iHit < nTrackHits; iHit++){
1139 trackParamAtHit = recTrack->GetTrackParamAtHit();
1140 trackParam = (AliMUONTrackParam*) trackParamAtHit->At(iHit);
1141 xRec = trackParam->GetNonBendingCoor();
1142 yRec = trackParam->GetBendingCoor();
1143 zRec = trackParam->GetZ();
1144 points->SetPoint(iPoint,xRec,yRec,zRec);
1146 } // end loop rec. hits
1147 PrintTrack(iRecTracks,recTrack);
1148 } // end loop tracks
1153 void AliMUONDisplay::PrintTrack(Int_t iRecTracks, AliMUONTrack *recTrack)
1155 AliMUONTrackParam *trackParam;
1156 Float_t vertex[3], momentum[3];
1157 Float_t pYZ, bendingSlope, nonBendingSlope, chi2dof;
1160 trackParam = recTrack->GetTrackParamAtVertex();
1161 vertex[0] = trackParam->GetNonBendingCoor();
1162 vertex[1] = trackParam->GetBendingCoor();
1163 vertex[2] = trackParam->GetZ();
1164 pYZ = 1./TMath::Abs(trackParam->GetInverseBendingMomentum());
1165 bendingSlope = trackParam->GetBendingSlope();
1166 nonBendingSlope = trackParam->GetNonBendingSlope();
1167 momentum[2] = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);
1168 momentum[0] = momentum[2] * nonBendingSlope;
1169 momentum[1] = momentum[2] * bendingSlope;
1170 charge = Int_t(TMath::Sign(1.,trackParam->GetInverseBendingMomentum()));
1171 chi2dof = recTrack->GetFitFMin()/(2.0 * recTrack->GetNTrackHits() - 5.);
1173 printf("===================================================\n");
1174 printf(" Reconstructed track # %d \n",iRecTracks);
1175 printf(" charge: %d \n",charge);
1176 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
1177 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
1178 printf(" track chi2/dof: %f \n",chi2dof);
1182 //___________________________________________
1183 void AliMUONDisplay::LoadHits(Int_t chamber)
1185 // Read hits info and store x,y,z info in arrays fPhits
1186 // Loop on all detectors
1188 if (chamber > 14) return;
1195 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1196 AliMUONChamber* iChamber;
1198 iChamber = &(pMUON->Chamber(chamber-1));
1199 Float_t zpos=iChamber->Z();
1202 if (GetMUONData()->TreeH()) {
1203 GetMUONData()->SetTreeAddress("H");
1204 Int_t ntracks = (Int_t)GetMUONData()->TreeH()->GetEntries(); //skowron
1206 for (track = 0; track < ntracks; track++) {
1207 GetMUONData()->ResetHits();
1208 GetMUONData()->GetTrack(track);//skowron
1209 TClonesArray *muonHits = GetMUONData()->Hits();
1210 if (muonHits == 0) return;
1211 nthits += muonHits->GetEntriesFast();
1213 if (fPhits == 0) fPhits = new TObjArray(nthits);
1215 for (track=0; track<ntracks;track++) {
1216 GetMUONData()->ResetHits();
1217 GetMUONData()->GetTrack(track);//skowron
1218 TClonesArray *muonHits = GetMUONData()->Hits();
1219 if (muonHits == 0) return;
1220 Int_t nhits = muonHits->GetEntriesFast();
1221 if (nhits == 0) continue;
1223 AliMUONPoints *points = 0;
1225 for (Int_t hit=0;hit<nhits;hit++) {
1226 mHit = (AliMUONHit*)muonHits->UncheckedAt(hit);
1227 Int_t nch = mHit->Chamber(); // chamber number
1228 if (nch != chamber) continue;
1230 // Retrieve info and set the objects
1232 points = new AliMUONPoints(npoints);
1233 fPhits->AddAt(points,nhold+hit);
1234 points->SetMarkerColor(kRed);
1235 points->SetMarkerStyle(5);
1236 points->SetMarkerSize(1.);
1237 points->SetParticle(mHit->Track());
1238 points->SetHitIndex(hit);
1239 points->SetTrackIndex(track);
1240 points->SetDigitIndex(-1);
1241 points->SetPoint(0,mHit->X(),mHit->Y(),zpos);
1242 // printf("%f and %f and %f\n",mHit->X(),mHit->Y(),mHit->Z());
1249 //_____________________________________________________________________________
1250 void AliMUONDisplay::Paint(Option_t *)
1252 // Paint miscellaneous items
1255 //_____________________________________________________________________________
1256 void AliMUONDisplay::SetPickMode()
1258 // Set parameters for pick mode.
1262 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1263 fTrigPad->Modified();
1266 //_____________________________________________________________________________
1267 void AliMUONDisplay::SetZoomMode()
1269 // Set parameters for zoom mode
1272 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1273 fTrigPad->Modified();
1276 //_____________________________________________________________________________
1277 void AliMUONDisplay::NextChamber(Int_t delta)
1279 // to go from chamber to next chamber if delta = 1
1280 // or previous chamber otherwise
1282 if (fChamber < AliMUONConstants::NCh()) fChamber++;
1284 if (fChamber > 1) fChamber--;
1288 LoadDigits(fChamber, fCathode);
1292 //_____________________________________________________________________________
1293 void AliMUONDisplay::NextCathode()
1295 // to switch to other cathode plane
1298 if (fCathode == 1) {
1299 LoadDigits(fChamber, 2);
1301 LoadDigits(fChamber, 1);
1303 fNextCathode = kTRUE; // to keep the same zoom
1305 fNextCathode = kFALSE;
1306 TPad *pad = (TPad*)gPad->GetPadSave();
1307 pad->Range(fZoomX0[fZooms], fZoomY0[fZooms],
1308 fZoomX1[fZooms], fZoomY1[fZooms]);
1314 //_____________________________________________________________________________
1315 void AliMUONDisplay::Trigger()
1318 AliMUONGlobalTrigger* globalTrig;
1320 GetMUONData()->SetTreeAddress("GLT");
1321 GetMUONData()->GetTriggerD();
1323 globalTrig = (AliMUONGlobalTrigger*)GetMUONData()->GlobalTrigger()->UncheckedAt(0);
1324 if (globalTrig == 0) return;
1326 printf("===================================================\n");
1327 printf(" Global Trigger output Low pt High pt All\n");
1329 printf(" number of Single Plus :\t");
1330 printf("%i\t",globalTrig->SinglePlusLpt());
1331 printf("%i\t",globalTrig->SinglePlusHpt());
1332 printf("%i\t",globalTrig->SinglePlusApt());
1335 printf(" number of Single Minus :\t");
1336 printf("%i\t",globalTrig->SingleMinusLpt());
1337 printf("%i\t",globalTrig->SingleMinusHpt());
1338 printf("%i\t",globalTrig->SingleMinusApt());
1341 printf(" number of Single Undefined :\t");
1342 printf("%i\t",globalTrig->SingleUndefLpt());
1343 printf("%i\t",globalTrig->SingleUndefHpt());
1344 printf("%i\t",globalTrig->SingleUndefApt());
1347 printf(" number of UnlikeSign pair :\t");
1348 printf("%i\t",globalTrig->PairUnlikeLpt());
1349 printf("%i\t",globalTrig->PairUnlikeHpt());
1350 printf("%i\t",globalTrig->PairUnlikeApt());
1353 printf(" number of LikeSign pair :\t");
1354 printf("%i\t",globalTrig->PairLikeLpt());
1355 printf("%i\t",globalTrig->PairLikeHpt());
1356 printf("%i\t",globalTrig->PairLikeApt());
1358 printf("===================================================\n");
1362 // // returns Trigger Decision for current event
1363 // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(GetLoader(),1);
1365 // // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
1366 // AliMUONData* muonData = decision->GetMUONData();
1367 // muonData->SetTreeAddress("D");
1368 // decision->Trigger();
1370 //_____________________________________________________________________________
1371 void AliMUONDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1373 // Set chamber and cathode number
1379 LoadDigits(chamber,cathode);
1383 void AliMUONDisplay::SetEvent(Int_t newevent)
1386 gAlice->GetEvent(newevent);
1388 if (!gAlice->TreeD()) return;
1391 LoadDigits(fChamber,fCathode);
1395 //_____________________________________________________________________________
1396 void AliMUONDisplay::SetRange(Float_t rrange, Float_t zrange)
1398 // Set view range along R and Z
1407 //_____________________________________________________________________________
1408 void AliMUONDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1410 // change viewing angles for current event
1418 TView *view = gPad->GetView();
1419 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1424 //_____________________________________________________________________________
1425 void AliMUONDisplay::ShowNextEvent(Int_t delta)
1427 AliRunLoader * runLoader;
1429 runLoader = fLoader->GetRunLoader();
1433 // Display (current event_number + delta)
1434 // delta = 1 shown next event
1435 // delta = -1 show previous event
1437 //runLoader->CleanDetectors();
1438 //runLoader->CleanKinematics();
1439 Int_t currentEvent = runLoader->GetEventNumber();
1440 Int_t newEvent = currentEvent + delta;
1441 runLoader->GetEvent(newEvent);
1444 LoadDigits(fChamber, fCathode);
1449 //______________________________________________________________________________
1450 void AliMUONDisplay::UnZoom()
1453 if (fZooms <= 0) return;
1455 TPad *pad = (TPad*)gPad->GetPadSave();
1456 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1460 //_____________________________________________________________________________
1461 void AliMUONDisplay::ResetPoints()
1464 // Reset array of points
1472 //_____________________________________________________________________________
1473 void AliMUONDisplay::ResetPhits()
1476 // Reset array of points
1484 //_____________________________________________________________________________
1485 void AliMUONDisplay::ResetRpoints()
1488 // Reset array of points
1497 AliMUONDisplay & AliMUONDisplay::operator = (const AliMUONDisplay & rhs)
1499 // Protected assignement operator
1501 if (this == &rhs) return *this;
1503 AliFatal("Not implemented.");