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 "AliSegmentation.h"
58 #include "AliMUONChamber.h"
59 #include "AliMUONConstants.h"
62 // to manage the same zoom on both cathodes
66 ClassImp(AliMUONDisplay)
69 //_____________________________________________________________________________
70 AliMUONDisplay::AliMUONDisplay()
78 fNextCathode = kFALSE;
82 //_____________________________________________________________________________
83 AliMUONDisplay::AliMUONDisplay(Int_t size, AliLoader * loader)
86 // Create an event display object.
87 // A canvas named "edisplay" is created with a vertical size in pixels
89 // A QUICK Overview of the Event Display functions
90 // ===============================================
92 // The event display can ve invoked by executing the macro "display.C"
93 // A canvas like in the picture below will appear.
95 // On the left side of the canvas, the following buttons appear:
96 // *Next* to move to the next event
97 // *Previous* to move to the previous event
99 // *Pick* Select this option to be able to point on a track with the
100 // mouse. Once on the track, use the right button to select
101 // an action. For example, select SetMarkerAttributes to
102 // change the marker type/color/size for the track.
103 // *Zoom* Select this option (default) if you want to zoom.
104 // To zoom, simply select the selected area with the left button.
105 // *UnZoom* To revert to the previous picture size.
107 // slider R On the left side, the vertical slider can be used to
108 // set the default picture size.
110 // When you are in Zoom mode, you can click on the black part of the canvas
111 // to select special options with the right mouse button.
114 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
115 // When you are on a track, select the menu item "InspectParticle"
116 // to display the current particle attributes.
118 // You can activate the Root browser by selecting the Inspect menu
119 // in the canvas tool bar menu. Then select "Start Browser"
120 // This will open a new canvas with the browser. At this point, you may want
121 // to display some histograms (from the Trees). Go to the "File" menu
122 // of the browser and click on "New canvas".
123 // In the browser, click on item "ROOT files" in the left pane.
124 // Click on galice.root.
126 // Click on TPC for example
127 // Click on any variable (eg TPC.fX) to histogram the variable.
129 // If you are lost, you can click on HELP in any Root canvas or browser.
132 <img src="gif/AliMUONDisplay.gif">
139 gAlice->SetDisplay(this);
141 // Initialize display default parameters
143 // Set front view by default
150 fDrawClusters = kTRUE;
152 fDrawTracks = kFALSE;
161 // Create display canvas
163 if (ysize < 100) ysize = 750;
164 Int_t xsize = Int_t(size*830./ysize);
165 fCanvas = new TCanvas("Canvas", "MUON Display",14,47,xsize,ysize);
166 fCanvas->ToggleEventStatus();
168 // Create main display pad
169 fPad = new TPad("viewpad", "MUON display",0.15,0,0.9,1);
172 fPad->SetFillColor(30);
173 fPad->SetBorderSize(2);
178 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
180 fColPad->SetFillColor(17);
181 fColPad->SetBorderSize(2);
186 // Create user interface control pad
190 // Create Range and mode pad
193 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
196 fTrigPad->SetFillColor(22);
197 fTrigPad->SetBorderSize(2);
198 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
199 fRangeSlider->SetObject(this);
200 char pickmode[] = "gAlice->Display()->SetPickMode()";
202 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
203 fPickButton->SetFillColor(38);
205 char zoommode[] = "gAlice->Display()->SetZoomMode()";
206 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
207 fZoomButton->SetFillColor(38);
209 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
210 fArcButton->SetFillColor(kGreen);
212 char butUnzoom[] = "gAlice->Display()->UnZoom()";
213 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
214 button->SetFillColor(38);
216 AppendPad(); // append display object as last object to force selection
219 fTrigPad->SetEditable(kFALSE);
220 fButtons->SetEditable(kFALSE);
222 fNextCathode = kFALSE;
224 // initialize container
226 fMUONData = new AliMUONData(fLoader,"MUON","MUON");
231 AliMUONDisplay::AliMUONDisplay(const AliMUONDisplay & display)
232 : AliDisplay(display)
234 // Protected copy constructor
236 AliFatal("Not implemented.");
241 //_____________________________________________________________________________
242 AliMUONDisplay::~AliMUONDisplay()
244 // Delete space point structure
245 if (fPoints) fPoints->Delete();
249 if (fPhits) fPhits->Delete();
253 if (fRpoints) fRpoints->Delete();
258 //_____________________________________________________________________________
259 void AliMUONDisplay::Clear(Option_t *)
261 // Delete graphics temporary objects
264 //_____________________________________________________________________________
265 void AliMUONDisplay::DisplayButtons()
267 // Create the user interface buttons
270 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
272 fButtons->SetFillColor(38);
273 fButtons->SetBorderSize(2);
276 // Int_t butcolor = 33;
277 Float_t dbutton = 0.08;
284 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
285 button = new TButton("Event +", but1, x0, y - dbutton, x1, y);
286 button->SetFillColor(38);
290 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
291 button = new TButton("Event -", but2, x0, y - dbutton, x1, y);
292 button->SetFillColor(38);
296 char but3[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(1)";
297 button = new TButton("Chamber +", but3, x0, y - dbutton, x1, y);
298 button->SetFillColor(38);
302 char but4[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(-1)";
303 button = new TButton("Chamber -", but4, x0, y - dbutton, x1, y);
304 button->SetFillColor(38);
308 char but5[] = "((AliMUONDisplay*)(gAlice->Display()))->SetChamberAndCathode(1,1)";
309 button = new TButton("Chamber 1", but5, x0, y - dbutton, x1, y);
310 button->SetFillColor(38);
314 char but6[] = "((AliMUONDisplay*)(gAlice->Display()))->NextCathode()";
315 button = new TButton("Cathode <>", but6, x0, y - dbutton, x1, y);
316 button->SetFillColor(38);
320 char but7[] = "((AliMUONDisplay*)(gAlice->Display()))->Trigger()";
321 button = new TButton("Trigger", but7, x0, y - dbutton, x1, y);
322 button->SetFillColor(38);
326 char but8[] = "((AliMUONDisplay*)(gAlice->Display()))->DrawReco()";
327 button = new TButton("Tracking", but8, x0, y - dbutton, x1, y);
328 button->SetFillColor(38);
332 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
333 diamond->SetFillColor(50);
334 diamond->SetTextAlign(22);
335 diamond->SetTextColor(5);
336 diamond->SetTextSize(0.11);
338 diamond->AddText(".. ");
339 diamond->AddText("ROOT");
340 diamond->AddText("MUON");
341 diamond->AddText("... ");
342 diamond->AddText(" ");
345 //_____________________________________________________________________________
346 void AliMUONDisplay::CreateColors() const
348 // Create the colors palette used to display clusters
363 new TColor(color,r,g,b);
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);
410 //_____________________________________________________________________________
411 void AliMUONDisplay::DisplayColorScale()
413 // Display pulse height color scale
416 Float_t xlow, ylow, xup, yup, hs;
417 Float_t x1, y1, x2, y2;
421 TText *text = new TText(0,0,"");
422 text->SetTextFont(61);
423 text->SetTextSize(0.2);
424 text->SetTextAlign(22);
427 Int_t adcmax=4096; // default 12 bits ADC
433 //*-* draw colortable boxes
434 hs = (y2-y1)/Float_t(22);
438 ylow = y1 + hs*(Float_t(i));
439 yup = y1 + hs*(Float_t(i+1));
441 Double_t logscale=Double_t(i+1)*(TMath::Log(adcmax)/22);
442 Int_t scale=(Int_t)TMath::Exp(logscale);
443 sprintf(label,"%d",scale);
444 box = new TBox(xlow, ylow, xup, yup);
446 box->SetFillColor(color);
447 text->DrawText(xlow+0.7, 0.5*(ylow+yup),label);
451 //______________________________________________________________________________
452 Int_t AliMUONDisplay::DistancetoPrimitive(Int_t px, Int_t)
454 // Compute distance from point px,py to objects in event
456 gPad->SetCursor(kCross);
458 if (gPad == fTrigPad) return 9999;
460 const Int_t kBig = 9999;
462 Float_t xmin = gPad->GetX1();
463 Float_t xmax = gPad->GetX2();
464 Float_t dx = 0.02*(xmax - xmin);
465 Float_t x = gPad->AbsPixeltoX(px);
466 if (x < xmin+dx || x > xmax-dx) return dist;
468 if (fZoomMode) return 0;
472 //_____________________________________________________________________________
473 void AliMUONDisplay::Draw(Option_t *)
475 // Display current event
483 //_____________________________________________________________________________
484 void AliMUONDisplay::DrawChamber()
487 fDrawTracks = kFALSE;
489 DrawView(fTheta, fPhi, fPsi);
490 // Display the event number and title
495 //_____________________________________________________________________________
496 void AliMUONDisplay::DrawReco(Option_t *)
498 // Display current event
501 // print kinematics of generated particles
503 // Draw global view of muon system
505 DrawGlobalView(135, -50, -140);
507 // Display the event number and title
512 //_____________________________________________________________________________
513 void AliMUONDisplay::PrintKinematics()
515 AliRunLoader * runLoader;
516 TParticle *particle = new TParticle();
518 Float_t vertex[3], momentum[3];
521 runLoader = fLoader->GetRunLoader();
525 printf("****** Event # %d ******\n",runLoader->GetEventNumber());
526 runLoader->TreeK()->GetBranch("Particles")->SetAddress(&particle);
527 nPart = (Int_t)runLoader->TreeK()->GetEntries();
528 for(Int_t iPart = 0; iPart < nPart; iPart++) {
529 runLoader->TreeK()->GetEvent(iPart);
530 vertex[0] = particle->Vx();
531 vertex[1] = particle->Vy();
532 vertex[2] = particle->Vz();
533 momentum[0] = particle->Px();
534 momentum[1] = particle->Py();
535 momentum[2] = particle->Pz();
537 printf("===================================================\n");
538 printf(" Generated particle # %d \n",iPart);
539 printf(" name: %s \n",particle->GetName());
540 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
541 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
546 void AliMUONDisplay::DrawSegmentation()
548 // Draw graphical representation of segmenatation
549 // Attention: still experimental code
552 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
553 AliMUONChamber* iChamber;
554 AliSegmentation* seg;
555 iChamber = &(pMUON->Chamber(fChamber));
556 seg=iChamber->SegmentationModel(icat);
557 Float_t zpos=iChamber->Z();
558 Float_t r=iChamber->ROuter();
560 TMarker3DBox *marker;
562 for (Int_t j=0; j<seg->Npy(); j++) {
564 y0=j*seg->Dpy()-seg->Dpy()/2.;
565 for (seg->FirstPad(0.,y0,0,300,0.);
569 if (seg->ISector()==0) continue;
571 seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
572 Float_t dpx=seg->Dpx(seg->ISector())/2;
573 Float_t dpy=seg->Dpy(seg->ISector())/2;
574 marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
575 marker->SetLineColor(seg->ISector()+1);
576 marker->SetFillStyle(1001);
577 marker->SetFillColor(0);
582 for (Int_t j=0; j<250; j++) {
583 Float_t x0=j*seg->Dpx();
584 Float_t y0=TMath::Sqrt(r*r-x0*x0);
586 for (seg->FirstPad(x0,0,0,0,y0);
590 if (seg->ISector()==0) continue;
593 seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
594 Float_t dpx=seg->Dpx(seg->ISector())/2;
595 Float_t dpy=seg->Dpy(seg->ISector())/2;
596 marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
597 marker->SetLineColor(seg->ISector()+1);
598 marker->SetFillStyle(1001);
599 marker->SetFillColor(0);
606 //_____________________________________________________________________________
607 void AliMUONDisplay::DrawClusters()
609 // Draw clusters for MUON chambers
611 Int_t ndigits, digit;
619 ndigits = points->GetEntriesFast();
620 for (digit=0;digit<ndigits;digit++){
621 pm = (AliMUONPoints*)points->UncheckedAt(digit);
625 for (Int_t im=0;im<3;im++) {
626 TMarker3DBox *marker=pm->GetMarker(im);
631 fClustersCuts +=pm->GetN();
635 //_____________________________________________________________________________
636 void AliMUONDisplay::DrawHits()
638 // Draw hits for MUON chambers
642 Int_t ntracks, track;
649 ntracks = points->GetEntriesFast();
650 for (track=0;track<ntracks;track++) {
651 pm = (AliMUONPoints*)points->UncheckedAt(track);
654 fHitsCuts += pm->GetN();
659 //_____________________________________________________________________________
660 void AliMUONDisplay::DrawCoG()
662 // Draw hits for MUON chambers
663 if (!fDrawCoG) return;
664 if (fChamber > 10) return;
665 LoadCoG(fChamber,fCathode);
673 ncog = points->GetEntriesFast();
674 for (icog=0;icog<ncog;icog++) {
675 pm = (AliMUONPoints*)points->UncheckedAt(icog);
680 //_____________________________________________________________________________
681 void AliMUONDisplay::DrawTracks()
684 if (!fDrawTracks) return;
687 Int_t nTrack, iTrack;
693 nTrack = points->GetEntriesFast();
694 for ( iTrack = 0; iTrack < nTrack; iTrack++) {
695 pm = (TPolyLine3D*)points->UncheckedAt(iTrack);
700 //_____________________________________________________________________________
702 void AliMUONDisplay::DrawTitle(Option_t *option)
704 // Draw the event title
706 Float_t xmin = gPad->GetX1();
707 Float_t xmax = gPad->GetX2();
708 Float_t ymin = gPad->GetY1();
709 Float_t ymax = gPad->GetY2();
710 Float_t dx = xmax-xmin;
711 Float_t dy = ymax-ymin;
713 AliRunLoader * runLoader;
715 runLoader = fLoader->GetRunLoader();
720 if (strlen(option) == 0) {
721 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
722 // title->SetTextSize(0.023932);
723 title->SetTextSize(0.02);
724 title->SetBit(kCanDelete);
725 title->SetFillColor(42);
728 sprintf(ptitle, "Alice event:%d Run:%d Chamber:%d Cathode:%d",
729 runLoader->GetEventNumber(),
730 gAlice->GetHeader()->GetRun(),
733 title->AddText(ptitle);
734 Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast();
735 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
736 nparticles, fHitsCuts,fClustersCuts);
737 title->AddText(ptitle);
739 TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
740 label->SetBit(kCanDelete);
741 label->SetFillColor(42);
746 //_____________________________________________________________________________
747 void AliMUONDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
749 // Draw a view of MUON clusters
750 AliInfo(" Draw View");
752 gPad->SetCursor(kWatch);
753 // gPad->SetFillColor(39);
754 gPad->SetFillColor(1);
756 // gPad->SetFillColor(39);
757 gPad->SetFillColor(1);
761 TView *view = new TView(1);
763 Float_t range = fRrange*fRangeSlider->GetMaximum();
764 view->SetRange(-range,-range,-range,range, range, range);
765 // zoom back to full scale only if DrawView not called from NextCathode
774 // Display MUON Chamber Geometry
776 sprintf(nodeName,"MUON%d",100+fChamber);
778 TNode *node1=gAlice->GetGeometry()->GetNode(nodeName);
779 if (node1) node1->Draw("same");
780 //add clusters to the pad
784 // DrawSegmentation();
785 // add itself to the list (must be last)
787 view->SetView(phi, theta, psi, iret);
790 //_____________________________________________________________________________
791 void AliMUONDisplay::DrawGlobalView(Float_t theta, Float_t phi, Float_t psi)
793 // Draw a view of muons chambers with tracks
795 gPad->SetCursor(kWatch);
796 // gPad->SetFillColor(39);
797 gPad->SetFillColor(1);
799 // gPad->SetFillColor(39);
800 gPad->SetFillColor(1);
804 TView *view = new TView(1);
806 Float_t range = fRrange*fRangeSlider->GetMaximum()*3.;
807 view->SetRange(-range,-range,-range,range,range,range);
809 // Display all MUON Chambers segmentation
812 sprintf(nodeName,"alice");
814 node1=gAlice->GetGeometry()->GetNode(nodeName);
815 if (node1) node1->Draw("same");
818 // Draw clusters for all chambers
819 Int_t chamberSave = fChamber;
820 for (fChamber = 1; fChamber <= 10; fChamber++){
823 fChamber = chamberSave;
824 // Draw reconstructed tracks
831 Float_t x0 = (-1+shift)/zoom;
832 Float_t y0 = (-1+shift)/zoom;
833 Float_t x1 = (1+shift)/zoom;
834 Float_t y1 = (1+shift)/zoom;
835 gPad->Range(x0,y0,x1,y1);
836 view->SetView(phi, theta, psi, iret);
840 //______________________________________________________________________________
841 void AliMUONDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
843 // Execute action corresponding to the mouse event
845 static Float_t x0, y0, x1, y1;
847 static Int_t pxold, pyold;
848 static Int_t px0, py0;
849 static Int_t linedrawn;
852 if (px == 0 && py == 0) { //when called by sliders
853 if (event == kButton1Up) {
858 if (!fZoomMode && gPad->GetView()) {
859 gPad->GetView()->ExecuteRotateView(event, px, py);
863 // something to zoom ?
864 gPad->SetCursor(kCross);
869 gVirtualX->SetLineColor(-1);
870 gPad->TAttLine::Modify(); //Change line attributes only if necessary
871 x0 = gPad->AbsPixeltoX(px);
872 y0 = gPad->AbsPixeltoY(py);
874 pxold = px; pyold = py;
879 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
883 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
887 gPad->GetCanvas()->FeedbackMode(kFALSE);
888 if (px == px0) return;
889 if (py == py0) return;
890 x1 = gPad->AbsPixeltoX(px);
891 y1 = gPad->AbsPixeltoY(py);
893 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
894 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
895 gPad->Range(x0,y0,x1,y1);
896 if (fZooms < AliMUONConstants::MaxZoom()-1) {
898 fZoomX0[fZooms] = x0;
899 fZoomY0[fZooms] = y0;
900 fZoomX1[fZooms] = x1;
901 fZoomY1[fZooms] = y1;
903 gPad->Modified(kTRUE);
908 //___________________________________________
909 void AliMUONDisplay::LoadDigits(Int_t chamber, Int_t cathode)
911 // Read digits info and store x,y,z info in arrays fPoints
912 // Loop on all detectors
914 if (chamber > 14) return;
920 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
921 AliMUONChamber* iChamber;
922 AliSegmentation* segmentation;
924 GetMUONData()->SetTreeAddress("D");
926 TClonesArray *muonDigits = GetMUONData()->Digits(chamber-1);
927 if (muonDigits == 0) return;
929 gAlice->ResetDigits();
932 if (GetLoader()->TreeD()) {
933 nent = (Int_t) GetLoader()->TreeD()->GetEntries();
934 // gAlice->TreeD()->GetEvent(nent-2+cathode-1);
935 GetMUONData()->GetCathode(cathode-1);
938 Int_t ndigits = muonDigits->GetEntriesFast();
939 if (ndigits == 0) return;
940 if (fPoints == 0) fPoints = new TObjArray(ndigits);
942 iChamber = &(pMUON->Chamber(chamber-1));
944 segmentation = iChamber->SegmentationModel(cathode);
945 Float_t zpos = iChamber->Z();
948 AliMUONPoints *points = 0;
949 TMarker3DBox *marker = 0;
951 //loop over all digits and store their position
954 Float_t adcmax = 1024; // default
955 if (chamber<11) adcmax = 4096;
957 for (Int_t digit = 0; digit < ndigits; digit++) {
958 mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
959 if (mdig->Cathode() != cathode-1) continue;
962 // First get all needed parameters
964 Int_t charge = mdig->Signal();
965 Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
966 Int_t color = 261+index;
967 Int_t colorTrigger = 2;
968 if (color > 282) color = 282;
970 if (chamber > 10) { // trigger chamber
973 for (Int_t icharge = 0; icharge < 10; icharge++) {
974 sumCharge = sumCharge+mdig->TrackCharge(icharge);
976 Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10;
977 if(sumCharge <= 10 || testCharge > 0) {
978 colorTrigger = color;
984 // get the center of the pad - add on x and y half of pad size
985 Float_t xpad, ypad, zpad;
986 segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
988 Int_t isec = segmentation->Sector(mdig->PadX(), mdig->PadY());
989 Float_t dpx = segmentation->Dpx(isec)/2;
990 Float_t dpy = segmentation->Dpy(isec)/2;
992 // segmentation->Dump();
995 // Then set the objects
997 points = new AliMUONPoints(npoints);
998 fPoints->AddAt(points,digit);
1000 points->SetMarkerColor(colorTrigger);
1002 points->SetMarkerColor(color);
1004 points->SetMarkerStyle(21);
1005 points->SetMarkerSize(0.5);
1006 points->SetParticle(-1);
1007 points->SetHitIndex(-1);
1008 points->SetTrackIndex(-1);
1009 points->SetDigitIndex(digit);
1010 points->SetPoint(0,xpad,ypad,zpos);
1012 Int_t lineColor = (zpad-zpos > 0) ? 2:3;
1013 marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0);
1016 marker->SetLineColor(lineColor);
1017 marker->SetFillStyle(1001);
1018 marker->SetFillColor(color);
1019 marker->SetRefObject((TObject*)points);
1020 points->Set3DMarker(0, marker);
1023 //___________________________________________
1024 void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/)
1026 // Read raw clusters info and store x,y,z info in arrays fRpoints
1027 // Loop on all detectors
1029 if (chamber > 10) return;
1033 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1034 AliMUONChamber* iChamber;
1036 GetMUONData()->SetTreeAddress("RC");
1037 TClonesArray *muonRawClusters = GetMUONData()->RawClusters(chamber-1);
1039 if (muonRawClusters == 0) return;
1042 if (GetMUONData()->TreeR()) {
1043 nent=(Int_t) GetMUONData()->TreeR()->GetEntries();
1044 GetMUONData()->TreeR()->GetEvent(0);
1047 Int_t nrawcl = muonRawClusters->GetEntriesFast();
1048 if (nrawcl == 0) return;
1049 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
1051 iChamber = &(pMUON->Chamber(chamber-1));
1052 Float_t zpos=iChamber->Z();
1053 AliMUONRawCluster *mRaw;
1054 AliMUONPoints *points = 0;
1056 //loop over all raw clusters and store their position
1057 points = new AliMUONPoints(nrawcl);
1058 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
1059 mRaw = (AliMUONRawCluster*)muonRawClusters->UncheckedAt(iraw);
1060 points->SetMarkerColor(51);
1061 points->SetMarkerStyle(2);
1062 points->SetMarkerSize(1.);
1063 points->SetParticle(-1);
1064 points->SetHitIndex(-1);
1065 points->SetTrackIndex(-1);
1066 points->SetDigitIndex(-1);
1067 points->SetPoint(iraw,mRaw->GetX(0),mRaw->GetY(0),zpos);
1068 fRpoints->AddAt(points,iraw);
1069 // printf("%f and %f and %f\n",mRaw->GetX(0),mRaw->GetY(0),mRaw->GetZ(0));
1073 //___________________________________________
1074 void AliMUONDisplay::LoadTracks()
1077 AliMUONTrack* recTrack = 0;
1078 AliMUONTrackParam* trackParam = 0;
1079 TClonesArray * trackParamAtHit = 0;
1083 GetMUONData()->SetTreeAddress("RT");
1084 TClonesArray* recTracksArray = GetMUONData()->RecTracks();
1085 if (recTracksArray == NULL) return;
1086 GetMUONData()->GetRecTracks();
1088 Int_t nRecTracks = 0;
1090 nRecTracks = (Int_t) recTracksArray->GetEntriesFast();
1093 if (fRpoints == 0) fRpoints = new TObjArray(nRecTracks);
1095 for (Int_t iRecTracks = 0; iRecTracks < nRecTracks; iRecTracks++) {
1096 // reading info from tracks
1097 recTrack = (AliMUONTrack*) recTracksArray->At(iRecTracks);
1099 Int_t nTrackHits = recTrack->GetNTrackHits();
1101 if (nTrackHits == 0) continue;
1104 TPolyLine3D *points = new TPolyLine3D(nTrackHits+1);
1105 points->SetLineColor(6);
1106 points->SetLineWidth(1);
1107 fRpoints->AddAt(points,iRecTracks);
1113 trackParam = recTrack->GetTrackParamAtVertex();
1114 xRec = trackParam->GetNonBendingCoor();
1115 yRec = trackParam->GetBendingCoor();
1116 zRec = trackParam->GetZ();
1117 points->SetPoint(iPoint,xRec,yRec,zRec);
1120 for (Int_t iHit = 0; iHit < nTrackHits; iHit++){
1121 trackParamAtHit = recTrack->GetTrackParamAtHit();
1122 trackParam = (AliMUONTrackParam*) trackParamAtHit->At(iHit);
1123 xRec = trackParam->GetNonBendingCoor();
1124 yRec = trackParam->GetBendingCoor();
1125 zRec = trackParam->GetZ();
1126 points->SetPoint(iPoint,xRec,yRec,zRec);
1128 } // end loop rec. hits
1129 PrintTrack(iRecTracks,recTrack);
1130 } // end loop tracks
1135 void AliMUONDisplay::PrintTrack(Int_t iRecTracks, AliMUONTrack *recTrack)
1137 AliMUONTrackParam *trackParam;
1138 Float_t vertex[3], momentum[3];
1139 Float_t pYZ, bendingSlope, nonBendingSlope, chi2dof;
1142 trackParam = recTrack->GetTrackParamAtVertex();
1143 vertex[0] = trackParam->GetNonBendingCoor();
1144 vertex[1] = trackParam->GetBendingCoor();
1145 vertex[2] = trackParam->GetZ();
1146 pYZ = 1./TMath::Abs(trackParam->GetInverseBendingMomentum());
1147 bendingSlope = trackParam->GetBendingSlope();
1148 nonBendingSlope = trackParam->GetNonBendingSlope();
1149 momentum[2] = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);
1150 momentum[0] = momentum[2] * nonBendingSlope;
1151 momentum[1] = momentum[2] * bendingSlope;
1152 charge = Int_t(TMath::Sign(1.,trackParam->GetInverseBendingMomentum()));
1153 chi2dof = recTrack->GetFitFMin()/(2.0 * recTrack->GetNTrackHits() - 5.);
1155 printf("===================================================\n");
1156 printf(" Reconstructed track # %d \n",iRecTracks);
1157 printf(" charge: %d \n",charge);
1158 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
1159 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
1160 printf(" track chi2/dof: %f \n",chi2dof);
1164 //___________________________________________
1165 void AliMUONDisplay::LoadHits(Int_t chamber)
1167 // Read hits info and store x,y,z info in arrays fPhits
1168 // Loop on all detectors
1170 if (chamber > 14) return;
1177 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1178 AliMUONChamber* iChamber;
1180 iChamber = &(pMUON->Chamber(chamber-1));
1181 Float_t zpos=iChamber->Z();
1184 if (GetMUONData()->TreeH()) {
1185 GetMUONData()->SetTreeAddress("H");
1186 Int_t ntracks = (Int_t)GetMUONData()->TreeH()->GetEntries(); //skowron
1188 for (track = 0; track < ntracks; track++) {
1189 GetMUONData()->ResetHits();
1190 GetMUONData()->GetTrack(track);//skowron
1191 TClonesArray *muonHits = GetMUONData()->Hits();
1192 if (muonHits == 0) return;
1193 nthits += muonHits->GetEntriesFast();
1195 if (fPhits == 0) fPhits = new TObjArray(nthits);
1197 for (track=0; track<ntracks;track++) {
1198 GetMUONData()->ResetHits();
1199 GetMUONData()->GetTrack(track);//skowron
1200 TClonesArray *muonHits = GetMUONData()->Hits();
1201 if (muonHits == 0) return;
1202 Int_t nhits = muonHits->GetEntriesFast();
1203 if (nhits == 0) continue;
1205 AliMUONPoints *points = 0;
1207 for (Int_t hit=0;hit<nhits;hit++) {
1208 mHit = (AliMUONHit*)muonHits->UncheckedAt(hit);
1209 Int_t nch = mHit->Chamber(); // chamber number
1210 if (nch != chamber) continue;
1212 // Retrieve info and set the objects
1214 points = new AliMUONPoints(npoints);
1215 fPhits->AddAt(points,nhold+hit);
1216 points->SetMarkerColor(kRed);
1217 points->SetMarkerStyle(5);
1218 points->SetMarkerSize(1.);
1219 points->SetParticle(mHit->Track());
1220 points->SetHitIndex(hit);
1221 points->SetTrackIndex(track);
1222 points->SetDigitIndex(-1);
1223 points->SetPoint(0,mHit->X(),mHit->Y(),zpos);
1224 // printf("%f and %f and %f\n",mHit->X(),mHit->Y(),mHit->Z());
1231 //_____________________________________________________________________________
1232 void AliMUONDisplay::Paint(Option_t *)
1234 // Paint miscellaneous items
1237 //_____________________________________________________________________________
1238 void AliMUONDisplay::SetPickMode()
1240 // Set parameters for pick mode.
1244 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1245 fTrigPad->Modified();
1248 //_____________________________________________________________________________
1249 void AliMUONDisplay::SetZoomMode()
1251 // Set parameters for zoom mode
1254 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1255 fTrigPad->Modified();
1258 //_____________________________________________________________________________
1259 void AliMUONDisplay::NextChamber(Int_t delta)
1261 // to go from chamber to next chamber if delta = 1
1262 // or previous chamber otherwise
1264 if (fChamber < AliMUONConstants::NCh()) fChamber++;
1266 if (fChamber > 1) fChamber--;
1270 LoadDigits(fChamber, fCathode);
1274 //_____________________________________________________________________________
1275 void AliMUONDisplay::NextCathode()
1277 // to switch to other cathode plane
1280 if (fCathode == 1) {
1281 LoadDigits(fChamber, 2);
1283 LoadDigits(fChamber, 1);
1285 fNextCathode = kTRUE; // to keep the same zoom
1287 fNextCathode = kFALSE;
1288 TPad *pad = (TPad*)gPad->GetPadSave();
1289 pad->Range(fZoomX0[fZooms], fZoomY0[fZooms],
1290 fZoomX1[fZooms], fZoomY1[fZooms]);
1296 //_____________________________________________________________________________
1297 void AliMUONDisplay::Trigger()
1300 AliMUONGlobalTrigger* globalTrig;
1302 GetMUONData()->SetTreeAddress("GLT");
1303 GetMUONData()->GetTriggerD();
1305 globalTrig = (AliMUONGlobalTrigger*)GetMUONData()->GlobalTrigger()->UncheckedAt(0);
1306 if (globalTrig == 0) return;
1308 printf("===================================================\n");
1309 printf(" Global Trigger output Low pt High pt All\n");
1311 printf(" number of Single Plus :\t");
1312 printf("%i\t",globalTrig->SinglePlusLpt());
1313 printf("%i\t",globalTrig->SinglePlusHpt());
1314 printf("%i\t",globalTrig->SinglePlusApt());
1317 printf(" number of Single Minus :\t");
1318 printf("%i\t",globalTrig->SingleMinusLpt());
1319 printf("%i\t",globalTrig->SingleMinusHpt());
1320 printf("%i\t",globalTrig->SingleMinusApt());
1323 printf(" number of Single Undefined :\t");
1324 printf("%i\t",globalTrig->SingleUndefLpt());
1325 printf("%i\t",globalTrig->SingleUndefHpt());
1326 printf("%i\t",globalTrig->SingleUndefApt());
1329 printf(" number of UnlikeSign pair :\t");
1330 printf("%i\t",globalTrig->PairUnlikeLpt());
1331 printf("%i\t",globalTrig->PairUnlikeHpt());
1332 printf("%i\t",globalTrig->PairUnlikeApt());
1335 printf(" number of LikeSign pair :\t");
1336 printf("%i\t",globalTrig->PairLikeLpt());
1337 printf("%i\t",globalTrig->PairLikeHpt());
1338 printf("%i\t",globalTrig->PairLikeApt());
1340 printf("===================================================\n");
1344 // // returns Trigger Decision for current event
1345 // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(GetLoader(),1);
1347 // // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
1348 // AliMUONData* muonData = decision->GetMUONData();
1349 // muonData->SetTreeAddress("D");
1350 // decision->Trigger();
1352 //_____________________________________________________________________________
1353 void AliMUONDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1355 // Set chamber and cathode number
1361 LoadDigits(chamber,cathode);
1365 void AliMUONDisplay::SetEvent(Int_t newevent)
1368 gAlice->GetEvent(newevent);
1370 if (!gAlice->TreeD()) return;
1373 LoadDigits(fChamber,fCathode);
1377 //_____________________________________________________________________________
1378 void AliMUONDisplay::SetRange(Float_t rrange, Float_t zrange)
1380 // Set view range along R and Z
1389 //_____________________________________________________________________________
1390 void AliMUONDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1392 // change viewing angles for current event
1400 TView *view = gPad->GetView();
1401 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1406 //_____________________________________________________________________________
1407 void AliMUONDisplay::ShowNextEvent(Int_t delta)
1409 AliRunLoader * runLoader;
1411 runLoader = fLoader->GetRunLoader();
1415 // Display (current event_number + delta)
1416 // delta = 1 shown next event
1417 // delta = -1 show previous event
1419 //runLoader->CleanDetectors();
1420 //runLoader->CleanKinematics();
1421 Int_t currentEvent = runLoader->GetEventNumber();
1422 Int_t newEvent = currentEvent + delta;
1423 runLoader->GetEvent(newEvent);
1426 LoadDigits(fChamber, fCathode);
1431 //______________________________________________________________________________
1432 void AliMUONDisplay::UnZoom()
1435 if (fZooms <= 0) return;
1437 TPad *pad = (TPad*)gPad->GetPadSave();
1438 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1442 //_____________________________________________________________________________
1443 void AliMUONDisplay::ResetPoints()
1446 // Reset array of points
1454 //_____________________________________________________________________________
1455 void AliMUONDisplay::ResetPhits()
1458 // Reset array of points
1466 //_____________________________________________________________________________
1467 void AliMUONDisplay::ResetRpoints()
1470 // Reset array of points
1479 AliMUONDisplay & AliMUONDisplay::operator = (const AliMUONDisplay & rhs)
1481 // Protected assignement operator
1483 if (this == &rhs) return *this;
1485 AliFatal("Not implemented.");