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>
31 #include <TClonesArray.h>
33 #include <TPaveText.h>
35 #include <TObjArray.h>
40 #include "AliMUONVDigit.h"
41 #include "AliMpSegmentation.h"
42 #include "AliMpVSegmentation.h"
43 #include "AliMUONGeometryTransformer.h"
45 #include "AliMUONTriggerGUIboard.h"
46 #include "AliMUONTriggerGUIdimap.h"
48 #include "AliMUONVDigitStore.h"
51 ClassImp(AliMUONTriggerGUIdimap)
54 //__________________________________________________________________________
55 AliMUONTriggerGUIdimap::AliMUONTriggerGUIdimap(AliLoader *loader, 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");
206 //__________________________________________________________________________
207 AliMUONTriggerGUIdimap::~AliMUONTriggerGUIdimap()
211 for (Int_t it = 0; it < kNMT; it++) {
212 for (Int_t ib = 0; ib < kNBoards; ib++) {
213 delete fPaveBoard[it][ib];
217 fMain->DeleteWindow();
221 //__________________________________________________________________________
222 void AliMUONTriggerGUIdimap::DrawMaps(Int_t chamber)
224 /// draw the digits map for chamber-
226 TString mapspath = gSystem->Getenv("ALICE_ROOT");
227 mapspath.Append("/MUON/data");
229 TCanvas *canvas = fEc[chamber-11]->GetCanvas();
235 AliRunLoader *runLoader = fLoader->GetRunLoader();
236 gAlice = runLoader->GetAliRun();
237 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
238 const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer();
240 fLoader->LoadDigits("READ");
241 TTree* treeD = fLoader->TreeD();
242 AliMUONVDigitStore* digitStore = AliMUONVDigitStore::Create(*treeD);
247 Char_t fntxt[6], name[8], cln[2];
248 Int_t detElemId, cathode, ix, iy, charge, color;
249 Int_t side, col, line, nbx;
250 Int_t holdS, holdL, holdC;
251 Float_t xCenter, yCenter, zCenter, xWidth, yWidth, holdXC, holdYC;
252 Float_t xMin, xMax, yMin, yMax;
253 Float_t ptx1, ptx2, pty1, pty2;
254 Float_t xpmin, xpmax, ypmin, ypmax;
255 Float_t xg1, xg2, yg1, yg2, zg1;
257 Float_t frameXmax = 0., frameYmax = 0.;
287 sprintf(fntxt,"%s/guimapp%2d.txt",mapspath.Data(),chamber);
288 FILE *ftxt = fopen(fntxt,"r");
290 for (Int_t ib = 0; ib < kNBoards; ib++) {
292 fscanf(ftxt,"%d %d %d %d %f %f %f %f %f %s \n",
293 &side,&col,&line,&nbx,
294 &xCenter,&yCenter,&xWidth,&yWidth,&zCenter,
297 //printf("%d %d %d %d %f %f %f %f %f %s \n",side,col,line,nbx,xCenter,yCenter,xWidth,yWidth,zCenter,name);
306 xMin = xCenter - xWidth/2;
307 xMax = xCenter + xWidth/2;
308 yMin = yCenter - yWidth/2;
309 yMax = yCenter + yWidth/2;
311 fPaveBoard[chamber-11][ib] = new TPave(xMin,yMin,xMax,yMax,1);
312 fPaveBoard[chamber-11][ib]->SetBit(kCannotPick);
313 fPaveBoard[chamber-11][ib]->SetFillStyle(0);
314 fPaveBoard[chamber-11][ib]->Draw();
316 Float_t lWidth = 12.0;
320 sprintf(cln,"C%1d",holdC);
322 ptx1 = holdXC - lWidth;
323 ptx2 = holdXC + lWidth;
324 pty1 = +1.065*frameYmax - lWidth;
325 pty2 = +1.065*frameYmax + lWidth;
327 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
329 label->SetBorderSize(0);
330 label->SetBit(kCannotPick);
335 sprintf(cln,"C%1d",holdC);
337 ptx1 = holdXC - lWidth;
338 ptx2 = holdXC + lWidth;
339 pty1 = -1.065*frameYmax - lWidth;
340 pty2 = -1.065*frameYmax + lWidth;
342 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
344 label->SetBorderSize(0);
345 label->SetBit(kCannotPick);
348 if (holdS == 0 && holdC == 7) {
350 sprintf(cln,"L%1d",holdL);
352 ptx1 = -1.07*frameXmax - lWidth;
353 ptx2 = -1.07*frameXmax + lWidth;
354 pty1 = holdYC - lWidth;
355 pty2 = holdYC + lWidth;
357 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
359 label->SetBorderSize(0);
360 label->SetBit(kCannotPick);
363 if (holdS == 1 && holdC == 7) {
365 sprintf(cln,"L%1d",holdL);
367 ptx1 = +1.07*frameXmax - lWidth;
368 ptx2 = +1.07*frameXmax + lWidth;
369 pty1 = holdYC - lWidth;
370 pty2 = holdYC + lWidth;
372 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
374 label->SetBorderSize(0);
375 label->SetBit(kCannotPick);
383 // draw digits set from the board GUI
385 AliMUONTriggerGUIboard *board;
386 Int_t imt = chamber -11;
387 Int_t nStripX, nStripY;
389 for (Int_t ib = 0; ib < kNBoards; ib++) {
391 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
393 xCenter = board->GetXCenter(imt);
394 yCenter = board->GetYCenter(imt);
396 nStripX = board->GetXSiy2() - board->GetXSiy1() + 1;
397 nStripY = board->GetYSix2() - board->GetYSix1() + 1 ;
399 for (Int_t is = 0; is < nStripX; is++) {
401 if (board->GetXDig(imt,is) == 0) continue;
403 box = board->GetXDigBox(imt,is);
405 xpmin = box->GetX1();
406 xpmax = box->GetX2();
407 ypmin = box->GetY1();
408 ypmax = box->GetY2();
415 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
419 for (Int_t is = 0; is < nStripY; is++) {
421 if (board->GetYDig(imt,is) == 0) continue;
423 box = board->GetYDigBox(imt,is);
425 xpmin = box->GetX1();
426 xpmax = box->GetX2();
427 ypmin = box->GetY1();
428 ypmax = box->GetY2();
435 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
443 TIter next(digitStore->CreateIterator());
446 while ( ( mdig = static_cast<AliMUONVDigit*>(next()) ) )
448 cathode = mdig->Cathode()+1;
452 detElemId=mdig->DetElemId();
453 charge = (Int_t)mdig->Charge();
454 color = 261+5*(charge-1);
455 if (color > 282) color = 282;
457 const AliMpVSegmentation* seg2 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode-1));
459 mpad = seg2->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
461 // get the pad position and dimensions
462 Float_t xlocal1 = mpad.Position().X();
463 Float_t ylocal1 = mpad.Position().Y();
464 Float_t xlocal2 = mpad.Dimensions().X();
465 Float_t ylocal2 = mpad.Dimensions().Y();
467 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
468 // (no transformation for pad dimensions)
472 // transform in the monitor coordinate system
473 //xpmin = -(xg1+xg2);
474 //xpmax = -(xg1-xg2);
475 //ypmin = -(yg2-yg1);
476 //ypmax = +(yg2+yg1);
483 boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
484 boxd->SetBit(kCannotPick);
485 boxd->SetFillStyle(1001);
486 boxd->SetFillColor(2);
497 //__________________________________________________________________________
498 void AliMUONTriggerGUIdimap::DoTab(Int_t id) const
500 /// some action when chamber tab is selected...
517 //__________________________________________________________________________
518 void AliMUONTriggerGUIdimap::DoClose()
520 /// close the main frame
527 //__________________________________________________________________________
528 void AliMUONTriggerGUIdimap::DoUpdate()
530 /// update maps for another run/event
532 for (Int_t it = 0; it < kNMT; it++) {
533 for (Int_t ib = 0; ib < kNBoards; ib++) {
534 delete fPaveBoard[it][ib];
543 AliMUONTriggerGUIboard *board;
544 for (Int_t ib = 0; ib < kNBoards; ib++) {
545 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
546 if (board->IsOpen()) SelectBoard(ib);
551 //__________________________________________________________________________
552 void AliMUONTriggerGUIdimap::DoReset()
554 /// draw unselected boards
556 for (Int_t it = 0; it < kNMT; it++) {
558 TCanvas *canvas = fEc[it]->GetCanvas();
561 for (Int_t ib = 0; ib < kNBoards; ib++) {
562 fPaveBoard[it][ib]->SetFillStyle(0);
572 //__________________________________________________________________________
573 void AliMUONTriggerGUIdimap::SelectBoard(Int_t id)
575 /// highlight on the map the open board
577 for (Int_t it = 0; it < kNMT; it++) {
579 TCanvas *canvas = fEc[it]->GetCanvas();
582 fPaveBoard[it][id]->SetFillStyle(4020);
583 fPaveBoard[it][id]->SetFillColor(7);
592 //__________________________________________________________________________
593 void AliMUONTriggerGUIdimap::CloseWindow()
595 /// called when window is closed via the window manager.
597 fMain->CloseWindow();