]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerGUIdimap.cxx
Added documentation about how to operate the Alignment task
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerGUIdimap.cxx
CommitLineData
905654c2 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
bae1aa70 16// $Id$
17
3d1463c8 18//-----------------------------------------------------------------------------
bae1aa70 19/// \class AliMUONTriggerGUIdimap
20///
21/// The digit maps of the four trigger chambers, all boards
22///
23/// \author Bogdan Vulpescu, LPC Clermont-Ferrand
3d1463c8 24//-----------------------------------------------------------------------------
905654c2 25
26#include <TCanvas.h>
905654c2 27#include <TGButton.h>
28#include <TGTab.h>
29#include <TRootEmbeddedCanvas.h>
30#include <TBox.h>
905654c2 31#include <TPave.h>
32#include <TPaveText.h>
33#include <TStyle.h>
34#include <TObjArray.h>
35
c93255fe 36#include "AliLoader.h"
8b067dfe 37#include "AliRunLoader.h"
905654c2 38
bae1aa70 39#include "AliMUONVDigit.h"
905654c2 40#include "AliMpSegmentation.h"
41#include "AliMpVSegmentation.h"
42#include "AliMUONGeometryTransformer.h"
f9eb4448 43#include "AliMUONMCDataInterface.h"
905654c2 44
45#include "AliMUONTriggerGUIboard.h"
46#include "AliMUONTriggerGUIdimap.h"
47
8b067dfe 48#include "AliMUONDigitStoreV1.h"
bae1aa70 49
b785c4bd 50#include <cstdio>
51
905654c2 52/// \cond CLASSIMP
53ClassImp(AliMUONTriggerGUIdimap)
54/// \endcond
55
56//__________________________________________________________________________
f9eb4448 57AliMUONTriggerGUIdimap::AliMUONTriggerGUIdimap(TObjArray *boards, const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
bae1aa70 58 : TGFrame(0),
905654c2 59 fMain(0),
60 fLoader(0),
f9eb4448 61 fMCDataInterface(0),
8b067dfe 62 fRawDigitStore(0),
905654c2 63 fBoards(0),
64 fIsOn(0)
65{
66 /// frame constructor
67
905654c2 68 fIsOn = kTRUE;
69 fBoards = boards;
70
905654c2 71 gStyle->SetPadLeftMargin(0.05);
72 gStyle->SetPadRightMargin(0.05);
73 gStyle->SetPadTopMargin(0.05);
74 gStyle->SetPadBottomMargin(0.05);
75
76 gStyle->SetOptDate(0);
77 gStyle->SetOptTitle(0);
78 gStyle->SetOptStat(0);
79
80 fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
81 fMain->Connect("CloseWindow()", "AliMUONTriggerGUIdimap", this, "DoClose()");
82 fMain->DontCallClose(); // to avoid double deletions.
83
84 // use hierarchical cleaning
85 fMain->SetCleanup(kDeepCleanup);
86
87 TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
88
89 TGTextButton *closeButton = new TGTextButton(hframe, "Close", 1);
90 closeButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoClose()");
91
92 hframe->AddFrame(closeButton,
93 new TGLayoutHints(kLHintsTop |
94 kLHintsLeft,
95 2, 2, 2, 2)
96 );
97
98 hframe->Resize(150, closeButton->GetDefaultHeight());
99
100 TGTextButton *updateButton = new TGTextButton(hframe, "Update", 2);
101 updateButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoUpdate()");
102 updateButton->SetToolTipText("Read the digits for the current event");
103
104 hframe->AddFrame(updateButton,
105 new TGLayoutHints(kLHintsTop |
106 kLHintsLeft,
107 2, 2, 2, 2)
108 );
109
110 hframe->Resize(150, updateButton->GetDefaultHeight());
111 /*
112 TGTextButton *resetButton = new TGTextButton(hframe, "Reset", 3);
113 resetButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoReset()");
114 resetButton->SetToolTipText("Redraw unselected boards");
115
116 hframe->AddFrame(resetButton,
117 new TGLayoutHints(kLHintsTop |
118 kLHintsLeft,
119 2, 2, 2, 2)
120 );
121
122 hframe->Resize(150, resetButton->GetDefaultHeight());
123 */
124 fMain->AddFrame(hframe,
125 new TGLayoutHints(kLHintsBottom |
126 kLHintsLeft,
127 2, 2, 2, 2)
128 );
129
130 TGTab *tab = new TGTab(fMain, 300, 300);
131 //tab->Connect("Selected(Int_t)", "AliMUONTriggerGUIdimap", this, "DoTab(Int_t)");
132
133 // Tabs for MT11, MT12, MT21, MT22
134 TGLayoutHints *lot = new TGLayoutHints(kLHintsTop |
135 kLHintsLeft |
136 kLHintsExpandX |
137 kLHintsExpandY,
138 5, 5, 5, 5);
139
140 TGCompositeFrame *tf = 0;
141
142 // Tab for MT11
143 tf = tab->AddTab("MT11");
144
145 TGCompositeFrame *cf1 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
146 fEc[0] = new TRootEmbeddedCanvas("ec1", cf1, 500, 500);
147 cf1->AddFrame(fEc[0], lot);
148
149 tf->AddFrame(cf1, lot);
150 fEc[0]->GetCanvas()->SetBorderMode(0);
151 fEc[0]->GetCanvas()->SetBit(kNoContextMenu);
152
153 // Tab for MT12
154 tf = tab->AddTab("MT12");
155
156 TGCompositeFrame *cf2 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
157 fEc[1] = new TRootEmbeddedCanvas("ec2", cf2, 500, 500);
158 cf2->AddFrame(fEc[1], lot);
159
160 tf->AddFrame(cf2, lot);
161 fEc[1]->GetCanvas()->SetBorderMode(0);
162 fEc[1]->GetCanvas()->SetBit(kNoContextMenu);
163
164 // Tab for MT21
165 tf = tab->AddTab("MT21");
166
167 TGCompositeFrame *cf3 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
168 fEc[2] = new TRootEmbeddedCanvas("ec3", cf3, 500, 500);
169 cf3->AddFrame(fEc[2], lot);
170
171 tf->AddFrame(cf3, lot);
172 fEc[2]->GetCanvas()->SetBorderMode(0);
173 fEc[2]->GetCanvas()->SetBit(kNoContextMenu);
174
175 // Tab for MT22
176 tf = tab->AddTab("MT22");
177
178 TGCompositeFrame *cf4 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
179 fEc[3] = new TRootEmbeddedCanvas("ec4", cf4, 500, 500);
180 cf4->AddFrame(fEc[3], lot);
181
182 tf->AddFrame(cf4, lot);
183 fEc[3]->GetCanvas()->SetBorderMode(0);
184 fEc[3]->GetCanvas()->SetBit(kNoContextMenu);
185
186 fMain->AddFrame(tab,
187 new TGLayoutHints(kLHintsBottom |
188 kLHintsExpandX |
189 kLHintsExpandY,
190 2, 2, 2, 2)
191 );
192
193 fMain->MapSubwindows();
194 fMain->Resize();
195
196 fMain->CenterOnParent();
197
198 fMain->SetWindowName("Chambers digit maps");
199
200 fMain->MapWindow();
201
905654c2 202}
203
204//__________________________________________________________________________
205AliMUONTriggerGUIdimap::~AliMUONTriggerGUIdimap()
206{
207 /// destructor
208
209 for (Int_t it = 0; it < kNMT; it++) {
210 for (Int_t ib = 0; ib < kNBoards; ib++) {
211 delete fPaveBoard[it][ib];
212 }
213 }
214
905654c2 215 fMain->DeleteWindow();
216
217}
218
f9eb4448 219//__________________________________________________________________________
220void AliMUONTriggerGUIdimap::DrawAllMaps()
221{
222 /// draw maps
223
224 if (fLoader == 0x0) {
8b067dfe 225 //return;
f9eb4448 226 }
227 if (fMCDataInterface == 0x0) {
8b067dfe 228 //return;
f9eb4448 229 }
230
231 DrawMaps(11);
232 DrawMaps(12);
233 DrawMaps(13);
234 DrawMaps(14);
235
236}
237
905654c2 238//__________________________________________________________________________
239void AliMUONTriggerGUIdimap::DrawMaps(Int_t chamber)
240{
241 /// draw the digits map for chamber-
242
8b067dfe 243 Bool_t drawDigits = kTRUE;
244 Bool_t drawDigitsRaw = kTRUE;
245 if (fLoader == 0x0) {
246 drawDigits = kFALSE;
247 }
248 if (fRawDigitStore == 0x0) {
249 drawDigitsRaw = kFALSE;
250 }
251
252 AliMUONTriggerGUIboard *board;
905654c2 253
254 TCanvas *canvas = fEc[chamber-11]->GetCanvas();
255 canvas->cd();
256 canvas->Clear();
257
905654c2 258 TPaveText *label;
259 TBox *boxd;
260
5d844edb 261 Char_t cln[4]; // must be 4 long - room for terminating '\0'
905654c2 262 Int_t detElemId, cathode, ix, iy, charge, color;
905654c2 263 Int_t holdS, holdL, holdC;
8b067dfe 264 Float_t xCenter, yCenter, xWidth, yWidth, holdXC, holdYC;
905654c2 265 Float_t xMin, xMax, yMin, yMax;
266 Float_t ptx1, ptx2, pty1, pty2;
267 Float_t xpmin, xpmax, ypmin, ypmax;
268 Float_t xg1, xg2, yg1, yg2, zg1;
269
270 Float_t frameXmax = 0., frameYmax = 0.;
271
272 switch(chamber) {
273 case 11:
274 frameXmax = 257.0;
275 frameYmax = 306.6;
276 break;
277 case 12:
278 frameXmax = 259.7;
279 frameYmax = 309.9;
280 break;
281 case 13:
282 frameXmax = 273.0;
283 frameYmax = 325.7;
284 break;
285 case 14:
286 frameXmax = 275.7;
287 frameYmax = 329.0;
288 break;
289 }
290
291 canvas->Range(
292 -(1.15*frameXmax),
293 -(1.15*frameYmax),
294 +(1.15*frameXmax),
295 +(1.15*frameYmax)
296 );
297
298 // draw the boards
299
905654c2 300 for (Int_t ib = 0; ib < kNBoards; ib++) {
301
8b067dfe 302 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
905654c2 303
8b067dfe 304 holdS = board->GetSide();
305 holdC = board->GetCol();
306 holdL = board->GetLine();
905654c2 307
8b067dfe 308 xCenter = board->GetXCenter(chamber-11);
309 yCenter = board->GetYCenter(chamber-11);
310 xWidth = board->GetXWidth(chamber-11);
311 yWidth = board->GetYWidth(chamber-11);
905654c2 312
313 holdXC = xCenter;
314 holdYC = yCenter;
315
316 xMin = xCenter - xWidth/2;
317 xMax = xCenter + xWidth/2;
318 yMin = yCenter - yWidth/2;
319 yMax = yCenter + yWidth/2;
320
321 fPaveBoard[chamber-11][ib] = new TPave(xMin,yMin,xMax,yMax,1);
322 fPaveBoard[chamber-11][ib]->SetBit(kCannotPick);
323 fPaveBoard[chamber-11][ib]->SetFillStyle(0);
324 fPaveBoard[chamber-11][ib]->Draw();
325
326 Float_t lWidth = 12.0;
327
328 if (holdL == 9) {
329
5d844edb 330 snprintf(cln,4,"C%1d",holdC);
905654c2 331
332 ptx1 = holdXC - lWidth;
333 ptx2 = holdXC + lWidth;
334 pty1 = +1.065*frameYmax - lWidth;
335 pty2 = +1.065*frameYmax + lWidth;
336
337 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
338 label->AddText(cln);
339 label->SetBorderSize(0);
340 label->SetBit(kCannotPick);
341 label->Draw();
342 }
343 if (holdL == 1) {
344
5d844edb 345 snprintf(cln,4,"C%1d",holdC);
905654c2 346
347 ptx1 = holdXC - lWidth;
348 ptx2 = holdXC + lWidth;
349 pty1 = -1.065*frameYmax - lWidth;
350 pty2 = -1.065*frameYmax + lWidth;
351
352 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
353 label->AddText(cln);
354 label->SetBorderSize(0);
355 label->SetBit(kCannotPick);
356 label->Draw();
357 }
358 if (holdS == 0 && holdC == 7) {
359
5d844edb 360 snprintf(cln,4,"L%1d",holdL);
905654c2 361
362 ptx1 = -1.07*frameXmax - lWidth;
363 ptx2 = -1.07*frameXmax + lWidth;
364 pty1 = holdYC - lWidth;
365 pty2 = holdYC + lWidth;
366
367 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
368 label->AddText(cln);
369 label->SetBorderSize(0);
370 label->SetBit(kCannotPick);
371 label->Draw();
372 }
373 if (holdS == 1 && holdC == 7) {
374
5d844edb 375 snprintf(cln,4,"L%1d",holdL);
905654c2 376
377 ptx1 = +1.07*frameXmax - lWidth;
378 ptx2 = +1.07*frameXmax + lWidth;
379 pty1 = holdYC - lWidth;
380 pty2 = holdYC + lWidth;
381
382 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
383 label->AddText(cln);
384 label->SetBorderSize(0);
385 label->SetBit(kCannotPick);
386 label->Draw();
387 }
388
389 }
390
905654c2 391 // draw digits set from the board GUI
392
905654c2 393 Int_t imt = chamber -11;
394 Int_t nStripX, nStripY;
395 TBox *box;
396 for (Int_t ib = 0; ib < kNBoards; ib++) {
397
398 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
399
400 xCenter = board->GetXCenter(imt);
401 yCenter = board->GetYCenter(imt);
402
403 nStripX = board->GetXSiy2() - board->GetXSiy1() + 1;
404 nStripY = board->GetYSix2() - board->GetYSix1() + 1 ;
405
406 for (Int_t is = 0; is < nStripX; is++) {
407
408 if (board->GetXDig(imt,is) == 0) continue;
409
410 box = board->GetXDigBox(imt,is);
411
412 xpmin = box->GetX1();
413 xpmax = box->GetX2();
414 ypmin = box->GetY1();
415 ypmax = box->GetY2();
416
417 xpmin += xCenter;
418 xpmax += xCenter;
419 ypmin += yCenter;
420 ypmax += yCenter;
421
422 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
423
424 }
425
426 for (Int_t is = 0; is < nStripY; is++) {
427
428 if (board->GetYDig(imt,is) == 0) continue;
429
430 box = board->GetYDigBox(imt,is);
431
432 xpmin = box->GetX1();
433 xpmax = box->GetX2();
434 ypmin = box->GetY1();
435 ypmax = box->GetY2();
436
437 xpmin += xCenter;
438 xpmax += xCenter;
439 ypmin += yCenter;
440 ypmax += yCenter;
441
442 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
443
444 }
445
446 }
447
8b067dfe 448 // draw the digits from galice
905654c2 449
8b067dfe 450 if (drawDigits || drawDigitsRaw) {
f9eb4448 451
8b067dfe 452 AliMUONGeometryTransformer transformer;
453 transformer.LoadGeometryData("transform.dat");
905654c2 454
8b067dfe 455 AliMUONVDigitStore *digitStore = 0x0;
905654c2 456
8b067dfe 457 if (drawDigits) {
458 AliRunLoader *runLoader = fLoader->GetRunLoader();
459 digitStore = fMCDataInterface->DigitStore(runLoader->GetEventNumber());
460 }
461 if (drawDigitsRaw) {
e1ac4804 462 digitStore = fRawDigitStore;
8b067dfe 463 }
905654c2 464
8b067dfe 465 TIter next(digitStore->CreateIterator());
466 AliMUONVDigit* mdig;
905654c2 467
8b067dfe 468 while ( ( mdig = static_cast<AliMUONVDigit*>(next()) ) ) {
469
470 cathode = mdig->Cathode()+1;
471
472 ix=mdig->PadX();
473 iy=mdig->PadY();
474 detElemId=mdig->DetElemId();
475 charge = (Int_t)mdig->Charge();
476 color = 261+5*(charge-1);
477 if (color > 282) color = 282;
478
479 if (detElemId/100 != chamber) continue;
480
481 const AliMpVSegmentation* seg2 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode-1));
482
168e9c4d 483 AliMpPad mpad = seg2->PadByIndices(ix,iy,kTRUE);
8b067dfe 484
485 // get the pad position and dimensions
6e97fbb8 486 Float_t xlocal1 = mpad.GetPositionX();
487 Float_t ylocal1 = mpad.GetPositionY();
488 Float_t xlocal2 = mpad.GetDimensionX();
489 Float_t ylocal2 = mpad.GetDimensionY();
8b067dfe 490
491 transformer.Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
492 // (no transformation for pad dimensions)
493 xg2 = xlocal2;
494 yg2 = ylocal2;
495
496 // transform in the monitor coordinate system
497 // ALICE SC
498 xpmin = +(xg1-xg2);
499 xpmax = +(xg1+xg2);
500 ypmin = -(yg2-yg1);
501 ypmax = +(yg2+yg1);
502
503 boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
504 boxd->SetBit(kCannotPick);
505 boxd->SetFillStyle(1001);
506 boxd->SetFillColor(2);
507 boxd->Draw();
508
509 } // end digits loop
510
511 } // end draw digits
512
905654c2 513 canvas->Modified();
514 canvas->Update();
515
516}
517
518//__________________________________________________________________________
519void AliMUONTriggerGUIdimap::DoTab(Int_t id) const
520{
521 /// some action when chamber tab is selected...
522
523 switch (id) {
524 case 0:
525 break;
526 case 1:
527 break;
528 case 2:
529 break;
530 case 3:
531 break;
532 default:
533 break;
534 }
535
536}
537
538//__________________________________________________________________________
539void AliMUONTriggerGUIdimap::DoClose()
540{
541 /// close the main frame
542
543 fIsOn = kFALSE;
544 CloseWindow();
545
546}
547
548//__________________________________________________________________________
549void AliMUONTriggerGUIdimap::DoUpdate()
550{
551 /// update maps for another run/event
552
905654c2 553 for (Int_t it = 0; it < kNMT; it++) {
554 for (Int_t ib = 0; ib < kNBoards; ib++) {
555 delete fPaveBoard[it][ib];
556 }
557 }
558
559 DrawMaps(11);
560 DrawMaps(12);
561 DrawMaps(13);
562 DrawMaps(14);
563
564 AliMUONTriggerGUIboard *board;
565 for (Int_t ib = 0; ib < kNBoards; ib++) {
566 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
567 if (board->IsOpen()) SelectBoard(ib);
568 }
569
570}
571
572//__________________________________________________________________________
573void AliMUONTriggerGUIdimap::DoReset()
574{
575 /// draw unselected boards
576
577 for (Int_t it = 0; it < kNMT; it++) {
578
579 TCanvas *canvas = fEc[it]->GetCanvas();
580 canvas->cd();
581
582 for (Int_t ib = 0; ib < kNBoards; ib++) {
583 fPaveBoard[it][ib]->SetFillStyle(0);
584 }
585
586 canvas->Modified();
587 canvas->Update();
588
589 }
590
591}
592
593//__________________________________________________________________________
594void AliMUONTriggerGUIdimap::SelectBoard(Int_t id)
595{
596 /// highlight on the map the open board
597
598 for (Int_t it = 0; it < kNMT; it++) {
599
600 TCanvas *canvas = fEc[it]->GetCanvas();
601 canvas->cd();
602
603 fPaveBoard[it][id]->SetFillStyle(4020);
604 fPaveBoard[it][id]->SetFillColor(7);
605
606 canvas->Modified();
607 canvas->Update();
608
609 }
610
611}
612
613//__________________________________________________________________________
614void AliMUONTriggerGUIdimap::CloseWindow()
615{
616 /// called when window is closed via the window manager.
617
618 fMain->CloseWindow();
619
620}
621
622