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 "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 // to be re-written for new seg
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 AliMUONGeometrySegmentation* segmentation2 = 0x0;
927 GetMUONData()->SetTreeAddress("D");
929 TClonesArray *muonDigits = GetMUONData()->Digits(chamber-1);
930 if (muonDigits == 0) return;
932 gAlice->ResetDigits();
935 if (GetLoader()->TreeD()) {
936 nent = (Int_t) GetLoader()->TreeD()->GetEntries();
937 // gAlice->TreeD()->GetEvent(nent-2+cathode-1);
938 GetMUONData()->GetDigits();
941 Int_t ndigits = muonDigits->GetEntriesFast();
942 if (ndigits == 0) return;
943 if (fPoints == 0) fPoints = new TObjArray(ndigits);
945 iChamber = &(pMUON->Chamber(chamber-1));
947 segmentation2 = iChamber->SegmentationModel2(cathode);
949 Float_t zpos = iChamber->Z();
952 AliMUONPoints *points = 0;
953 TMarker3DBox *marker = 0;
955 //loop over all digits and store their position
958 Float_t adcmax = 1024; // default
959 if (chamber<11) adcmax = 4096;
961 for (Int_t digit = 0; digit < ndigits; digit++) {
962 mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
963 if (mdig->Cathode() != cathode-1) continue;
966 // First get all needed parameters
968 Int_t charge = mdig->Signal();
969 Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
970 Int_t color = 261+index;
971 Int_t colorTrigger = 2;
972 if (color > 282) color = 282;
974 if (chamber > 10) { // trigger chamber
977 for (Int_t icharge = 0; icharge < 10; icharge++) {
978 sumCharge = sumCharge+mdig->TrackCharge(icharge);
980 Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10;
981 if(sumCharge <= 10 || testCharge > 0) {
982 colorTrigger = color;
988 // get the center of the pad - add on x and y half of pad size
989 Float_t xpad, ypad, zpad;
993 Int_t detElemId = mdig->DetElemId();
994 segmentation2->GetPadC(detElemId, mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
995 isec = segmentation2->Sector(detElemId, mdig->PadX(), mdig->PadY());
996 dpx = segmentation2->Dpx(detElemId, isec)/2;
997 dpy = segmentation2->Dpy(detElemId, isec)/2;
1000 // segmentation->Dump();
1003 // Then set the objects
1005 points = new AliMUONPoints(npoints);
1006 fPoints->AddAt(points,digit);
1008 points->SetMarkerColor(colorTrigger);
1010 points->SetMarkerColor(color);
1012 points->SetMarkerStyle(21);
1013 points->SetMarkerSize(0.5);
1014 points->SetParticle(-1);
1015 points->SetHitIndex(-1);
1016 points->SetTrackIndex(-1);
1017 points->SetDigitIndex(digit);
1018 points->SetPoint(0,xpad,ypad,zpos);
1020 Int_t lineColor = (zpad-zpos > 0) ? 2:3;
1021 marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0);
1024 marker->SetLineColor(lineColor);
1025 marker->SetFillStyle(1001);
1026 marker->SetFillColor(color);
1027 marker->SetRefObject((TObject*)points);
1028 points->Set3DMarker(0, marker);
1031 //___________________________________________
1032 void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/)
1034 // Read raw clusters info and store x,y,z info in arrays fRpoints
1035 // Loop on all detectors
1037 if (chamber > 10) return;
1041 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1042 AliMUONChamber* iChamber;
1044 GetMUONData()->SetTreeAddress("RC");
1045 TClonesArray *muonRawClusters = GetMUONData()->RawClusters(chamber-1);
1047 if (muonRawClusters == 0) return;
1050 if (GetMUONData()->TreeR()) {
1051 nent=(Int_t) GetMUONData()->TreeR()->GetEntries();
1052 GetMUONData()->TreeR()->GetEvent(0);
1055 Int_t nrawcl = muonRawClusters->GetEntriesFast();
1056 if (nrawcl == 0) return;
1057 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
1059 iChamber = &(pMUON->Chamber(chamber-1));
1060 Float_t zpos=iChamber->Z();
1061 AliMUONRawCluster *mRaw;
1062 AliMUONPoints *points = 0;
1064 //loop over all raw clusters and store their position
1065 points = new AliMUONPoints(nrawcl);
1066 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
1067 mRaw = (AliMUONRawCluster*)muonRawClusters->UncheckedAt(iraw);
1068 points->SetMarkerColor(51);
1069 points->SetMarkerStyle(2);
1070 points->SetMarkerSize(1.);
1071 points->SetParticle(-1);
1072 points->SetHitIndex(-1);
1073 points->SetTrackIndex(-1);
1074 points->SetDigitIndex(-1);
1075 points->SetPoint(iraw,mRaw->GetX(0),mRaw->GetY(0),zpos);
1076 fRpoints->AddAt(points,iraw);
1077 // printf("%f and %f and %f\n",mRaw->GetX(0),mRaw->GetY(0),mRaw->GetZ(0));
1081 //___________________________________________
1082 void AliMUONDisplay::LoadTracks()
1085 AliMUONTrack* recTrack = 0;
1086 AliMUONTrackParam* trackParam = 0;
1087 TClonesArray * trackParamAtHit = 0;
1091 GetMUONData()->SetTreeAddress("RT");
1092 TClonesArray* recTracksArray = GetMUONData()->RecTracks();
1093 if (recTracksArray == NULL) return;
1094 GetMUONData()->GetRecTracks();
1096 Int_t nRecTracks = 0;
1098 nRecTracks = (Int_t) recTracksArray->GetEntriesFast();
1101 if (fRpoints == 0) fRpoints = new TObjArray(nRecTracks);
1103 for (Int_t iRecTracks = 0; iRecTracks < nRecTracks; iRecTracks++) {
1104 // reading info from tracks
1105 recTrack = (AliMUONTrack*) recTracksArray->At(iRecTracks);
1107 Int_t nTrackHits = recTrack->GetNTrackHits();
1109 if (nTrackHits == 0) continue;
1112 TPolyLine3D *points = new TPolyLine3D(nTrackHits+1);
1113 points->SetLineColor(6);
1114 points->SetLineWidth(1);
1115 fRpoints->AddAt(points,iRecTracks);
1121 trackParam = recTrack->GetTrackParamAtVertex();
1122 xRec = trackParam->GetNonBendingCoor();
1123 yRec = trackParam->GetBendingCoor();
1124 zRec = trackParam->GetZ();
1125 points->SetPoint(iPoint,xRec,yRec,zRec);
1128 for (Int_t iHit = 0; iHit < nTrackHits; iHit++){
1129 trackParamAtHit = recTrack->GetTrackParamAtHit();
1130 trackParam = (AliMUONTrackParam*) trackParamAtHit->At(iHit);
1131 xRec = trackParam->GetNonBendingCoor();
1132 yRec = trackParam->GetBendingCoor();
1133 zRec = trackParam->GetZ();
1134 points->SetPoint(iPoint,xRec,yRec,zRec);
1136 } // end loop rec. hits
1137 PrintTrack(iRecTracks,recTrack);
1138 } // end loop tracks
1143 void AliMUONDisplay::PrintTrack(Int_t iRecTracks, AliMUONTrack *recTrack)
1145 AliMUONTrackParam *trackParam;
1146 Float_t vertex[3], momentum[3];
1147 Float_t pYZ, bendingSlope, nonBendingSlope, chi2dof;
1150 trackParam = recTrack->GetTrackParamAtVertex();
1151 vertex[0] = trackParam->GetNonBendingCoor();
1152 vertex[1] = trackParam->GetBendingCoor();
1153 vertex[2] = trackParam->GetZ();
1154 pYZ = 1./TMath::Abs(trackParam->GetInverseBendingMomentum());
1155 bendingSlope = trackParam->GetBendingSlope();
1156 nonBendingSlope = trackParam->GetNonBendingSlope();
1157 momentum[2] = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);
1158 momentum[0] = momentum[2] * nonBendingSlope;
1159 momentum[1] = momentum[2] * bendingSlope;
1160 charge = Int_t(TMath::Sign(1.,trackParam->GetInverseBendingMomentum()));
1161 chi2dof = recTrack->GetFitFMin()/(2.0 * recTrack->GetNTrackHits() - 5.);
1163 printf("===================================================\n");
1164 printf(" Reconstructed track # %d \n",iRecTracks);
1165 printf(" charge: %d \n",charge);
1166 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
1167 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
1168 printf(" track chi2/dof: %f \n",chi2dof);
1172 //___________________________________________
1173 void AliMUONDisplay::LoadHits(Int_t chamber)
1175 // Read hits info and store x,y,z info in arrays fPhits
1176 // Loop on all detectors
1178 if (chamber > 14) return;
1185 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1186 AliMUONChamber* iChamber;
1188 iChamber = &(pMUON->Chamber(chamber-1));
1189 Float_t zpos=iChamber->Z();
1192 if (GetMUONData()->TreeH()) {
1193 GetMUONData()->SetTreeAddress("H");
1194 Int_t ntracks = (Int_t)GetMUONData()->TreeH()->GetEntries(); //skowron
1196 for (track = 0; track < ntracks; track++) {
1197 GetMUONData()->ResetHits();
1198 GetMUONData()->GetTrack(track);//skowron
1199 TClonesArray *muonHits = GetMUONData()->Hits();
1200 if (muonHits == 0) return;
1201 nthits += muonHits->GetEntriesFast();
1203 if (fPhits == 0) fPhits = new TObjArray(nthits);
1205 for (track=0; track<ntracks;track++) {
1206 GetMUONData()->ResetHits();
1207 GetMUONData()->GetTrack(track);//skowron
1208 TClonesArray *muonHits = GetMUONData()->Hits();
1209 if (muonHits == 0) return;
1210 Int_t nhits = muonHits->GetEntriesFast();
1211 if (nhits == 0) continue;
1213 AliMUONPoints *points = 0;
1215 for (Int_t hit=0;hit<nhits;hit++) {
1216 mHit = (AliMUONHit*)muonHits->UncheckedAt(hit);
1217 Int_t nch = mHit->Chamber(); // chamber number
1218 if (nch != chamber) continue;
1220 // Retrieve info and set the objects
1222 points = new AliMUONPoints(npoints);
1223 fPhits->AddAt(points,nhold+hit);
1224 points->SetMarkerColor(kRed);
1225 points->SetMarkerStyle(5);
1226 points->SetMarkerSize(1.);
1227 points->SetParticle(mHit->Track());
1228 points->SetHitIndex(hit);
1229 points->SetTrackIndex(track);
1230 points->SetDigitIndex(-1);
1231 points->SetPoint(0,mHit->X(),mHit->Y(),zpos);
1232 // printf("%f and %f and %f\n",mHit->X(),mHit->Y(),mHit->Z());
1239 //_____________________________________________________________________________
1240 void AliMUONDisplay::Paint(Option_t *)
1242 // Paint miscellaneous items
1245 //_____________________________________________________________________________
1246 void AliMUONDisplay::SetPickMode()
1248 // Set parameters for pick mode.
1252 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1253 fTrigPad->Modified();
1256 //_____________________________________________________________________________
1257 void AliMUONDisplay::SetZoomMode()
1259 // Set parameters for zoom mode
1262 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1263 fTrigPad->Modified();
1266 //_____________________________________________________________________________
1267 void AliMUONDisplay::NextChamber(Int_t delta)
1269 // to go from chamber to next chamber if delta = 1
1270 // or previous chamber otherwise
1272 if (fChamber < AliMUONConstants::NCh()) fChamber++;
1274 if (fChamber > 1) fChamber--;
1278 LoadDigits(fChamber, fCathode);
1282 //_____________________________________________________________________________
1283 void AliMUONDisplay::NextCathode()
1285 // to switch to other cathode plane
1288 if (fCathode == 1) {
1289 LoadDigits(fChamber, 2);
1291 LoadDigits(fChamber, 1);
1293 fNextCathode = kTRUE; // to keep the same zoom
1295 fNextCathode = kFALSE;
1296 TPad *pad = (TPad*)gPad->GetPadSave();
1297 pad->Range(fZoomX0[fZooms], fZoomY0[fZooms],
1298 fZoomX1[fZooms], fZoomY1[fZooms]);
1304 //_____________________________________________________________________________
1305 void AliMUONDisplay::Trigger()
1308 AliMUONGlobalTrigger* globalTrig;
1310 GetMUONData()->SetTreeAddress("GLT");
1311 GetMUONData()->GetTriggerD();
1313 globalTrig = (AliMUONGlobalTrigger*)GetMUONData()->GlobalTrigger()->UncheckedAt(0);
1314 if (globalTrig == 0) return;
1316 printf("===================================================\n");
1317 printf(" Global Trigger output Low pt High pt All\n");
1319 printf(" number of Single Plus :\t");
1320 printf("%i\t",globalTrig->SinglePlusLpt());
1321 printf("%i\t",globalTrig->SinglePlusHpt());
1322 printf("%i\t",globalTrig->SinglePlusApt());
1325 printf(" number of Single Minus :\t");
1326 printf("%i\t",globalTrig->SingleMinusLpt());
1327 printf("%i\t",globalTrig->SingleMinusHpt());
1328 printf("%i\t",globalTrig->SingleMinusApt());
1331 printf(" number of Single Undefined :\t");
1332 printf("%i\t",globalTrig->SingleUndefLpt());
1333 printf("%i\t",globalTrig->SingleUndefHpt());
1334 printf("%i\t",globalTrig->SingleUndefApt());
1337 printf(" number of UnlikeSign pair :\t");
1338 printf("%i\t",globalTrig->PairUnlikeLpt());
1339 printf("%i\t",globalTrig->PairUnlikeHpt());
1340 printf("%i\t",globalTrig->PairUnlikeApt());
1343 printf(" number of LikeSign pair :\t");
1344 printf("%i\t",globalTrig->PairLikeLpt());
1345 printf("%i\t",globalTrig->PairLikeHpt());
1346 printf("%i\t",globalTrig->PairLikeApt());
1348 printf("===================================================\n");
1352 // // returns Trigger Decision for current event
1353 // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(GetLoader(),1);
1355 // // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
1356 // AliMUONData* muonData = decision->GetMUONData();
1357 // muonData->SetTreeAddress("D");
1358 // decision->Trigger();
1360 //_____________________________________________________________________________
1361 void AliMUONDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1363 // Set chamber and cathode number
1369 LoadDigits(chamber,cathode);
1373 void AliMUONDisplay::SetEvent(Int_t newevent)
1376 gAlice->GetEvent(newevent);
1378 if (!gAlice->TreeD()) return;
1381 LoadDigits(fChamber,fCathode);
1385 //_____________________________________________________________________________
1386 void AliMUONDisplay::SetRange(Float_t rrange, Float_t zrange)
1388 // Set view range along R and Z
1397 //_____________________________________________________________________________
1398 void AliMUONDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1400 // change viewing angles for current event
1408 TView *view = gPad->GetView();
1409 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1414 //_____________________________________________________________________________
1415 void AliMUONDisplay::ShowNextEvent(Int_t delta)
1417 AliRunLoader * runLoader;
1419 runLoader = fLoader->GetRunLoader();
1423 // Display (current event_number + delta)
1424 // delta = 1 shown next event
1425 // delta = -1 show previous event
1427 //runLoader->CleanDetectors();
1428 //runLoader->CleanKinematics();
1429 Int_t currentEvent = runLoader->GetEventNumber();
1430 Int_t newEvent = currentEvent + delta;
1431 runLoader->GetEvent(newEvent);
1434 LoadDigits(fChamber, fCathode);
1439 //______________________________________________________________________________
1440 void AliMUONDisplay::UnZoom()
1443 if (fZooms <= 0) return;
1445 TPad *pad = (TPad*)gPad->GetPadSave();
1446 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1450 //_____________________________________________________________________________
1451 void AliMUONDisplay::ResetPoints()
1454 // Reset array of points
1462 //_____________________________________________________________________________
1463 void AliMUONDisplay::ResetPhits()
1466 // Reset array of points
1474 //_____________________________________________________________________________
1475 void AliMUONDisplay::ResetRpoints()
1478 // Reset array of points
1487 AliMUONDisplay & AliMUONDisplay::operator = (const AliMUONDisplay & rhs)
1489 // Protected assignement operator
1491 if (this == &rhs) return *this;
1493 AliFatal("Not implemented.");