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"
50 ClassImp(AliMUONTriggerGUIdimap)
53 //__________________________________________________________________________
54 AliMUONTriggerGUIdimap::AliMUONTriggerGUIdimap(TObjArray *boards, const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
68 gStyle->SetPadLeftMargin(0.05);
69 gStyle->SetPadRightMargin(0.05);
70 gStyle->SetPadTopMargin(0.05);
71 gStyle->SetPadBottomMargin(0.05);
73 gStyle->SetOptDate(0);
74 gStyle->SetOptTitle(0);
75 gStyle->SetOptStat(0);
77 fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
78 fMain->Connect("CloseWindow()", "AliMUONTriggerGUIdimap", this, "DoClose()");
79 fMain->DontCallClose(); // to avoid double deletions.
81 // use hierarchical cleaning
82 fMain->SetCleanup(kDeepCleanup);
84 TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
86 TGTextButton *closeButton = new TGTextButton(hframe, "Close", 1);
87 closeButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoClose()");
89 hframe->AddFrame(closeButton,
90 new TGLayoutHints(kLHintsTop |
95 hframe->Resize(150, closeButton->GetDefaultHeight());
97 TGTextButton *updateButton = new TGTextButton(hframe, "Update", 2);
98 updateButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoUpdate()");
99 updateButton->SetToolTipText("Read the digits for the current event");
101 hframe->AddFrame(updateButton,
102 new TGLayoutHints(kLHintsTop |
107 hframe->Resize(150, updateButton->GetDefaultHeight());
109 TGTextButton *resetButton = new TGTextButton(hframe, "Reset", 3);
110 resetButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoReset()");
111 resetButton->SetToolTipText("Redraw unselected boards");
113 hframe->AddFrame(resetButton,
114 new TGLayoutHints(kLHintsTop |
119 hframe->Resize(150, resetButton->GetDefaultHeight());
121 fMain->AddFrame(hframe,
122 new TGLayoutHints(kLHintsBottom |
127 TGTab *tab = new TGTab(fMain, 300, 300);
128 //tab->Connect("Selected(Int_t)", "AliMUONTriggerGUIdimap", this, "DoTab(Int_t)");
130 // Tabs for MT11, MT12, MT21, MT22
131 TGLayoutHints *lot = new TGLayoutHints(kLHintsTop |
137 TGCompositeFrame *tf = 0;
140 tf = tab->AddTab("MT11");
142 TGCompositeFrame *cf1 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
143 fEc[0] = new TRootEmbeddedCanvas("ec1", cf1, 500, 500);
144 cf1->AddFrame(fEc[0], lot);
146 tf->AddFrame(cf1, lot);
147 fEc[0]->GetCanvas()->SetBorderMode(0);
148 fEc[0]->GetCanvas()->SetBit(kNoContextMenu);
151 tf = tab->AddTab("MT12");
153 TGCompositeFrame *cf2 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
154 fEc[1] = new TRootEmbeddedCanvas("ec2", cf2, 500, 500);
155 cf2->AddFrame(fEc[1], lot);
157 tf->AddFrame(cf2, lot);
158 fEc[1]->GetCanvas()->SetBorderMode(0);
159 fEc[1]->GetCanvas()->SetBit(kNoContextMenu);
162 tf = tab->AddTab("MT21");
164 TGCompositeFrame *cf3 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
165 fEc[2] = new TRootEmbeddedCanvas("ec3", cf3, 500, 500);
166 cf3->AddFrame(fEc[2], lot);
168 tf->AddFrame(cf3, lot);
169 fEc[2]->GetCanvas()->SetBorderMode(0);
170 fEc[2]->GetCanvas()->SetBit(kNoContextMenu);
173 tf = tab->AddTab("MT22");
175 TGCompositeFrame *cf4 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
176 fEc[3] = new TRootEmbeddedCanvas("ec4", cf4, 500, 500);
177 cf4->AddFrame(fEc[3], lot);
179 tf->AddFrame(cf4, lot);
180 fEc[3]->GetCanvas()->SetBorderMode(0);
181 fEc[3]->GetCanvas()->SetBit(kNoContextMenu);
184 new TGLayoutHints(kLHintsBottom |
190 fMain->MapSubwindows();
193 fMain->CenterOnParent();
195 fMain->SetWindowName("Chambers digit maps");
201 //__________________________________________________________________________
202 AliMUONTriggerGUIdimap::~AliMUONTriggerGUIdimap()
206 for (Int_t it = 0; it < kNMT; it++) {
207 for (Int_t ib = 0; ib < kNBoards; ib++) {
208 delete fPaveBoard[it][ib];
212 fMain->DeleteWindow();
216 //__________________________________________________________________________
217 void AliMUONTriggerGUIdimap::DrawAllMaps()
221 if (fLoader == 0x0) {
224 if (fMCDataInterface == 0x0) {
235 //__________________________________________________________________________
236 void AliMUONTriggerGUIdimap::DrawMaps(Int_t chamber)
238 /// draw the digits map for chamber-
240 Bool_t drawDigits = kTRUE;
241 Bool_t drawDigitsRaw = kTRUE;
242 if (fLoader == 0x0) {
245 if (fRawDigitStore == 0x0) {
246 drawDigitsRaw = kFALSE;
249 AliMUONTriggerGUIboard *board;
251 TCanvas *canvas = fEc[chamber-11]->GetCanvas();
259 Int_t detElemId, cathode, ix, iy, charge, color;
260 Int_t holdS, holdL, holdC;
261 Float_t xCenter, yCenter, xWidth, yWidth, holdXC, holdYC;
262 Float_t xMin, xMax, yMin, yMax;
263 Float_t ptx1, ptx2, pty1, pty2;
264 Float_t xpmin, xpmax, ypmin, ypmax;
265 Float_t xg1, xg2, yg1, yg2, zg1;
267 Float_t frameXmax = 0., frameYmax = 0.;
297 for (Int_t ib = 0; ib < kNBoards; ib++) {
299 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
301 holdS = board->GetSide();
302 holdC = board->GetCol();
303 holdL = board->GetLine();
305 xCenter = board->GetXCenter(chamber-11);
306 yCenter = board->GetYCenter(chamber-11);
307 xWidth = board->GetXWidth(chamber-11);
308 yWidth = board->GetYWidth(chamber-11);
313 xMin = xCenter - xWidth/2;
314 xMax = xCenter + xWidth/2;
315 yMin = yCenter - yWidth/2;
316 yMax = yCenter + yWidth/2;
318 fPaveBoard[chamber-11][ib] = new TPave(xMin,yMin,xMax,yMax,1);
319 fPaveBoard[chamber-11][ib]->SetBit(kCannotPick);
320 fPaveBoard[chamber-11][ib]->SetFillStyle(0);
321 fPaveBoard[chamber-11][ib]->Draw();
323 Float_t lWidth = 12.0;
327 sprintf(cln,"C%1d",holdC);
329 ptx1 = holdXC - lWidth;
330 ptx2 = holdXC + lWidth;
331 pty1 = +1.065*frameYmax - lWidth;
332 pty2 = +1.065*frameYmax + lWidth;
334 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
336 label->SetBorderSize(0);
337 label->SetBit(kCannotPick);
342 sprintf(cln,"C%1d",holdC);
344 ptx1 = holdXC - lWidth;
345 ptx2 = holdXC + lWidth;
346 pty1 = -1.065*frameYmax - lWidth;
347 pty2 = -1.065*frameYmax + lWidth;
349 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
351 label->SetBorderSize(0);
352 label->SetBit(kCannotPick);
355 if (holdS == 0 && holdC == 7) {
357 sprintf(cln,"L%1d",holdL);
359 ptx1 = -1.07*frameXmax - lWidth;
360 ptx2 = -1.07*frameXmax + lWidth;
361 pty1 = holdYC - lWidth;
362 pty2 = holdYC + lWidth;
364 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
366 label->SetBorderSize(0);
367 label->SetBit(kCannotPick);
370 if (holdS == 1 && holdC == 7) {
372 sprintf(cln,"L%1d",holdL);
374 ptx1 = +1.07*frameXmax - lWidth;
375 ptx2 = +1.07*frameXmax + lWidth;
376 pty1 = holdYC - lWidth;
377 pty2 = holdYC + lWidth;
379 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
381 label->SetBorderSize(0);
382 label->SetBit(kCannotPick);
388 // draw digits set from the board GUI
390 Int_t imt = chamber -11;
391 Int_t nStripX, nStripY;
393 for (Int_t ib = 0; ib < kNBoards; ib++) {
395 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
397 xCenter = board->GetXCenter(imt);
398 yCenter = board->GetYCenter(imt);
400 nStripX = board->GetXSiy2() - board->GetXSiy1() + 1;
401 nStripY = board->GetYSix2() - board->GetYSix1() + 1 ;
403 for (Int_t is = 0; is < nStripX; is++) {
405 if (board->GetXDig(imt,is) == 0) continue;
407 box = board->GetXDigBox(imt,is);
409 xpmin = box->GetX1();
410 xpmax = box->GetX2();
411 ypmin = box->GetY1();
412 ypmax = box->GetY2();
419 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
423 for (Int_t is = 0; is < nStripY; is++) {
425 if (board->GetYDig(imt,is) == 0) continue;
427 box = board->GetYDigBox(imt,is);
429 xpmin = box->GetX1();
430 xpmax = box->GetX2();
431 ypmin = box->GetY1();
432 ypmax = box->GetY2();
439 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
445 // draw the digits from galice
447 if (drawDigits || drawDigitsRaw) {
449 AliMUONGeometryTransformer transformer;
450 transformer.LoadGeometryData("transform.dat");
452 AliMUONVDigitStore *digitStore = 0x0;
455 AliRunLoader *runLoader = fLoader->GetRunLoader();
456 digitStore = fMCDataInterface->DigitStore(runLoader->GetEventNumber());
459 digitStore = fRawDigitStore;
462 TIter next(digitStore->CreateIterator());
465 while ( ( mdig = static_cast<AliMUONVDigit*>(next()) ) ) {
467 cathode = mdig->Cathode()+1;
471 detElemId=mdig->DetElemId();
472 charge = (Int_t)mdig->Charge();
473 color = 261+5*(charge-1);
474 if (color > 282) color = 282;
476 if (detElemId/100 != chamber) continue;
478 const AliMpVSegmentation* seg2 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode-1));
480 AliMpPad mpad = seg2->PadByIndices(ix,iy,kTRUE);
482 // get the pad position and dimensions
483 Float_t xlocal1 = mpad.GetPositionX();
484 Float_t ylocal1 = mpad.GetPositionY();
485 Float_t xlocal2 = mpad.GetDimensionX();
486 Float_t ylocal2 = mpad.GetDimensionY();
488 transformer.Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
489 // (no transformation for pad dimensions)
493 // transform in the monitor coordinate system
500 boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
501 boxd->SetBit(kCannotPick);
502 boxd->SetFillStyle(1001);
503 boxd->SetFillColor(2);
515 //__________________________________________________________________________
516 void AliMUONTriggerGUIdimap::DoTab(Int_t id) const
518 /// some action when chamber tab is selected...
535 //__________________________________________________________________________
536 void AliMUONTriggerGUIdimap::DoClose()
538 /// close the main frame
545 //__________________________________________________________________________
546 void AliMUONTriggerGUIdimap::DoUpdate()
548 /// update maps for another run/event
550 for (Int_t it = 0; it < kNMT; it++) {
551 for (Int_t ib = 0; ib < kNBoards; ib++) {
552 delete fPaveBoard[it][ib];
561 AliMUONTriggerGUIboard *board;
562 for (Int_t ib = 0; ib < kNBoards; ib++) {
563 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
564 if (board->IsOpen()) SelectBoard(ib);
569 //__________________________________________________________________________
570 void AliMUONTriggerGUIdimap::DoReset()
572 /// draw unselected boards
574 for (Int_t it = 0; it < kNMT; it++) {
576 TCanvas *canvas = fEc[it]->GetCanvas();
579 for (Int_t ib = 0; ib < kNBoards; ib++) {
580 fPaveBoard[it][ib]->SetFillStyle(0);
590 //__________________________________________________________________________
591 void AliMUONTriggerGUIdimap::SelectBoard(Int_t id)
593 /// highlight on the map the open board
595 for (Int_t it = 0; it < kNMT; it++) {
597 TCanvas *canvas = fEc[it]->GetCanvas();
600 fPaveBoard[it][id]->SetFillStyle(4020);
601 fPaveBoard[it][id]->SetFillColor(7);
610 //__________________________________________________________________________
611 void AliMUONTriggerGUIdimap::CloseWindow()
613 /// called when window is closed via the window manager.
615 fMain->CloseWindow();