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