]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONdisplay.cxx
Introduction of the Copyright and cvs Log
[u/mrichter/AliRoot.git] / MUON / AliMUONdisplay.cxx
CommitLineData
4c039060 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
16/*
17$Log$
18*/
19
fe4da5cc 20
21//////////////////////////////////////////////////////////////////////////
22// //
23// AliDisplay //
24// //
25// Utility class to display ALICE outline, tracks, hits,.. //
26// //
27//////////////////////////////////////////////////////////////////////////
28
29#include <TROOT.h>
30#include <TTree.h>
31#include <TButton.h>
32#include <TColor.h>
33#include <TCanvas.h>
34#include <TView.h>
35#include <TText.h>
36#include <TPolyMarker3D.h>
fe4da5cc 37#include <TPaveLabel.h>
38#include <TPaveText.h>
39#include <TList.h>
40#include <TDiamond.h>
41#include <TNode.h>
42#include <TArc.h>
43#include <TTUBE.h>
44#include <TSlider.h>
45#include <TSliderBox.h>
46#include <TGaxis.h>
47#include <TGXW.h>
48#include <TMath.h>
a897a37a 49#include <TMatrix.h>
fe4da5cc 50#include <X3DBuffer.h>
51
52#include "AliRun.h"
53#include "AliDetector.h"
54#include "AliMUON.h"
55#include "AliMUONConst.h"
56#include "AliMUONdisplay.h"
57#include "AliMUONpoints.h"
1578254f 58#include "TParticle.h"
fe4da5cc 59
60
a897a37a 61
fe4da5cc 62ClassImp(AliMUONdisplay)
63
64
65//_____________________________________________________________________________
66AliMUONdisplay::AliMUONdisplay()
67{
68 fPoints = 0;
69 fPhits = 0;
a897a37a 70 fRpoints = 0;
71 fR2points = 0;
72 fCpoints = 0;
fe4da5cc 73 fCanvas = 0;
74}
75
76//_____________________________________________________________________________
77AliMUONdisplay::AliMUONdisplay(Int_t size)
78{
79// Create an event display object.
80// A canvas named "edisplay" is created with a vertical size in pixels
81//
82// A QUICK Overview of the Event Display functions
83// ===============================================
84//
85// The event display can ve invoked by executing the macro "display.C"
86// A canvas like in the picture below will appear.
87//
88// On the left side of the canvas, the following buttons appear:
89// *Next* to move to the next event
90// *Previous* to move to the previous event
91
92// *Pick* Select this option to be able to point on a track with the
93// mouse. Once on the track, use the right button to select
94// an action. For example, select SetMarkerAttributes to
95// change the marker type/color/size for the track.
96// *Zoom* Select this option (default) if you want to zoom.
97// To zoom, simply select the selected area with the left button.
98// *UnZoom* To revert to the previous picture size.
99//
100// slider R On the left side, the vertical slider can be used to
101// set the default picture size.
102//
103// When you are in Zoom mode, you can click on the black part of the canvas
104// to select special options with the right mouse button.
105
106//
107// When you are in pick mode, you can "Inspect" the object pointed by the mouse.
108// When you are on a track, select the menu item "InspectParticle"
109// to display the current particle attributes.
110//
111// You can activate the Root browser by selecting the Inspect menu
112// in the canvas tool bar menu. Then select "Start Browser"
113// This will open a new canvas with the browser. At this point, you may want
114// to display some histograms (from the Trees). Go to the "File" menu
115// of the browser and click on "New canvas".
116// In the browser, click on item "ROOT files" in the left pane.
117// Click on galice.root.
118// Click on TH
119// Click on TPC for example
120// Click on any variable (eg TPC.fX) to histogram the variable.
121//
122// If you are lost, you can click on HELP in any Root canvas or browser.
123//Begin_Html
124/*
a897a37a 125<img src="gif/aliMUONdisplay.gif">
fe4da5cc 126*/
127//End_Html
128
129
130 fPad = 0;
131
132 gAlice->SetDisplay(this);
133
134 // Initialize display default parameters
a897a37a 135 SetRange(200,2000);
fe4da5cc 136 // Set front view by default
a897a37a 137 fTheta = 0;
fe4da5cc 138 fPhi = -90;
a897a37a 139 fPsi = 0;
fe4da5cc 140 fChamber = 1;
141 fCathode = 1;
142 // fRzone = 1.e10;
143 fDrawClusters = kTRUE;
a897a37a 144 fDrawCoG = kTRUE;
145 fDrawCoG = kTRUE;
146 fDrawCathCor = kTRUE;
fe4da5cc 147 fZoomMode = 1;
148 fZooms = 0;
149 fClustersCuts = 0;
150 fPoints = 0;
a897a37a 151 fPhits = 0;
152 fRpoints = 0;
153 fR2points = 0;
154 fCpoints = 0;
fe4da5cc 155 // Create colors
156 CreateColors();
157 // Create display canvas
158 Int_t ysize = size;
159 if (ysize < 100) ysize = 750;
160 Int_t xsize = Int_t(size*830./ysize);
161 fCanvas = new TCanvas("Canvas", "MUON Clusters Display",14,47,xsize,ysize);
162 fCanvas->SetEditable(kIsNotEditable);
163 fCanvas->ToggleEventStatus();
164
165 // Create main display pad
166 fPad = new TPad("viewpad", "MUON display",0.15,0,0.9,1);
167 fPad->Draw();
168 fPad->Modified();
169 fPad->SetFillColor(1);
170 fPad->SetBorderSize(2);
171
172 fCanvas->cd();
173
174 // Create colors pad
175 fColPad = new TPad("colpad", "Colors pad",0.9,0,1,1);
176 fColPad->Draw();
177 fColPad->Modified();
178 fColPad->SetFillColor(19);
179 fColPad->SetBorderSize(2);
180 fColPad->cd();
181 DisplayColorScale();
182
183 fCanvas->cd();
184
185 // Create user interface control pad
186 DisplayButtons();
187 fCanvas->cd();
188
189 // Create Range and mode pad
190 Float_t dxtr = 0.15;
191 Float_t dytr = 0.45;
192 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
193 fTrigPad->Draw();
194 fTrigPad->cd();
195 fTrigPad->SetFillColor(22);
196 fTrigPad->SetBorderSize(2);
197 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
198 fRangeSlider->SetObject(this);
199 char pickmode[] = "gAlice->Display()->SetPickMode()";
200 Float_t db = 0.09;
201 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
202 fPickButton->SetFillColor(38);
203 fPickButton->Draw();
204 char zoommode[] = "gAlice->Display()->SetZoomMode()";
205 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
206 fZoomButton->SetFillColor(38);
207 fZoomButton->Draw();
208 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
209 fArcButton->SetFillColor(kGreen);
210 fArcButton->Draw();
211 char butUnzoom[] = "gAlice->Display()->UnZoom()";
212 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
213 button->SetFillColor(38);
214 button->Draw();
215 AppendPad(); // append display object as last object to force selection
216
217 fCanvas->cd();
218 fCanvas->Update();
219}
220
221
222//_____________________________________________________________________________
223AliMUONdisplay::~AliMUONdisplay()
224{
225 // Delete space point structure
226 if (fPoints) fPoints->Delete();
227 delete fPoints;
228 fPoints = 0;
229 //
230 if (fPhits) fPhits->Delete();
231 delete fPhits;
232 fPhits = 0;
a897a37a 233 //
234 if (fRpoints) fRpoints->Delete();
235 delete fRpoints;
236 fRpoints = 0;
237//
238 if (fR2points) fR2points->Delete();
239 delete fR2points;
240 fR2points = 0;
241//
242 if (fCpoints) fCpoints->Delete();
243 delete fCpoints;
244 fCpoints = 0;
fe4da5cc 245}
246
247//_____________________________________________________________________________
248void AliMUONdisplay::Clear(Option_t *)
249{
250// Delete graphics temporary objects
251}
252
253//_____________________________________________________________________________
254void AliMUONdisplay::DisplayButtons()
255{
256// Create the user interface buttons
257
258
259 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
260 fButtons->Draw();
261 fButtons->SetFillColor(38);
262 fButtons->SetBorderSize(2);
263 fButtons->cd();
264
a897a37a 265// Int_t butcolor = 33;
fe4da5cc 266 Float_t dbutton = 0.08;
267 Float_t y = 0.96;
268 Float_t dy = 0.014;
269 Float_t x0 = 0.05;
270 Float_t x1 = 0.95;
271
272 TButton *button;
273 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
274 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
275 button->SetFillColor(38);
276 button->Draw();
277
278 y -= dbutton +dy;
279 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
280 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
281 button->SetFillColor(38);
282 button->Draw();
283 /*
284 y -= dbutton +dy;
285 char but3[] = "gAlice->Display()->SetChamberAndCathode(1,1)";
286 button = new TButton("Cham&Cath",but3,x0,y-dbutton,x1,y);
287 button->SetFillColor(butcolor);
288 button->Draw();
289 */
290 // display logo
291 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
292 diamond->SetFillColor(50);
293 diamond->SetTextAlign(22);
294 diamond->SetTextColor(5);
295 diamond->SetTextSize(0.11);
296 diamond->Draw();
297 diamond->AddText(".. ");
298 diamond->AddText("ROOT");
299 diamond->AddText("MUON");
300 diamond->AddText("... ");
301 diamond->AddText(" ");
302}
303
304//_____________________________________________________________________________
305void AliMUONdisplay::CreateColors()
306{
307// Create the colors palette used to display clusters
308
309 Int_t k,i;
310 Int_t color;
311 Float_t r,g,b;
312
313 for (k=1;k<=5;k++) {
314 switch(k) {
315 case 1:
316 for (i=1;i<=5;i++) {
317 r=1.;
318 g=i*0.2;
319 b=0.;
320 color=i;
a897a37a 321 color=260+23-color;
fe4da5cc 322 new TColor(color,r,g,b);
323 }
fe4da5cc 324 break;
325 case 2:
326 for (i=1;i<=4;i++) {
327 r=1.1-i*0.2;
328 g=1.;
329 b=0.;
330 color=i+5;
a897a37a 331 color=260+23-color;
fe4da5cc 332 new TColor(color,r,g,b);
333 }
fe4da5cc 334 break;
335 case 3:
336 for (i=1;i<=4;i++) {
337 r=0.;
338 g=1.;
339 b=i*0.2+0.2;
340 color=i+9;
a897a37a 341 color=260+23-color;
fe4da5cc 342 new TColor(color,r,g,b);
343 }
fe4da5cc 344 break;
345 case 4:
346 for (i=1;i<=4;i++) {
347 r=0.;
348 g=1.1-i*0.2;
349 b=1.;
350 color=i+13;
a897a37a 351 color=260+23-color;
fe4da5cc 352 new TColor(color,r,g,b);
353 }
fe4da5cc 354 break;
355 case 5:
356 for (i=1;i<=5;i++) {
357 r=i*0.2;
358 g=0.;
359 b=1.;
360 color=i+17;
a897a37a 361 color=260+23-color;
fe4da5cc 362 new TColor(color,r,g,b);
363 }
fe4da5cc 364 break;
365 }
366
367 }
368
369}
370
371//_____________________________________________________________________________
372void AliMUONdisplay::DisplayColorScale()
373{
374
375 Int_t i;
376 Int_t color;
377 Float_t xlow, ylow, xup, yup, hs;
378 Float_t x1, y1, x2, y2;
379 x1 = y1 = 0;
380 x2 = y2 = 20;
381
382 gPad->SetFillColor(0);
383 gPad->Clear();
384 gPad->Range(x1,y1,x2,y2);
385
386 TText *text = new TText(0,0,"");
387 text->SetTextFont(61);
a897a37a 388 text->SetTextSize(0.2);
fe4da5cc 389 text->SetTextAlign(22);
a897a37a 390
8eb67615 391 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
392 AliMUONchamber *iChamber = &(MUON->Chamber(fChamber-1));
393 AliMUONresponse * response=iChamber->GetResponseModel();
394 Int_t adcmax= (Int_t) response->MaxAdc();
a897a37a 395
fe4da5cc 396
397 TBox *box;
398 char label[8];
399//*-* draw colortable boxes
400 hs = (y2-y1)/Float_t(22);
401 xlow=x1+1;
402 xup=x2-9;
403 for (i=0;i<22;i++) {
404 ylow = y1 + hs*(Float_t(i));
405 yup = y1 + hs*(Float_t(i+1));
a897a37a 406 color = 261+i;
a897a37a 407 Double_t logscale=Double_t(i+1)*(TMath::Log(adcmax)/22);
fe4da5cc 408 Int_t scale=(Int_t)TMath::Exp(logscale);
409 sprintf(label,"%d",scale);
410 box = new TBox(xlow, ylow, xup, yup);
411 box->SetFillColor(color);
412 box->Draw();
413 text->DrawText(xup+4, 0.5*(ylow+yup),label);
414 }
415}
416
417//______________________________________________________________________________
418Int_t AliMUONdisplay::DistancetoPrimitive(Int_t px, Int_t)
419{
420// Compute distance from point px,py to objects in event
421
422 gPad->SetCursor(kCross);
423
424 if (gPad == fTrigPad) return 9999;
425
426 const Int_t big = 9999;
427 Int_t dist = big;
428 Float_t xmin = gPad->GetX1();
429 Float_t xmax = gPad->GetX2();
430 Float_t dx = 0.02*(xmax - xmin);
431 Float_t x = gPad->AbsPixeltoX(px);
432 if (x < xmin+dx || x > xmax-dx) return dist;
433
434 if (fZoomMode) return 0;
435 else return 7;
436}
437
438//_____________________________________________________________________________
439void AliMUONdisplay::Draw(Option_t *)
440{
441// Display current event
442
443 fPad->cd();
444
a897a37a 445 DrawView(fTheta, fPhi, fPsi);
fe4da5cc 446 // Display the event number and title
447 fPad->cd();
448 DrawTitle();
449}
450
451
452//_____________________________________________________________________________
453void AliMUONdisplay::DrawClusters()
454{
455// Draw clusterss for MUON chambers
456
457 Int_t ndigits, digit;
458 TObjArray *points;
459 AliMUONpoints *pm;
460
fe4da5cc 461
462 fClustersCuts = 0;
463 points = Points();
464 if (!points) return;
465 ndigits = points->GetEntriesFast();
fe4da5cc 466 for (digit=0;digit<ndigits;digit++){
467 pm = (AliMUONpoints*)points->UncheckedAt(digit);
468 if (!pm) continue;
a897a37a 469 Float_t *pxyz;
470 pxyz=pm->GetP();
a897a37a 471 for (Int_t im=0;im<3;im++) {
472 TMarker3DBox *marker=pm->GetMarker(im);
a897a37a 473 if (marker)
474 marker->Draw();
475 }
476 pm->Draw();
fe4da5cc 477 fClustersCuts +=pm->GetN();
a897a37a 478
fe4da5cc 479 }
480}
481
482//_____________________________________________________________________________
483void AliMUONdisplay::DrawHits()
484{
485// Draw hits for MUON chambers
486
487 LoadHits(fChamber);
488
489 Int_t ntracks, track;
490 TObjArray *points;
491 AliMUONpoints *pm;
492
493 fHitsCuts = 0;
494 points = Phits();
495 if (!points) return;
496 ntracks = points->GetEntriesFast();
fe4da5cc 497 for (track=0;track<ntracks;track++) {
498 pm = (AliMUONpoints*)points->UncheckedAt(track);
499 if (!pm) continue;
500 pm->Draw();
501 fHitsCuts += pm->GetN();
502 }
503}
504
505
a897a37a 506//_____________________________________________________________________________
507void AliMUONdisplay::DrawCoG()
508{
509// Draw hits for MUON chambers
510 if (!fDrawCoG) return;
511 LoadCoG(fChamber,fCathode);
512
513 Int_t ncog, icog;
514 TObjArray *points;
515 AliMUONpoints *pm;
516
517 points = Rpoints();
518 if (!points) return;
519 ncog = points->GetEntriesFast();
a897a37a 520 for (icog=0;icog<ncog;icog++) {
521 pm = (AliMUONpoints*)points->UncheckedAt(icog);
522 if (!pm) continue;
523 pm->Draw();
524 }
525}
526void AliMUONdisplay::DrawCoG2()
527{
528// Draw hits for MUON chambers
529
530 if (!fDrawCoG) return;
531
532
533 if (fCathode==1) {
534 LoadCoG2(fChamber,2);
535 } else if (fCathode==2) {
536 LoadCoG2(fChamber,1);
537 }
538
539 Int_t ncog, icog;
540 TObjArray *points;
541 AliMUONpoints *pm;
542
543 points = R2points();
544 if (!points) return;
545 ncog = points->GetEntriesFast();
a897a37a 546 for (icog=0;icog<ncog;icog++) {
547 pm = (AliMUONpoints*)points->UncheckedAt(icog);
548 if (!pm) continue;
549 pm->Draw();
550 }
551
552}
553//_____________________________________________________________________________
554void AliMUONdisplay::DrawCathCor()
555{
556// Draw hits for MUON chambers
557
558 if (!fDrawCathCor) return;
559
560 LoadCathCor(fChamber);
561
562 Int_t ncog, icog;
563 TObjArray *points;
564 AliMUONpoints *pm;
565
566 points = Cpoints();
567 if (!points) return;
568 ncog = points->GetEntriesFast();
a897a37a 569 for (icog=0;icog<ncog;icog++) {
570 pm = (AliMUONpoints*)points->UncheckedAt(icog);
571 if (!pm) continue;
572 pm->Draw();
573 }
574}
575//_____________________________________________________________________________
fe4da5cc 576//_____________________________________________________________________________
577void AliMUONdisplay::DrawTitle(Option_t *option)
578{
579// Draw the event title
580
581 Float_t xmin = gPad->GetX1();
582 Float_t xmax = gPad->GetX2();
583 Float_t ymin = gPad->GetY1();
584 Float_t ymax = gPad->GetY2();
585 Float_t dx = xmax-xmin;
586 Float_t dy = ymax-ymin;
587
588 if (strlen(option) == 0) {
589 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
590 title->SetBit(kCanDelete);
591 title->SetFillColor(42);
592 title->Draw();
593 char ptitle[100];
594 sprintf(ptitle,"Alice event: %d, Run:%d",gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
595 title->AddText(ptitle);
596 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
597 sprintf(ptitle,"Nparticles = %d Nhits = %d Npads fired = %d",nparticles, fHitsCuts,fClustersCuts);
598 title->AddText(ptitle);
599 } else {
600 TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
601 label->SetBit(kCanDelete);
602 label->SetFillColor(42);
603 label->Draw();
604 }
605}
606
607//_____________________________________________________________________________
608void AliMUONdisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
609{
610// Draw a view of MUON clusters
611
612 gPad->SetCursor(kWatch);
613 gPad->SetFillColor(1);
614 gPad->Clear();
615
a897a37a 616 Int_t iret=0;
fe4da5cc 617 TView *view = new TView(1);
a897a37a 618
fe4da5cc 619 Float_t range = fRrange*fRangeSlider->GetMaximum();
620 view->SetRange(-range,-range,-range,range, range, range);
621 fZoomX0[0] = -1;
622 fZoomY0[0] = -1;
623 fZoomX1[0] = 1;
624 fZoomY1[0] = 1;
625 fZooms = 0;
a897a37a 626
627// Display MUON Chamber Geometry
628// gAlice->GetGeometry()->Draw("same");
629 char NodeName[7];
630 sprintf(NodeName,"MUON%d",100+fChamber);
631 printf("Node name %s", NodeName);
fe4da5cc 632
a897a37a 633 TNode *node1=gAlice->GetGeometry()->GetNode(NodeName);
634 if (node1) node1->Draw("same");
635// ok if I rotate the chamber in a proper way
636
637//add clusters to the pad
fe4da5cc 638 DrawClusters();
639 DrawHits();
a897a37a 640 DrawCoG();
641 DrawCoG2();
642 DrawCathCor();
fe4da5cc 643 // add itself to the list (must be last)
644 AppendPad();
fe4da5cc 645 view->SetView(phi, theta, psi, iret);
646}
647
648
649//______________________________________________________________________________
650void AliMUONdisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
651{
652// Execute action corresponding to the mouse event
653
654 static Float_t x0, y0, x1, y1;
655
656 static Int_t pxold, pyold;
657 static Int_t px0, py0;
658 static Int_t linedrawn;
659 Float_t temp;
660
661 if (px == 0 && py == 0) { //when called by sliders
662 if (event == kButton1Up) {
663 Draw();
664 }
665 return;
666 }
667 if (!fZoomMode && gPad->GetView()) {
668 gPad->GetView()->ExecuteRotateView(event, px, py);
669 return;
670 }
671
672 // something to zoom ?
673 gPad->SetCursor(kCross);
674
675 switch (event) {
676
677 case kButton1Down:
678 gGXW->SetLineColor(-1);
679 gPad->TAttLine::Modify(); //Change line attributes only if necessary
680 x0 = gPad->AbsPixeltoX(px);
681 y0 = gPad->AbsPixeltoY(py);
682 px0 = px; py0 = py;
683 pxold = px; pyold = py;
684 linedrawn = 0;
685 return;
686
687 case kButton1Motion:
688 if (linedrawn) gGXW->DrawBox(px0, py0, pxold, pyold, TGXW::kHollow);
689 pxold = px;
690 pyold = py;
691 linedrawn = 1;
692 gGXW->DrawBox(px0, py0, pxold, pyold, TGXW::kHollow);
693 return;
694
695 case kButton1Up:
696 gPad->GetCanvas()->FeedbackMode(kFALSE);
697 if (px == px0) return;
698 if (py == py0) return;
699 x1 = gPad->AbsPixeltoX(px);
700 y1 = gPad->AbsPixeltoY(py);
701
702 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
703 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
704 gPad->Range(x0,y0,x1,y1);
705 if (fZooms < kMAXZOOM-1) {
706 fZooms++;
707 fZoomX0[fZooms] = x0;
708 fZoomY0[fZooms] = y0;
709 fZoomX1[fZooms] = x1;
710 fZoomY1[fZooms] = y1;
711 }
712 gPad->Modified(kTRUE);
713 return;
714 }
715
716}
717
718//___________________________________________
719void AliMUONdisplay::LoadDigits(Int_t chamber, Int_t cathode)
720{
721// Read digits info and store x,y,z info in arrays fPoints
722// Loop on all detectors
723
a897a37a 724 if (chamber > 10) return;
725
fe4da5cc 726 fChamber=chamber;
727 fCathode=cathode;
a897a37a 728
fe4da5cc 729 ResetPoints();
730
0f439796 731 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
fe4da5cc 732 AliMUONchamber* iChamber;
733 AliMUONsegmentation* segmentation;
734
735 TClonesArray *MUONdigits = MUON->DigitsAddress(chamber-1);
736 if (MUONdigits == 0) return;
737
738 gAlice->ResetDigits();
a897a37a 739
740 Int_t nent=(Int_t)gAlice->TreeD()->GetEntries();
741 gAlice->TreeD()->GetEvent(nent-2+cathode-1);
742 //gAlice->TreeD()->GetEvent(cathode);
fe4da5cc 743 Int_t ndigits = MUONdigits->GetEntriesFast();
744 if (ndigits == 0) return;
745 if (fPoints == 0) fPoints = new TObjArray(ndigits);
fe4da5cc 746
747 iChamber = &(MUON->Chamber(chamber-1));
fe4da5cc 748 segmentation=iChamber->GetSegmentationModel(cathode);
8eb67615 749 //Float_t dpxbig = segmentation->Dpx()/2.;
750 // Float_t dpy = segmentation->Dpy()/2.;
751 Float_t zpos=iChamber->ZPosition();
fe4da5cc 752 AliMUONdigit *mdig;
753 AliMUONpoints *points = 0;
a897a37a 754 TMarker3DBox *marker=0;
755 // TMatrix *matrix;
fe4da5cc 756 //
757 //loop over all digits and store their position
758 // points = new AliMUONpoints(ndigits);
759 Int_t npoints=1;
760 for (Int_t digit=0;digit<ndigits;digit++) {
a897a37a 761 mdig = (AliMUONdigit*)MUONdigits->UncheckedAt(digit);
762 //
763 // First get all needed parameters
764 //
fe4da5cc 765 Int_t charge=mdig->fSignal;
fe4da5cc 766 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
a897a37a 767 Int_t color=261+index;
768 if (color>282) color=282;
fe4da5cc 769 // get the center of the pad - add on x and y half of pad size
770 Float_t xpad, ypad;
771 segmentation->GetPadCxy(mdig->fPadX, mdig->fPadY,xpad, ypad);
a897a37a 772 // printf("xpad,ypad,zpos,dpx,dpy %f %f %f %f %f\n",xpad,ypad,zpos,dpx,dpy);
773 Int_t isec=segmentation->Sector(mdig->fPadX, mdig->fPadY);
774 // printf(" isec %d \n",isec);
775 Float_t dpx=segmentation->Dpx(isec)/2;
776 Float_t dpy=segmentation->Dpy(isec)/2;
777 // printf(" dpx %f \n",dpx);
778 Int_t nPara, offset;
779 segmentation->GetNParallelAndOffset(mdig->fPadX,mdig->fPadY,
780 &nPara,&offset);
781 //
782 // Then set the objects
783 //
784 points = new AliMUONpoints(npoints);
785 fPoints->AddAt(points,digit);
786
787 points->SetMarkerColor(color);
788 points->SetMarkerStyle(21);
789 points->SetMarkerSize(0.5);
fe4da5cc 790 points->SetParticle(-1);
791 points->SetHitIndex(-1);
792 points->SetTrackIndex(-1);
793 points->SetDigitIndex(digit);
a897a37a 794 points->SetPoint(0,xpad,ypad,zpos);
795 for (Int_t imark=0;imark<nPara; imark++)
796 {
797 segmentation->GetPadCxy(mdig->fPadX + imark*offset, mdig->fPadY,xpad, ypad);
798 marker=new TMarker3DBox(xpad,ypad,zpos,dpx,dpy,0,0,0);
799 marker->SetLineColor(2);
800 marker->SetFillStyle(1001);
801 marker->SetFillColor(color);
802 marker->SetRefObject((TObject*)points);
803 points->Set3DMarker(imark, marker);
804
a897a37a 805 }
806 }
807}
808//___________________________________________
809void AliMUONdisplay::LoadCoG(Int_t chamber, Int_t cathode)
810{
811// Read raw clusters info and store x,y,z info in arrays fRpoints
812// Loop on all detectors
813
814 if (chamber > 10) return;
815
816 ResetRpoints();
817
818 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
819 AliMUONchamber* iChamber;
a897a37a 820
821 TClonesArray *MUONrawclust = MUON->RawClustAddress(chamber-1);
822 if (MUONrawclust == 0) return;
823
824 MUON->ResetRawClusters();
825
a897a37a 826
827 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
828 gAlice->TreeR()->GetEvent(nent-2+cathode-1);
829 //gAlice->TreeR()->GetEvent(cathode);
830 Int_t nrawcl = MUONrawclust->GetEntriesFast();
831 if (nrawcl == 0) return;
832 if (fRpoints == 0) fRpoints = new TObjArray(nrawcl);
a897a37a 833
834 iChamber = &(MUON->Chamber(chamber-1));
8eb67615 835 Float_t zpos=iChamber->ZPosition();
a897a37a 836 AliMUONRawCluster *mRaw;
837 AliMUONpoints *points = 0;
838 //
839 //loop over all raw clusters and store their position
840 points = new AliMUONpoints(nrawcl);
841 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
842 mRaw = (AliMUONRawCluster*)MUONrawclust->UncheckedAt(iraw);
843 fRpoints->AddAt(points,iraw);
844 points->SetMarkerColor(51);
845 points->SetMarkerStyle(2);
846 points->SetMarkerSize(1.);
847 points->SetParticle(-1);
848 points->SetHitIndex(-1);
849 points->SetTrackIndex(-1);
850 points->SetDigitIndex(-1);
851 points->SetPoint(iraw,mRaw->fX,mRaw->fY,zpos);
852 }
853}
854//___________________________________________
855void AliMUONdisplay::LoadCoG2(Int_t chamber, Int_t cathode)
856{
857// Read raw clusters info and store x,y,z info in arrays fRpoints
858// Loop on all detectors
859
860 if (chamber > 10) return;
861
862 ResetR2points();
863
864 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
865 AliMUONchamber* iChamber;
a897a37a 866
867 TClonesArray *MUONrawclust = MUON->RawClustAddress(chamber-1);
868 if (MUONrawclust == 0) return;
869
870 MUON->ResetRawClusters();
871
a897a37a 872 Int_t nent=(Int_t)gAlice->TreeR()->GetEntries();
873 gAlice->TreeR()->GetEvent(nent-2+cathode-1);
874 //gAlice->TreeR()->GetEvent(cathode);
875 Int_t nrawcl = MUONrawclust->GetEntriesFast();
876 if (nrawcl == 0) return;
877 if (fR2points == 0) fR2points = new TObjArray(nrawcl);
a897a37a 878
879 iChamber = &(MUON->Chamber(chamber-1));
8eb67615 880 Float_t zpos=iChamber->ZPosition();
a897a37a 881 AliMUONRawCluster *mRaw;
882 AliMUONpoints *points = 0;
883 //
884 //loop over all raw clusters and store their position
885 points = new AliMUONpoints(nrawcl);
886 for (Int_t iraw=0;iraw<nrawcl;iraw++) {
887 mRaw = (AliMUONRawCluster*)MUONrawclust->UncheckedAt(iraw);
888 fR2points->AddAt(points,iraw);
889 points->SetMarkerColor(51);
890 points->SetMarkerStyle(4);
891 points->SetMarkerSize(1.3);
892 points->SetParticle(-1);
893 points->SetHitIndex(-1);
894 points->SetTrackIndex(-1);
895 points->SetDigitIndex(-1);
896 points->SetPoint(iraw,mRaw->fX,mRaw->fY,zpos);
fe4da5cc 897 }
898}
a897a37a 899//___________________________________________
900void AliMUONdisplay::LoadCathCor(Int_t chamber)
901{
902// Read correlation info and store x,y,z info in arrays fCpoints
903// Loop on all detectors
904
905 if (chamber > 10) return;
906 fChamber=chamber;
907 ResetCpoints();
908
909 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
910 AliMUONchamber* iChamber;
911 iChamber = &(MUON->Chamber(chamber-1));
912 Float_t zpos=iChamber->ZPosition(); // check with Andreas
913
914
915 //new
916 MUON->GetTreeC(fEvent);
917 TTree *TC=MUON->TreeC();
918 if (!TC) return;
8eb67615 919 // Int_t nent=(Int_t)TC->GetEntries();
a897a37a 920
921 TClonesArray *MUONcorrel = MUON->CathCorrelAddress(chamber-1);
922 if (MUONcorrel == 0) return;
923
924 MUON->ResetCorrelation();
a897a37a 925 TC->GetEvent();
926
927 Int_t ncor = MUONcorrel->GetEntries();
a897a37a 928 if (!ncor) return;
929 if (!fCpoints) fCpoints = new TObjArray(ncor);
930
931 AliMUONcorrelation *mCor;
932 AliMUONpoints *points = 0;
933 //
934 //loop over all raw clusters and store their position
935 points = new AliMUONpoints(ncor);
936 for (Int_t icor=0;icor<ncor;icor++) {
937 mCor = (AliMUONcorrelation*)MUONcorrel->UncheckedAt(icor);
938 fCpoints->AddAt(points,icor);
939 points->SetMarkerColor(4);
940 points->SetMarkerStyle(4);
941 points->SetMarkerSize(0.8);
942 points->SetParticle(-1);
943 points->SetHitIndex(-1);
944 points->SetTrackIndex(-1);
945 points->SetDigitIndex(-1);
946 points->SetPoint(icor,mCor->fX[0],mCor->fY[0],zpos);
947 }
948}
949
fe4da5cc 950//___________________________________________
951void AliMUONdisplay::LoadHits(Int_t chamber)
952{
953// Read hits info and store x,y,z info in arrays fPhits
954// Loop on all detectors
955
a897a37a 956 if (chamber > 10) return;
a6f39961 957 Int_t track;
a897a37a 958
fe4da5cc 959 fChamber=chamber;
960
961 ResetPhits();
962
0f439796 963 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
fe4da5cc 964 AliMUONchamber* iChamber;
965
966 iChamber = &(MUON->Chamber(chamber-1));
967 Float_t zpos=iChamber->ZPosition();
fe4da5cc 968
969 Int_t ntracks = (Int_t)gAlice->TreeH()->GetEntries();
8eb67615 970 //Int_t ntrks = gAlice->GetNtrack();
971
fe4da5cc 972
a897a37a 973 Int_t nthits=0;
a6f39961 974 for (track=0; track<ntracks;track++) {
a897a37a 975 gAlice->ResetHits();
976 gAlice->TreeH()->GetEvent(track);
977 TClonesArray *MUONhits = MUON->Hits();
978 if (MUONhits == 0) return;
979 nthits += MUONhits->GetEntriesFast();
980 }
981 if (fPhits == 0) fPhits = new TObjArray(nthits);
982 //printf("nthits %d \n",nthits);
fe4da5cc 983
a897a37a 984 // old stuff
985 //
986 //if (fPhits == 0) fPhits = new TObjArray(ntracks);
987 /*
988 TVector *xp = new TVector(20);
989 TVector *yp = new TVector(20);
990 // TVector *zp = new TVector(20);
991 TVector *ptrk = new TVector(20);
992 TVector *phit = new TVector(20);
993 */
994 // end old stuff
995
996 Int_t nhold=0;
a6f39961 997 for (track=0; track<ntracks;track++) {
fe4da5cc 998 gAlice->ResetHits();
999 gAlice->TreeH()->GetEvent(track);
1000 TClonesArray *MUONhits = MUON->Hits();
fe4da5cc 1001 if (MUONhits == 0) return;
1002 Int_t nhits = MUONhits->GetEntriesFast();
1003 if (nhits == 0) continue;
fe4da5cc 1004 AliMUONhit *mHit;
1005 AliMUONpoints *points = 0;
a897a37a 1006 Int_t npoints=1;
1007 for (Int_t hit=0;hit<nhits;hit++) {
1008 mHit = (AliMUONhit*)MUONhits->UncheckedAt(hit);
1009 Int_t nch = mHit->fChamber; // chamber number
1010 if (nch != chamber) continue;
1011 //
1012 // Retrieve info and set the objects
1013 //
1014 points = new AliMUONpoints(npoints);
1015 fPhits->AddAt(points,nhold+hit);
1016 points->SetMarkerColor(kRed);
1017 points->SetMarkerStyle(5);
1018 points->SetMarkerSize(1.);
1019 points->SetParticle(mHit->fTrack);
a897a37a 1020 points->SetHitIndex(hit);
1021 points->SetTrackIndex(track);
1022 points->SetDigitIndex(-1);
1023 points->SetPoint(0,mHit->fX,mHit->fY,zpos);
1024 }
1025 nhold+=nhits;
1026
1027
1028 // old stuff
1029 /*
fe4da5cc 1030 Int_t npoints=0;
1031 for (Int_t hit=0;hit<nhits;hit++) {
1032 mHit = (AliMUONhit*)MUONhits->UncheckedAt(hit);
1033 Int_t nch = mHit->fChamber; // chamber number
1034 if (nch != chamber) continue;
a897a37a 1035
fe4da5cc 1036 (*xp)(npoints)=mHit->fX;
1037 (*yp)(npoints)=mHit->fY;
a897a37a 1038 // (*zp)(npoints)=mHit->fZ;
fe4da5cc 1039 (*ptrk)(npoints)=Float_t(mHit->GetTrack());
a897a37a 1040 //(*ptrk)(npoints)=Float_t(mHit->fTrack);
1041 (*phit)(npoints)=Float_t(hit);
1042 printf("hit,(*phit)(npoints), track, trk, fTrack ipart %d %f %d %d %d %f\n",hit,(*phit)(npoints),track,mHit->GetTrack(),mHit->fTrack,mHit->fParticle);
fe4da5cc 1043 npoints++;
1044 }
1045 if (npoints == 0) continue;
1046 // printf("npoints %d \n",npoints);
1047 points = new AliMUONpoints(npoints);
1048 for (Int_t p=0;p<npoints;p++) {
1049 points->SetMarkerColor(kRed);
1050 points->SetMarkerStyle(5);
1051 points->SetMarkerSize(1.);
1052 points->SetParticle(Int_t((*ptrk)(p)));
a897a37a 1053 Int_t index=points->GetIndex();
fe4da5cc 1054 points->SetHitIndex(Int_t((*phit)(p)));
1055 points->SetTrackIndex(track);
a897a37a 1056 printf("p, index, Int_t((*ptrk)(p)), hit, track %d %d %d %d %d \n",p, index,Int_t((*ptrk)(p)),Int_t((*phit)(p)),track);
fe4da5cc 1057 points->SetDigitIndex(-1);
a897a37a 1058 points->SetPoint(p,(*xp)(p),(*yp)(p),zpos);
1059 // points->SetPoint(p,(*xp)(p),(*yp)(p),(*zp)(p));
fe4da5cc 1060 }
a897a37a 1061 xp->Zero();
1062 yp->Zero();
1063 // zp->Zero();
1064 ptrk->Zero();
1065 phit->Zero();
1066 fPhits->AddAt(points,track);
1067 // Int_t np=points->GetN();
1068 // printf("np %d \n",np);
1069
1070
1071 */
1072 // end old stuff
1073
fe4da5cc 1074 }
1075
1076}
1077
1078//_____________________________________________________________________________
1079void AliMUONdisplay::Paint(Option_t *)
1080{
1081// Paint miscellaneous items
1082
1083}
1084
1085//_____________________________________________________________________________
1086void AliMUONdisplay::SetPickMode()
1087{
1088 fZoomMode = 0;
1089
1090 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
1091 fTrigPad->Modified();
1092}
1093
1094//_____________________________________________________________________________
1095void AliMUONdisplay::SetZoomMode()
1096{
1097 fZoomMode = 1;
1098
1099 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
1100 fTrigPad->Modified();
1101}
1102
1103//_____________________________________________________________________________
1104void AliMUONdisplay::SetChamberAndCathode(Int_t chamber, Int_t cathode)
1105{
1106// Set chamber and cathode number
1107 fChamber = chamber;
1108 fCathode = cathode;
1109
fe4da5cc 1110 if (!fPad) return;
1111 fPad->Clear();
1112 LoadDigits(chamber,cathode);
1113 Draw();
1114}
1115
1116//_____________________________________________________________________________
1117void AliMUONdisplay::SetRange(Float_t rrange, Float_t zrange)
1118{
1119// Set view range along R and Z
1120 fRrange = rrange;
1121 fZrange = zrange;
1122
1123 if (!fPad) return;
1124 fPad->Clear();
1125 Draw();
1126}
1127
1128//_____________________________________________________________________________
1129void AliMUONdisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
1130{
1131// change viewing angles for current event
1132
1133 fPad->cd();
1134 fPhi = phi;
1135 fTheta = theta;
1136 fPsi = psi;
1137 Int_t iret = 0;
1138
1139 TView *view = gPad->GetView();
1140 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
1141 else Draw();
1142
1143 gPad->Modified();
1144}
1145
1146//_____________________________________________________________________________
1147void AliMUONdisplay::ShowNextEvent(Int_t delta)
1148{
1149// Display (current event_number+delta)
1150// delta = 1 shown next event
1151// delta = -1 show previous event
fe4da5cc 1152 if (delta) {
1153 gAlice->Clear();
1154 Int_t current_event = gAlice->GetHeader()->GetEvent();
1155 Int_t new_event = current_event + delta;
1156 gAlice->GetEvent(new_event);
a897a37a 1157 fEvent=new_event;
fe4da5cc 1158 if (!gAlice->TreeD()) return;
1159 }
1160 LoadDigits(fChamber,fCathode);
1161 fPad->cd();
1162 Draw();
1163}
1164
1165//______________________________________________________________________________
1166void AliMUONdisplay::UnZoom()
1167{
1168 if (fZooms <= 0) return;
1169 fZooms--;
1170 TPad *pad = (TPad*)gPad->GetPadSave();
1171 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
1172 pad->Modified();
1173}
1174
1175//_____________________________________________________________________________
1176void AliMUONdisplay::ResetPoints()
1177{
1178 //
1179 // Reset array of points
1180 //
1181 if (fPoints) {
1182 fPoints->Delete();
1183 delete fPoints;
1184 fPoints = 0;
1185 }
1186}
1187//_____________________________________________________________________________
1188void AliMUONdisplay::ResetPhits()
1189{
1190 //
1191 // Reset array of points
1192 //
1193 if (fPhits) {
1194 fPhits->Delete();
1195 delete fPhits;
1196 fPhits = 0;
1197 }
1198}
a897a37a 1199//_____________________________________________________________________________
1200void AliMUONdisplay::ResetRpoints()
1201{
1202 //
1203 // Reset array of points
1204 //
1205 if (fRpoints) {
1206 fRpoints->Delete();
1207 delete fRpoints;
1208 fRpoints = 0;
1209 }
1210}
1211//_____________________________________________________________________________
1212void AliMUONdisplay::ResetR2points()
1213{
1214 //
1215 // Reset array of points
1216 //
1217 if (fR2points) {
1218 fR2points->Delete();
1219 delete fR2points;
1220 fR2points = 0;
1221 }
1222}
1223//_____________________________________________________________________________
1224void AliMUONdisplay::ResetCpoints()
1225{
1226 //
1227 // Reset array of points
1228 //
1229 if (fCpoints) {
1230 fCpoints->Delete();
1231 delete fCpoints;
1232 fCpoints = 0;
1233 }
1234}
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245