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 AliMUONTriggerGUIbdmap
21 /// The gui map of a single board object, strips/digits
23 /// \author Bogdan Vulpescu, LPC Clermont-Ferrand
24 //-----------------------------------------------------------------------------
26 #include <TPolyLine.h>
29 #include <TRootEmbeddedCanvas.h>
31 #include <TPaveText.h>
32 #include <TGTextEdit.h>
35 #include <TObjArray.h>
40 #include "AliMUONVDigit.h"
41 #include "AliMpVSegmentation.h"
42 #include "AliMpSegmentation.h"
43 #include "AliMUONGeometryTransformer.h"
44 #include "AliMpDEIterator.h"
45 #include "AliMUONLocalTrigger.h"
46 #include "AliMUONLocalTriggerBoard.h"
47 #include "AliMUONTriggerCrateStore.h"
49 #include "AliMUONTriggerGUIboard.h"
50 #include "AliMUONTriggerGUIbdmap.h"
52 #include "AliMUONVTriggerStore.h"
53 #include "AliMUONVDigitStore.h"
55 #include "AliMpDEManager.h"
58 ClassImp(AliMUONTriggerGUIbdmap)
61 //__________________________________________________________________________
62 AliMUONTriggerGUIbdmap::AliMUONTriggerGUIbdmap(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
83 gStyle->SetPadLeftMargin(0.05);
84 gStyle->SetPadRightMargin(0.05);
85 gStyle->SetPadTopMargin(0.05);
86 gStyle->SetPadBottomMargin(0.05);
88 fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
89 fMain->Connect("CloseWindow()", "AliMUONTriggerGUIbdmap", this, "CloseWindow()");
90 fMain->DontCallClose(); // to avoid double deletions.
92 // use hierarchical cleaning
93 fMain->SetCleanup(kDeepCleanup);
95 fMain->ChangeOptions((fMain->GetOptions() & ~kVerticalFrame) | kHorizontalFrame);
97 // strips/digits canvases
101 TRootEmbeddedCanvas *recanvas[4];
103 for (Int_t i = 0; i < kNMT; i++) {
105 sprintf(ecname,"%1d",i+1);
106 recanvas[i] = new TRootEmbeddedCanvas(ecname,fMain,fCanvasSize,fCanvasSize);
108 fCanvas[i] = recanvas[i]->GetCanvas();
110 fCanvas[i]->SetBorderMode(0);
111 fCanvas[i]->SetBit(kNoContextMenu);
113 fCanvas[i]->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
114 "AliMUONTriggerGUIbdmap",this,
115 "EditStrips(Int_t,Int_t,Int_t,TObject*)");
117 fMain->AddFrame(recanvas[i],
119 new TGTableLayoutHints(2,5,2,6,
120 kLHintsExpandX|kLHintsExpandY |
121 kLHintsShrinkX|kLHintsShrinkY |
122 kLHintsFillX|kLHintsFillY)
124 new TGLayoutHints(kLHintsTop |
131 //TGDimension size = fMain->GetDefaultSize();
132 //fMain->Resize(size);
136 TGCompositeFrame *cf0 = new TGCompositeFrame(fMain, 60, 20, kVerticalFrame);
138 TGCompositeFrame *cf1 = new TGCompositeFrame(cf0, 60, 20, kVerticalFrame | kFixedWidth);
140 cf1->AddFrame(fXStrips = new TGCheckButton(cf1, "Draw X strips and digits", 1),
141 new TGLayoutHints(kLHintsTop |
146 cf1->Resize(fXStrips->GetDefaultWidth()+10, fMain->GetDefaultHeight());
148 cf1->AddFrame(fYStrips = new TGCheckButton(cf1, "Draw Y strips and digits", 2),
149 new TGLayoutHints(kLHintsTop |
154 cf1->Resize(fYStrips->GetDefaultWidth()+10, fMain->GetDefaultHeight());
156 cf1->AddFrame(fEditStrips = new TGCheckButton(cf1, "Set/unset strips", 3),
157 new TGLayoutHints(kLHintsTop |
162 fXStrips->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "HandleButtons()");
163 fYStrips->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "HandleButtons()");
164 fEditStrips->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "HandleEditButton()");
167 new TGLayoutHints(kLHintsTop |
172 TGCompositeFrame *cf2 = new TGCompositeFrame(cf0, 60, 20, kHorizontalFrame | kFixedWidth);
174 TGTextButton *digitsButton = new TGTextButton(cf2, "Digits", 4);
175 digitsButton->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "DoDigits()");
177 //cf2->Resize(digitsButton->GetDefaultWidth()+40, fMain->GetDefaultHeight());
179 cf2->AddFrame(digitsButton,
180 new TGLayoutHints(kLHintsTop |
186 TGTextButton *dresetButton = new TGTextButton(cf2, "Reset", 5);
187 dresetButton->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "ResetDigits()");
189 //cf2->Resize(dresetButton->GetDefaultWidth()+40, fMain->GetDefaultHeight());
191 cf2->AddFrame(dresetButton,
192 new TGLayoutHints(kLHintsTop |
198 TGTextButton *closeButton = new TGTextButton(cf2, "Close", 6);
199 closeButton->Connect("Clicked()", "AliMUONTriggerGUIbdmap", this, "DoClose()");
201 //cf2->Resize(closeButton->GetDefaultWidth()+40, fMain->GetDefaultHeight());
203 cf2->AddFrame(closeButton,
204 new TGLayoutHints(kLHintsTop |
211 new TGLayoutHints(kLHintsTop |
216 // editor window for the local trigger
218 TGCompositeFrame *cf3 = new TGCompositeFrame(cf0, 60, 20, kVerticalFrame | kFixedWidth);
220 fLocTrigE = new TGTextEdit(cf3, 100, 100, kSunkenFrame | kDoubleBorder);
221 cf3->AddFrame(fLocTrigE,
222 new TGLayoutHints(kLHintsExpandX |
228 new TGLayoutHints(kLHintsTop |
234 new TGLayoutHints(kLHintsTop |
239 fIsEditable = kFALSE;
243 fMain->MapSubwindows();
246 fMain->CenterOnParent();
248 //fMain->MapWindow();
249 //gClient->WaitFor(fMain);
253 //__________________________________________________________________________
254 AliMUONTriggerGUIbdmap::~AliMUONTriggerGUIbdmap()
258 fMain->DeleteWindow();
262 //__________________________________________________________________________
263 void AliMUONTriggerGUIbdmap::Show()
265 /// map the main frame
272 //__________________________________________________________________________
273 void AliMUONTriggerGUIbdmap::LocalTriggerInfo()
275 /// print the local trigger
277 AliMUONTriggerCrateStore* crateManager = new AliMUONTriggerCrateStore();
278 crateManager->ReadFromFile();
283 sprintf(buffer,"Local trigger info\n");
284 fLocTrigE->LoadBuffer(buffer);
286 AliRunLoader *runLoader = fLoader->GetRunLoader();
287 gAlice = runLoader->GetAliRun();
289 fLoader->LoadDigits("READ");
291 TTree* treeD = fLoader->TreeD();
293 AliMUONVTriggerStore* triggerStore = AliMUONVTriggerStore::Create(*treeD);
295 Int_t circuitNumber = fBoard->GetIdCircuit();
297 UShort_t x2m, x2u, x2d;
299 Int_t loStripX, loStripY, loDev, loCircuit, iStripX, iStripY, loLpt, loHpt;
300 AliMUONLocalTrigger *mlt;
302 TIter next(triggerStore->CreateLocalIterator());
304 while ( ( mlt = static_cast<AliMUONLocalTrigger*>(next()) ) )
306 loCircuit = mlt->LoCircuit();
308 if (loCircuit == circuitNumber) {
310 AliMUONLocalTriggerBoard* ltb = crateManager->LocalBoard(loCircuit);
311 x2d = ltb->GetSwitch(0);
312 x2m = ltb->GetSwitch(1);
313 x2u = ltb->GetSwitch(2);
315 loStripX = mlt->LoStripX();
316 loStripY = mlt->LoStripY();
317 loDev = mlt->LoDev();
318 loLpt = mlt->LoLpt();
319 loHpt = mlt->LoHpt();
321 iStripX = loStripX/2;
322 if ((x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) {
323 iStripY = loStripY/2;
328 sprintf(buffer,"Circuit = %03d",loCircuit);
329 txt.LoadBuffer(buffer);
330 fLocTrigE->AddText(&txt);
332 sprintf(buffer,"LoStripX = %2d",loStripX);
333 txt.LoadBuffer(buffer);
334 fLocTrigE->AddText(&txt);
336 sprintf(buffer,"LoStripY = %2d",loStripY);
337 txt.LoadBuffer(buffer);
338 fLocTrigE->AddText(&txt);
340 sprintf(buffer,"LoDev = %2d",loDev);
341 txt.LoadBuffer(buffer);
342 fLocTrigE->AddText(&txt);
344 sprintf(buffer,"--------------------");
345 txt.LoadBuffer(buffer);
346 fLocTrigE->AddText(&txt);
348 sprintf(buffer,"X-strip = %2d ( %2d )",iStripX,(loStripX+loDev+1)/2);
349 txt.LoadBuffer(buffer);
350 fLocTrigE->AddText(&txt);
352 sprintf(buffer,"Y-strip = %2d",iStripY);
353 txt.LoadBuffer(buffer);
354 fLocTrigE->AddText(&txt);
356 sprintf(buffer,"--------------------");
357 txt.LoadBuffer(buffer);
358 fLocTrigE->AddText(&txt);
360 sprintf(buffer,"LoLpt = %2d",loLpt);
361 txt.LoadBuffer(buffer);
362 fLocTrigE->AddText(&txt);
364 sprintf(buffer,"LoHpt = %2d",loHpt);
365 txt.LoadBuffer(buffer);
366 fLocTrigE->AddText(&txt);
377 //__________________________________________________________________________
378 void AliMUONTriggerGUIbdmap::Init()
380 /// initialize the boards in the four MT
382 TString mapspath = gSystem->Getenv("ALICE_ROOT");
383 mapspath.Append("/MUON/data");
385 TString mapName[kNMT];
386 mapName[0] = TString(mapspath.Data());
387 mapName[1] = TString(mapspath.Data());
388 mapName[2] = TString(mapspath.Data());
389 mapName[3] = TString(mapspath.Data());
390 mapName[0].Append("/guimapp11.txt");
391 mapName[1].Append("/guimapp12.txt");
392 mapName[2].Append("/guimapp13.txt");
393 mapName[3].Append("/guimapp14.txt");
395 Int_t side, col, line, nbx;
396 Float_t xCenter, yCenter, zCenter, xWidth, yWidth;
400 for (Int_t i = 0; i < kNMT; i++) {
402 fmap = fopen(mapName[i].Data(),"r");
404 for (Int_t ib = 0; ib < kNBoards; ib++) {
406 fscanf(fmap,"%d %d %d %d %f %f %f %f %f %s \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]);
409 sprintf(name,"LC%1dL%1dB%1d%1d",col,line,2*nbx-1,2*nbx);
412 sprintf(name,"RC%1dL%1dB%1d%1d",col,line,2*nbx-1,2*nbx);
415 if (strncmp(name,fBoard->GetBoardName(),7) == 0) {
418 fXCenter[i] = xCenter;
419 fYCenter[i] = yCenter;
431 for (Int_t i = 0; i < kNMT; i++) {
432 xw = 1.20*fXWidth[i];
433 yw = 1.20*fYWidth[i];
434 fCanvas[i]->Range(-xw/2,-yw/2,+xw/2,+yw/2);
435 for (Int_t is = 0; is < kNS; is++) {
437 fXDigPL[i][is] = new TPolyLine(5);
438 fYDigPL[i][is] = new TPolyLine(5);
439 fXDigPL[i][is]->SetBit(kCannotPick);
440 fYDigPL[i][is]->SetBit(kCannotPick);
441 fXDigPL[i][is]->SetLineColor(4);
442 fYDigPL[i][is]->SetLineColor(4);
444 fXDigBox[i][is] = new TBox(0,0,0,0);
445 fYDigBox[i][is] = new TBox(0,0,0,0);
446 fXDigBox[i][is]->SetBit(kCannotPick);
447 fYDigBox[i][is]->SetBit(kCannotPick);
448 fXDigBox[i][is]->SetFillStyle(0);
449 fYDigBox[i][is]->SetFillStyle(0);
450 fXDigBox[i][is]->SetLineColor(4);
451 fYDigBox[i][is]->SetLineColor(4);
465 fNStripX = fBoard->GetXSiy2() - fBoard->GetXSiy1() + 1;
466 fNStripY = fBoard->GetYSix2() - fBoard->GetYSix1() + 1;
470 //__________________________________________________________________________
471 void AliMUONTriggerGUIbdmap::HandleEditButton()
473 /// handle the editable check button
475 if (((fXOn && !fYOn) || (!fXOn && fYOn)) &&
476 (fEditStrips->GetState() == kButtonDown)) {
479 fIsEditable = kFALSE;
484 //__________________________________________________________________________
485 void AliMUONTriggerGUIbdmap::EditStrips(Int_t event, Int_t x, Int_t y, TObject *sel)
492 Double_t xf1, yf1, xf2, yf2;
494 Double_t xMin, xMax, yMin, yMax;
495 Float_t xd, yd, fxDim, fyDim, cDim;
498 cDim = (Float_t)fCanvasSize;
500 // the (x,y) event does not really go up to the canvas size...
505 if (event == kButton1Down) {
507 cs = TString(sel->GetName());
512 fCanvas[iMT]->GetRange(xf1,yf1,xf2,yf2);
513 fxDim = (Float_t)xf2;
514 fyDim = (Float_t)yf2;
516 //xd = fxDim*(+2.0*(Float_t)(x)/cDim - 1.0);
517 //yd = fyDim*(-2.0*(Float_t)(y)/cDim + 1.0);
519 xd = +(2.0*fxDim*(Float_t)(x))/cDim - fxDim;
520 yd = -(2.0*fyDim*(Float_t)(y))/cDim + fyDim;
524 for (Int_t ix = 0; ix < fNStripX; ix++) {
526 px = fXDigPL[iMT][ix]->GetX();
527 py = fXDigPL[iMT][ix]->GetY();
533 for (Int_t ip = 0; ip < np; ip++) {
534 xMin = TMath::Min(xMin,px[ip]);
535 xMax = TMath::Max(xMax,px[ip]);
536 yMin = TMath::Min(yMin,py[ip]);
537 yMax = TMath::Max(yMax,py[ip]);
540 if (yd > (Float_t)yMin && yd < (Float_t)yMax) {
542 if (fXDigBox[iMT][ix]->GetFillStyle() == 0) {
544 fXDigBox[iMT][ix]->SetFillStyle(1001);
545 fXDigBox[iMT][ix]->SetFillColor(2);
547 sprintf(cln,"%2d",ix);
549 fXLabelL[iMT][ix]->Clear();
550 fXLabelL[iMT][ix]->AddText(cln);
551 fXLabelL[iMT][ix]->Draw();
553 fXLabelR[iMT][ix]->Clear();
554 fXLabelR[iMT][ix]->AddText(cln);
555 fXLabelR[iMT][ix]->Draw();
557 fXDigBox[iMT][ix]->SetX1(xMin);
558 fXDigBox[iMT][ix]->SetY1(yMin);
559 fXDigBox[iMT][ix]->SetX2(xMax);
560 fXDigBox[iMT][ix]->SetY2(yMax);
562 fXDigBox[iMT][ix]->Draw();
564 } else if (fXDigBox[iMT][ix]->GetFillStyle() == 1001) {
566 fXDigBox[iMT][ix]->SetFillStyle(0);
568 fXLabelL[iMT][ix]->Clear();
569 fXLabelL[iMT][ix]->Draw();
571 fXLabelR[iMT][ix]->Clear();
572 fXLabelR[iMT][ix]->Draw();
574 fXDigBox[iMT][ix]->SetX1(-fBoard->GetXCenter(iMT));
575 fXDigBox[iMT][ix]->SetY1(-fBoard->GetYCenter(iMT));
576 fXDigBox[iMT][ix]->SetX2(-fBoard->GetXCenter(iMT));
577 fXDigBox[iMT][ix]->SetY2(-fBoard->GetYCenter(iMT));
579 fXDigBox[iMT][ix]->Draw();
583 if (!fXDigBox[iMT][ix]->TestBit(kObjInCanvas))
584 fXDigBox[iMT][ix]->Draw();
586 fCanvas[iMT]->Modified();
587 fCanvas[iMT]->Update();
598 for (Int_t iy = 0; iy < fNStripY; iy++) {
600 px = fYDigPL[iMT][iy]->GetX();
601 py = fYDigPL[iMT][iy]->GetY();
607 for (Int_t ip = 0; ip < np; ip++) {
608 xMin = TMath::Min(xMin,px[ip]);
609 xMax = TMath::Max(xMax,px[ip]);
610 yMin = TMath::Min(yMin,py[ip]);
611 yMax = TMath::Max(yMax,py[ip]);
614 if (xd > (Float_t)xMin && xd < (Float_t)xMax) {
616 if (fYDigBox[iMT][iy]->GetFillStyle() == 0) {
618 fYDigBox[iMT][iy]->SetFillStyle(1001);
619 fYDigBox[iMT][iy]->SetFillColor(2);
621 sprintf(cln,"%2d",iy);
623 fYLabelL[iMT][iy]->Clear();
624 fYLabelL[iMT][iy]->AddText(cln);
625 fYLabelL[iMT][iy]->Draw();
627 fYLabelR[iMT][iy]->Clear();
628 fYLabelR[iMT][iy]->AddText(cln);
629 fYLabelR[iMT][iy]->Draw();
631 fYDigBox[iMT][iy]->SetX1(xMin);
632 fYDigBox[iMT][iy]->SetY1(yMin);
633 fYDigBox[iMT][iy]->SetX2(xMax);
634 fYDigBox[iMT][iy]->SetY2(yMax);
636 //fYDigBox[iMT][iy]->Draw();
638 } else if (fYDigBox[iMT][iy]->GetFillStyle() == 1001) {
640 fYDigBox[iMT][iy]->SetFillStyle(0);
642 fYLabelL[iMT][iy]->Clear();
643 fYLabelL[iMT][iy]->Draw();
645 fYLabelR[iMT][iy]->Clear();
646 fYLabelR[iMT][iy]->Draw();
648 fYDigBox[iMT][iy]->SetX1(-fBoard->GetXCenter(iMT));
649 fYDigBox[iMT][iy]->SetY1(-fBoard->GetYCenter(iMT));
650 fYDigBox[iMT][iy]->SetX2(-fBoard->GetXCenter(iMT));
651 fYDigBox[iMT][iy]->SetY2(-fBoard->GetYCenter(iMT));
653 //fYDigBox[iMT][iy]->Draw();
657 if (!fYDigBox[iMT][iy]->TestBit(kObjInCanvas))
658 fYDigBox[iMT][iy]->Draw();
660 fCanvas[iMT]->Modified();
661 fCanvas[iMT]->Update();
670 } // end button event
676 //__________________________________________________________________________
677 void AliMUONTriggerGUIbdmap::DoDigits()
679 /// set the board digits from GUI input (set/unset)
682 Int_t number = fBoard->GetNumber();
684 pos = fBoard->GetPosition();
685 over = fBoard->GetYOver();
686 AliMUONTriggerGUIboard *board;
688 for (Int_t imt = 0; imt < kNMT; imt++) {
690 for (Int_t ix = 0; ix < fNStripX; ix++) {
691 if (fXDigBox[imt][ix]->GetFillStyle() == 0) {
694 if (fXDigBox[imt][ix]->GetFillStyle() == 1001) {
697 fBoard->SetDigitX(imt,ix,amp);
700 for (Int_t iy = 0; iy < fNStripY; iy++) {
701 if (fYDigBox[imt][iy]->GetFillStyle() == 0) {
704 if (fYDigBox[imt][iy]->GetFillStyle() == 1001) {
707 fBoard->SetDigitY(imt,iy,amp);
710 for (Int_t io = 1; io <= over; io++) {
711 if (io == pos) continue;
712 board = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
713 board->SetDigitY(imt,iy,amp);
722 //__________________________________________________________________________
723 void AliMUONTriggerGUIbdmap::ResetDigits()
725 /// set the board digits from GUI input (set/unset)
728 Int_t number = fBoard->GetNumber();
729 AliMUONTriggerGUIboard *board;
731 pos = fBoard->GetPosition();
732 over = fBoard->GetYOver();
734 for (Int_t imt = 0; imt < kNMT; imt++) {
735 for (Int_t ix = 0; ix < fNStripX; ix++) {
736 fXDigBox[imt][ix]->SetFillStyle(0);
737 fXDigBox[imt][ix]->SetX1(-fBoard->GetXCenter(imt));
738 fXDigBox[imt][ix]->SetY1(-fBoard->GetYCenter(imt));
739 fXDigBox[imt][ix]->SetX2(-fBoard->GetXCenter(imt));
740 fXDigBox[imt][ix]->SetY2(-fBoard->GetYCenter(imt));
742 fBoard->SetDigitX(imt,ix,amp);
744 for (Int_t iy = 0; iy < fNStripY; iy++) {
745 fYDigBox[imt][iy]->SetFillStyle(0);
746 fYDigBox[imt][iy]->SetX1(-fBoard->GetXCenter(imt));
747 fYDigBox[imt][iy]->SetY1(-fBoard->GetYCenter(imt));
748 fYDigBox[imt][iy]->SetX2(-fBoard->GetXCenter(imt));
749 fYDigBox[imt][iy]->SetY2(-fBoard->GetYCenter(imt));
751 fBoard->SetDigitY(imt,iy,amp);
754 for (Int_t io = 1; io <= over; io++) {
755 if (io == pos) continue;
756 board = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
758 board->SetDigitY(imt,iy,amp);
765 fBoard->ClearXDigits();
766 fBoard->ClearYDigits();
769 for (Int_t io = 1; io <= over; io++) {
770 if (io == pos) continue;
771 board = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
772 board->ClearYDigits();
775 fXStrips->SetState(kButtonUp);
776 fYStrips->SetState(kButtonUp);
777 fEditStrips->SetState(kButtonUp);
778 fIsEditable = kFALSE;
786 //__________________________________________________________________________
787 void AliMUONTriggerGUIbdmap::HandleButtons(Int_t id)
789 /// handle the check buttons
792 TGButton *btn = (TGButton *) gTQSender;
793 id = btn->WidgetId();
797 if(fXStrips->GetState() == kButtonDown &&
798 fYStrips->GetState() == kButtonDown ) {
801 DrawStrips(kTRUE,kTRUE);
802 DrawDigits(kTRUE,kTRUE);
809 if(fXStrips->GetState() == kButtonDown &&
810 fYStrips->GetState() == kButtonUp ) {
813 DrawStrips(kTRUE,kFALSE);
814 DrawDigits(kTRUE,kFALSE);
821 if(fXStrips->GetState() == kButtonUp &&
822 fYStrips->GetState() == kButtonDown ) {
825 DrawStrips(kFALSE,kTRUE);
826 DrawDigits(kFALSE,kTRUE);
833 if(fXStrips->GetState() == kButtonUp &&
834 fYStrips->GetState() == kButtonUp ) {
846 //__________________________________________________________________________
847 void AliMUONTriggerGUIbdmap::DrawClear()
849 /// draw the frame of the board image in the canvas
851 for (Int_t i = 0; i < kNMT; i++) {
856 fCanvas[i]->Modified();
857 fCanvas[i]->Update();
863 //__________________________________________________________________________
864 void AliMUONTriggerGUIbdmap::DrawDigits(Bool_t bx, Bool_t by)
866 /// draw the digits in "x" or/and "y"
868 AliRunLoader *runLoader = fLoader->GetRunLoader();
869 gAlice = runLoader->GetAliRun();
870 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
871 const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer();
873 AliMUONTriggerGUIboard *board;
874 Int_t over, pos, number;
875 const AliMpVSegmentation* seg;
877 Int_t cathode, detElemId, ix, iy, charge;
878 Int_t chamber, np = 5;
880 Float_t xpmin, xpmax, ypmin, ypmax;
881 Float_t xg1, xg2, yg1, yg2, zg1;
882 Float_t xdw, ydw, xcw, ycw;
883 Double_t xc1, xc2, yc1, yc2;
886 Double_t xMin, xMax, yMin, yMax;
889 number = fBoard->GetNumber();
890 pos = fBoard->GetPosition();
891 over = fBoard->GetYOver();
893 fLoader->LoadDigits("READ");
894 TTree* treeD = fLoader->TreeD();
895 AliMUONVDigitStore* digitStore = AliMUONVDigitStore::Create(*treeD);
897 for (Int_t i = 0; i < kNMT; i++) {
901 fCanvas[i]->GetRange(xc1,yc1,xc2,yc2);
902 xcw = (Float_t)(0.5*(xc2-xc1));
903 ycw = (Float_t)(0.5*(yc2-yc1));
907 AliMpIntPair deRange = AliMpDEManager::GetDetElemIdRange(chamber-1);
908 TIter next(digitStore->CreateIterator(deRange.GetFirst(),deRange.GetSecond()));
911 while ( ( mdig = static_cast<AliMUONVDigit*>(next())) )
913 cathode = mdig->Cathode()+1;
917 detElemId = mdig->DetElemId();
918 charge = (Int_t)mdig->Charge();
920 Bool_t triggerBgn = kFALSE;
921 Int_t schg = (Int_t)(charge + 0.5);
922 // APPLY CONDITION ON SOFT BACKGROUND
923 Int_t tchg = schg - (Int_t(schg/10))*10;
924 if (schg<=10 || tchg>0) {
930 if (detElemId%100 != fBoard->GetDetElemId()) continue;
932 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cathode-1));
934 pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
936 //if (cathode == 1) printf("GUI x: ix %d iy %d \n",ix,iy);
937 //if (cathode == 2) printf("GUI y: ix %d iy %d \n",ix,iy);
939 // get the pad position and dimensions
940 Float_t xlocal1 = pad.Position().X();
941 Float_t ylocal1 = pad.Position().Y();
942 Float_t xlocal2 = pad.Dimensions().X();
943 Float_t ylocal2 = pad.Dimensions().Y();
945 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
946 // (no transformation for pad dimensions)
950 // transform in the monitor coordinate system
951 //xpmin = -(xg1+xg2);
952 //xpmax = -(xg1-xg2);
953 //ypmin = -(yg2-yg1);
954 //ypmax = +(yg2+yg1);
961 xpmin -= fXCenter[i];
962 xpmax -= fXCenter[i];
963 ypmin -= fYCenter[i];
964 ypmax -= fYCenter[i];
970 if ((xdw > ydw) && bx) {
972 //printf("X strips mdig->Cathode() = %1d \n",mdig->Cathode());
975 iX = fBoard->GetXSix();
976 iY1 = fBoard->GetXSiy1();
977 iY2 = fBoard->GetXSiy2();
978 if (ix == iX && iy >= iY1 && iy <= iY2) {
979 //printf("Digit indices (x-strip) ix = %3d iy = %3d board = %s %d chamber = %2d \n",ix,iy,fBoard->GetBoardName(),fBoard->GetNumber(),chamber);
981 xpmin += 0.01*fXWidth[i];
982 xpmax -= 0.01*fXWidth[i];
986 boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
987 boxd->SetFillStyle(1001);
988 if (triggerBgn) boxd->SetFillColor(6);
989 else boxd->SetFillColor(5);
990 boxd->SetBit(kCannotPick);
993 fXDigBox[i][iy-iY1]->SetFillStyle(1001);
994 fXDigBox[i][iy-iY1]->SetFillColor(2);
995 fXDigBox[i][iy-iY1]->SetX1(xpmin);
996 fXDigBox[i][iy-iY1]->SetY1(ypmin);
997 fXDigBox[i][iy-iY1]->SetX2(xpmax);
998 fXDigBox[i][iy-iY1]->SetY2(ypmax);
999 fXDigBox[i][iy-iY1]->Draw();
1001 sprintf(cln,"%2d",(iy-iY1));
1002 fXLabelL[i][iy-iY1]->Clear();
1003 fXLabelL[i][iy-iY1]->AddText(cln);
1004 fXLabelL[i][iy-iY1]->Draw();
1005 fXLabelR[i][iy-iY1]->Clear();
1006 fXLabelR[i][iy-iY1]->AddText(cln);
1007 fXLabelR[i][iy-iY1]->Draw();
1009 fBoard->SetDigitX(i,iy-iY1,charge);
1016 if ((xdw < ydw) && by) {
1018 //printf("Y strips mdig->Cathode() = %1d \n",mdig->Cathode());
1021 iX1 = fBoard->GetYSix1();
1022 iX2 = fBoard->GetYSix2();
1023 iY = fBoard->GetYSiy();
1024 if (ix >= iX1 && ix <= iX2 && iy == iY) {
1025 //printf("Digit indices (y-strip) ix = %3d iy = %3d board = %s chamber = %2d \n",ix,iy,fBoard->GetBoardName(),chamber);
1026 ypmin = -0.5*fYWidth[i];
1027 ypmax = +0.5*fYWidth[i];
1029 ypmin = -0.5*fYWidth[i];
1030 ypmax = +0.5*fYWidth[i];
1031 ypmin += 0.01*fYWidth[i];
1032 ypmax -= 0.01*fYWidth[i];
1036 boxd = new TBox(xpmin,ypmin,xpmax,ypmax);
1037 boxd->SetFillStyle(1001);
1038 if (triggerBgn) boxd->SetFillColor(6);
1039 else boxd->SetFillColor(5);
1040 boxd->SetBit(kCannotPick);
1043 fYDigBox[i][ix-iX1]->SetFillStyle(1001);
1044 fYDigBox[i][ix-iX1]->SetFillColor(2);
1045 fYDigBox[i][ix-iX1]->SetX1(xpmin);
1046 fYDigBox[i][ix-iX1]->SetY1(ypmin);
1047 fYDigBox[i][ix-iX1]->SetX2(xpmax);
1048 fYDigBox[i][ix-iX1]->SetY2(ypmax);
1049 fYDigBox[i][ix-iX1]->Draw();
1051 sprintf(cln,"%2d",(ix-iX1));
1052 fYLabelL[i][ix-iX1]->Clear();
1053 fYLabelL[i][ix-iX1]->AddText(cln);
1054 fYLabelL[i][ix-iX1]->Draw();
1055 fYLabelR[i][ix-iX1]->Clear();
1056 fYLabelR[i][ix-iX1]->AddText(cln);
1057 fYLabelR[i][ix-iX1]->Draw();
1059 fBoard->SetDigitY(i,ix-iX1,charge);
1061 // extended y-strips
1062 for (Int_t io = 1; io <= over; io++) {
1063 if (io == pos) continue;
1064 board = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
1065 board->SetDigitY(i,ix-iX1,charge);
1071 } // end digits loop
1076 for (Int_t ix = 0; ix < fNStripX; ix++) {
1077 //if (fBoard->GetXDig(i,ix) > 0) {
1078 if (fXDigBox[i][ix]->GetFillStyle() == 1001 ||
1079 fBoard->GetXDig(i,ix) > 0) {
1081 px = fXDigPL[i][ix]->GetX();
1082 py = fXDigPL[i][ix]->GetY();
1088 for (Int_t ip = 0; ip < np; ip++) {
1089 xMin = TMath::Min(xMin,px[ip]);
1090 xMax = TMath::Max(xMax,px[ip]);
1091 yMin = TMath::Min(yMin,py[ip]);
1092 yMax = TMath::Max(yMax,py[ip]);
1095 if (fXDigBox[i][ix]->GetFillStyle() == 0) {
1096 fXDigBox[i][ix]->SetFillStyle(1001);
1097 fXDigBox[i][ix]->SetFillColor(2);
1098 fXDigBox[i][ix]->SetX1(xMin);
1099 fXDigBox[i][ix]->SetY1(yMin);
1100 fXDigBox[i][ix]->SetX2(xMax);
1101 fXDigBox[i][ix]->SetY2(yMax);
1104 sprintf(cln,"%2d",ix);
1106 fXLabelL[i][ix]->Clear();
1107 fXLabelL[i][ix]->AddText(cln);
1108 fXLabelL[i][ix]->Draw();
1110 fXLabelR[i][ix]->Clear();
1111 fXLabelR[i][ix]->AddText(cln);
1112 fXLabelR[i][ix]->Draw();
1114 fXDigBox[i][ix]->Draw();
1125 for (Int_t iy = 0; iy < fNStripY; iy++) {
1126 //if (fBoard->GetYDig(i,iy) > 0) {
1127 if (fYDigBox[i][iy]->GetFillStyle() == 1001 ||
1128 fBoard->GetYDig(i,iy) > 0) {
1130 px = fYDigPL[i][iy]->GetX();
1131 py = fYDigPL[i][iy]->GetY();
1137 for (Int_t ip = 0; ip < np; ip++) {
1138 xMin = TMath::Min(xMin,px[ip]);
1139 xMax = TMath::Max(xMax,px[ip]);
1140 yMin = TMath::Min(yMin,py[ip]);
1141 yMax = TMath::Max(yMax,py[ip]);
1144 if (fYDigBox[i][iy]->GetFillStyle() == 0) {
1145 fYDigBox[i][iy]->SetFillStyle(1001);
1146 fYDigBox[i][iy]->SetFillColor(2);
1147 fYDigBox[i][iy]->SetX1(xMin);
1148 fYDigBox[i][iy]->SetY1(yMin);
1149 fYDigBox[i][iy]->SetX2(xMax);
1150 fYDigBox[i][iy]->SetY2(yMax);
1153 sprintf(cln,"%2d",iy);
1155 fYLabelL[i][iy]->Clear();
1156 fYLabelL[i][iy]->AddText(cln);
1157 fYLabelL[i][iy]->Draw();
1159 fYLabelR[i][iy]->Clear();
1160 fYLabelR[i][iy]->AddText(cln);
1161 fYLabelR[i][iy]->Draw();
1164 fYDigBox[i][iy]->Draw();
1172 fCanvas[i]->Modified();
1173 fCanvas[i]->Update();
1175 } // end canvas loop
1182 //__________________________________________________________________________
1183 void AliMUONTriggerGUIbdmap::DrawStrips(Bool_t bx, Bool_t by)
1185 /// draw the "x" or/and "y" strips
1187 AliRunLoader *runLoader = fLoader->GetRunLoader();
1188 gAlice = runLoader->GetAliRun();
1189 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1190 const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer();
1192 const AliMpVSegmentation* seg;
1196 Float_t xg1, xg2, yg1, yg2, zg1;
1197 Float_t xlocal1, xlocal2, ylocal1, ylocal2;
1198 Int_t detElemId, ic, maxX, maxY;
1199 Float_t xdw, ydw, xpmin, xpmax, ypmin, ypmax;
1200 Float_t ptx1, ptx2, pty1, pty2;
1202 Double_t xc1, xc2, yc1, yc2;
1205 Bool_t makeLabelsX = kFALSE;
1206 Bool_t makeLabelsY = kFALSE;
1208 if (bx && !fLabelX) {
1209 makeLabelsX = kTRUE;
1213 if (by && !fLabelY) {
1214 makeLabelsY = kTRUE;
1218 for (Int_t i = 0; i < kNMT; i++) {
1222 fCanvas[i]->GetRange(xc1,yc1,xc2,yc2);
1223 xcw = (Float_t)(0.5*(xc2-xc1));
1224 ycw = (Float_t)(0.5*(yc2-yc1));
1228 for ( it.First(chamber-1); ! it.IsDone(); it.Next() ) {
1230 detElemId = it.CurrentDEId();
1232 if (detElemId%100 != fBoard->GetDetElemId()) continue;
1234 /*---------- y-pads ic = 2 ----------*/
1237 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(ic-1));
1239 maxX = seg->MaxPadIndexX();
1240 maxY = seg->MaxPadIndexY();
1242 for (Int_t ix = 0; ix <= maxX; ix++) {
1243 for (Int_t iy = 0; iy <= maxY; iy++) {
1245 pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE);
1247 if (!pad.IsValid()) continue;
1249 // get the pad position and dimensions
1250 xlocal1 = pad.Position().X();
1251 ylocal1 = pad.Position().Y();
1252 xlocal2 = pad.Dimensions().X();
1253 ylocal2 = pad.Dimensions().Y();
1255 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
1256 // (no transformation for pad dimensions)
1260 // transform in the monitor coordinate system
1261 //xpmin = -(xg1+xg2);
1262 //xpmax = -(xg1-xg2);
1263 //ypmin = -(yg2-yg1);
1264 //ypmax = +(yg2+yg1);
1271 xpmin -= fXCenter[i];
1272 xpmax -= fXCenter[i];
1273 ypmin -= fYCenter[i];
1274 ypmax -= fYCenter[i];
1282 Int_t iX1, iX2, iY, ixDig;
1283 iX1 = fBoard->GetYSix1();
1284 iX2 = fBoard->GetYSix2();
1285 iY = fBoard->GetYSiy();
1286 if (ix >= iX1 && ix <= iX2 && iy == iY) {
1288 ypmin = -0.5*fYWidth[i];
1289 ypmax = +0.5*fYWidth[i];
1291 ypmin += 0.01*fYWidth[i];
1292 ypmax -= 0.01*fYWidth[i];
1297 fYDigPL[i][ixDig]->SetPoint(0,xpmin,ypmin);
1298 fYDigPL[i][ixDig]->SetPoint(1,xpmax,ypmin);
1299 fYDigPL[i][ixDig]->SetPoint(2,xpmax,ypmax);
1300 fYDigPL[i][ixDig]->SetPoint(3,xpmin,ypmax);
1301 fYDigPL[i][ixDig]->SetPoint(4,xpmin,ypmin);
1302 fYDigPL[i][ixDig]->Draw();
1304 fYDigBox[i][ixDig]->SetFillStyle(1001);
1305 fYDigBox[i][ixDig]->SetFillColor(5);
1306 fYDigBox[i][ixDig]->DrawBox(xpmin,ypmin,xpmax,ypmax);
1309 sprintf(cln,"%2d",(ix-iX1));
1313 pty1 = 1.065*ypmin - 0.04*ycw;
1314 pty2 = 1.065*ypmin + 0.04*ycw;
1315 fYLabelL[i][ix-iX1] = new TPaveText(ptx1,pty1,ptx2,pty2);
1316 fYLabelL[i][ix-iX1]->SetBorderSize(0);
1317 fYLabelL[i][ix-iX1]->SetBit(kCannotPick);
1319 pty1 = 1.065*ypmax - 0.04*ycw;
1320 pty2 = 1.065*ypmax + 0.04*ycw;
1321 fYLabelR[i][ix-iX1] = new TPaveText(ptx1,pty1,ptx2,pty2);
1322 fYLabelR[i][ix-iX1]->SetBorderSize(0);
1323 fYLabelR[i][ix-iX1]->SetBit(kCannotPick);
1334 /*---------- x-pads ic = 1 ----------*/
1337 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(ic-1));
1339 maxX = seg->MaxPadIndexX();
1340 maxY = seg->MaxPadIndexY();
1342 for (Int_t ix = 0; ix <= maxX; ix++) {
1343 for (Int_t iy = 0; iy <= maxY; iy++) {
1345 pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE);
1347 if (!pad.IsValid()) continue;
1349 // get the pad position and dimensions
1350 xlocal1 = pad.Position().X();
1351 ylocal1 = pad.Position().Y();
1352 xlocal2 = pad.Dimensions().X();
1353 ylocal2 = pad.Dimensions().Y();
1355 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
1356 // (no transformation for pad dimensions)
1360 // transform in the monitor coordinate system
1361 //xpmin = -(xg1+xg2);
1362 //xpmax = -(xg1-xg2);
1363 //ypmin = -(yg2-yg1);
1364 //ypmax = +(yg2+yg1);
1371 xpmin -= fXCenter[i];
1372 xpmax -= fXCenter[i];
1373 ypmin -= fYCenter[i];
1374 ypmax -= fYCenter[i];
1381 Int_t iX, iY1, iY2, iyDig;
1382 iX = fBoard->GetXSix();
1383 iY1 = fBoard->GetXSiy1();
1384 iY2 = fBoard->GetXSiy2();
1385 if (ix == iX && iy >= iY1 && iy <= iY2) {
1387 xpmin += 0.01*fXWidth[i];
1388 xpmax -= 0.01*fXWidth[i];
1393 fXDigPL[i][iyDig]->SetPoint(0,xpmin,ypmin);
1394 fXDigPL[i][iyDig]->SetPoint(1,xpmax,ypmin);
1395 fXDigPL[i][iyDig]->SetPoint(2,xpmax,ypmax);
1396 fXDigPL[i][iyDig]->SetPoint(3,xpmin,ypmax);
1397 fXDigPL[i][iyDig]->SetPoint(4,xpmin,ypmin);
1398 fXDigPL[i][iyDig]->Draw();
1400 fXDigBox[i][iyDig]->SetFillStyle(1001);
1401 fXDigBox[i][iyDig]->SetFillColor(5);
1402 fXDigBox[i][iyDig]->DrawBox(xpmin,ypmin,xpmax,ypmax);
1405 sprintf(cln,"%2d",(iy-iY1));
1409 ptx1 = 1.065*xpmin - 0.04*xcw;
1410 ptx2 = 1.065*xpmin + 0.04*xcw;
1411 fXLabelL[i][iy-iY1] = new TPaveText(ptx1,pty1,ptx2,pty2);
1412 fXLabelL[i][iy-iY1]->SetBorderSize(0);
1413 fXLabelL[i][iy-iY1]->SetBit(kCannotPick);
1415 ptx1 = 1.065*xpmax - 0.04*xcw;
1416 ptx2 = 1.065*xpmax + 0.04*xcw;
1417 fXLabelR[i][iy-iY1] = new TPaveText(ptx1,pty1,ptx2,pty2);
1418 fXLabelR[i][iy-iY1]->SetBorderSize(0);
1419 fXLabelR[i][iy-iY1]->SetBit(kCannotPick);
1432 fCanvas[i]->Modified();
1433 fCanvas[i]->Update();
1441 //__________________________________________________________________________
1442 void AliMUONTriggerGUIbdmap::CloseWindow()
1444 /// close dialog in response to window manager close.
1450 //__________________________________________________________________________
1451 void AliMUONTriggerGUIbdmap::DoClose()
1453 /// handle Close button.
1455 fBoard->SetOpen(kFALSE);
1456 TTimer::SingleShot(150,"AliMUONTriggerGUIbdmap",this,"CloseWindow()");