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