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 //////////////////////////////////////////////////////////////////////////
26 #include "AliMUONDisplay.h"
28 #include "AliMUONPoints.h"
29 #include "AliMUONGlobalTrigger.h"
30 #include "AliMUONHit.h"
31 #include "AliMUONDigit.h"
32 #include "AliMUONRawCluster.h"
33 #include "AliMUONTrack.h"
34 #include "AliMUONTrackParam.h"
35 #include "AliMUONGeometryTransformer.h"
36 #include "AliMUONSegmentation.h"
37 #include "AliMUONGeometrySegmentation.h"
38 #include "AliMUONConstants.h"
39 #include "AliMUONTriggerSegmentationV2.h"
41 #include "AliMpDEIterator.h"
42 #include "AliMpSegFactory.h"
43 #include "AliMpSlatSegmentation.h"
44 #include "AliMpSlat.h"
45 #include "AliMpSectorSegmentation.h"
46 #include "AliMpSector.h"
47 #include "AliMpTriggerSegmentation.h"
48 #include "AliMpTrigger.h"
49 #include "AliMpStationType.h"
50 #include "AliMpDEManager.h"
55 #include "AliHeader.h"
62 #include <TPaveLabel.h>
63 #include <TPaveText.h>
68 #include <TVirtualX.h>
70 #include <TGeometry.h>
71 #include <TMarker3DBox.h>
72 #include <TParticle.h>
73 #include <TPolyLine3D.h>
78 ClassImp(AliMUONDisplay)
81 //_____________________________________________________________________________
82 AliMUONDisplay::AliMUONDisplay()
90 fNextCathode = kFALSE;
94 //_____________________________________________________________________________
95 AliMUONDisplay::AliMUONDisplay(Int_t size, AliLoader * loader)
98 // Create an event display object.
99 // A canvas named "edisplay" is created with a vertical size in pixels
101 // A QUICK Overview of the Event Display functions
102 // ===============================================
104 // The event display can ve invoked by executing the macro "display.C"
105 // A canvas like in the picture below will appear.
107 // On the left side of the canvas, the following buttons appear:
108 // *Next* to move to the next event
109 // *Previous* to move to the previous event
111 // *Pick* Select this option to be able to point on a track with the
112 // mouse. Once on the track, use the right button to select
113 // an action. For example, select SetMarkerAttributes to
114 // change the marker type/color/size for the track.
115 // *Zoom* Select this option (default) if you want to zoom.
116 // To zoom, simply select the selected area with the left button.
117 // *UnZoom* To revert to the previous picture size.
119 // slider R On the left side, the vertical slider can be used to
120 // set the default picture size.
122 // When you are in Zoom mode, you can click on the black part of the canvas
123 // to select special options with the right mouse button.
126 // When you are in pick mode, you can "Inspect" the object pointed by the mouse.
127 // When you are on a track, select the menu item "InspectParticle"
128 // to display the current particle attributes.
130 // You can activate the Root browser by selecting the Inspect menu
131 // in the canvas tool bar menu. Then select "Start Browser"
132 // This will open a new canvas with the browser. At this point, you may want
133 // to display some histograms (from the Trees). Go to the "File" menu
134 // of the browser and click on "New canvas".
135 // In the browser, click on item "ROOT files" in the left pane.
136 // Click on galice.root.
138 // Click on TPC for example
139 // Click on any variable (eg TPC.fX) to histogram the variable.
141 // If you are lost, you can click on HELP in any Root canvas or browser.
144 <img src="gif/AliMUONDisplay.gif">
151 gAlice->SetDisplay(this);
153 // Initialize display default parameters
155 // Set front view by default
162 fDrawClusters = kTRUE;
164 fDrawTracks = kFALSE;
173 // Create display canvas
175 if (ysize < 100) ysize = 750;
176 Int_t xsize = Int_t(size*830./ysize);
177 fCanvas = new TCanvas("Canvas", "MUON Display",14,47,xsize,ysize);
178 fCanvas->ToggleEventStatus();
180 // Create main display pad
181 fPad = new TPad("viewpad", "MUON display",0.15,0,0.9,1);
184 fPad->SetFillColor(30);
185 fPad->SetBorderSize(2);
190 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
192 fColPad->SetFillColor(17);
193 fColPad->SetBorderSize(2);
198 // Create user interface control pad
202 // Create Range and mode pad
205 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
208 fTrigPad->SetFillColor(22);
209 fTrigPad->SetBorderSize(2);
210 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
211 fRangeSlider->SetObject(this);
212 char pickmode[] = "gAlice->Display()->SetPickMode()";
214 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
215 fPickButton->SetFillColor(38);
217 char zoommode[] = "gAlice->Display()->SetZoomMode()";
218 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
219 fZoomButton->SetFillColor(38);
221 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
222 fArcButton->SetFillColor(kGreen);
224 char butUnzoom[] = "gAlice->Display()->UnZoom()";
225 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
226 button->SetFillColor(38);
228 AppendPad(); // append display object as last object to force selection
231 fTrigPad->SetEditable(kFALSE);
232 fButtons->SetEditable(kFALSE);
234 fNextCathode = kFALSE;
236 // initialize container
238 fMUONData = new AliMUONData(fLoader,"MUON","MUON");
243 AliMUONDisplay::AliMUONDisplay(const AliMUONDisplay & display)
244 : AliDisplay(display)
246 // Protected copy constructor
248 AliFatal("Not implemented.");
253 //_____________________________________________________________________________
254 AliMUONDisplay::~AliMUONDisplay()
256 // Delete space point structure
257 if (fPoints) fPoints->Delete();
261 if (fPhits) fPhits->Delete();
265 if (fRpoints) fRpoints->Delete();
270 //_____________________________________________________________________________
271 void AliMUONDisplay::Clear(Option_t *)
273 // Delete graphics temporary objects
276 //_____________________________________________________________________________
277 void AliMUONDisplay::DisplayButtons()
279 // Create the user interface buttons
282 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
284 fButtons->SetFillColor(38);
285 fButtons->SetBorderSize(2);
288 // Int_t butcolor = 33;
289 Float_t dbutton = 0.08;
296 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
297 button = new TButton("Event +", but1, x0, y - dbutton, x1, y);
298 button->SetFillColor(38);
302 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
303 button = new TButton("Event -", but2, x0, y - dbutton, x1, y);
304 button->SetFillColor(38);
308 char but3[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(1)";
309 button = new TButton("Chamber +", but3, x0, y - dbutton, x1, y);
310 button->SetFillColor(38);
314 char but4[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(-1)";
315 button = new TButton("Chamber -", but4, x0, y - dbutton, x1, y);
316 button->SetFillColor(38);
320 char but5[] = "((AliMUONDisplay*)(gAlice->Display()))->SetChamberAndCathode(1,1)";
321 button = new TButton("Chamber 1", but5, x0, y - dbutton, x1, y);
322 button->SetFillColor(38);
326 char but6[] = "((AliMUONDisplay*)(gAlice->Display()))->NextCathode()";
327 button = new TButton("Cathode <>", but6, x0, y - dbutton, x1, y);
328 button->SetFillColor(38);
332 char but7[] = "((AliMUONDisplay*)(gAlice->Display()))->Trigger()";
333 button = new TButton("Trigger", but7, x0, y - dbutton, x1, y);
334 button->SetFillColor(38);
338 char but8[] = "((AliMUONDisplay*)(gAlice->Display()))->DrawReco()";
339 button = new TButton("Tracking", but8, x0, y - dbutton, x1, y);
340 button->SetFillColor(38);
344 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
345 diamond->SetFillColor(50);
346 diamond->SetTextAlign(22);
347 diamond->SetTextColor(5);
348 diamond->SetTextSize(0.11);
350 diamond->AddText(".. ");
351 diamond->AddText("ROOT");
352 diamond->AddText("MUON");
353 diamond->AddText("... ");
354 diamond->AddText(" ");
357 //_____________________________________________________________________________
358 void AliMUONDisplay::CreateColors() const
360 // Create the colors palette used to display clusters
375 new TColor(color,r,g,b);
385 new TColor(color,r,g,b);
395 new TColor(color,r,g,b);
405 new TColor(color,r,g,b);
415 new TColor(color,r,g,b);
422 //_____________________________________________________________________________
423 void AliMUONDisplay::DisplayColorScale()
425 // Display pulse height color scale
428 Float_t xlow, ylow, xup, yup, hs;
429 Float_t x1, y1, x2, y2;
433 TText *text = new TText(0,0,"");
434 text->SetTextFont(61);
435 text->SetTextSize(0.2);
436 text->SetTextAlign(22);
439 Int_t adcmax=4096; // default 12 bits ADC
445 //*-* draw colortable boxes
446 hs = (y2-y1)/Float_t(22);
450 ylow = y1 + hs*(Float_t(i));
451 yup = y1 + hs*(Float_t(i+1));
453 Double_t logscale=Double_t(i+1)*(TMath::Log(adcmax)/22);
454 Int_t scale=(Int_t)TMath::Exp(logscale);
455 sprintf(label,"%d",scale);
456 box = new TBox(xlow, ylow, xup, yup);
458 box->SetFillColor(color);
459 text->DrawText(xlow+0.7, 0.5*(ylow+yup),label);
463 //______________________________________________________________________________
464 Int_t AliMUONDisplay::DistancetoPrimitive(Int_t px, Int_t)
466 // Compute distance from point px,py to objects in event
468 gPad->SetCursor(kCross);
470 if (gPad == fTrigPad) return 9999;
472 const Int_t kBig = 9999;
474 Float_t xmin = gPad->GetX1();
475 Float_t xmax = gPad->GetX2();
476 Float_t dx = 0.02*(xmax - xmin);
477 Float_t x = gPad->AbsPixeltoX(px);
478 if (x < xmin+dx || x > xmax-dx) return dist;
480 if (fZoomMode) return 0;
484 //_____________________________________________________________________________
485 void AliMUONDisplay::Draw(Option_t *)
487 // Display current event
495 //_____________________________________________________________________________
496 void AliMUONDisplay::DrawChamber()
499 fDrawTracks = kFALSE;
501 DrawView(fTheta, fPhi, fPsi);
502 // Display the event number and title
507 //_____________________________________________________________________________
508 void AliMUONDisplay::DrawReco(Option_t *)
510 // Display current event
513 // print kinematics of generated particles
515 // Draw global view of muon system
517 DrawGlobalView(135, -50, -140);
519 // Display the event number and title
524 //_____________________________________________________________________________
525 void AliMUONDisplay::PrintKinematics()
527 AliRunLoader * runLoader;
528 TParticle *particle = new TParticle();
530 Float_t vertex[3], momentum[3];
533 runLoader = fLoader->GetRunLoader();
537 printf("****** Event # %d ******\n",runLoader->GetEventNumber());
538 runLoader->TreeK()->GetBranch("Particles")->SetAddress(&particle);
539 nPart = (Int_t)runLoader->TreeK()->GetEntries();
540 for(Int_t iPart = 0; iPart < nPart; iPart++) {
541 runLoader->TreeK()->GetEvent(iPart);
542 vertex[0] = particle->Vx();
543 vertex[1] = particle->Vy();
544 vertex[2] = particle->Vz();
545 momentum[0] = particle->Px();
546 momentum[1] = particle->Py();
547 momentum[2] = particle->Pz();
549 printf("===================================================\n");
550 printf(" Generated particle # %d \n",iPart);
551 printf(" name: %s \n",particle->GetName());
552 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
553 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
558 void AliMUONDisplay::DrawSegmentation()
560 // to be re-written for new seg
561 // Draw graphical representation of segmenatation
562 // Attention: still experimental code
565 // AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
566 // AliMUONChamber* iChamber;
568 // AliSegmentation* seg;
569 // iChamber = &(pMUON->Chamber(fChamber));
570 // seg=iChamber->SegmentationModel(icat);
572 // Float_t zpos=iChamber->Z();
573 // Float_t r=iChamber->ROuter();
575 // TMarker3DBox *marker;
577 // for (Int_t j=0; j<seg->Npy(); j++) {
579 // y0=j*seg->Dpy()-seg->Dpy()/2.;
580 // for (seg->FirstPad(0.,y0,0,300,0.);
584 // if (seg->ISector()==0) continue;
586 // seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
587 // Float_t dpx=seg->Dpx(seg->ISector())/2;
588 // Float_t dpy=seg->Dpy(seg->ISector())/2;
589 // marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
590 // marker->SetLineColor(seg->ISector()+1);
591 // marker->SetFillStyle(1001);
592 // marker->SetFillColor(0);
597 // for (Int_t j=0; j<250; j++) {
598 // Float_t x0=j*seg->Dpx();
599 // Float_t y0=TMath::Sqrt(r*r-x0*x0);
601 // for (seg->FirstPad(x0,0,0,0,y0);
605 // if (seg->ISector()==0) continue;
608 // seg->GetPadC(seg->Ix(), seg->Iy(), x, y, z);
609 // Float_t dpx=seg->Dpx(seg->ISector())/2;
610 // Float_t dpy=seg->Dpy(seg->ISector())/2;
611 // marker=new TMarker3DBox(x,y,zpos,dpx,dpy,0,0,0);
612 // marker->SetLineColor(seg->ISector()+1);
613 // marker->SetFillStyle(1001);
614 // marker->SetFillColor(0);
621 //_____________________________________________________________________________
622 void AliMUONDisplay::DrawClusters()
624 // Draw clusters for MUON chambers
626 Int_t ndigits, digit;
634 ndigits = points->GetEntriesFast();
635 for (digit=0;digit<ndigits;digit++){
636 pm = (AliMUONPoints*)points->UncheckedAt(digit);
640 for (Int_t im=0;im<3;im++) {
641 TMarker3DBox *marker=pm->GetMarker(im);
646 fClustersCuts += pm->GetN();
650 //_____________________________________________________________________________
651 void AliMUONDisplay::DrawHits()
653 // Draw hits for MUON chambers
657 Int_t ntracks, track;
664 ntracks = points->GetEntriesFast();
665 for (track=0;track<ntracks;track++) {
666 pm = (AliMUONPoints*)points->UncheckedAt(track);
669 fHitsCuts += pm->GetN();
674 //_____________________________________________________________________________
675 void AliMUONDisplay::DrawCoG()
677 // Draw hits for MUON chambers
678 if (!fDrawCoG) return;
679 if (fChamber > 10) return;
680 LoadCoG(fChamber,fCathode);
688 ncog = points->GetEntriesFast();
689 for (icog=0;icog<ncog;icog++) {
690 pm = (AliMUONPoints*)points->UncheckedAt(icog);
695 //_____________________________________________________________________________
696 void AliMUONDisplay::DrawTracks()
699 if (!fDrawTracks) return;
702 Int_t nTrack, iTrack;
708 nTrack = points->GetEntriesFast();
709 for ( iTrack = 0; iTrack < nTrack; iTrack++) {
710 pm = (TPolyLine3D*)points->UncheckedAt(iTrack);
715 //_____________________________________________________________________________
717 void AliMUONDisplay::DrawTitle(Option_t *option)
719 // Draw the event title
721 Float_t xmin = gPad->GetX1();
722 Float_t xmax = gPad->GetX2();
723 Float_t ymin = gPad->GetY1();
724 Float_t ymax = gPad->GetY2();
725 Float_t dx = xmax-xmin;
726 Float_t dy = ymax-ymin;
728 AliRunLoader * runLoader;
730 runLoader = fLoader->GetRunLoader();
735 if (strlen(option) == 0) {
736 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
737 // title->SetTextSize(0.023932);
738 title->SetTextSize(0.02);
739 title->SetBit(kCanDelete);
740 title->SetFillColor(42);
743 sprintf(ptitle, "Alice event:%d Run:%d Chamber:%d Cathode:%d",
744 runLoader->GetEventNumber(),
745 gAlice->GetHeader()->GetRun(),
748 title->AddText(ptitle);
749 Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast();
750 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
751 nparticles, fHitsCuts,fClustersCuts);
752 title->AddText(ptitle);
754 TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
755 label->SetBit(kCanDelete);
756 label->SetFillColor(42);
761 //_____________________________________________________________________________
762 void AliMUONDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
764 // Draw a view of MUON clusters
765 AliInfo(" Draw View");
767 gPad->SetCursor(kWatch);
768 // gPad->SetFillColor(39);
769 gPad->SetFillColor(1);
771 // gPad->SetFillColor(39);
772 gPad->SetFillColor(1);
775 TView *view = new TView(1);
777 Float_t range = fRrange*fRangeSlider->GetMaximum();
778 view->SetRange(-range,-range,-range,range, range, range);
779 // zoom back to full scale only if DrawView not called from NextCathode
788 Float_t xg1, xg2, yg1, yg2, zg1, zg2;
790 // Recovering the chamber
791 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
793 const AliMUONGeometryTransformer* kGeomTransformer
794 = pMUON->GetGeometryTransformer();
796 AliMUONSegmentation* segmentation = pMUON->GetSegmentation();
797 AliMpSegFactory segFactory;
798 // Mapping segmentation factory will be used only to create mapping
799 // segmentations if not present in the DE segmentations
801 // Display MUON Chamber Geometry
803 sprintf(nodeName,"MUON%d",100+fChamber);
804 printf(">>>> chamber is %d\n",fChamber);
808 for ( it.First(fChamber-1); ! it.IsDone(); it.Next() ) {
810 Int_t detElemId = it.CurrentDE();
811 AliMpSectorSegmentation * seg =
812 (AliMpSectorSegmentation *) segmentation->GetMpSegmentation(detElemId, 0);
813 const AliMpSector * sector = seg->GetSector();
815 // get sector measurements
816 TVector2 position = sector->Position();
817 TVector2 dimension = sector->Dimensions(); // half length
819 Float_t xlocal1 = position.Px(); // FIXME: not really needed as it's 0 ?
820 Float_t ylocal1 = position.Py(); // FIXME: not really needed as it's 0 ?
821 Float_t xlocal2 = dimension.Px() * 2.;
822 Float_t ylocal2 = dimension.Px() * 2.;
824 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
825 kGeomTransformer->Local2Global(detElemId, xlocal2, ylocal2, 0, xg2, yg2, zg2);
828 TPolyLine3D* poly = new TPolyLine3D();
831 poly->SetPoint(nPoint++, xg1, yg1, 0.);
832 for (Float_t d = 0; d < TMath::Pi()/2.; d+= 0.01) {
833 Float_t x = xg1 + xg2 * TMath::Cos(d);
834 Float_t y = yg1 + yg2 * TMath::Sin(d);
835 poly->SetPoint(nPoint++, x, y, 0.);
837 poly->SetPoint(nPoint++, xg1, yg1, 0.);
839 poly->SetLineColor(2);
848 for ( it.First(fChamber-1); ! it.IsDone(); it.Next() )
850 Int_t detElemId = it.CurrentDE();
851 AliMpStationType stationType = AliMpDEManager::GetStationType(detElemId);
853 if ( segmentation->HasDE(detElemId) )
855 const AliMpVSegmentation* seg = segmentation->GetMpSegmentation(detElemId, 0);
857 // Create mapping segmentation if old trigger segmentation
858 // (not using mapping)
859 seg = segFactory.CreateMpSegmentation(detElemId, 0);
863 Float_t deltax = seg->Dimensions().X();
864 Float_t deltay = seg->Dimensions().Y();
865 Float_t xlocal1 = -deltax;
866 Float_t ylocal1 = -deltay;
867 Float_t xlocal2 = +deltax;
868 Float_t ylocal2 = +deltay;
869 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
870 kGeomTransformer->Local2Global(detElemId, xlocal2, ylocal2, 0, xg2, yg2, zg2);
872 // drawing slat active volumes
873 Float_t xCenter = (xg1 + xg2)/2.;
874 Float_t yCenter = (yg1 + yg2)/2.;
876 TMarker3DBox* box = new TMarker3DBox(xCenter,yCenter,0,xlocal1,ylocal2,0,0,0);
878 box->SetFillStyle(0);
879 box->SetLineColor( stationType == kStationTrigger ? 4 : 2);
882 if ( stationType == kStation345 )
884 // drawing inner circle + disc
885 TPolyLine3D* poly = new TPolyLine3D();
886 TPolyLine3D* poly1 = new TPolyLine3D();
890 for (Float_t d = 0; d < 6.24; d+= 0.005)
892 Double_t x = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Cos(d)/2.;
893 Double_t y = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Sin(d)/2.;
894 if (nPoint % 2 == 0) poly->SetPoint(nPoint++, 0., 0., 0.);
895 poly->SetPoint(nPoint++, x, y, 0.);
896 poly1->SetPoint(nPoint1++, x, y, 0.);
898 poly->SetLineColor(1);
900 poly1->SetLineColor(2);
908 // // Delete mapping segmentations created with factory
909 // segFactory.DeleteSegmentations();
911 //add clusters to the pad
915 // DrawSegmentation();
916 // add itself to the list (must be last)
918 view->SetView(phi, theta, psi, iret);
921 //_____________________________________________________________________________
922 void AliMUONDisplay::DrawGlobalView(Float_t theta, Float_t phi, Float_t psi)
924 // Draw a view of muons chambers with tracks
926 gPad->SetCursor(kWatch);
927 // gPad->SetFillColor(39);
928 gPad->SetFillColor(1);
930 // gPad->SetFillColor(39);
931 gPad->SetFillColor(1);
935 TView *view = new TView(1);
937 Float_t range = fRrange*fRangeSlider->GetMaximum()*3.;
938 view->SetRange(-range,-range,-range,range,range,range);
940 // Display all MUON Chambers segmentation
943 sprintf(nodeName,"alice");
945 node1=gAlice->GetGeometry()->GetNode(nodeName);
946 if (node1) node1->Draw("same");
949 // Draw clusters for all chambers
950 Int_t chamberSave = fChamber;
951 for (fChamber = 1; fChamber <= 10; fChamber++){
954 fChamber = chamberSave;
955 // Draw reconstructed tracks
962 Float_t x0 = (-1+shift)/zoom;
963 Float_t y0 = (-1+shift)/zoom;
964 Float_t x1 = (1+shift)/zoom;
965 Float_t y1 = (1+shift)/zoom;
966 gPad->Range(x0,y0,x1,y1);
967 view->SetView(phi, theta, psi, iret);
971 //______________________________________________________________________________
972 void AliMUONDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
974 // Execute action corresponding to the mouse event
976 static Float_t x0, y0, x1, y1;
978 static Int_t pxold, pyold;
979 static Int_t px0, py0;
980 static Int_t linedrawn;
983 if (px == 0 && py == 0) { //when called by sliders
984 if (event == kButton1Up) {
989 if (!fZoomMode && gPad->GetView()) {
990 gPad->GetView()->ExecuteRotateView(event, px, py);
994 // something to zoom ?
995 gPad->SetCursor(kCross);
1000 gVirtualX->SetLineColor(-1);
1001 gPad->TAttLine::Modify(); //Change line attributes only if necessary
1002 x0 = gPad->AbsPixeltoX(px);
1003 y0 = gPad->AbsPixeltoY(py);
1005 pxold = px; pyold = py;
1009 case kButton1Motion:
1010 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
1014 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
1018 gPad->GetCanvas()->FeedbackMode(kFALSE);
1019 if (px == px0) return;
1020 if (py == py0) return;
1021 x1 = gPad->AbsPixeltoX(px);
1022 y1 = gPad->AbsPixeltoY(py);
1024 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
1025 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
1026 gPad->Range(x0,y0,x1,y1);
1027 if (fZooms < AliMUONConstants::MaxZoom()-1) {
1029 fZoomX0[fZooms] = x0;
1030 fZoomY0[fZooms] = y0;
1031 fZoomX1[fZooms] = x1;
1032 fZoomY1[fZooms] = y1;
1034 gPad->Modified(kTRUE);
1039 //___________________________________________
1040 void AliMUONDisplay::LoadDigits(Int_t chamber, Int_t cathode)
1042 // Read digits info and store x,y,z info in arrays fPoints
1043 // Loop on all detectors
1045 if (chamber > 14) return;
1051 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1053 AliMUONGeometrySegmentation* segmentation2 = 0x0;
1055 GetMUONData()->SetTreeAddress("D");
1057 TClonesArray *muonDigits = GetMUONData()->Digits(chamber-1);
1058 if (muonDigits == 0) return;
1060 gAlice->ResetDigits();
1063 if (GetLoader()->TreeD()) {
1064 nent = (Int_t) GetLoader()->TreeD()->GetEntries();
1065 // gAlice->TreeD()->GetEvent(nent-2+cathode-1);
1066 GetMUONData()->GetDigits();
1069 Int_t ndigits = muonDigits->GetEntriesFast();
1070 if (ndigits == 0) return;
1071 if (fPoints == 0) fPoints = new TObjArray(ndigits);
1073 Float_t zpos = AliMUONConstants::DefaultChamberZ(chamber-1);
1076 AliMUONPoints *points = 0;
1077 TMarker3DBox *marker = 0;
1080 Float_t adcmax = 1024; // default
1081 if (chamber<11) adcmax = 4096;
1083 // check if trigger is using new or old segmentation
1085 AliMUONSegmentation* segmentation = pMUON->GetSegmentation();
1086 if ( segmentation->GetMpSegmentation(1100, cathode-1) ) old = false;
1088 if ( old && chamber > 10) {
1089 if (chamber > 10) printf(">>> old segmentation for trigger \n");
1090 else printf(">>> old segmentation for tracking \n");
1093 = pMUON->GetSegmentation()->GetModuleSegmentation(chamber-1, cathode-1);
1094 for (Int_t digit = 0; digit < ndigits; digit++) {
1095 mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
1096 if (mdig->Cathode() != cathode-1) continue;
1099 // First get all needed parameters
1101 Int_t charge = mdig->Signal();
1102 Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
1103 Int_t color = 261+index;
1104 Int_t colorTrigger = 2;
1105 if (color > 282) color = 282;
1107 if (chamber > 10) { // trigger chamber
1109 Int_t sumCharge = 0;
1110 for (Int_t icharge = 0; icharge < 10; icharge++) {
1111 sumCharge = sumCharge+mdig->TrackCharge(icharge);
1113 Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10;
1114 if(sumCharge <= 10 || testCharge > 0) {
1115 colorTrigger = color;
1121 // get the center of the pad - add on x and y half of pad size
1122 Float_t xpad, ypad, zpad;
1126 Int_t detElemId = mdig->DetElemId();
1127 segmentation2->GetPadC(detElemId, mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
1128 isec = segmentation2->Sector(detElemId, mdig->PadX(), mdig->PadY());
1129 dpx = segmentation2->Dpx(detElemId, isec)/2;
1130 dpy = segmentation2->Dpy(detElemId, isec)/2;
1132 // Then set the objects
1133 points = new AliMUONPoints(npoints);
1134 fPoints->AddAt(points,digit);
1136 points->SetMarkerColor(colorTrigger);
1138 points->SetMarkerColor(color);
1140 points->SetMarkerStyle(21);
1141 points->SetMarkerSize(0.5);
1142 points->SetParticle(-1);
1143 points->SetHitIndex(-1);
1144 points->SetTrackIndex(-1);
1145 points->SetDigitIndex(digit);
1146 points->SetPoint(0,xpad,ypad,zpos);
1148 Int_t lineColor = (zpad-zpos > 0) ? 2:3;
1149 marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0);
1152 marker->SetLineColor(lineColor);
1153 marker->SetFillStyle(1001);
1154 marker->SetFillColor(color);
1155 marker->SetRefObject((TObject*)points);
1156 points->Set3DMarker(0, marker);
1157 } // end loop on digits
1160 if (chamber > 10) printf(">>> new segmentation for trigger \n");
1161 else printf(">>> new segmentation for tracking \n");
1163 const AliMUONGeometryTransformer* kGeomTransformer
1164 = pMUON->GetGeometryTransformer();
1166 //loop over all digits and store their position
1167 for (Int_t digit = 0; digit < ndigits; digit++) {
1168 mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
1169 if (mdig->Cathode() != cathode-1) continue;
1171 // get all needed parameters
1172 Int_t ix=mdig->PadX();
1173 Int_t iy=mdig->PadY();
1174 Int_t detElemId=mdig->DetElemId();
1175 Int_t charge = mdig->Signal();
1176 Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
1177 Int_t color = 261+index;
1178 Int_t colorTrigger = 2;
1179 if (color > 282) color = 282;
1181 const AliMpVSegmentation* seg =
1182 pMUON->GetSegmentation()->GetMpSegmentation(detElemId,cathode-1);
1184 AliMpPad pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
1186 if (chamber > 10) { // trigger chamber
1187 Int_t sumCharge = 0;
1188 Int_t n = mdig->Ntracks();
1189 for (Int_t icharge = 0; icharge < n; icharge++) {
1190 sumCharge = sumCharge+mdig->TrackCharge(icharge);
1192 assert(sumCharge==mdig->Signal());
1193 Int_t testCharge = sumCharge-(Int_t(sumCharge/n))*n;
1194 if(sumCharge <= n || testCharge > 0) {
1195 colorTrigger = color;
1201 // get the pad position and dimensions
1202 Float_t xlocal1 = pad.Position().X();
1203 Float_t ylocal1 = pad.Position().Y();
1204 Float_t xlocal2 = pad.Dimensions().X();
1205 Float_t ylocal2 = pad.Dimensions().Y();
1207 Float_t xg1, xg2, yg1, yg2, zg1;
1209 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
1210 // (no transformation for pad dimensions)
1214 // Then set the objects
1215 points = new AliMUONPoints(npoints);
1216 fPoints->AddAt(points,digit);
1218 points->SetMarkerColor(colorTrigger);
1220 points->SetMarkerColor(color);
1222 points->SetMarkerStyle(21);
1223 points->SetMarkerSize(0.5);
1224 points->SetParticle(-1);
1225 points->SetHitIndex(-1);
1226 points->SetTrackIndex(-1);
1227 points->SetDigitIndex(digit);
1228 points->SetPoint(0,xg1,yg1,zpos);
1230 Int_t lineColor = (zg1-zpos > 0) ? 2:3;
1231 marker=new TMarker3DBox(xg1,yg1,zpos,xg2,yg2,0,0,0);
1233 marker->SetLineColor(lineColor);
1234 marker->SetFillStyle(1001);
1235 marker->SetFillColor(color);
1236 marker->SetRefObject((TObject*)points);
1237 points->Set3DMarker(0, marker);
1239 } // end loop on digits
1240 } // end of new segmentation
1242 //___________________________________________
1243 void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/)
1245 // Read raw clusters info and store x,y,z info in arrays fRpoints
1246 // Loop on all detectors
1248 if (chamber > 10) return;
1252 GetMUONData()->SetTreeAddress("RC");
1253 TClonesArray *muonRawClusters = GetMUONData()->RawClusters(chamber-1);
1255 if (muonRawClusters == 0) return;
1258 if (GetMUONData()->TreeR()) {
1259 nent=(Int_t) GetMUONData()->TreeR()->GetEntries();
1260 GetMUONData()->TreeR()->GetEvent(0);
1263 Int_t nrawcl = muonRawClusters->GetEntriesFast();
1264 if (nrawcl == 0) return;
1265 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
1267 Float_t zpos = AliMUONConstants::DefaultChamberZ(chamber-1);
1268 AliMUONRawCluster *mRaw;
1269 AliMUONPoints *points = 0;
1271 //loop over all raw clusters and store their position
1272 points = new AliMUONPoints(nrawcl);
1273 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
1274 mRaw = (AliMUONRawCluster*)muonRawClusters->UncheckedAt(iraw);
1275 points->SetMarkerColor(51);
1276 points->SetMarkerStyle(2);
1277 points->SetMarkerSize(1.);
1278 points->SetParticle(-1);
1279 points->SetHitIndex(-1);
1280 points->SetTrackIndex(-1);
1281 points->SetDigitIndex(-1);
1282 points->SetPoint(iraw,mRaw->GetX(0),mRaw->GetY(0),zpos);
1283 fRpoints->AddAt(points,iraw);
1284 // printf("%f and %f and %f\n",mRaw->GetX(0),mRaw->GetY(0),mRaw->GetZ(0));
1288 //___________________________________________
1289 void AliMUONDisplay::LoadTracks()
1292 AliMUONTrack* recTrack = 0;
1293 AliMUONTrackParam* trackParam = 0;
1294 TClonesArray * trackParamAtHit = 0;
1298 GetMUONData()->SetTreeAddress("RT");
1299 TClonesArray* recTracksArray = GetMUONData()->RecTracks();
1300 if (recTracksArray == NULL) return;
1301 GetMUONData()->GetRecTracks();
1303 Int_t nRecTracks = 0;
1305 nRecTracks = (Int_t) recTracksArray->GetEntriesFast();
1308 if (fRpoints == 0) fRpoints = new TObjArray(nRecTracks);
1310 for (Int_t iRecTracks = 0; iRecTracks < nRecTracks; iRecTracks++) {
1311 // reading info from tracks
1312 recTrack = (AliMUONTrack*) recTracksArray->At(iRecTracks);
1314 Int_t nTrackHits = recTrack->GetNTrackHits();
1316 if (nTrackHits == 0) continue;
1319 TPolyLine3D *points = new TPolyLine3D(nTrackHits+1);
1320 points->SetLineColor(6);
1321 points->SetLineWidth(1);
1322 fRpoints->AddAt(points,iRecTracks);
1328 trackParam = recTrack->GetTrackParamAtVertex();
1329 xRec = trackParam->GetNonBendingCoor();
1330 yRec = trackParam->GetBendingCoor();
1331 zRec = trackParam->GetZ();
1332 points->SetPoint(iPoint,xRec,yRec,zRec);
1335 for (Int_t iHit = 0; iHit < nTrackHits; iHit++){
1336 trackParamAtHit = recTrack->GetTrackParamAtHit();
1337 trackParam = (AliMUONTrackParam*) trackParamAtHit->At(iHit);
1338 xRec = trackParam->GetNonBendingCoor();
1339 yRec = trackParam->GetBendingCoor();
1340 zRec = trackParam->GetZ();
1341 points->SetPoint(iPoint,xRec,yRec,zRec);
1343 } // end loop rec. hits
1344 PrintTrack(iRecTracks,recTrack);
1345 } // end loop tracks
1350 void AliMUONDisplay::PrintTrack(Int_t iRecTracks, AliMUONTrack *recTrack)
1352 AliMUONTrackParam *trackParam;
1353 Float_t vertex[3], momentum[3];
1354 Float_t pYZ, bendingSlope, nonBendingSlope, chi2dof;
1357 trackParam = recTrack->GetTrackParamAtVertex();
1358 vertex[0] = trackParam->GetNonBendingCoor();
1359 vertex[1] = trackParam->GetBendingCoor();
1360 vertex[2] = trackParam->GetZ();
1361 pYZ = 1./TMath::Abs(trackParam->GetInverseBendingMomentum());
1362 bendingSlope = trackParam->GetBendingSlope();
1363 nonBendingSlope = trackParam->GetNonBendingSlope();
1364 momentum[2] = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);
1365 momentum[0] = momentum[2] * nonBendingSlope;
1366 momentum[1] = momentum[2] * bendingSlope;
1367 charge = Int_t(TMath::Sign(1.,trackParam->GetInverseBendingMomentum()));
1368 chi2dof = recTrack->GetFitFMin()/(2.0 * recTrack->GetNTrackHits() - 5.);
1370 printf("===================================================\n");
1371 printf(" Reconstructed track # %d \n",iRecTracks);
1372 printf(" charge: %d \n",charge);
1373 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
1374 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
1375 printf(" track chi2/dof: %f \n",chi2dof);
1379 //___________________________________________
1380 void AliMUONDisplay::LoadHits(Int_t chamber)
1382 // Read hits info and store x,y,z info in arrays fPhits
1383 // Loop on all detectors
1385 if (chamber > 14) return;
1392 Float_t zpos=AliMUONConstants::DefaultChamberZ(chamber-1);
1394 if (GetMUONData()->TreeH()) {
1395 GetMUONData()->SetTreeAddress("H");
1396 Int_t ntracks = (Int_t)GetMUONData()->TreeH()->GetEntries(); //skowron
1398 for (track = 0; track < ntracks; track++) {
1399 GetMUONData()->ResetHits();
1400 GetMUONData()->GetTrack(track);//skowron
1401 TClonesArray *muonHits = GetMUONData()->Hits();
1402 if (muonHits == 0) return;
1403 nthits += muonHits->GetEntriesFast();
1405 if (fPhits == 0) fPhits = new TObjArray(nthits);
1407 for (track=0; track<ntracks;track++) {
1408 GetMUONData()->ResetHits();
1409 GetMUONData()->GetTrack(track);//skowron
1410 TClonesArray *muonHits = GetMUONData()->Hits();
1411 if (muonHits == 0) return;
1412 Int_t nhits = muonHits->GetEntriesFast();
1413 if (nhits == 0) continue;
1415 AliMUONPoints *points = 0;
1417 for (Int_t hit=0;hit<nhits;hit++) {
1418 mHit = (AliMUONHit*)muonHits->UncheckedAt(hit);
1419 Int_t nch = mHit->Chamber(); // chamber number
1420 if (nch != chamber) continue;
1422 // Retrieve info and set the objects
1424 points = new AliMUONPoints(npoints);
1425 fPhits->AddAt(points,nhold+hit);
1426 points->SetMarkerColor(kRed);
1427 points->SetMarkerStyle(5);
1428 points->SetMarkerSize(1.);
1429 points->SetParticle(mHit->Track());
1430 points->SetHitIndex(hit);
1431 points->SetTrackIndex(track);
1432 points->SetDigitIndex(-1);
1433 points->SetPoint(0,mHit->X(),mHit->Y(),zpos);
1434 // printf("%f and %f and %f\n",mHit->X(),mHit->Y(),mHit->Z());
1441 //_____________________________________________________________________________
1442 void AliMUONDisplay::Paint(Option_t *)
1444 // Paint miscellaneous items
1447 //_____________________________________________________________________________
1448 void AliMUONDisplay::SetPickMode()
1450 // Set parameters for pick mode.
1454 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1455 fTrigPad->Modified();
1458 //_____________________________________________________________________________
1459 void AliMUONDisplay::SetZoomMode()
1461 // Set parameters for zoom mode
1464 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1465 fTrigPad->Modified();
1468 //_____________________________________________________________________________
1469 void AliMUONDisplay::NextChamber(Int_t delta)
1471 // to go from chamber to next chamber if delta = 1
1472 // or previous chamber otherwise
1474 if (fChamber < AliMUONConstants::NCh()) fChamber++;
1476 if (fChamber > 1) fChamber--;
1480 LoadDigits(fChamber, fCathode);
1484 //_____________________________________________________________________________
1485 void AliMUONDisplay::NextCathode()
1487 // to switch to other cathode plane
1490 if (fCathode == 1) {
1491 LoadDigits(fChamber, 2);
1493 LoadDigits(fChamber, 1);
1495 fNextCathode = kTRUE; // to keep the same zoom
1497 fNextCathode = kFALSE;
1498 TPad *pad = (TPad*)gPad->GetPadSave();
1499 pad->Range(fZoomX0[fZooms], fZoomY0[fZooms],
1500 fZoomX1[fZooms], fZoomY1[fZooms]);
1506 //_____________________________________________________________________________
1507 void AliMUONDisplay::Trigger()
1510 AliMUONGlobalTrigger* globalTrig;
1512 GetMUONData()->SetTreeAddress("GLT");
1513 GetMUONData()->GetTriggerD();
1515 globalTrig = (AliMUONGlobalTrigger*)GetMUONData()->GlobalTrigger()->UncheckedAt(0);
1516 if (globalTrig == 0) return;
1518 printf("===================================================\n");
1519 printf(" Global Trigger output Low pt High pt All\n");
1521 printf(" number of Single Plus :\t");
1522 printf("%i\t",globalTrig->SinglePlusLpt());
1523 printf("%i\t",globalTrig->SinglePlusHpt());
1524 printf("%i\t",globalTrig->SinglePlusApt());
1527 printf(" number of Single Minus :\t");
1528 printf("%i\t",globalTrig->SingleMinusLpt());
1529 printf("%i\t",globalTrig->SingleMinusHpt());
1530 printf("%i\t",globalTrig->SingleMinusApt());
1533 printf(" number of Single Undefined :\t");
1534 printf("%i\t",globalTrig->SingleUndefLpt());
1535 printf("%i\t",globalTrig->SingleUndefHpt());
1536 printf("%i\t",globalTrig->SingleUndefApt());
1539 printf(" number of UnlikeSign pair :\t");
1540 printf("%i\t",globalTrig->PairUnlikeLpt());
1541 printf("%i\t",globalTrig->PairUnlikeHpt());
1542 printf("%i\t",globalTrig->PairUnlikeApt());
1545 printf(" number of LikeSign pair :\t");
1546 printf("%i\t",globalTrig->PairLikeLpt());
1547 printf("%i\t",globalTrig->PairLikeHpt());
1548 printf("%i\t",globalTrig->PairLikeApt());
1550 printf("===================================================\n");
1554 // // returns Trigger Decision for current event
1555 // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(GetLoader(),1);
1557 // // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
1558 // AliMUONData* muonData = decision->GetMUONData();
1559 // muonData->SetTreeAddress("D");
1560 // decision->Trigger();
1562 //_____________________________________________________________________________
1563 void AliMUONDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1565 // Set chamber and cathode number
1571 LoadDigits(chamber,cathode);
1575 void AliMUONDisplay::SetEvent(Int_t newevent)
1578 gAlice->GetEvent(newevent);
1580 if (!gAlice->TreeD()) return;
1583 LoadDigits(fChamber,fCathode);
1587 //_____________________________________________________________________________
1588 void AliMUONDisplay::SetRange(Float_t rrange, Float_t zrange)
1590 // Set view range along R and Z
1599 //_____________________________________________________________________________
1600 void AliMUONDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1602 // change viewing angles for current event
1610 TView *view = gPad->GetView();
1611 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1616 //_____________________________________________________________________________
1617 void AliMUONDisplay::ShowNextEvent(Int_t delta)
1619 AliRunLoader * runLoader;
1621 runLoader = fLoader->GetRunLoader();
1625 // Display (current event_number + delta)
1626 // delta = 1 shown next event
1627 // delta = -1 show previous event
1629 //runLoader->CleanDetectors();
1630 //runLoader->CleanKinematics();
1631 Int_t currentEvent = runLoader->GetEventNumber();
1632 Int_t newEvent = currentEvent + delta;
1633 runLoader->GetEvent(newEvent);
1636 LoadDigits(fChamber, fCathode);
1641 //______________________________________________________________________________
1642 void AliMUONDisplay::UnZoom()
1645 if (fZooms <= 0) return;
1647 TPad *pad = (TPad*)gPad->GetPadSave();
1648 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1652 //_____________________________________________________________________________
1653 void AliMUONDisplay::ResetPoints()
1656 // Reset array of points
1664 //_____________________________________________________________________________
1665 void AliMUONDisplay::ResetPhits()
1668 // Reset array of points
1676 //_____________________________________________________________________________
1677 void AliMUONDisplay::ResetRpoints()
1680 // Reset array of points
1689 AliMUONDisplay & AliMUONDisplay::operator = (const AliMUONDisplay & rhs)
1691 // Protected assignement operator
1693 if (this == &rhs) return *this;
1695 AliFatal("Not implemented.");