1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONTriggerGUIdimap
21 /// The digit maps of the four trigger chambers, all boards
23 /// \author Bogdan Vulpescu, LPC Clermont-Ferrand
24 //-----------------------------------------------------------------------------
29 #include <TRootEmbeddedCanvas.h>
32 #include <TPaveText.h>
34 #include <TObjArray.h>
36 #include "AliRunLoader.h"
38 #include "AliMUONVDigit.h"
39 #include "AliMpSegmentation.h"
40 #include "AliMpVSegmentation.h"
41 #include "AliMUONGeometryTransformer.h"
42 #include "AliMUONMCDataInterface.h"
44 #include "AliMUONTriggerGUIboard.h"
45 #include "AliMUONTriggerGUIdimap.h"
47 #include "AliMUONDigitStoreV1.h"
52 ClassImp(AliMUONTriggerGUIdimap)
55 //__________________________________________________________________________
56 AliMUONTriggerGUIdimap::AliMUONTriggerGUIdimap(TObjArray *boards, const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
70 gStyle->SetPadLeftMargin(0.05);
71 gStyle->SetPadRightMargin(0.05);
72 gStyle->SetPadTopMargin(0.05);
73 gStyle->SetPadBottomMargin(0.05);
75 gStyle->SetOptDate(0);
76 gStyle->SetOptTitle(0);
77 gStyle->SetOptStat(0);
79 fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
80 fMain->Connect("CloseWindow()", "AliMUONTriggerGUIdimap", this, "DoClose()");
81 fMain->DontCallClose(); // to avoid double deletions.
83 // use hierarchical cleaning
84 fMain->SetCleanup(kDeepCleanup);
86 TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
88 TGTextButton *closeButton = new TGTextButton(hframe, "Close", 1);
89 closeButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoClose()");
91 hframe->AddFrame(closeButton,
92 new TGLayoutHints(kLHintsTop |
97 hframe->Resize(150, closeButton->GetDefaultHeight());
99 TGTextButton *updateButton = new TGTextButton(hframe, "Update", 2);
100 updateButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoUpdate()");
101 updateButton->SetToolTipText("Read the digits for the current event");
103 hframe->AddFrame(updateButton,
104 new TGLayoutHints(kLHintsTop |
109 hframe->Resize(150, updateButton->GetDefaultHeight());
111 TGTextButton *resetButton = new TGTextButton(hframe, "Reset", 3);
112 resetButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoReset()");
113 resetButton->SetToolTipText("Redraw unselected boards");
115 hframe->AddFrame(resetButton,
116 new TGLayoutHints(kLHintsTop |
121 hframe->Resize(150, resetButton->GetDefaultHeight());
123 fMain->AddFrame(hframe,
124 new TGLayoutHints(kLHintsBottom |
129 TGTab *tab = new TGTab(fMain, 300, 300);
130 //tab->Connect("Selected(Int_t)", "AliMUONTriggerGUIdimap", this, "DoTab(Int_t)");
132 // Tabs for MT11, MT12, MT21, MT22
133 TGLayoutHints *lot = new TGLayoutHints(kLHintsTop |
139 TGCompositeFrame *tf = 0;
142 tf = tab->AddTab("MT11");
144 TGCompositeFrame *cf1 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
145 fEc[0] = new TRootEmbeddedCanvas("ec1", cf1, 500, 500);
146 cf1->AddFrame(fEc[0], lot);
148 tf->AddFrame(cf1, lot);
149 fEc[0]->GetCanvas()->SetBorderMode(0);
150 fEc[0]->GetCanvas()->SetBit(kNoContextMenu);
153 tf = tab->AddTab("MT12");
155 TGCompositeFrame *cf2 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
156 fEc[1] = new TRootEmbeddedCanvas("ec2", cf2, 500, 500);
157 cf2->AddFrame(fEc[1], lot);
159 tf->AddFrame(cf2, lot);
160 fEc[1]->GetCanvas()->SetBorderMode(0);
161 fEc[1]->GetCanvas()->SetBit(kNoContextMenu);
164 tf = tab->AddTab("MT21");
166 TGCompositeFrame *cf3 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
167 fEc[2] = new TRootEmbeddedCanvas("ec3", cf3, 500, 500);
168 cf3->AddFrame(fEc[2], lot);
170 tf->AddFrame(cf3, lot);
171 fEc[2]->GetCanvas()->SetBorderMode(0);
172 fEc[2]->GetCanvas()->SetBit(kNoContextMenu);
175 tf = tab->AddTab("MT22");
177 TGCompositeFrame *cf4 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
178 fEc[3] = new TRootEmbeddedCanvas("ec4", cf4, 500, 500);
179 cf4->AddFrame(fEc[3], lot);
181 tf->AddFrame(cf4, lot);
182 fEc[3]->GetCanvas()->SetBorderMode(0);
183 fEc[3]->GetCanvas()->SetBit(kNoContextMenu);
186 new TGLayoutHints(kLHintsBottom |
192 fMain->MapSubwindows();
195 fMain->CenterOnParent();
197 fMain->SetWindowName("Chambers digit maps");
203 //__________________________________________________________________________
204 AliMUONTriggerGUIdimap::~AliMUONTriggerGUIdimap()
208 for (Int_t it = 0; it < kNMT; it++) {
209 for (Int_t ib = 0; ib < kNBoards; ib++) {
210 delete fPaveBoard[it][ib];
214 fMain->DeleteWindow();
218 //__________________________________________________________________________
219 void AliMUONTriggerGUIdimap::DrawAllMaps()
223 if (fLoader == 0x0) {
226 if (fMCDataInterface == 0x0) {
237 //__________________________________________________________________________
238 void AliMUONTriggerGUIdimap::DrawMaps(Int_t chamber)
240 /// draw the digits map for chamber-
242 Bool_t drawDigits = kTRUE;
243 Bool_t drawDigitsRaw = kTRUE;
244 if (fLoader == 0x0) {
247 if (fRawDigitStore == 0x0) {
248 drawDigitsRaw = kFALSE;
251 AliMUONTriggerGUIboard *board;
253 TCanvas *canvas = fEc[chamber-11]->GetCanvas();
261 Int_t detElemId, cathode, ix, iy, charge, color;
262 Int_t holdS, holdL, holdC;
263 Float_t xCenter, yCenter, xWidth, yWidth, holdXC, holdYC;
264 Float_t xMin, xMax, yMin, yMax;
265 Float_t ptx1, ptx2, pty1, pty2;
266 Float_t xpmin, xpmax, ypmin, ypmax;
267 Float_t xg1, xg2, yg1, yg2, zg1;
269 Float_t frameXmax = 0., frameYmax = 0.;
299 for (Int_t ib = 0; ib < kNBoards; ib++) {
301 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
303 holdS = board->GetSide();
304 holdC = board->GetCol();
305 holdL = board->GetLine();
307 xCenter = board->GetXCenter(chamber-11);
308 yCenter = board->GetYCenter(chamber-11);
309 xWidth = board->GetXWidth(chamber-11);
310 yWidth = board->GetYWidth(chamber-11);
315 xMin = xCenter - xWidth/2;
316 xMax = xCenter + xWidth/2;
317 yMin = yCenter - yWidth/2;
318 yMax = yCenter + yWidth/2;
320 fPaveBoard[chamber-11][ib] = new TPave(xMin,yMin,xMax,yMax,1);
321 fPaveBoard[chamber-11][ib]->SetBit(kCannotPick);
322 fPaveBoard[chamber-11][ib]->SetFillStyle(0);
323 fPaveBoard[chamber-11][ib]->Draw();
325 Float_t lWidth = 12.0;
329 snprintf(cln,3,"C%1d",holdC);
331 ptx1 = holdXC - lWidth;
332 ptx2 = holdXC + lWidth;
333 pty1 = +1.065*frameYmax - lWidth;
334 pty2 = +1.065*frameYmax + lWidth;
336 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
338 label->SetBorderSize(0);
339 label->SetBit(kCannotPick);
344 snprintf(cln,3,"C%1d",holdC);
346 ptx1 = holdXC - lWidth;
347 ptx2 = holdXC + lWidth;
348 pty1 = -1.065*frameYmax - lWidth;
349 pty2 = -1.065*frameYmax + lWidth;
351 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
353 label->SetBorderSize(0);
354 label->SetBit(kCannotPick);
357 if (holdS == 0 && holdC == 7) {
359 snprintf(cln,3,"L%1d",holdL);
361 ptx1 = -1.07*frameXmax - lWidth;
362 ptx2 = -1.07*frameXmax + lWidth;
363 pty1 = holdYC - lWidth;
364 pty2 = holdYC + lWidth;
366 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
368 label->SetBorderSize(0);
369 label->SetBit(kCannotPick);
372 if (holdS == 1 && holdC == 7) {
374 snprintf(cln,3,"L%1d",holdL);
376 ptx1 = +1.07*frameXmax - lWidth;
377 ptx2 = +1.07*frameXmax + lWidth;
378 pty1 = holdYC - lWidth;
379 pty2 = holdYC + lWidth;
381 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
383 label->SetBorderSize(0);
384 label->SetBit(kCannotPick);
390 // draw digits set from the board GUI
392 Int_t imt = chamber -11;
393 Int_t nStripX, nStripY;
395 for (Int_t ib = 0; ib < kNBoards; ib++) {
397 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
399 xCenter = board->GetXCenter(imt);
400 yCenter = board->GetYCenter(imt);
402 nStripX = board->GetXSiy2() - board->GetXSiy1() + 1;
403 nStripY = board->GetYSix2() - board->GetYSix1() + 1 ;
405 for (Int_t is = 0; is < nStripX; is++) {
407 if (board->GetXDig(imt,is) == 0) continue;
409 box = board->GetXDigBox(imt,is);
411 xpmin = box->GetX1();
412 xpmax = box->GetX2();
413 ypmin = box->GetY1();
414 ypmax = box->GetY2();
421 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
425 for (Int_t is = 0; is < nStripY; is++) {
427 if (board->GetYDig(imt,is) == 0) continue;
429 box = board->GetYDigBox(imt,is);
431 xpmin = box->GetX1();
432 xpmax = box->GetX2();
433 ypmin = box->GetY1();
434 ypmax = box->GetY2();
441 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
447 // draw the digits from galice
449 if (drawDigits || drawDigitsRaw) {
451 AliMUONGeometryTransformer transformer;
452 transformer.LoadGeometryData("transform.dat");
454 AliMUONVDigitStore *digitStore = 0x0;
457 AliRunLoader *runLoader = fLoader->GetRunLoader();
458 digitStore = fMCDataInterface->DigitStore(runLoader->GetEventNumber());
461 digitStore = fRawDigitStore;
464 TIter next(digitStore->CreateIterator());
467 while ( ( mdig = static_cast<AliMUONVDigit*>(next()) ) ) {
469 cathode = mdig->Cathode()+1;
473 detElemId=mdig->DetElemId();
474 charge = (Int_t)mdig->Charge();
475 color = 261+5*(charge-1);
476 if (color > 282) color = 282;
478 if (detElemId/100 != chamber) continue;
480 const AliMpVSegmentation* seg2 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode-1));
482 AliMpPad mpad = seg2->PadByIndices(ix,iy,kTRUE);
484 // get the pad position and dimensions
485 Float_t xlocal1 = mpad.GetPositionX();
486 Float_t ylocal1 = mpad.GetPositionY();
487 Float_t xlocal2 = mpad.GetDimensionX();
488 Float_t ylocal2 = mpad.GetDimensionY();
490 transformer.Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
491 // (no transformation for pad dimensions)
495 // transform in the monitor coordinate system
502 boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
503 boxd->SetBit(kCannotPick);
504 boxd->SetFillStyle(1001);
505 boxd->SetFillColor(2);
517 //__________________________________________________________________________
518 void AliMUONTriggerGUIdimap::DoTab(Int_t id) const
520 /// some action when chamber tab is selected...
537 //__________________________________________________________________________
538 void AliMUONTriggerGUIdimap::DoClose()
540 /// close the main frame
547 //__________________________________________________________________________
548 void AliMUONTriggerGUIdimap::DoUpdate()
550 /// update maps for another run/event
552 for (Int_t it = 0; it < kNMT; it++) {
553 for (Int_t ib = 0; ib < kNBoards; ib++) {
554 delete fPaveBoard[it][ib];
563 AliMUONTriggerGUIboard *board;
564 for (Int_t ib = 0; ib < kNBoards; ib++) {
565 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
566 if (board->IsOpen()) SelectBoard(ib);
571 //__________________________________________________________________________
572 void AliMUONTriggerGUIdimap::DoReset()
574 /// draw unselected boards
576 for (Int_t it = 0; it < kNMT; it++) {
578 TCanvas *canvas = fEc[it]->GetCanvas();
581 for (Int_t ib = 0; ib < kNBoards; ib++) {
582 fPaveBoard[it][ib]->SetFillStyle(0);
592 //__________________________________________________________________________
593 void AliMUONTriggerGUIdimap::SelectBoard(Int_t id)
595 /// highlight on the map the open board
597 for (Int_t it = 0; it < kNMT; it++) {
599 TCanvas *canvas = fEc[it]->GetCanvas();
602 fPaveBoard[it][id]->SetFillStyle(4020);
603 fPaveBoard[it][id]->SetFillColor(7);
612 //__________________________________________________________________________
613 void AliMUONTriggerGUIdimap::CloseWindow()
615 /// called when window is closed via the window manager.
617 fMain->CloseWindow();