]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONDisplay.cxx
Move to new mapping
[u/mrichter/AliRoot.git] / MUON / AliMUONDisplay.cxx
CommitLineData
a9e2aefa 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
88cb7938 16/* $Id$ */
a9e2aefa 17
18//////////////////////////////////////////////////////////////////////////
19// //
20// AliDisplay //
21// //
22// Utility class to display ALICE outline, tracks, hits,.. //
23// //
24//////////////////////////////////////////////////////////////////////////
25
30178c30 26#include "AliMUONDisplay.h"
a9e2aefa 27#include "AliMUON.h"
a9e2aefa 28#include "AliMUONPoints.h"
d226f81b 29#include "AliMUONGlobalTrigger.h"
a9e2aefa 30#include "AliMUONHit.h"
a9e2aefa 31#include "AliMUONDigit.h"
32#include "AliMUONRawCluster.h"
572d5bb2 33#include "AliMUONTrack.h"
34#include "AliMUONTrackParam.h"
b7ef3c96 35#include "AliMUONGeometryTransformer.h"
7502d0e5 36#include "AliMUONSegmentation.h"
37#include "AliMUONGeometrySegmentation.h"
38#include "AliMUONConstants.h"
1169bc87 39#include "AliMUONTriggerSegmentationV2.h"
7502d0e5 40
41#include "AliMpDEIterator.h"
42#include "AliMpSegFactory.h"
123469eb 43#include "AliMpSlatSegmentation.h"
44#include "AliMpSlat.h"
63216d66 45#include "AliMpSectorSegmentation.h"
e0d2f4db 46#include "AliMpSector.h"
e0d2f4db 47#include "AliMpTriggerSegmentation.h"
48#include "AliMpTrigger.h"
1169bc87 49#include "AliMpStationType.h"
50#include "AliMpDEManager.h"
123469eb 51
5d12ce38 52#include "AliMC.h"
8c343c7c 53#include "AliLog.h"
7502d0e5 54#include "AliRun.h"
55#include "AliHeader.h"
56
57#include <TButton.h>
58#include <TColor.h>
59#include <TCanvas.h>
60#include <TView.h>
61#include <TText.h>
62#include <TPaveLabel.h>
63#include <TPaveText.h>
64#include <TDiamond.h>
65#include <TNode.h>
66#include <TArc.h>
67#include <TSlider.h>
68#include <TVirtualX.h>
69#include <TMath.h>
70#include <TGeometry.h>
71#include <TMarker3DBox.h>
72#include <TParticle.h>
73#include <TPolyLine3D.h>
74#include <TBox.h>
a9e2aefa 75
76
77
78ClassImp(AliMUONDisplay)
79
80
81//_____________________________________________________________________________
82AliMUONDisplay::AliMUONDisplay()
30178c30 83 : AliDisplay()
a9e2aefa 84{
85// Constructor
d226f81b 86 fPoints = 0;
87 fPhits = 0;
88 fRpoints = 0;
89 fCanvas = 0;
a9e2aefa 90 fNextCathode = kFALSE;
d226f81b 91 fColPad = 0;
a9e2aefa 92}
93
94//_____________________________________________________________________________
307d9d04 95AliMUONDisplay::AliMUONDisplay(Int_t size, AliLoader * loader)
30178c30 96 : AliDisplay()
a9e2aefa 97{
98// Create an event display object.
99// A canvas named "edisplay" is created with a vertical size in pixels
100//
101// A QUICK Overview of the Event Display functions
102// ===============================================
103//
104// The event display can ve invoked by executing the macro "display.C"
105// A canvas like in the picture below will appear.
106//
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
110
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.
118//
119// slider R On the left side, the vertical slider can be used to
120// set the default picture size.
121//
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.
124
125//
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.
129//
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.
137// Click on TH
138// Click on TPC for example
139// Click on any variable (eg TPC.fX) to histogram the variable.
140//
141// If you are lost, you can click on HELP in any Root canvas or browser.
142//Begin_Html
143/*
144<img src="gif/AliMUONDisplay.gif">
145*/
146//End_Html
147
148
149 fPad = 0;
150
151 gAlice->SetDisplay(this);
152
153 // Initialize display default parameters
154 SetRange(200,2000);
155 // Set front view by default
156 fTheta = 0;
157 fPhi = -90;
158 fPsi = 0;
159 fChamber = 1;
160 fCathode = 1;
161 // fRzone = 1.e10;
162 fDrawClusters = kTRUE;
163 fDrawCoG = kTRUE;
572d5bb2 164 fDrawTracks = kFALSE;
a9e2aefa 165 fZoomMode = 1;
166 fZooms = 0;
167 fClustersCuts = 0;
d226f81b 168 fPoints = 0;
169 fPhits = 0;
170 fRpoints = 0;
a9e2aefa 171 // Create colors
172 CreateColors();
173 // Create display canvas
174 Int_t ysize = size;
175 if (ysize < 100) ysize = 750;
176 Int_t xsize = Int_t(size*830./ysize);
572d5bb2 177 fCanvas = new TCanvas("Canvas", "MUON Display",14,47,xsize,ysize);
a9e2aefa 178 fCanvas->ToggleEventStatus();
179
180 // Create main display pad
181 fPad = new TPad("viewpad", "MUON display",0.15,0,0.9,1);
182 fPad->Draw();
183 fPad->Modified();
184 fPad->SetFillColor(30);
185 fPad->SetBorderSize(2);
186
187 fCanvas->cd();
188
189 // Create colors pad
190 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
191 fColPad->Draw();
192 fColPad->SetFillColor(17);
193 fColPad->SetBorderSize(2);
194 fColPad->cd();
195 DisplayColorScale();
196
197 fCanvas->cd();
198 // Create user interface control pad
199 DisplayButtons();
200 fCanvas->cd();
201
202 // Create Range and mode pad
203 Float_t dxtr = 0.15;
204 Float_t dytr = 0.45;
205 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
a9e2aefa 206 fTrigPad->Draw();
207 fTrigPad->cd();
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()";
213 Float_t db = 0.09;
214 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
215 fPickButton->SetFillColor(38);
216 fPickButton->Draw();
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);
220 fZoomButton->Draw();
221 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
222 fArcButton->SetFillColor(kGreen);
223 fArcButton->Draw();
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);
227 button->Draw();
228 AppendPad(); // append display object as last object to force selection
229
230 fCanvas->cd();
1c4b7942 231 fTrigPad->SetEditable(kFALSE);
232 fButtons->SetEditable(kFALSE);
a9e2aefa 233 fCanvas->Update();
234 fNextCathode = kFALSE;
307d9d04 235 fLoader = loader;
d226f81b 236 // initialize container
237 if(fLoader)
238 fMUONData = new AliMUONData(fLoader,"MUON","MUON");
239 else
240 fMUONData =0x0;
a9e2aefa 241}
242
30178c30 243AliMUONDisplay::AliMUONDisplay(const AliMUONDisplay & display)
244 : AliDisplay(display)
a9e2aefa 245{
30178c30 246// Protected copy constructor
247
8c343c7c 248 AliFatal("Not implemented.");
a9e2aefa 249}
250
251
252
253//_____________________________________________________________________________
254AliMUONDisplay::~AliMUONDisplay()
255{
256 // Delete space point structure
257 if (fPoints) fPoints->Delete();
258 delete fPoints;
259 fPoints = 0;
260 //
261 if (fPhits) fPhits->Delete();
262 delete fPhits;
263 fPhits = 0;
264 //
d226f81b 265 if (fRpoints) fRpoints->Delete();
a9e2aefa 266 delete fRpoints;
d226f81b 267 fRpoints = 0;
a9e2aefa 268}
269
270//_____________________________________________________________________________
271void AliMUONDisplay::Clear(Option_t *)
272{
273// Delete graphics temporary objects
274}
275
276//_____________________________________________________________________________
277void AliMUONDisplay::DisplayButtons()
278{
279// Create the user interface buttons
280
281
282 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
a9e2aefa 283 fButtons->Draw();
284 fButtons->SetFillColor(38);
285 fButtons->SetBorderSize(2);
286 fButtons->cd();
287
288// Int_t butcolor = 33;
289 Float_t dbutton = 0.08;
290 Float_t y = 0.96;
291 Float_t dy = 0.014;
292 Float_t x0 = 0.05;
293 Float_t x1 = 0.95;
294
295 TButton *button;
296 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
297 button = new TButton("Event +", but1, x0, y - dbutton, x1, y);
298 button->SetFillColor(38);
299 button->Draw();
300
301 y -= dbutton + dy;
302 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
303 button = new TButton("Event -", but2, x0, y - dbutton, x1, y);
304 button->SetFillColor(38);
305 button->Draw();
306
307 y -= dbutton + dy;
308 char but3[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(1)";
309 button = new TButton("Chamber +", but3, x0, y - dbutton, x1, y);
310 button->SetFillColor(38);
311 button->Draw();
312
313 y -= dbutton + dy;
314 char but4[] = "((AliMUONDisplay*)(gAlice->Display()))->NextChamber(-1)";
315 button = new TButton("Chamber -", but4, x0, y - dbutton, x1, y);
316 button->SetFillColor(38);
317 button->Draw();
318
319 y -= dbutton + dy;
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);
323 button->Draw();
324
325 y -= dbutton + dy;
326 char but6[] = "((AliMUONDisplay*)(gAlice->Display()))->NextCathode()";
327 button = new TButton("Cathode <>", but6, x0, y - dbutton, x1, y);
328 button->SetFillColor(38);
329 button->Draw();
330
331 y -= dbutton + dy;
332 char but7[] = "((AliMUONDisplay*)(gAlice->Display()))->Trigger()";
333 button = new TButton("Trigger", but7, x0, y - dbutton, x1, y);
334 button->SetFillColor(38);
335 button->Draw();
336
572d5bb2 337 y -= dbutton + dy;
338 char but8[] = "((AliMUONDisplay*)(gAlice->Display()))->DrawReco()";
339 button = new TButton("Tracking", but8, x0, y - dbutton, x1, y);
340 button->SetFillColor(38);
341 button->Draw();
342
a9e2aefa 343 // display logo
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);
349 diamond->Draw();
350 diamond->AddText(".. ");
351 diamond->AddText("ROOT");
352 diamond->AddText("MUON");
353 diamond->AddText("... ");
354 diamond->AddText(" ");
355}
356
357//_____________________________________________________________________________
30178c30 358void AliMUONDisplay::CreateColors() const
a9e2aefa 359{
360// Create the colors palette used to display clusters
361
362 Int_t k,i;
363 Int_t color;
364 Float_t r,g,b;
365
366 for (k=1;k<=5;k++) {
367 switch(k) {
368 case 1:
369 for (i=1;i<=5;i++) {
370 r=1.;
371 g=i*0.2;
372 b=0.;
373 color=i;
374 color=260+23-color;
375 new TColor(color,r,g,b);
376 }
377 break;
378 case 2:
379 for (i=1;i<=4;i++) {
380 r=1.1-i*0.2;
381 g=1.;
382 b=0.;
383 color=i+5;
384 color=260+23-color;
385 new TColor(color,r,g,b);
386 }
387 break;
388 case 3:
389 for (i=1;i<=4;i++) {
390 r=0.;
391 g=1.;
392 b=i*0.2+0.2;
393 color=i+9;
394 color=260+23-color;
395 new TColor(color,r,g,b);
396 }
397 break;
398 case 4:
399 for (i=1;i<=4;i++) {
400 r=0.;
401 g=1.1-i*0.2;
402 b=1.;
403 color=i+13;
404 color=260+23-color;
405 new TColor(color,r,g,b);
406 }
407 break;
408 case 5:
409 for (i=1;i<=5;i++) {
410 r=i*0.2;
411 g=0.;
412 b=1.;
413 color=i+17;
414 color=260+23-color;
415 new TColor(color,r,g,b);
416 }
417 break;
418 }
419 }
420}
421
422//_____________________________________________________________________________
423void AliMUONDisplay::DisplayColorScale()
424{
425// Display pulse height color scale
426 Int_t i;
427 Int_t color;
428 Float_t xlow, ylow, xup, yup, hs;
429 Float_t x1, y1, x2, y2;
430 x1 = y1 = 0;
431 x2 = y2 = 1.0;
432
433 TText *text = new TText(0,0,"");
434 text->SetTextFont(61);
435 text->SetTextSize(0.2);
436 text->SetTextAlign(22);
437
7e4a628d 438
439 Int_t adcmax=4096; // default 12 bits ADC
440
a9e2aefa 441
442
443 TBox *box;
444 char label[8];
445//*-* draw colortable boxes
446 hs = (y2-y1)/Float_t(22);
447 xlow=x1+.05;
448 xup=x2-0.5;
449 for (i=0;i<22;i++) {
450 ylow = y1 + hs*(Float_t(i));
451 yup = y1 + hs*(Float_t(i+1));
452 color = 261+i;
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);
457 box->Draw();
458 box->SetFillColor(color);
459 text->DrawText(xlow+0.7, 0.5*(ylow+yup),label);
460 }
461}
462
463//______________________________________________________________________________
464Int_t AliMUONDisplay::DistancetoPrimitive(Int_t px, Int_t)
465{
466// Compute distance from point px,py to objects in event
467
468 gPad->SetCursor(kCross);
469
470 if (gPad == fTrigPad) return 9999;
471
472 const Int_t kBig = 9999;
473 Int_t dist = kBig;
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;
479
480 if (fZoomMode) return 0;
481 else return 7;
482}
483
484//_____________________________________________________________________________
485void AliMUONDisplay::Draw(Option_t *)
486{
487// Display current event
488
572d5bb2 489 if (!fDrawTracks)
490 DrawChamber();
491 else
492 DrawReco();
493
494}
495//_____________________________________________________________________________
496void AliMUONDisplay::DrawChamber()
497{
a9e2aefa 498
572d5bb2 499 fDrawTracks = kFALSE;
500 fPad->cd();
501 DrawView(fTheta, fPhi, fPsi);
502 // Display the event number and title
503 fPad->cd();
504 DrawTitle();
505
506}
507//_____________________________________________________________________________
508void AliMUONDisplay::DrawReco(Option_t *)
509{
510// Display current event
511
512 fDrawTracks = kTRUE;
513 // print kinematics of generated particles
514 PrintKinematics();
515 // Draw global view of muon system
516 fPad->cd();
517 DrawGlobalView(135, -50, -140);
518
a9e2aefa 519 // Display the event number and title
520 fPad->cd();
521 DrawTitle();
522}
523
572d5bb2 524//_____________________________________________________________________________
525void AliMUONDisplay::PrintKinematics()
526{
527 AliRunLoader * runLoader;
528 TParticle *particle = new TParticle();
529 Int_t nPart;
530 Float_t vertex[3], momentum[3];
531
532 if (fLoader)
533 runLoader = fLoader->GetRunLoader();
534 else
535 runLoader = 0x0;
536
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();
548
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]);
554 }
555 delete particle;
556}
557
a9e2aefa 558void AliMUONDisplay::DrawSegmentation()
559{
002920d1 560 // to be re-written for new seg
a9e2aefa 561// Draw graphical representation of segmenatation
562// Attention: still experimental code
002920d1 563// Int_t icat=1;
a9e2aefa 564
002920d1 565// AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
566// AliMUONChamber* iChamber;
76dadf7e 567
002920d1 568// AliSegmentation* seg;
569// iChamber = &(pMUON->Chamber(fChamber));
570// seg=iChamber->SegmentationModel(icat);
76dadf7e 571
002920d1 572// Float_t zpos=iChamber->Z();
573// Float_t r=iChamber->ROuter();
a9e2aefa 574
002920d1 575// TMarker3DBox *marker;
576// if (icat == 1) {
577// for (Int_t j=0; j<seg->Npy(); j++) {
578// Float_t y0;
579// y0=j*seg->Dpy()-seg->Dpy()/2.;
580// for (seg->FirstPad(0.,y0,0,300,0.);
581// seg->MorePads();
582// seg->NextPad())
583// {
584// if (seg->ISector()==0) continue;
585// Float_t x,y,z;
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);
593// marker->Draw();
594// }
595// }
596// } else {
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);
a9e2aefa 600
002920d1 601// for (seg->FirstPad(x0,0,0,0,y0);
602// seg->MorePads();
603// seg->NextPad())
604// {
605// if (seg->ISector()==0) continue;
a9e2aefa 606
002920d1 607// Float_t x,y,z;
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);
615// marker->Draw();
616// }
617// }
618// }
619 }
a9e2aefa 620
621//_____________________________________________________________________________
622void AliMUONDisplay::DrawClusters()
623{
624// Draw clusters for MUON chambers
625
626 Int_t ndigits, digit;
627 TObjArray *points;
628 AliMUONPoints *pm;
629
630
631 fClustersCuts = 0;
632 points = Points();
633 if (!points) return;
634 ndigits = points->GetEntriesFast();
635 for (digit=0;digit<ndigits;digit++){
636 pm = (AliMUONPoints*)points->UncheckedAt(digit);
637 if (!pm) continue;
638 Float_t *pxyz;
639 pxyz=pm->GetP();
640 for (Int_t im=0;im<3;im++) {
641 TMarker3DBox *marker=pm->GetMarker(im);
642 if (marker)
643 marker->Draw();
644 }
645 pm->Draw();
123469eb 646 fClustersCuts += pm->GetN();
a9e2aefa 647 }
648}
649
650//_____________________________________________________________________________
651void AliMUONDisplay::DrawHits()
652{
653// Draw hits for MUON chambers
654
655 LoadHits(fChamber);
656
657 Int_t ntracks, track;
658 TObjArray *points;
659 AliMUONPoints *pm;
660
661 fHitsCuts = 0;
662 points = Phits();
663 if (!points) return;
664 ntracks = points->GetEntriesFast();
665 for (track=0;track<ntracks;track++) {
666 pm = (AliMUONPoints*)points->UncheckedAt(track);
667 if (!pm) continue;
668 pm->Draw();
669 fHitsCuts += pm->GetN();
670 }
671}
672
673
674//_____________________________________________________________________________
675void AliMUONDisplay::DrawCoG()
676{
677// Draw hits for MUON chambers
678 if (!fDrawCoG) return;
679 if (fChamber > 10) return;
680 LoadCoG(fChamber,fCathode);
681
682 Int_t ncog, icog;
683 TObjArray *points;
684 AliMUONPoints *pm;
685
686 points = Rpoints();
687 if (!points) return;
688 ncog = points->GetEntriesFast();
689 for (icog=0;icog<ncog;icog++) {
690 pm = (AliMUONPoints*)points->UncheckedAt(icog);
691 if (!pm) continue;
692 pm->Draw();
693 }
694}
a9e2aefa 695//_____________________________________________________________________________
572d5bb2 696void AliMUONDisplay::DrawTracks()
697{
698// Draw tracks
699 if (!fDrawTracks) return;
700 LoadTracks();
701
702 Int_t nTrack, iTrack;
703 TObjArray *points;
704 TPolyLine3D *pm;
705
706 points = Rpoints();
707 if (!points) return;
708 nTrack = points->GetEntriesFast();
709 for ( iTrack = 0; iTrack < nTrack; iTrack++) {
710 pm = (TPolyLine3D*)points->UncheckedAt(iTrack);
711 if (!pm) continue;
712 pm->Draw();
713 }
714}
715//_____________________________________________________________________________
a9e2aefa 716
717void AliMUONDisplay::DrawTitle(Option_t *option)
718{
719// Draw the event title
720
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;
727
30178c30 728 AliRunLoader * runLoader;
307d9d04 729 if (fLoader)
30178c30 730 runLoader = fLoader->GetRunLoader();
307d9d04 731 else
30178c30 732 runLoader = 0x0;
7985603c 733
734
a9e2aefa 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);
741 title->Draw();
742 char ptitle[100];
743 sprintf(ptitle, "Alice event:%d Run:%d Chamber:%d Cathode:%d",
30178c30 744 runLoader->GetEventNumber(),
a9e2aefa 745 gAlice->GetHeader()->GetRun(),
746 fChamber,
747 fCathode);
748 title->AddText(ptitle);
5d12ce38 749 Int_t nparticles = gAlice->GetMCApp()->Particles()->GetEntriesFast();
a9e2aefa 750 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",
751 nparticles, fHitsCuts,fClustersCuts);
752 title->AddText(ptitle);
753 } else {
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);
757 label->Draw();
758 }
759}
760
761//_____________________________________________________________________________
762void AliMUONDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
763{
764// Draw a view of MUON clusters
c177f73d 765 AliInfo(" Draw View");
a9e2aefa 766
767 gPad->SetCursor(kWatch);
768 // gPad->SetFillColor(39);
769 gPad->SetFillColor(1);
770 gPad->Clear();
771 // gPad->SetFillColor(39);
772 gPad->SetFillColor(1);
773
774
775 Int_t iret=0;
776 TView *view = new TView(1);
777
778 Float_t range = fRrange*fRangeSlider->GetMaximum();
779 view->SetRange(-range,-range,-range,range, range, range);
780 // zoom back to full scale only if DrawView not called from NextCathode
781 if (!fNextCathode) {
782 fZoomX0[0] = -1;
783 fZoomY0[0] = -1;
784 fZoomX1[0] = 1;
785 fZoomY1[0] = 1;
786 fZooms = 0;
787 }
63216d66 788
789 Float_t xg1, xg2, yg1, yg2, zg1, zg2;
790
123469eb 791 // Recovering the chamber
792 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
b7ef3c96 793
794 const AliMUONGeometryTransformer* kGeomTransformer
795 = pMUON->GetGeometryTransformer();
796
797 AliMUONSegmentation* segmentation = pMUON->GetSegmentation();
7502d0e5 798 AliMpSegFactory segFactory;
799 // Mapping segmentation factory will be used only to create mapping
800 // segmentations if not present in the DE segmentations
a9e2aefa 801
802// Display MUON Chamber Geometry
a9e2aefa 803 char nodeName[7];
804 sprintf(nodeName,"MUON%d",100+fChamber);
123469eb 805 printf(">>>> chamber is %d\n",fChamber);
806
807 if(fChamber < 5) {
7502d0e5 808 AliMpDEIterator it;
809 for ( it.First(fChamber-1); ! it.IsDone(); it.Next() ) {
63216d66 810
7502d0e5 811 Int_t detElemId = it.CurrentDE();
b7ef3c96 812 AliMpSectorSegmentation * seg =
813 (AliMpSectorSegmentation *) segmentation->GetMpSegmentation(detElemId, 0);
814 const AliMpSector * sector = seg->GetSector();
63216d66 815
816 // get sector measurements
817 TVector2 position = sector->Position();
818 TVector2 dimension = sector->Dimensions(); // half length
819
7c618420 820 Float_t xlocal1 = position.Px(); // mm to cm
821 Float_t ylocal1 = position.Py();
822 Float_t xlocal2 = dimension.Px() * 2.;
823 Float_t ylocal2 = dimension.Px() * 2.;
63216d66 824
b7ef3c96 825 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
826 kGeomTransformer->Local2Global(detElemId, xlocal2, ylocal2, 0, xg2, yg2, zg2);
63216d66 827
828 // drawing
829 TPolyLine3D* poly = new TPolyLine3D();
830 Int_t nPoint = 0;
831
832 poly->SetPoint(nPoint++, xg1, yg1, 0.);
833 for (Float_t d = 0; d < TMath::Pi()/2.; d+= 0.01) {
834 Float_t x = xg1 + xg2 * TMath::Cos(d);
835 Float_t y = yg1 + yg2 * TMath::Sin(d);
836 poly->SetPoint(nPoint++, x, y, 0.);
837 }
838 poly->SetPoint(nPoint++, xg1, yg1, 0.);
839
840 poly->SetLineColor(2);
841 poly->Draw("s");
123469eb 842 }
63216d66 843
844 // }
123469eb 845
63216d66 846 }
123469eb 847
848 if(fChamber >4 && fChamber <11) {
7502d0e5 849 AliMpDEIterator it;
850 for ( it.First(fChamber-1); ! it.IsDone(); it.Next() ) {
851 Int_t detElemId = it.CurrentDE();
b7ef3c96 852 if ( segmentation->HasDE(detElemId) ) {
123469eb 853 AliMpSlatSegmentation * seg =
b7ef3c96 854 (AliMpSlatSegmentation *) segmentation->GetMpSegmentation(detElemId, 0);
7502d0e5 855 if (!seg) {
856 // Create mapping segmentation if old trigger segmentation
857 // (not using mapping)
858 seg = (AliMpSlatSegmentation *)
859 segFactory.CreateMpSegmentation(detElemId, 0);
16495fbc 860 }
b7ef3c96 861 if (seg) {
862 const AliMpSlat* slat = seg->Slat();
863 Float_t deltax = slat->DX();
864 Float_t deltay = slat->DY();
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);
871
872 // drawing slat active volumes
873 Float_t xCenter = (xg1 + xg2)/2.;
874 Float_t yCenter = (yg1 + yg2)/2.;
875
876 TMarker3DBox* box = new TMarker3DBox(xCenter,yCenter,0,xlocal1,ylocal2,0,0,0);
877
878 box->SetFillStyle(0);
879 box->SetLineColor(2);
880 box->Draw("s");
881
882 // drawing inner circle + disc
883 TPolyLine3D* poly = new TPolyLine3D();
884 TPolyLine3D* poly1 = new TPolyLine3D();
885
886 Int_t nPoint = 0;
887 Int_t nPoint1 = 0;
888 for (Float_t d = 0; d < 6.24; d+= 0.005) {
889 Double_t x = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Cos(d)/2.;
890 Double_t y = AliMUONConstants::Dmin((fChamber-1)/2) * TMath::Sin(d)/2.;
891 if (nPoint % 2 == 0) poly->SetPoint(nPoint++, 0., 0., 0.);
892 poly->SetPoint(nPoint++, x, y, 0.);
893 poly1->SetPoint(nPoint1++, x, y, 0.);
123469eb 894
b7ef3c96 895 }
896 poly->SetLineColor(1);
897 poly->Draw("s");
898 poly1->SetLineColor(2);
899 poly1->Draw("s");
900 }
123469eb 901 }
902 }
e0d2f4db 903 }
904
905/*-- Trigger Chambers ---------------------------------------*/
906 if(fChamber >10 && fChamber <15) {
7502d0e5 907 AliMpDEIterator it;
908 for ( it.First(fChamber-1); ! it.IsDone(); it.Next() ) {
909 Int_t detElemId = it.CurrentDE();
16495fbc 910 AliMpTriggerSegmentation * seg
911 = (AliMpTriggerSegmentation *) segmentation->GetMpSegmentation(detElemId, 0);
912 if (!seg) {
1169bc87 913 printf(" AliMUONDisplay no segmentation \n");
914
7502d0e5 915 // Create mapping segmentation if old trigger segmentation
916 // (not using mapping)
917 seg = (AliMpTriggerSegmentation *)
918 segFactory.CreateMpSegmentation(detElemId, 0);
16495fbc 919 }
b7ef3c96 920 if (seg) {
e0d2f4db 921 const AliMpTrigger* slat = seg->Slat();
922 Float_t deltax = slat->DX();
923 Float_t deltay = slat->DY();
924 Float_t xlocal1 = -deltax;
925 Float_t ylocal1 = -deltay;
926 Float_t xlocal2 = +deltax;
927 Float_t ylocal2 = +deltay;
b7ef3c96 928
929 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
930 kGeomTransformer->Local2Global(detElemId, xlocal2, ylocal2, 0, xg2, yg2, zg2);
e0d2f4db 931
932 // drawing slat active volumes
933 Float_t xCenter = (xg1 + xg2)/2.;
934 Float_t yCenter = (yg1 + yg2)/2.;
935
936 TMarker3DBox* box = new TMarker3DBox(xCenter,yCenter,0,xlocal1,ylocal2,0,0,0);
937
938 box->SetFillStyle(0);
939 box->SetLineColor(4);
940 box->Draw("s");
b7ef3c96 941 }
e0d2f4db 942 }
943 }
7502d0e5 944 // Delete mapping segmentations created with factory
3984c1d5 945 segFactory.DeleteSegmentations();
7502d0e5 946
a9e2aefa 947//add clusters to the pad
948 DrawClusters();
a9e2aefa 949 DrawHits();
950 DrawCoG();
a9e2aefa 951// DrawSegmentation();
952 // add itself to the list (must be last)
953 AppendPad();
954 view->SetView(phi, theta, psi, iret);
955}
956
572d5bb2 957//_____________________________________________________________________________
958void AliMUONDisplay::DrawGlobalView(Float_t theta, Float_t phi, Float_t psi)
959{
960// Draw a view of muons chambers with tracks
961
962 gPad->SetCursor(kWatch);
963 // gPad->SetFillColor(39);
964 gPad->SetFillColor(1);
965 gPad->Clear();
966 // gPad->SetFillColor(39);
967 gPad->SetFillColor(1);
968
969
970 Int_t iret=0;
971 TView *view = new TView(1);
972
973 Float_t range = fRrange*fRangeSlider->GetMaximum()*3.;
974 view->SetRange(-range,-range,-range,range,range,range);
975
976// Display all MUON Chambers segmentation
977 char nodeName[7];
978 TNode *node1;
979 sprintf(nodeName,"alice");
980
981 node1=gAlice->GetGeometry()->GetNode(nodeName);
982 if (node1) node1->Draw("same");
983
984
985// Draw clusters for all chambers
986 Int_t chamberSave = fChamber;
987 for (fChamber = 1; fChamber <= 10; fChamber++){
988 DrawCoG();
989 }
990 fChamber = chamberSave;
991// Draw reconstructed tracks
992 DrawTracks();
993
994 AppendPad();
995
996 Float_t zoom = 2.;
997 Float_t shift = 0.9;
998 Float_t x0 = (-1+shift)/zoom;
999 Float_t y0 = (-1+shift)/zoom;
1000 Float_t x1 = (1+shift)/zoom;
1001 Float_t y1 = (1+shift)/zoom;
1002 gPad->Range(x0,y0,x1,y1);
1003 view->SetView(phi, theta, psi, iret);
1004
1005}
a9e2aefa 1006
1007//______________________________________________________________________________
1008void AliMUONDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
1009{
1010// Execute action corresponding to the mouse event
1011
1012 static Float_t x0, y0, x1, y1;
1013
1014 static Int_t pxold, pyold;
1015 static Int_t px0, py0;
1016 static Int_t linedrawn;
1017 Float_t temp;
1018
1019 if (px == 0 && py == 0) { //when called by sliders
1020 if (event == kButton1Up) {
1021 Draw();
1022 }
1023 return;
1024 }
1025 if (!fZoomMode && gPad->GetView()) {
1026 gPad->GetView()->ExecuteRotateView(event, px, py);
1027 return;
1028 }
1029
1030 // something to zoom ?
1031 gPad->SetCursor(kCross);
1032
1033 switch (event) {
1034
1035 case kButton1Down:
1036 gVirtualX->SetLineColor(-1);
1037 gPad->TAttLine::Modify(); //Change line attributes only if necessary
1038 x0 = gPad->AbsPixeltoX(px);
1039 y0 = gPad->AbsPixeltoY(py);
1040 px0 = px; py0 = py;
1041 pxold = px; pyold = py;
1042 linedrawn = 0;
1043 return;
1044
1045 case kButton1Motion:
1046 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
1047 pxold = px;
1048 pyold = py;
1049 linedrawn = 1;
1050 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
1051 return;
1052
1053 case kButton1Up:
1054 gPad->GetCanvas()->FeedbackMode(kFALSE);
1055 if (px == px0) return;
1056 if (py == py0) return;
1057 x1 = gPad->AbsPixeltoX(px);
1058 y1 = gPad->AbsPixeltoY(py);
1059
1060 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
1061 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
1062 gPad->Range(x0,y0,x1,y1);
97ccf8cb 1063 if (fZooms < AliMUONConstants::MaxZoom()-1) {
a9e2aefa 1064 fZooms++;
1065 fZoomX0[fZooms] = x0;
1066 fZoomY0[fZooms] = y0;
1067 fZoomX1[fZooms] = x1;
1068 fZoomY1[fZooms] = y1;
1069 }
1070 gPad->Modified(kTRUE);
1071 return;
1072 }
1073}
1074
1075//___________________________________________
1076void AliMUONDisplay::LoadDigits(Int_t chamber, Int_t cathode)
1077{
1078// Read digits info and store x,y,z info in arrays fPoints
1079// Loop on all detectors
1080
1081 if (chamber > 14) return;
08a636a8 1082 fChamber = chamber;
1083 fCathode = cathode;
a9e2aefa 1084
1085 ResetPoints();
1086
08a636a8 1087 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1169bc87 1088
76dadf7e 1089 AliMUONGeometrySegmentation* segmentation2 = 0x0;
1090
d226f81b 1091 GetMUONData()->SetTreeAddress("D");
a9e2aefa 1092
d226f81b 1093 TClonesArray *muonDigits = GetMUONData()->Digits(chamber-1);
a9e2aefa 1094 if (muonDigits == 0) return;
1095
d226f81b 1096 gAlice->ResetDigits();
00f56532 1097 Int_t nent = 0;
1098
1169bc87 1099 if (GetLoader()->TreeD()) {
1100 nent = (Int_t) GetLoader()->TreeD()->GetEntries();
1101 // gAlice->TreeD()->GetEvent(nent-2+cathode-1);
1102 GetMUONData()->GetDigits();
00f56532 1103 }
1104
1169bc87 1105 Int_t ndigits = muonDigits->GetEntriesFast();
a9e2aefa 1106 if (ndigits == 0) return;
1107 if (fPoints == 0) fPoints = new TObjArray(ndigits);
1108
b7ef3c96 1109 Float_t zpos = AliMUONConstants::DefaultChamberZ(chamber-1);
08a636a8 1110
a9e2aefa 1111 AliMUONDigit *mdig;
08a636a8 1112 AliMUONPoints *points = 0;
1113 TMarker3DBox *marker = 0;
1169bc87 1114
08a636a8 1115 Int_t npoints = 1;
7e4a628d 1116 Float_t adcmax = 1024; // default
1117 if (chamber<11) adcmax = 4096;
a9e2aefa 1118
1169bc87 1119// check if trigger is using new or old segmentation
1120 Bool_t old = true;
1121 AliMUONSegmentation* segmentation = pMUON->GetSegmentation();
1122 if ( segmentation->GetMpSegmentation(1100, cathode-1) ) old = false;
a9e2aefa 1123
1169bc87 1124 if ( old && chamber > 10) {
1125 if (chamber > 10) printf(">>> old segmentation for trigger \n");
1126 else printf(">>> old segmentation for tracking \n");
76dadf7e 1127
1169bc87 1128 segmentation2
1129 = pMUON->GetSegmentation()->GetModuleSegmentation(chamber-1, cathode-1);
1130 for (Int_t digit = 0; digit < ndigits; digit++) {
1131 mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
1132 if (mdig->Cathode() != cathode-1) continue;
1133
1134 //
1135 // First get all needed parameters
1136 //
1137 Int_t charge = mdig->Signal();
1138 Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
1139 Int_t color = 261+index;
1140 Int_t colorTrigger = 2;
1141 if (color > 282) color = 282;
1142
1143 if (chamber > 10) { // trigger chamber
1144
1145 Int_t sumCharge = 0;
1146 for (Int_t icharge = 0; icharge < 10; icharge++) {
1147 sumCharge = sumCharge+mdig->TrackCharge(icharge);
1148 }
1149 Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10;
1150 if(sumCharge <= 10 || testCharge > 0) {
1151 colorTrigger = color;
1152 } else {
1153 colorTrigger = 5;
1154 }
1155 }
1156
1157 // get the center of the pad - add on x and y half of pad size
1158 Float_t xpad, ypad, zpad;
1159 Int_t isec;
1160 Float_t dpx, dpy;
1161
1162 Int_t detElemId = mdig->DetElemId();
1163 segmentation2->GetPadC(detElemId, mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
1164 isec = segmentation2->Sector(detElemId, mdig->PadX(), mdig->PadY());
1165 dpx = segmentation2->Dpx(detElemId, isec)/2;
1166 dpy = segmentation2->Dpy(detElemId, isec)/2;
1167
1168 // Then set the objects
1169 points = new AliMUONPoints(npoints);
1170 fPoints->AddAt(points,digit);
1171 if (chamber > 10) {
1172 points->SetMarkerColor(colorTrigger);
1173 } else {
1174 points->SetMarkerColor(color);
1175 }
1176 points->SetMarkerStyle(21);
1177 points->SetMarkerSize(0.5);
1178 points->SetParticle(-1);
1179 points->SetHitIndex(-1);
1180 points->SetTrackIndex(-1);
1181 points->SetDigitIndex(digit);
1182 points->SetPoint(0,xpad,ypad,zpos);
1183
1184 Int_t lineColor = (zpad-zpos > 0) ? 2:3;
1185 marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0);
1186
1187
1188 marker->SetLineColor(lineColor);
1189 marker->SetFillStyle(1001);
1190 marker->SetFillColor(color);
1191 marker->SetRefObject((TObject*)points);
1192 points->Set3DMarker(0, marker);
1193 } // end loop on digits
a9e2aefa 1194
1169bc87 1195 } else {
1196 if (chamber > 10) printf(">>> new segmentation for trigger \n");
1197 else printf(">>> new segmentation for tracking \n");
4554f81d 1198
1169bc87 1199 const AliMUONGeometryTransformer* kGeomTransformer
1200 = pMUON->GetGeometryTransformer();
1201
1202 //loop over all digits and store their position
1203 for (Int_t digit = 0; digit < ndigits; digit++) {
1204 mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit);
1205 if (mdig->Cathode() != cathode-1) continue;
08a636a8 1206
1169bc87 1207 // get all needed parameters
1208 Int_t ix=mdig->PadX();
1209 Int_t iy=mdig->PadY();
1210 Int_t detElemId=mdig->DetElemId();
1211 Int_t charge = mdig->Signal();
1212 Int_t index = Int_t(TMath::Log(charge)/(TMath::Log(adcmax)/22));
1213 Int_t color = 261+index;
1214 Int_t colorTrigger = 2;
1215 if (color > 282) color = 282;
1216
1217 const AliMpVSegmentation* seg =
1218 pMUON->GetSegmentation()->GetMpSegmentation(detElemId,cathode-1);
1219
1220 AliMpStationType station = AliMpDEManager::GetStationType(detElemId);
1221
1222 Int_t intOffset = station == kStation345 ? 1 : 0;
1223
1224 AliMpPad pad =
1225 seg->PadByIndices(AliMpIntPair(ix-intOffset,iy-intOffset),kTRUE);
1226
1227 if (chamber > 10) { // trigger chamber
1228 Int_t sumCharge = 0;
1229 for (Int_t icharge = 0; icharge < 10; icharge++) {
1230 sumCharge = sumCharge+mdig->TrackCharge(icharge);
1231 }
1232 Int_t testCharge = sumCharge-(Int_t(sumCharge/10))*10;
1233 if(sumCharge <= 10 || testCharge > 0) {
1234 colorTrigger = color;
1235 } else {
1236 colorTrigger = 5;
1237 }
1238 }
1239
1240 // get the pad position and dimensions
1241 Float_t xlocal1 = pad.Position().X();
1242 Float_t ylocal1 = pad.Position().Y();
1243 Float_t xlocal2 = pad.Dimensions().X();
1244 Float_t ylocal2 = pad.Dimensions().Y();
1245
1246 Float_t xg1, xg2, yg1, yg2, zg1;
1247
1248 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
1249 // (no transformation for pad dimensions)
1250 xg2 = xlocal2;
1251 yg2 = ylocal2;
1252
1253 // Then set the objects
1254 points = new AliMUONPoints(npoints);
1255 fPoints->AddAt(points,digit);
1256 if (chamber > 10) {
1257 points->SetMarkerColor(colorTrigger);
1258 } else {
1259 points->SetMarkerColor(color);
1260 }
1261 points->SetMarkerStyle(21);
1262 points->SetMarkerSize(0.5);
1263 points->SetParticle(-1);
1264 points->SetHitIndex(-1);
1265 points->SetTrackIndex(-1);
1266 points->SetDigitIndex(digit);
1267 points->SetPoint(0,xg1,yg1,zpos);
1268
1269 Int_t lineColor = (zg1-zpos > 0) ? 2:3;
1270 marker=new TMarker3DBox(xg1,yg1,zpos,xg2,yg2,0,0,0);
1271
1272 marker->SetLineColor(lineColor);
1273 marker->SetFillStyle(1001);
1274 marker->SetFillColor(color);
1275 marker->SetRefObject((TObject*)points);
1276 points->Set3DMarker(0, marker);
1277
1278 } // end loop on digits
1279 } // end of new segmentation
a9e2aefa 1280}
1281//___________________________________________
e0875ac1 1282void AliMUONDisplay::LoadCoG(Int_t chamber, Int_t /*cathode*/)
a9e2aefa 1283{
d226f81b 1284// Read raw clusters info and store x,y,z info in arrays fRpoints
1285// Loop on all detectors
a9e2aefa 1286
1287 if (chamber > 10) return;
1288
1289 ResetRpoints();
1290
d226f81b 1291 GetMUONData()->SetTreeAddress("RC");
1292 TClonesArray *muonRawClusters = GetMUONData()->RawClusters(chamber-1);
a9e2aefa 1293
7985603c 1294 if (muonRawClusters == 0) return;
a9e2aefa 1295
00f56532 1296 Int_t nent = 0;
d226f81b 1297 if (GetMUONData()->TreeR()) {
1298 nent=(Int_t) GetMUONData()->TreeR()->GetEntries();
1299 GetMUONData()->TreeR()->GetEvent(0);
00f56532 1300 }
1301
a9e2aefa 1302 Int_t nrawcl = muonRawClusters->GetEntriesFast();
1303 if (nrawcl == 0) return;
d226f81b 1304 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
a9e2aefa 1305
b7ef3c96 1306 Float_t zpos = AliMUONConstants::DefaultChamberZ(chamber-1);
a9e2aefa 1307 AliMUONRawCluster *mRaw;
1308 AliMUONPoints *points = 0;
1309 //
1310 //loop over all raw clusters and store their position
1311 points = new AliMUONPoints(nrawcl);
1312 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
1313 mRaw = (AliMUONRawCluster*)muonRawClusters->UncheckedAt(iraw);
a9e2aefa 1314 points->SetMarkerColor(51);
1315 points->SetMarkerStyle(2);
1316 points->SetMarkerSize(1.);
1317 points->SetParticle(-1);
1318 points->SetHitIndex(-1);
1319 points->SetTrackIndex(-1);
1320 points->SetDigitIndex(-1);
ba12c242 1321 points->SetPoint(iraw,mRaw->GetX(0),mRaw->GetY(0),zpos);
d226f81b 1322 fRpoints->AddAt(points,iraw);
ba12c242 1323 // printf("%f and %f and %f\n",mRaw->GetX(0),mRaw->GetY(0),mRaw->GetZ(0));
a9e2aefa 1324 }
1325}
572d5bb2 1326
1327//___________________________________________
1328void AliMUONDisplay::LoadTracks()
1329{
1330// Load tracks
1331 AliMUONTrack* recTrack = 0;
1332 AliMUONTrackParam* trackParam = 0;
1333 TClonesArray * trackParamAtHit = 0;
1334
1335 ResetRpoints();
1336
1337 GetMUONData()->SetTreeAddress("RT");
1338 TClonesArray* recTracksArray = GetMUONData()->RecTracks();
1339 if (recTracksArray == NULL) return;
1340 GetMUONData()->GetRecTracks();
1341
1342 Int_t nRecTracks = 0;
1343 if (recTracksArray)
1344 nRecTracks = (Int_t) recTracksArray->GetEntriesFast();
1345
1346
1347 if (fRpoints == 0) fRpoints = new TObjArray(nRecTracks);
1348
1349 for (Int_t iRecTracks = 0; iRecTracks < nRecTracks; iRecTracks++) {
1350 // reading info from tracks
1351 recTrack = (AliMUONTrack*) recTracksArray->At(iRecTracks);
1352
1353 Int_t nTrackHits = recTrack->GetNTrackHits();
1354
1355 if (nTrackHits == 0) continue;
1356
1357 Int_t iPoint = 0;
1358 TPolyLine3D *points = new TPolyLine3D(nTrackHits+1);
1359 points->SetLineColor(6);
1360 points->SetLineWidth(1);
1361 fRpoints->AddAt(points,iRecTracks);
1362
1363 Float_t xRec=0;
1364 Float_t yRec=0;
1365 Float_t zRec=0;
1366
1367 trackParam = recTrack->GetTrackParamAtVertex();
1368 xRec = trackParam->GetNonBendingCoor();
1369 yRec = trackParam->GetBendingCoor();
1370 zRec = trackParam->GetZ();
1371 points->SetPoint(iPoint,xRec,yRec,zRec);
1372 iPoint++;
1373
1374 for (Int_t iHit = 0; iHit < nTrackHits; iHit++){
1375 trackParamAtHit = recTrack->GetTrackParamAtHit();
1376 trackParam = (AliMUONTrackParam*) trackParamAtHit->At(iHit);
1377 xRec = trackParam->GetNonBendingCoor();
1378 yRec = trackParam->GetBendingCoor();
1379 zRec = trackParam->GetZ();
1380 points->SetPoint(iPoint,xRec,yRec,zRec);
1381 iPoint++;
1382 } // end loop rec. hits
1383 PrintTrack(iRecTracks,recTrack);
1384 } // end loop tracks
1385
1386
1387}
1388
1389void AliMUONDisplay::PrintTrack(Int_t iRecTracks, AliMUONTrack *recTrack)
1390{
1391 AliMUONTrackParam *trackParam;
1392 Float_t vertex[3], momentum[3];
1393 Float_t pYZ, bendingSlope, nonBendingSlope, chi2dof;
1394 Int_t charge;
1395
1396 trackParam = recTrack->GetTrackParamAtVertex();
1397 vertex[0] = trackParam->GetNonBendingCoor();
1398 vertex[1] = trackParam->GetBendingCoor();
1399 vertex[2] = trackParam->GetZ();
1400 pYZ = 1./TMath::Abs(trackParam->GetInverseBendingMomentum());
1401 bendingSlope = trackParam->GetBendingSlope();
1402 nonBendingSlope = trackParam->GetNonBendingSlope();
1403 momentum[2] = -pYZ / TMath::Sqrt(1.0 + bendingSlope*bendingSlope);
1404 momentum[0] = momentum[2] * nonBendingSlope;
1405 momentum[1] = momentum[2] * bendingSlope;
1406 charge = Int_t(TMath::Sign(1.,trackParam->GetInverseBendingMomentum()));
1407 chi2dof = recTrack->GetFitFMin()/(2.0 * recTrack->GetNTrackHits() - 5.);
1408
1409 printf("===================================================\n");
1410 printf(" Reconstructed track # %d \n",iRecTracks);
1411 printf(" charge: %d \n",charge);
1412 printf(" vertex x,y,z (cm): %f %f %f \n",vertex[0],vertex[1],vertex[2]);
1413 printf(" momentum Px,Py,Pz (GeV/c): %f %f %f \n",momentum[0],momentum[1],momentum[2]);
1414 printf(" track chi2/dof: %f \n",chi2dof);
1415
1416}
1417
a9e2aefa 1418//___________________________________________
a9e2aefa 1419void AliMUONDisplay::LoadHits(Int_t chamber)
1420{
307d9d04 1421 // Read hits info and store x,y,z info in arrays fPhits
1422 // Loop on all detectors
a9e2aefa 1423
1424 if (chamber > 14) return;
1425 Int_t track;
1426
1427 fChamber=chamber;
1428
1429 ResetPhits();
1430
b7ef3c96 1431 Float_t zpos=AliMUONConstants::DefaultChamberZ(chamber-1);
c856e086 1432
1433 if (GetMUONData()->TreeH()) {
1434 GetMUONData()->SetTreeAddress("H");
1435 Int_t ntracks = (Int_t)GetMUONData()->TreeH()->GetEntries(); //skowron
1436 Int_t nthits = 0;
1437 for (track = 0; track < ntracks; track++) {
d226f81b 1438 GetMUONData()->ResetHits();
1439 GetMUONData()->GetTrack(track);//skowron
1440 TClonesArray *muonHits = GetMUONData()->Hits();
a9e2aefa 1441 if (muonHits == 0) return;
1442 nthits += muonHits->GetEntriesFast();
c856e086 1443 }
1444 if (fPhits == 0) fPhits = new TObjArray(nthits);
1445 Int_t nhold=0;
1446 for (track=0; track<ntracks;track++) {
d226f81b 1447 GetMUONData()->ResetHits();
1448 GetMUONData()->GetTrack(track);//skowron
1449 TClonesArray *muonHits = GetMUONData()->Hits();
a9e2aefa 1450 if (muonHits == 0) return;
1451 Int_t nhits = muonHits->GetEntriesFast();
1452 if (nhits == 0) continue;
1453 AliMUONHit *mHit;
1454 AliMUONPoints *points = 0;
1455 Int_t npoints=1;
1456 for (Int_t hit=0;hit<nhits;hit++) {
c856e086 1457 mHit = (AliMUONHit*)muonHits->UncheckedAt(hit);
1458 Int_t nch = mHit->Chamber(); // chamber number
1459 if (nch != chamber) continue;
1460 //
1461 // Retrieve info and set the objects
1462 //
1463 points = new AliMUONPoints(npoints);
1464 fPhits->AddAt(points,nhold+hit);
1465 points->SetMarkerColor(kRed);
1466 points->SetMarkerStyle(5);
1467 points->SetMarkerSize(1.);
1468 points->SetParticle(mHit->Track());
1469 points->SetHitIndex(hit);
1470 points->SetTrackIndex(track);
1471 points->SetDigitIndex(-1);
1472 points->SetPoint(0,mHit->X(),mHit->Y(),zpos);
1473 // printf("%f and %f and %f\n",mHit->X(),mHit->Y(),mHit->Z());
a9e2aefa 1474 }
1475 nhold+=nhits;
c856e086 1476 }
a9e2aefa 1477 }
1478}
1479
1480//_____________________________________________________________________________
1481void AliMUONDisplay::Paint(Option_t *)
1482{
1483// Paint miscellaneous items
1484}
1485
1486//_____________________________________________________________________________
1487void AliMUONDisplay::SetPickMode()
1488{
1489// Set parameters for pick mode.
1490//
1491 fZoomMode = 0;
1492
1493 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1494 fTrigPad->Modified();
1495}
1496
1497//_____________________________________________________________________________
1498void AliMUONDisplay::SetZoomMode()
1499{
1500// Set parameters for zoom mode
1501 fZoomMode = 1;
1502
1503 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1504 fTrigPad->Modified();
1505}
1506
1507//_____________________________________________________________________________
1508void AliMUONDisplay::NextChamber(Int_t delta)
1509{
1510 // to go from chamber to next chamber if delta = 1
1511 // or previous chamber otherwise
1512 if (delta == 1) {
f665c1ea 1513 if (fChamber < AliMUONConstants::NCh()) fChamber++;
a9e2aefa 1514 } else {
1515 if (fChamber > 1) fChamber--;
1516 }
1517 if (!fPad) return;
1518 fPad->Clear();
1519 LoadDigits(fChamber, fCathode);
572d5bb2 1520 DrawChamber();
a9e2aefa 1521}
1522
1523//_____________________________________________________________________________
1524void AliMUONDisplay::NextCathode()
1525{
1526 // to switch to other cathode plane
1527 if (!fPad) return;
1528 fPad->Clear();
1529 if (fCathode == 1) {
1530 LoadDigits(fChamber, 2);
1531 } else {
1532 LoadDigits(fChamber, 1);
1533 }
1534 fNextCathode = kTRUE; // to keep the same zoom
572d5bb2 1535 DrawChamber();
a9e2aefa 1536 fNextCathode = kFALSE;
1537 TPad *pad = (TPad*)gPad->GetPadSave();
1538 pad->Range(fZoomX0[fZooms], fZoomY0[fZooms],
1539 fZoomX1[fZooms], fZoomY1[fZooms]);
1540 pad->Modified();
1541 fPad->cd();
1542 DrawTitle();
1543}
1544
1545//_____________________________________________________________________________
1546void AliMUONDisplay::Trigger()
1547{
52c9bc11 1548
d226f81b 1549 AliMUONGlobalTrigger* globalTrig;
1550
1551 GetMUONData()->SetTreeAddress("GLT");
95e68a13 1552 GetMUONData()->GetTriggerD();
d226f81b 1553
1554 globalTrig = (AliMUONGlobalTrigger*)GetMUONData()->GlobalTrigger()->UncheckedAt(0);
1555 if (globalTrig == 0) return;
1556
1557 printf("===================================================\n");
1558 printf(" Global Trigger output Low pt High pt All\n");
1559
1560 printf(" number of Single Plus :\t");
1561 printf("%i\t",globalTrig->SinglePlusLpt());
1562 printf("%i\t",globalTrig->SinglePlusHpt());
1563 printf("%i\t",globalTrig->SinglePlusApt());
1564 printf("\n");
1565
1566 printf(" number of Single Minus :\t");
1567 printf("%i\t",globalTrig->SingleMinusLpt());
1568 printf("%i\t",globalTrig->SingleMinusHpt());
1569 printf("%i\t",globalTrig->SingleMinusApt());
1570 printf("\n");
1571
1572 printf(" number of Single Undefined :\t");
1573 printf("%i\t",globalTrig->SingleUndefLpt());
1574 printf("%i\t",globalTrig->SingleUndefHpt());
1575 printf("%i\t",globalTrig->SingleUndefApt());
1576 printf("\n");
1577
1578 printf(" number of UnlikeSign pair :\t");
1579 printf("%i\t",globalTrig->PairUnlikeLpt());
1580 printf("%i\t",globalTrig->PairUnlikeHpt());
1581 printf("%i\t",globalTrig->PairUnlikeApt());
1582 printf("\n");
1583
1584 printf(" number of LikeSign pair :\t");
1585 printf("%i\t",globalTrig->PairLikeLpt());
1586 printf("%i\t",globalTrig->PairLikeHpt());
1587 printf("%i\t",globalTrig->PairLikeApt());
1588 printf("\n");
1589 printf("===================================================\n");
1590 printf("\n");
1591
1592
1593 // // returns Trigger Decision for current event
1594// AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(GetLoader(),1);
1595
1596// // AliMUONTriggerDecision* decision= new AliMUONTriggerDecision(1);
1597// AliMUONData* muonData = decision->GetMUONData();
1598// muonData->SetTreeAddress("D");
1599// decision->Trigger();
a9e2aefa 1600}
a9e2aefa 1601//_____________________________________________________________________________
1602void AliMUONDisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1603{
1604// Set chamber and cathode number
1605 fChamber = chamber;
1606 fCathode = cathode;
1607
1608 if (!fPad) return;
1609 fPad->Clear();
1610 LoadDigits(chamber,cathode);
572d5bb2 1611 DrawChamber();
a9e2aefa 1612}
1613
1614void AliMUONDisplay::SetEvent(Int_t newevent)
1615{
1616// Chose event
1617 gAlice->GetEvent(newevent);
1618 fEvent=newevent;
1619 if (!gAlice->TreeD()) return;
1620 if (!fPad) return;
1621 fPad->Clear();
1622 LoadDigits(fChamber,fCathode);
1623 Draw();
1624}
1625
1626//_____________________________________________________________________________
1627void AliMUONDisplay::SetRange(Float_t rrange, Float_t zrange)
1628{
1629// Set view range along R and Z
1630 fRrange = rrange;
1631 fZrange = zrange;
1632
1633 if (!fPad) return;
1634 fPad->Clear();
1635 Draw();
1636}
1637
1638//_____________________________________________________________________________
1639void AliMUONDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1640{
1641// change viewing angles for current event
1642
1643 fPad->cd();
1644 fPhi = phi;
1645 fTheta = theta;
1646 fPsi = psi;
1647 Int_t iret = 0;
1648
1649 TView *view = gPad->GetView();
1650 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1651 else Draw();
1652 gPad->Modified();
1653}
1654
1655//_____________________________________________________________________________
1656void AliMUONDisplay::ShowNextEvent(Int_t delta)
1657{
30178c30 1658 AliRunLoader * runLoader;
307d9d04 1659 if (fLoader)
30178c30 1660 runLoader = fLoader->GetRunLoader();
307d9d04 1661 else
30178c30 1662 runLoader = 0x0;
1391e633 1663
a9e2aefa 1664// Display (current event_number + delta)
1665// delta = 1 shown next event
1666// delta = -1 show previous event
1667 if (delta) {
30178c30 1668 //runLoader->CleanDetectors();
1669 //runLoader->CleanKinematics();
1670 Int_t currentEvent = runLoader->GetEventNumber();
1391e633 1671 Int_t newEvent = currentEvent + delta;
30178c30 1672 runLoader->GetEvent(newEvent);
1391e633 1673 fEvent=newEvent;
a9e2aefa 1674 }
a9e2aefa 1675 LoadDigits(fChamber, fCathode);
1676 fPad->cd();
1677 Draw();
1678}
1679
1680//______________________________________________________________________________
1681void AliMUONDisplay::UnZoom()
1682{
1683// Unzoom
1684 if (fZooms <= 0) return;
1685 fZooms--;
1686 TPad *pad = (TPad*)gPad->GetPadSave();
1687 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1688 pad->Modified();
1689}
1690
1691//_____________________________________________________________________________
1692void AliMUONDisplay::ResetPoints()
1693{
1694 //
1695 // Reset array of points
1696 //
1697 if (fPoints) {
1698 fPoints->Delete();
1699 delete fPoints;
1700 fPoints = 0;
1701 }
1702}
1703//_____________________________________________________________________________
1704void AliMUONDisplay::ResetPhits()
1705{
1706 //
1707 // Reset array of points
1708 //
1709 if (fPhits) {
1710 fPhits->Delete();
1711 delete fPhits;
1712 fPhits = 0;
1713 }
1714}
1715//_____________________________________________________________________________
1716void AliMUONDisplay::ResetRpoints()
1717{
1718 //
1719 // Reset array of points
1720 //
d226f81b 1721 if (fRpoints) {
1722 fRpoints->Clear();
1723 // delete fRpoints;
1724 fRpoints = 0;
a9e2aefa 1725 }
1726}
a9e2aefa 1727
30178c30 1728AliMUONDisplay & AliMUONDisplay::operator = (const AliMUONDisplay & rhs)
a9e2aefa 1729{
30178c30 1730// Protected assignement operator
1731
1732 if (this == &rhs) return *this;
1733
8c343c7c 1734 AliFatal("Not implemented.");
30178c30 1735
1736 return *this;
a9e2aefa 1737}
1738
1739
1740
1741
1742
1743
1744
1745
1746