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 /// \class AliMUONTriggerGUIdimap
20 /// The digit maps of the four trigger chambers, all boards
22 /// \author Bogdan Vulpescu, LPC Clermont-Ferrand
27 #include <TRootEmbeddedCanvas.h>
29 #include <TClonesArray.h>
31 #include <TPaveText.h>
33 #include <TObjArray.h>
38 #include "AliMUONVDigit.h"
39 #include "AliMpSegmentation.h"
40 #include "AliMpVSegmentation.h"
41 #include "AliMUONGeometryTransformer.h"
43 #include "AliMUONTriggerGUIboard.h"
44 #include "AliMUONTriggerGUIdimap.h"
46 #include "AliMUONVDigitStore.h"
49 ClassImp(AliMUONTriggerGUIdimap)
52 //__________________________________________________________________________
53 AliMUONTriggerGUIdimap::AliMUONTriggerGUIdimap(AliLoader *loader, TObjArray *boards, const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
66 gStyle->SetPadLeftMargin(0.05);
67 gStyle->SetPadRightMargin(0.05);
68 gStyle->SetPadTopMargin(0.05);
69 gStyle->SetPadBottomMargin(0.05);
71 gStyle->SetOptDate(0);
72 gStyle->SetOptTitle(0);
73 gStyle->SetOptStat(0);
75 fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
76 fMain->Connect("CloseWindow()", "AliMUONTriggerGUIdimap", this, "DoClose()");
77 fMain->DontCallClose(); // to avoid double deletions.
79 // use hierarchical cleaning
80 fMain->SetCleanup(kDeepCleanup);
82 TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
84 TGTextButton *closeButton = new TGTextButton(hframe, "Close", 1);
85 closeButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoClose()");
87 hframe->AddFrame(closeButton,
88 new TGLayoutHints(kLHintsTop |
93 hframe->Resize(150, closeButton->GetDefaultHeight());
95 TGTextButton *updateButton = new TGTextButton(hframe, "Update", 2);
96 updateButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoUpdate()");
97 updateButton->SetToolTipText("Read the digits for the current event");
99 hframe->AddFrame(updateButton,
100 new TGLayoutHints(kLHintsTop |
105 hframe->Resize(150, updateButton->GetDefaultHeight());
107 TGTextButton *resetButton = new TGTextButton(hframe, "Reset", 3);
108 resetButton->Connect("Clicked()", "AliMUONTriggerGUIdimap", this, "DoReset()");
109 resetButton->SetToolTipText("Redraw unselected boards");
111 hframe->AddFrame(resetButton,
112 new TGLayoutHints(kLHintsTop |
117 hframe->Resize(150, resetButton->GetDefaultHeight());
119 fMain->AddFrame(hframe,
120 new TGLayoutHints(kLHintsBottom |
125 TGTab *tab = new TGTab(fMain, 300, 300);
126 //tab->Connect("Selected(Int_t)", "AliMUONTriggerGUIdimap", this, "DoTab(Int_t)");
128 // Tabs for MT11, MT12, MT21, MT22
129 TGLayoutHints *lot = new TGLayoutHints(kLHintsTop |
135 TGCompositeFrame *tf = 0;
138 tf = tab->AddTab("MT11");
140 TGCompositeFrame *cf1 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
141 fEc[0] = new TRootEmbeddedCanvas("ec1", cf1, 500, 500);
142 cf1->AddFrame(fEc[0], lot);
144 tf->AddFrame(cf1, lot);
145 fEc[0]->GetCanvas()->SetBorderMode(0);
146 fEc[0]->GetCanvas()->SetBit(kNoContextMenu);
149 tf = tab->AddTab("MT12");
151 TGCompositeFrame *cf2 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
152 fEc[1] = new TRootEmbeddedCanvas("ec2", cf2, 500, 500);
153 cf2->AddFrame(fEc[1], lot);
155 tf->AddFrame(cf2, lot);
156 fEc[1]->GetCanvas()->SetBorderMode(0);
157 fEc[1]->GetCanvas()->SetBit(kNoContextMenu);
160 tf = tab->AddTab("MT21");
162 TGCompositeFrame *cf3 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
163 fEc[2] = new TRootEmbeddedCanvas("ec3", cf3, 500, 500);
164 cf3->AddFrame(fEc[2], lot);
166 tf->AddFrame(cf3, lot);
167 fEc[2]->GetCanvas()->SetBorderMode(0);
168 fEc[2]->GetCanvas()->SetBit(kNoContextMenu);
171 tf = tab->AddTab("MT22");
173 TGCompositeFrame *cf4 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
174 fEc[3] = new TRootEmbeddedCanvas("ec4", cf4, 500, 500);
175 cf4->AddFrame(fEc[3], lot);
177 tf->AddFrame(cf4, lot);
178 fEc[3]->GetCanvas()->SetBorderMode(0);
179 fEc[3]->GetCanvas()->SetBit(kNoContextMenu);
182 new TGLayoutHints(kLHintsBottom |
188 fMain->MapSubwindows();
191 fMain->CenterOnParent();
193 fMain->SetWindowName("Chambers digit maps");
204 //__________________________________________________________________________
205 AliMUONTriggerGUIdimap::~AliMUONTriggerGUIdimap()
209 for (Int_t it = 0; it < kNMT; it++) {
210 for (Int_t ib = 0; ib < kNBoards; ib++) {
211 delete fPaveBoard[it][ib];
215 fMain->DeleteWindow();
219 //__________________________________________________________________________
220 void AliMUONTriggerGUIdimap::DrawMaps(Int_t chamber)
222 /// draw the digits map for chamber-
224 TString mapspath = gSystem->Getenv("ALICE_ROOT");
225 mapspath.Append("/MUON/data");
227 TCanvas *canvas = fEc[chamber-11]->GetCanvas();
233 AliRunLoader *runLoader = fLoader->GetRunLoader();
234 gAlice = runLoader->GetAliRun();
235 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
236 const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer();
238 fLoader->LoadDigits("READ");
239 TTree* treeD = fLoader->TreeD();
240 AliMUONVDigitStore* digitStore = AliMUONVDigitStore::Create(*treeD);
245 Char_t fntxt[6], name[8], cln[2];
246 Int_t detElemId, cathode, ix, iy, charge, color;
247 Int_t side, col, line, nbx;
248 Int_t holdS, holdL, holdC;
249 Float_t xCenter, yCenter, zCenter, xWidth, yWidth, holdXC, holdYC;
250 Float_t xMin, xMax, yMin, yMax;
251 Float_t ptx1, ptx2, pty1, pty2;
252 Float_t xpmin, xpmax, ypmin, ypmax;
253 Float_t xg1, xg2, yg1, yg2, zg1;
255 Float_t frameXmax = 0., frameYmax = 0.;
285 sprintf(fntxt,"%s/guimapp%2d.txt",mapspath.Data(),chamber);
286 FILE *ftxt = fopen(fntxt,"r");
288 for (Int_t ib = 0; ib < kNBoards; ib++) {
290 fscanf(ftxt,"%d %d %d %d %f %f %f %f %f %s \n",
291 &side,&col,&line,&nbx,
292 &xCenter,&yCenter,&xWidth,&yWidth,&zCenter,
295 //printf("%d %d %d %d %f %f %f %f %f %s \n",side,col,line,nbx,xCenter,yCenter,xWidth,yWidth,zCenter,name);
304 xMin = xCenter - xWidth/2;
305 xMax = xCenter + xWidth/2;
306 yMin = yCenter - yWidth/2;
307 yMax = yCenter + yWidth/2;
309 fPaveBoard[chamber-11][ib] = new TPave(xMin,yMin,xMax,yMax,1);
310 fPaveBoard[chamber-11][ib]->SetBit(kCannotPick);
311 fPaveBoard[chamber-11][ib]->SetFillStyle(0);
312 fPaveBoard[chamber-11][ib]->Draw();
314 Float_t lWidth = 12.0;
318 sprintf(cln,"C%1d",holdC);
320 ptx1 = holdXC - lWidth;
321 ptx2 = holdXC + lWidth;
322 pty1 = +1.065*frameYmax - lWidth;
323 pty2 = +1.065*frameYmax + lWidth;
325 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
327 label->SetBorderSize(0);
328 label->SetBit(kCannotPick);
333 sprintf(cln,"C%1d",holdC);
335 ptx1 = holdXC - lWidth;
336 ptx2 = holdXC + lWidth;
337 pty1 = -1.065*frameYmax - lWidth;
338 pty2 = -1.065*frameYmax + lWidth;
340 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
342 label->SetBorderSize(0);
343 label->SetBit(kCannotPick);
346 if (holdS == 0 && holdC == 7) {
348 sprintf(cln,"L%1d",holdL);
350 ptx1 = -1.07*frameXmax - lWidth;
351 ptx2 = -1.07*frameXmax + lWidth;
352 pty1 = holdYC - lWidth;
353 pty2 = holdYC + lWidth;
355 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
357 label->SetBorderSize(0);
358 label->SetBit(kCannotPick);
361 if (holdS == 1 && holdC == 7) {
363 sprintf(cln,"L%1d",holdL);
365 ptx1 = +1.07*frameXmax - lWidth;
366 ptx2 = +1.07*frameXmax + lWidth;
367 pty1 = holdYC - lWidth;
368 pty2 = holdYC + lWidth;
370 label = new TPaveText(ptx1,pty1,ptx2,pty2,cln);
372 label->SetBorderSize(0);
373 label->SetBit(kCannotPick);
381 // draw digits set from the board GUI
383 AliMUONTriggerGUIboard *board;
384 Int_t imt = chamber -11;
385 Int_t nStripX, nStripY;
387 for (Int_t ib = 0; ib < kNBoards; ib++) {
389 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
391 xCenter = board->GetXCenter(imt);
392 yCenter = board->GetYCenter(imt);
394 nStripX = board->GetXSiy2() - board->GetXSiy1() + 1;
395 nStripY = board->GetYSix2() - board->GetYSix1() + 1 ;
397 for (Int_t is = 0; is < nStripX; is++) {
399 if (board->GetXDig(imt,is) == 0) continue;
401 box = board->GetXDigBox(imt,is);
403 xpmin = box->GetX1();
404 xpmax = box->GetX2();
405 ypmin = box->GetY1();
406 ypmax = box->GetY2();
413 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
417 for (Int_t is = 0; is < nStripY; is++) {
419 if (board->GetYDig(imt,is) == 0) continue;
421 box = board->GetYDigBox(imt,is);
423 xpmin = box->GetX1();
424 xpmax = box->GetX2();
425 ypmin = box->GetY1();
426 ypmax = box->GetY2();
433 box->DrawBox(xpmin,ypmin,xpmax,ypmax);
441 TIter next(digitStore->CreateIterator());
444 while ( ( mdig = static_cast<AliMUONVDigit*>(next()) ) )
446 cathode = mdig->Cathode()+1;
450 detElemId=mdig->DetElemId();
451 charge = (Int_t)mdig->Charge();
452 color = 261+5*(charge-1);
453 if (color > 282) color = 282;
455 const AliMpVSegmentation* seg2 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode-1));
457 mpad = seg2->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
459 // get the pad position and dimensions
460 Float_t xlocal1 = mpad.Position().X();
461 Float_t ylocal1 = mpad.Position().Y();
462 Float_t xlocal2 = mpad.Dimensions().X();
463 Float_t ylocal2 = mpad.Dimensions().Y();
465 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
466 // (no transformation for pad dimensions)
470 // transform in the monitor coordinate system
471 //xpmin = -(xg1+xg2);
472 //xpmax = -(xg1-xg2);
473 //ypmin = -(yg2-yg1);
474 //ypmax = +(yg2+yg1);
481 boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
482 boxd->SetBit(kCannotPick);
483 boxd->SetFillStyle(1001);
484 boxd->SetFillColor(2);
495 //__________________________________________________________________________
496 void AliMUONTriggerGUIdimap::DoTab(Int_t id) const
498 /// some action when chamber tab is selected...
515 //__________________________________________________________________________
516 void AliMUONTriggerGUIdimap::DoClose()
518 /// close the main frame
525 //__________________________________________________________________________
526 void AliMUONTriggerGUIdimap::DoUpdate()
528 /// update maps for another run/event
530 for (Int_t it = 0; it < kNMT; it++) {
531 for (Int_t ib = 0; ib < kNBoards; ib++) {
532 delete fPaveBoard[it][ib];
541 AliMUONTriggerGUIboard *board;
542 for (Int_t ib = 0; ib < kNBoards; ib++) {
543 board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
544 if (board->IsOpen()) SelectBoard(ib);
549 //__________________________________________________________________________
550 void AliMUONTriggerGUIdimap::DoReset()
552 /// draw unselected boards
554 for (Int_t it = 0; it < kNMT; it++) {
556 TCanvas *canvas = fEc[it]->GetCanvas();
559 for (Int_t ib = 0; ib < kNBoards; ib++) {
560 fPaveBoard[it][ib]->SetFillStyle(0);
570 //__________________________________________________________________________
571 void AliMUONTriggerGUIdimap::SelectBoard(Int_t id)
573 /// highlight on the map the open board
575 for (Int_t it = 0; it < kNMT; it++) {
577 TCanvas *canvas = fEc[it]->GetCanvas();
580 fPaveBoard[it][id]->SetFillStyle(4020);
581 fPaveBoard[it][id]->SetFillColor(7);
590 //__________________________________________________________________________
591 void AliMUONTriggerGUIdimap::CloseWindow()
593 /// called when window is closed via the window manager.
595 fMain->CloseWindow();