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>
43 #include "AliMUONDisplay.h"
46 #include "AliMUONPoints.h"
47 #include "AliMUONGlobalTrigger.h"
48 #include "AliHeader.h"
50 #include "AliMUONHit.h"
51 #include "AliMUONDigit.h"
52 #include "AliMUONRawCluster.h"
53 #include "AliMUONTrack.h"
54 #include "AliMUONTrackParam.h"
56 #include "AliSegmentation.h"
57 #include "AliMUONResponse.h"
58 #include "AliMUONChamber.h"
59 #include "AliMUONConstants.h"
61 // to manage the same zoom on both cathodes
65 ClassImp(AliMUONDisplay)
68 //_____________________________________________________________________________
69 AliMUONDisplay::AliMUONDisplay()
77 fNextCathode = kFALSE;
81 //_____________________________________________________________________________
82 AliMUONDisplay::AliMUONDisplay(Int_t size, AliLoader * loader)
85 // Create an event display object.
86 // A canvas named "edisplay" is created with a vertical size in pixels
88 // A QUICK Overview of the Event Display functions
89 // ===============================================
91 // The event display can ve invoked by executing the macro "display.C"
92 // A canvas like in the picture below will appear.
94 // On the left side of the canvas, the following buttons appear:
95 // *Next* to move to the next event
96 // *Previous* to move to the previous event
98 // *Pick* Select this option to be able to point on a track with the
99 // mouse. Once on the track, use the right button to select
100 // an action. For example, select SetMarkerAttributes to
101 // change the marker type/color/size for the track.
102 // *Zoom* Select this option (default) if you want to zoom.
103 // To zoom, simply select the selected area with the left button.
104 // *UnZoom* To revert to the previous picture size.
106 // slider R On the left side, the vertical slider can be used to
107 // set the default picture size.
109 // When you are in Zoom mode, you can click on the black part of the canvas
110 // to select special options with the right mouse button.
113 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
114 // When you are on a track, select the menu item "InspectParticle"
115 // to display the current particle attributes.
117 // You can activate the Root browser by selecting the Inspect menu
118 // in the canvas tool bar menu. Then select "Start Browser"
119 // This will open a new canvas with the browser. At this point, you may want
120 // to display some histograms (from the Trees). Go to the "File" menu
121 // of the browser and click on "New canvas".
122 // In the browser, click on item "ROOT files" in the left pane.
123 // Click on galice.root.
125 // Click on TPC for example
126 // Click on any variable (eg TPC.fX) to histogram the variable.
128 // If you are lost, you can click on HELP in any Root canvas or browser.
131 <img src="gif/AliMUONDisplay.gif">
138 gAlice->SetDisplay(this);
140 // Initialize display default parameters
142 // Set front view by default
149 fDrawClusters = kTRUE;
151 fDrawTracks = kFALSE;
160 // Create display canvas
162 if (ysize < 100) ysize = 750;
163 Int_t xsize = Int_t(size*830./ysize);
164 fCanvas = new TCanvas("Canvas", "MUON Display",14,47,xsize,ysize);
165 fCanvas->ToggleEventStatus();
167 // Create main display pad
168 fPad = new TPad("viewpad", "MUON display",0.15,0,0.9,1);
171 fPad->SetFillColor(30);
172 fPad->SetBorderSize(2);
177 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
179 fColPad->SetFillColor(17);
180 fColPad->SetBorderSize(2);
185 // Create user interface control pad
189 // Create Range and mode pad
192 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
195 fTrigPad->SetFillColor(22);
196 fTrigPad->SetBorderSize(2);
197 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
198 fRangeSlider->SetObject(this);
199 char pickmode[] = "gAlice->Display()->SetPickMode()";
201 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
202 fPickButton->SetFillColor(38);
204 char zoommode[] = "gAlice->Display()->SetZoomMode()";
205 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
206 fZoomButton->SetFillColor(38);
208 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
209 fArcButton->SetFillColor(kGreen);
211 char butUnzoom[] = "gAlice->Display()->UnZoom()";
212 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
213 button->SetFillColor(38);
215 AppendPad(); // append display object as last object to force selection
218 fTrigPad->SetEditable(kFALSE);
219 fButtons->SetEditable(kFALSE);
221 fNextCathode = kFALSE;
223 // initialize container
225 fMUONData = new AliMUONData(fLoader,"MUON","MUON");
230 AliMUONDisplay::AliMUONDisplay(const AliMUONDisplay & display)
231 : AliDisplay(display)
233 // Protected copy constructor
235 Fatal("AliMUONDisplay", "Not implemented.");
240 //_____________________________________________________________________________
241 AliMUONDisplay::~AliMUONDisplay()
243 // Delete space point structure
244 if (fPoints) fPoints->Delete();
248 if (fPhits) fPhits->Delete();
252 if (fRpoints) fRpoints->Delete();
257 //_____________________________________________________________________________
258 void AliMUONDisplay::Clear(Option_t *)
260 // Delete graphics temporary objects
263 //_____________________________________________________________________________
264 void AliMUONDisplay::DisplayButtons()
266 // Create the user interface buttons
269 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
271 fButtons->SetFillColor(38);
272 fButtons->SetBorderSize(2);
275 // Int_t butcolor = 33;
276 Float_t dbutton = 0.08;
283 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
284 button = new TButton("Event +", but1, x0, y - dbutton, x1, y);
285 button->SetFillColor(38);
289 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
290 button = new TButton("Event -", but2, x0, y - dbutton, x1, y);
291 button->SetFillColor(38);
295 char but3[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(1)";
296 button = new TButton("Chamber +", but3, x0, y - dbutton, x1, y);
297 button->SetFillColor(38);
301 char but4[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(-1)";
302 button = new TButton("Chamber -", but4, x0, y - dbutton, x1, y);
303 button->SetFillColor(38);
307 char but5[] = "((AliMUONDisplay*)(gAlice->Display()))->SetChamberAndCathode(1,1)";
308 button = new TButton("Chamber 1", but5, x0, y - dbutton, x1, y);
309 button->SetFillColor(38);
313 char but6[] = "((AliMUONDisplay*)(gAlice->Display()))->NextCathode()";
314 button = new TButton("Cathode <>", but6, x0, y - dbutton, x1, y);
315 button->SetFillColor(38);
319 char but7[] = "((AliMUONDisplay*)(gAlice->Display()))->Trigger()";
320 button = new TButton("Trigger", but7, x0, y - dbutton, x1, y);
321 button->SetFillColor(38);
325 char but8[] = "((AliMUONDisplay*)(gAlice->Display()))->DrawReco()";
326 button = new TButton("Tracking", but8, x0, y - dbutton, x1, y);
327 button->SetFillColor(38);
331 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
332 diamond->SetFillColor(50);
333 diamond->SetTextAlign(22);
334 diamond->SetTextColor(5);
335 diamond->SetTextSize(0.11);
337 diamond->AddText(".. ");
338 diamond->AddText("ROOT");
339 diamond->AddText("MUON");
340 diamond->AddText("... ");
341 diamond->AddText(" ");
344 //_____________________________________________________________________________
345 void AliMUONDisplay::CreateColors() const
347 // Create the colors palette used to display clusters
362 new TColor(color,r,g,b);
372 new TColor(color,r,g,b);
382 new TColor(color,r,g,b);
392 new TColor(color,r,g,b);
402 new TColor(color,r,g,b);
409 //_____________________________________________________________________________
410 void AliMUONDisplay::DisplayColorScale()
412 // Display pulse height color scale
415 Float_t xlow, ylow, xup, yup, hs;
416 Float_t x1, y1, x2, y2;
420 TText *text = new TText(0,0,"");
421 text->SetTextFont(61);
422 text->SetTextSize(0.2);
423 text->SetTextAlign(22);
425 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
426 AliMUONChamber *iChamber = &(pMUON->Chamber(fChamber-1));
427 AliMUONResponse * response=iChamber->ResponseModel();
429 if (response) adcmax = (Int_t) response->MaxAdc();
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;
555 AliSegmentation* seg;
556 iChamber = &(pMUON->Chamber(fChamber));
557 seg=iChamber->SegmentationModel(icat);
558 Float_t zpos=iChamber->Z();
559 Float_t r=iChamber->ROuter();
561 TMarker3DBox *marker;
563 for (Int_t j=0; j<seg->Npy(); j++) {
565 y0=j*seg->Dpy()-seg->Dpy()/2.;
566 for (seg->FirstPad(0.,y0,0,300,0.);
570 if (seg->ISector()==0) continue;
572 seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
573 Float_t dpx=seg->Dpx(seg->ISector())/2;
574 Float_t dpy=seg->Dpy(seg->ISector())/2;
575 marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
576 marker->SetLineColor(seg->ISector()+1);
577 marker->SetFillStyle(1001);
578 marker->SetFillColor(0);
583 for (Int_t j=0; j<250; j++) {
584 Float_t x0=j*seg->Dpx();
585 Float_t y0=TMath::Sqrt(r*r-x0*x0);
587 for (seg->FirstPad(x0,0,0,0,y0);
591 if (seg->ISector()==0) continue;
594 seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
595 Float_t dpx=seg->Dpx(seg->ISector())/2;
596 Float_t dpy=seg->Dpy(seg->ISector())/2;
597 marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
598 marker->SetLineColor(seg->ISector()+1);
599 marker->SetFillStyle(1001);
600 marker->SetFillColor(0);
607 //_____________________________________________________________________________
608 void AliMUONDisplay::DrawClusters()
610 // Draw clusters for MUON chambers
612 Int_t ndigits, digit;
620 ndigits = points->GetEntriesFast();
621 for (digit=0;digit<ndigits;digit++){
622 pm = (AliMUONPoints*)points->UncheckedAt(digit);
626 for (Int_t im=0;im<3;im++) {
627 TMarker3DBox *marker=pm->GetMarker(im);
632 fClustersCuts +=pm->GetN();
636 //_____________________________________________________________________________
637 void AliMUONDisplay::DrawHits()
639 // Draw hits for MUON chambers
643 Int_t ntracks, track;
650 ntracks = points->GetEntriesFast();
651 for (track=0;track<ntracks;track++) {
652 pm = (AliMUONPoints*)points->UncheckedAt(track);
655 fHitsCuts += pm->GetN();
660 //_____________________________________________________________________________
661 void AliMUONDisplay::DrawCoG()
663 // Draw hits for MUON chambers
664 if (!fDrawCoG) return;
665 if (fChamber > 10) return;
666 LoadCoG(fChamber,fCathode);
674 ncog = points->GetEntriesFast();
675 for (icog=0;icog<ncog;icog++) {
676 pm = (AliMUONPoints*)points->UncheckedAt(icog);
681 //_____________________________________________________________________________
682 void AliMUONDisplay::DrawTracks()
685 if (!fDrawTracks) return;
688 Int_t nTrack, iTrack;
694 nTrack = points->GetEntriesFast();
695 for ( iTrack = 0; iTrack < nTrack; iTrack++) {
696 pm = (TPolyLine3D*)points->UncheckedAt(iTrack);
701 //_____________________________________________________________________________
703 void AliMUONDisplay::DrawTitle(Option_t *option)
705 // Draw the event title
707 Float_t xmin = gPad->GetX1();
708 Float_t xmax = gPad->GetX2();
709 Float_t ymin = gPad->GetY1();
710 Float_t ymax = gPad->GetY2();
711 Float_t dx = xmax-xmin;
712 Float_t dy = ymax-ymin;
714 AliRunLoader * runLoader;
716 runLoader = fLoader->GetRunLoader();
721 if (strlen(option) == 0) {
722 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
723 // title->SetTextSize(0.023932);
724 title->SetTextSize(0.02);
725 title->SetBit(kCanDelete);
726 title->SetFillColor(42);
729 sprintf(ptitle, "Alice event:%d Run:%d Chamber:%d Cathode:%d",
730 runLoader->GetEventNumber(),
731 gAlice->GetHeader()->GetRun(),
734 title->AddText(ptitle);
735 Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast();
736 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
737 nparticles, fHitsCuts,fClustersCuts);
738 title->AddText(ptitle);
740 TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
741 label->SetBit(kCanDelete);
742 label->SetFillColor(42);
747 //_____________________________________________________________________________
748 void AliMUONDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
750 // Draw a view of MUON clusters
751 printf("\n Draw View\n");
753 gPad->SetCursor(kWatch);
754 // gPad->SetFillColor(39);
755 gPad->SetFillColor(1);
757 // gPad->SetFillColor(39);
758 gPad->SetFillColor(1);
762 TView *view = new TView(1);
764 Float_t range = fRrange*fRangeSlider->GetMaximum();
765 view->SetRange(-range,-range,-range,range, range, range);
766 // zoom back to full scale only if DrawView not called from NextCathode
775 // Display MUON Chamber Geometry
777 sprintf(nodeName,"MUON%d",100+fChamber);
779 TNode *node1=gAlice->GetGeometry()->GetNode(nodeName);
780 if (node1) node1->Draw("same");
781 //add clusters to the pad
785 // DrawSegmentation();
786 // add itself to the list (must be last)
788 view->SetView(phi, theta, psi, iret);
791 //_____________________________________________________________________________
792 void AliMUONDisplay::DrawGlobalView(Float_t theta, Float_t phi, Float_t psi)
794 // Draw a view of muons chambers with tracks
796 gPad->SetCursor(kWatch);
797 // gPad->SetFillColor(39);
798 gPad->SetFillColor(1);
800 // gPad->SetFillColor(39);
801 gPad->SetFillColor(1);
805 TView *view = new TView(1);
807 Float_t range = fRrange*fRangeSlider->GetMaximum()*3.;
808 view->SetRange(-range,-range,-range,range,range,range);
810 // Display all MUON Chambers segmentation
813 sprintf(nodeName,"alice");
815 node1=gAlice->GetGeometry()->GetNode(nodeName);
816 if (node1) node1->Draw("same");
819 // Draw clusters for all chambers
820 Int_t chamberSave = fChamber;
821 for (fChamber = 1; fChamber <= 10; fChamber++){
824 fChamber = chamberSave;
825 // Draw reconstructed tracks
832 Float_t x0 = (-1+shift)/zoom;
833 Float_t y0 = (-1+shift)/zoom;
834 Float_t x1 = (1+shift)/zoom;
835 Float_t y1 = (1+shift)/zoom;
836 gPad->Range(x0,y0,x1,y1);
837 view->SetView(phi, theta, psi, iret);
841 //______________________________________________________________________________
842 void AliMUONDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
844 // Execute action corresponding to the mouse event
846 static Float_t x0, y0, x1, y1;
848 static Int_t pxold, pyold;
849 static Int_t px0, py0;
850 static Int_t linedrawn;
853 if (px == 0 && py == 0) { //when called by sliders
854 if (event == kButton1Up) {
859 if (!fZoomMode && gPad->GetView()) {
860 gPad->GetView()->ExecuteRotateView(event, px, py);
864 // something to zoom ?
865 gPad->SetCursor(kCross);
870 gVirtualX->SetLineColor(-1);
871 gPad->TAttLine::Modify(); //Change line attributes only if necessary
872 x0 = gPad->AbsPixeltoX(px);
873 y0 = gPad->AbsPixeltoY(py);
875 pxold = px; pyold = py;
880 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
884 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
888 gPad->GetCanvas()->FeedbackMode(kFALSE);
889 if (px == px0) return;
890 if (py == py0) return;
891 x1 = gPad->AbsPixeltoX(px);
892 y1 = gPad->AbsPixeltoY(py);
894 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
895 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
896 gPad->Range(x0,y0,x1,y1);
897 if (fZooms < AliMUONConstants::MaxZoom()-1) {
899 fZoomX0[fZooms] = x0;
900 fZoomY0[fZooms] = y0;
901 fZoomX1[fZooms] = x1;
902 fZoomY1[fZooms] = y1;
904 gPad->Modified(kTRUE);
909 //___________________________________________
910 void AliMUONDisplay::LoadDigits(Int_t chamber, Int_t cathode)
912 // Read digits info and store x,y,z info in arrays fPoints
913 // Loop on all detectors
915 if (chamber > 14) return;
921 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
922 AliMUONChamber* iChamber;
923 AliSegmentation* segmentation;
924 AliMUONResponse* response;
926 GetMUONData()->SetTreeAddress("D");
928 TClonesArray *muonDigits = GetMUONData()->Digits(chamber-1);
929 if (muonDigits == 0) return;
931 gAlice->ResetDigits();
934 if (GetLoader()->TreeD()) {
935 nent = (Int_t) GetLoader()->TreeD()->GetEntries();
936 // gAlice->TreeD()->GetEvent(nent-2+cathode-1);
937 GetMUONData()->GetCathode(cathode-1);
940 Int_t ndigits = muonDigits->GetEntriesFast();
941 if (ndigits == 0) return;
942 if (fPoints == 0) fPoints = new TObjArray(ndigits);
944 iChamber = &(pMUON->Chamber(chamber-1));
946 segmentation = iChamber->SegmentationModel(cathode);
947 response = iChamber->ResponseModel();
948 Float_t zpos = iChamber->Z();
951 AliMUONPoints *points = 0;
952 TMarker3DBox *marker = 0;
954 //loop over all digits and store their position
957 Float_t adcmax = 1024;
958 if (response&&chamber<11) adcmax = response->MaxAdc();
960 for (Int_t digit = 0; digit < ndigits; digit++) {
961 mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
962 if (mdig->Cathode() != cathode-1) continue;
965 // First get all needed parameters
967 Int_t charge = mdig->Signal();
968 Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
969 Int_t color = 261+index;
970 Int_t colorTrigger = 2;
971 if (color > 282) color = 282;
973 if (chamber > 10) { // trigger chamber
976 for (Int_t icharge = 0; icharge < 10; icharge++) {
977 sumCharge = sumCharge+mdig->TrackCharge(icharge);
979 Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10;
980 if(sumCharge <= 10 || testCharge > 0) {
981 colorTrigger = color;
987 // get the center of the pad - add on x and y half of pad size
988 Float_t xpad, ypad, zpad;
989 segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
991 Int_t isec = segmentation->Sector(mdig->PadX(), mdig->PadY());
992 Float_t dpx = segmentation->Dpx(isec)/2;
993 Float_t dpy = segmentation->Dpy(isec)/2;
995 // segmentation->Dump();
998 // Then set the objects
1000 points = new AliMUONPoints(npoints);
1001 fPoints->AddAt(points,digit);
1003 points->SetMarkerColor(colorTrigger);
1005 points->SetMarkerColor(color);
1007 points->SetMarkerStyle(21);
1008 points->SetMarkerSize(0.5);
1009 points->SetParticle(-1);
1010 points->SetHitIndex(-1);
1011 points->SetTrackIndex(-1);
1012 points->SetDigitIndex(digit);
1013 points->SetPoint(0,xpad,ypad,zpos);
1015 Int_t lineColor = (zpad-zpos > 0) ? 2:3;
1016 marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0);
1019 marker->SetLineColor(lineColor);
1020 marker->SetFillStyle(1001);
1021 marker->SetFillColor(color);
1022 marker->SetRefObject((TObject*)points);
1023 points->Set3DMarker(0, marker);
1026 //___________________________________________
1027 void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/)
1029 // Read raw clusters info and store x,y,z info in arrays fRpoints
1030 // Loop on all detectors
1032 if (chamber > 10) return;
1036 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1037 AliMUONChamber* iChamber;
1039 GetMUONData()->SetTreeAddress("RC");
1040 TClonesArray *muonRawClusters = GetMUONData()->RawClusters(chamber-1);
1042 if (muonRawClusters == 0) return;
1045 if (GetMUONData()->TreeR()) {
1046 nent=(Int_t) GetMUONData()->TreeR()->GetEntries();
1047 GetMUONData()->TreeR()->GetEvent(0);
1050 Int_t nrawcl = muonRawClusters->GetEntriesFast();
1051 if (nrawcl == 0) return;
1052 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
1054 iChamber = &(pMUON->Chamber(chamber-1));
1055 Float_t zpos=iChamber->Z();
1056 AliMUONRawCluster *mRaw;
1057 AliMUONPoints *points = 0;
1059 //loop over all raw clusters and store their position
1060 points = new AliMUONPoints(nrawcl);
1061 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
1062 mRaw = (AliMUONRawCluster*)muonRawClusters->UncheckedAt(iraw);
1063 points->SetMarkerColor(51);
1064 points->SetMarkerStyle(2);
1065 points->SetMarkerSize(1.);
1066 points->SetParticle(-1);
1067 points->SetHitIndex(-1);
1068 points->SetTrackIndex(-1);
1069 points->SetDigitIndex(-1);
1070 points->SetPoint(iraw,mRaw->GetX(0),mRaw->GetY(0),zpos);
1071 fRpoints->AddAt(points,iraw);
1072 // printf("%f and %f and %f\n",mRaw->GetX(0),mRaw->GetY(0),mRaw->GetZ(0));
1076 //___________________________________________
1077 void AliMUONDisplay::LoadTracks()
1080 AliMUONTrack* recTrack = 0;
1081 AliMUONTrackParam* trackParam = 0;
1082 TClonesArray * trackParamAtHit = 0;
1086 GetMUONData()->SetTreeAddress("RT");
1087 TClonesArray* recTracksArray = GetMUONData()->RecTracks();
1088 if (recTracksArray == NULL) return;
1089 GetMUONData()->GetRecTracks();
1091 Int_t nRecTracks = 0;
1093 nRecTracks = (Int_t) recTracksArray->GetEntriesFast();
1096 if (fRpoints == 0) fRpoints = new TObjArray(nRecTracks);
1098 for (Int_t iRecTracks = 0; iRecTracks < nRecTracks; iRecTracks++) {
1099 // reading info from tracks
1100 recTrack = (AliMUONTrack*) recTracksArray->At(iRecTracks);
1102 Int_t nTrackHits = recTrack->GetNTrackHits();
1104 if (nTrackHits == 0) continue;
1107 TPolyLine3D *points = new TPolyLine3D(nTrackHits+1);
1108 points->SetLineColor(6);
1109 points->SetLineWidth(1);
1110 fRpoints->AddAt(points,iRecTracks);
1116 trackParam = recTrack->GetTrackParamAtVertex();
1117 xRec = trackParam->GetNonBendingCoor();
1118 yRec = trackParam->GetBendingCoor();
1119 zRec = trackParam->GetZ();
1120 points->SetPoint(iPoint,xRec,yRec,zRec);
1123 for (Int_t iHit = 0; iHit < nTrackHits; iHit++){
1124 trackParamAtHit = recTrack->GetTrackParamAtHit();
1125 trackParam = (AliMUONTrackParam*) trackParamAtHit->At(iHit);
1126 xRec = trackParam->GetNonBendingCoor();
1127 yRec = trackParam->GetBendingCoor();
1128 zRec = trackParam->GetZ();
1129 points->SetPoint(iPoint,xRec,yRec,zRec);
1131 } // end loop rec. hits
1132 PrintTrack(iRecTracks,recTrack);
1133 } // end loop tracks
1138 void AliMUONDisplay::PrintTrack(Int_t iRecTracks, AliMUONTrack *recTrack)
1140 AliMUONTrackParam *trackParam;
1141 Float_t vertex[3], momentum[3];
1142 Float_t pYZ, bendingSlope, nonBendingSlope, chi2dof;
1145 trackParam = recTrack->GetTrackParamAtVertex();
1146 vertex[0] = trackParam->GetNonBendingCoor();
1147 vertex[1] = trackParam->GetBendingCoor();
1148 vertex[2] = trackParam->GetZ();
1149 pYZ = 1./TMath::Abs(trackParam->GetInverseBendingMomentum());
1150 bendingSlope = trackParam->GetBendingSlope();
1151 nonBendingSlope = trackParam->GetNonBendingSlope();
1152 momentum[2] = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);
1153 momentum[0] = momentum[2] * nonBendingSlope;
1154 momentum[1] = momentum[2] * bendingSlope;
1155 charge = Int_t(TMath::Sign(1.,trackParam->GetInverseBendingMomentum()));
1156 chi2dof = recTrack->GetFitFMin()/(2.0 * recTrack->GetNTrackHits() - 5.);
1158 printf("===================================================\n");
1159 printf(" Reconstructed track # %d \n",iRecTracks);
1160 printf(" charge: %d \n",charge);
1161 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
1162 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
1163 printf(" track chi2/dof: %f \n",chi2dof);
1167 //___________________________________________
1168 void AliMUONDisplay::LoadHits(Int_t chamber)
1170 // Read hits info and store x,y,z info in arrays fPhits
1171 // Loop on all detectors
1173 if (chamber > 14) return;
1180 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1181 AliMUONChamber* iChamber;
1183 iChamber = &(pMUON->Chamber(chamber-1));
1184 Float_t zpos=iChamber->Z();
1187 if (GetMUONData()->TreeH()) {
1188 GetMUONData()->SetTreeAddress("H");
1189 Int_t ntracks = (Int_t)GetMUONData()->TreeH()->GetEntries(); //skowron
1191 for (track = 0; track < ntracks; track++) {
1192 GetMUONData()->ResetHits();
1193 GetMUONData()->GetTrack(track);//skowron
1194 TClonesArray *muonHits = GetMUONData()->Hits();
1195 if (muonHits == 0) return;
1196 nthits += muonHits->GetEntriesFast();
1198 if (fPhits == 0) fPhits = new TObjArray(nthits);
1200 for (track=0; track<ntracks;track++) {
1201 GetMUONData()->ResetHits();
1202 GetMUONData()->GetTrack(track);//skowron
1203 TClonesArray *muonHits = GetMUONData()->Hits();
1204 if (muonHits == 0) return;
1205 Int_t nhits = muonHits->GetEntriesFast();
1206 if (nhits == 0) continue;
1208 AliMUONPoints *points = 0;
1210 for (Int_t hit=0;hit<nhits;hit++) {
1211 mHit = (AliMUONHit*)muonHits->UncheckedAt(hit);
1212 Int_t nch = mHit->Chamber(); // chamber number
1213 if (nch != chamber) continue;
1215 // Retrieve info and set the objects
1217 points = new AliMUONPoints(npoints);
1218 fPhits->AddAt(points,nhold+hit);
1219 points->SetMarkerColor(kRed);
1220 points->SetMarkerStyle(5);
1221 points->SetMarkerSize(1.);
1222 points->SetParticle(mHit->Track());
1223 points->SetHitIndex(hit);
1224 points->SetTrackIndex(track);
1225 points->SetDigitIndex(-1);
1226 points->SetPoint(0,mHit->X(),mHit->Y(),zpos);
1227 // printf("%f and %f and %f\n",mHit->X(),mHit->Y(),mHit->Z());
1234 //_____________________________________________________________________________
1235 void AliMUONDisplay::Paint(Option_t *)
1237 // Paint miscellaneous items
1240 //_____________________________________________________________________________
1241 void AliMUONDisplay::SetPickMode()
1243 // Set parameters for pick mode.
1247 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1248 fTrigPad->Modified();
1251 //_____________________________________________________________________________
1252 void AliMUONDisplay::SetZoomMode()
1254 // Set parameters for zoom mode
1257 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1258 fTrigPad->Modified();
1261 //_____________________________________________________________________________
1262 void AliMUONDisplay::NextChamber(Int_t delta)
1264 // to go from chamber to next chamber if delta = 1
1265 // or previous chamber otherwise
1267 if (fChamber < AliMUONConstants::NCh()) fChamber++;
1269 if (fChamber > 1) fChamber--;
1273 LoadDigits(fChamber, fCathode);
1277 //_____________________________________________________________________________
1278 void AliMUONDisplay::NextCathode()
1280 // to switch to other cathode plane
1283 if (fCathode == 1) {
1284 LoadDigits(fChamber, 2);
1286 LoadDigits(fChamber, 1);
1288 fNextCathode = kTRUE; // to keep the same zoom
1290 fNextCathode = kFALSE;
1291 TPad *pad = (TPad*)gPad->GetPadSave();
1292 pad->Range(fZoomX0[fZooms], fZoomY0[fZooms],
1293 fZoomX1[fZooms], fZoomY1[fZooms]);
1299 //_____________________________________________________________________________
1300 void AliMUONDisplay::Trigger()
1303 AliMUONGlobalTrigger* globalTrig;
1305 GetMUONData()->SetTreeAddress("GLT");
1306 GetMUONData()->GetTriggerD();
1308 globalTrig = (AliMUONGlobalTrigger*)GetMUONData()->GlobalTrigger()->UncheckedAt(0);
1309 if (globalTrig == 0) return;
1311 printf("===================================================\n");
1312 printf(" Global Trigger output Low pt High pt All\n");
1314 printf(" number of Single Plus :\t");
1315 printf("%i\t",globalTrig->SinglePlusLpt());
1316 printf("%i\t",globalTrig->SinglePlusHpt());
1317 printf("%i\t",globalTrig->SinglePlusApt());
1320 printf(" number of Single Minus :\t");
1321 printf("%i\t",globalTrig->SingleMinusLpt());
1322 printf("%i\t",globalTrig->SingleMinusHpt());
1323 printf("%i\t",globalTrig->SingleMinusApt());
1326 printf(" number of Single Undefined :\t");
1327 printf("%i\t",globalTrig->SingleUndefLpt());
1328 printf("%i\t",globalTrig->SingleUndefHpt());
1329 printf("%i\t",globalTrig->SingleUndefApt());
1332 printf(" number of UnlikeSign pair :\t");
1333 printf("%i\t",globalTrig->PairUnlikeLpt());
1334 printf("%i\t",globalTrig->PairUnlikeHpt());
1335 printf("%i\t",globalTrig->PairUnlikeApt());
1338 printf(" number of LikeSign pair :\t");
1339 printf("%i\t",globalTrig->PairLikeLpt());
1340 printf("%i\t",globalTrig->PairLikeHpt());
1341 printf("%i\t",globalTrig->PairLikeApt());
1343 printf("===================================================\n");
1347 // // returns Trigger Decision for current event
1348 // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(GetLoader(),1);
1350 // // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
1351 // AliMUONData* muonData = decision->GetMUONData();
1352 // muonData->SetTreeAddress("D");
1353 // decision->Trigger();
1355 //_____________________________________________________________________________
1356 void AliMUONDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1358 // Set chamber and cathode number
1364 LoadDigits(chamber,cathode);
1368 void AliMUONDisplay::SetEvent(Int_t newevent)
1371 gAlice->GetEvent(newevent);
1373 if (!gAlice->TreeD()) return;
1376 LoadDigits(fChamber,fCathode);
1380 //_____________________________________________________________________________
1381 void AliMUONDisplay::SetRange(Float_t rrange, Float_t zrange)
1383 // Set view range along R and Z
1392 //_____________________________________________________________________________
1393 void AliMUONDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1395 // change viewing angles for current event
1403 TView *view = gPad->GetView();
1404 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1409 //_____________________________________________________________________________
1410 void AliMUONDisplay::ShowNextEvent(Int_t delta)
1412 AliRunLoader * runLoader;
1414 runLoader = fLoader->GetRunLoader();
1418 // Display (current event_number + delta)
1419 // delta = 1 shown next event
1420 // delta = -1 show previous event
1422 //runLoader->CleanDetectors();
1423 //runLoader->CleanKinematics();
1424 Int_t currentEvent = runLoader->GetEventNumber();
1425 Int_t newEvent = currentEvent + delta;
1426 runLoader->GetEvent(newEvent);
1429 LoadDigits(fChamber, fCathode);
1434 //______________________________________________________________________________
1435 void AliMUONDisplay::UnZoom()
1438 if (fZooms <= 0) return;
1440 TPad *pad = (TPad*)gPad->GetPadSave();
1441 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1445 //_____________________________________________________________________________
1446 void AliMUONDisplay::ResetPoints()
1449 // Reset array of points
1457 //_____________________________________________________________________________
1458 void AliMUONDisplay::ResetPhits()
1461 // Reset array of points
1469 //_____________________________________________________________________________
1470 void AliMUONDisplay::ResetRpoints()
1473 // Reset array of points
1482 AliMUONDisplay & AliMUONDisplay::operator = (const AliMUONDisplay & rhs)
1484 // Protected assignement operator
1486 if (this == &rhs) return *this;
1488 Fatal("operator=", "Not implemented.");