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 AliMUONTriggerGUI
19 /// Graphical User Interface utility class for the MUON trigger detector
20 /// It creates, after initialisation with a data file, a sensitive map
21 /// of the trigger boards
22 /// \author Bogdan Vulpescu, LPC Clermont-Ferrand
24 #include "AliMUONTriggerGUI.h"
25 #include "AliMUONTriggerGUIboard.h"
26 #include "AliMUONTriggerGUIdimap.h"
27 #include "AliMUONTriggerGUIbdmap.h"
29 #include "AliMpSegmentation.h"
30 #include "AliMpVSegmentation.h"
32 #include "AliMpIntPair.h"
34 #include "AliMpDEIterator.h"
35 #include "AliMUONGeometryTransformer.h"
36 #include "AliMUONTriggerCrateStore.h"
37 #include "AliMUONLocalTriggerBoard.h"
38 #include "AliMUONTriggerElectronics.h"
39 #include "AliMUONCalibrationData.h"
42 #include "AliRunLoader.h"
43 #include "AliCDBManager.h"
48 #include <TApplication.h>
49 #include <TGDimension.h>
52 #include <TGTextEntry.h>
55 #include <TGImageMap.h>
56 #include <TGTextBuffer.h>
59 ClassImp(AliMUONTriggerGUI)
62 //__________________________________________________________________________
63 AliMUONTriggerGUI::AliMUONTriggerGUI()
90 /// main GUI frame of the trigger monitor
99 fFileName = new TString("");
100 fEvString = new TString("");
101 fPath = new TString("");
103 fTriggerProcessor = 0;
105 fCDBManager = AliCDBManager::Instance();
106 fCDBManager->SetDefaultStorage("local://$ALICE_ROOT");
107 fCalibrationData = new AliMUONCalibrationData(0); // runnumber zero
111 fMain = new TGMainFrame(gClient->GetRoot(), 750, 420);
112 fMain->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseWindow()");
116 TGMenuBar *menuBar = new TGMenuBar(fMain);
120 TGPopupMenu *menuFile = new TGPopupMenu(gClient->GetRoot());
121 //menuFile->AddLabel("");
123 menuFile->AddEntry("Run", kMFILERUN);
124 menuFile->AddEntry("Control", kMFILECNTRL);
125 menuFile->AddEntry("Exit", kMFILEEXIT);
127 menuFile->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this, "HandleMenu(Int_t)");
131 TGPopupMenu *menuCircuit = new TGPopupMenu(gClient->GetRoot());
132 //menuCircuit->AddLabel("");
134 menuCircuit->AddEntry("Open", kMCIRCUITOPEN);
136 menuCircuit->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this, "HandleMenu(Int_t)");
140 TGPopupMenu *menuMap = new TGPopupMenu(gClient->GetRoot());
141 //menuMap->AddLabel("");
143 menuMap->AddEntry("Digits map", kMMAPDIGITS);
144 menuMap->AddEntry("Reset digits", kMRESETDIGITS);
146 menuMap->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this,
147 "HandleMenu(Int_t)");
151 TGPopupMenu *menuTrigger = new TGPopupMenu(gClient->GetRoot());
152 //menuTrigger->AddLabel("");
154 menuTrigger->AddEntry("Trigger DSET", kMTRIGGERDSET);
156 menuTrigger->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this, "HandleMenu(Int_t)");
158 // Add menus to the menu bar
160 menuBar->AddPopup("File", menuFile,
161 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2)
164 menuBar->AddPopup("Maps", menuMap,
165 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2)
168 menuBar->AddPopup("Circuit", menuCircuit,
169 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2)
172 menuBar->AddPopup("Trigger", menuTrigger,
173 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2)
176 // Add menu bar to the main frame
178 fMain->AddFrame(menuBar,
179 new TGLayoutHints(kLHintsTop |
187 fImageMap = new TGImageMap(fMain,"$ALICE_ROOT/MUON/data/guimap.gif");
189 fImageMap->Connect("RegionClicked(Int_t)", "AliMUONTriggerGUI", this, "OpenBoard(Int_t)");
191 fImageMap->SetToolTipText("Map of the local boards as seen from the I.P.");
193 // Add image map to the main frame
195 fMain->AddFrame(fImageMap);
196 fMain->SetWindowName("Map of the local boards as seen from the I.P.");
198 // Resize the main frame
200 TGDimension size = fMain->GetDefaultSize();
203 fMain->MapSubwindows();
207 fBoardsInit = kFALSE;
209 //HandleMenu(kMFILERUN); // temporary
216 //__________________________________________________________________________
217 void AliMUONTriggerGUI::HandleMenu(Int_t id)
219 /// handles entry numbers in the available menus (EMenuIdentifiers)
221 TGCompositeFrame *runInput1, *runInput2, *runInput3;
222 TGCompositeFrame *control1, *control2, *circuit1, *circuit2;
223 TGLabel *runL1, *runL2, *circuitL1;
224 TGTextEntry *runText1, *runText2, *circuitText1;
225 TGTextButton *runApply, *runCancel;
226 TGTextButton *controlClose, *nextEvent, *previousEvent, *skipToEvent;
227 TGTextButton *circuitCancel, *circuitOpen;
229 //Int_t trigInfo[kNBoards*6] = {-1};
230 //Int_t nLocalTrigger = 0;
232 TString error = TString("");
233 if (id != kMFILEEXIT && id != kMFILERUN && fRunLoader == 0) {
234 error.Append("Run not initialized (Menu: File/Run)");
235 DoErrorGUI(error.Data());
251 fRunInput = new TGTransientFrame(gClient->GetRoot(), fMain, 400, 200);
252 fRunInput->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseRunInput()");
253 fRunInput->DontCallClose(); // to avoid double deletions.
255 // use hierarchical cleaning
256 fRunInput->SetCleanup(kDeepCleanup);
258 fRunInput->SetWindowName("Input file and event number");
260 // input galice and event number frames
262 runInput1 = new TGCompositeFrame(fRunInput, 400, 200, kHorizontalFrame);
263 runInput2 = new TGCompositeFrame(fRunInput, 400, 200, kHorizontalFrame);
267 runL1 = new TGLabel(runInput1, new TGString("Path to gAlice:"));
268 runL2 = new TGLabel(runInput2, new TGString("Event number:"));
272 runText1 = new TGTextEntry(runInput1, fTxtBuffer1 = new TGTextBuffer(100));
274 //fPath->Append("dset"); // temporary
275 //fTxtBuffer1->AddText(0,fPath->Data()); // temporary
277 runText1->SetToolTipText("Enter the path to galice.root");
278 runText1->Resize(300, runText1->GetDefaultHeight());
280 // event number text entry
282 runText2 = new TGTextEntry(runInput2, fTxtBuffer2 = new TGTextBuffer(5));
284 fEvString->Form("%d",0);
285 fTxtBuffer2->AddText(0,fEvString->Data());
287 runText2->SetToolTipText("Enter the first event number to start with");
288 runText2->Resize(300, runText2->GetDefaultHeight());
290 // add to galice frame
292 runInput1->AddFrame(runL1,
293 new TGLayoutHints(kLHintsLeft |
298 runInput1->AddFrame(runText1,
299 new TGLayoutHints(kLHintsRight |
304 // add to event number frame
306 runInput2->AddFrame(runL2,
307 new TGLayoutHints(kLHintsLeft |
312 runInput2->AddFrame(runText2,
313 new TGLayoutHints(kLHintsRight |
318 // add input frames to main input frame
320 fRunInput->AddFrame(runInput1,
321 new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
323 fRunInput->AddFrame(runInput2,
324 new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
326 // frame with buttons
328 runInput3 = new TGCompositeFrame(fRunInput, 400, 200, kHorizontalFrame);
332 runApply = new TGTextButton(runInput3, "Apply", 1);
333 runApply->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoRunApply()");
334 runApply->SetToolTipText("Apply changes");
336 runCancel = new TGTextButton(runInput3, "Cancel", 2);
337 runCancel->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoRunCancel()"); runCancel->SetToolTipText("Cancel changes");
341 runInput3->AddFrame(runApply,
342 new TGLayoutHints(kLHintsTop |
347 runInput3->AddFrame(runCancel,
348 new TGLayoutHints(kLHintsTop |
353 // add to the main input frame
355 fRunInput->AddFrame(runInput3,
356 new TGLayoutHints(kLHintsTop |
361 fRunInput->MapSubwindows();
363 fRunInput->MapWindow();
365 //DoRunApply(); // temporary
371 // control main frame
373 fControl = new TGTransientFrame(gClient->GetRoot(), fMain, 50, 50);
374 fControl->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseControl()");
375 fControl->DontCallClose(); // to avoid double deletions.
377 // use hierarchical cleaning
378 fControl->SetCleanup(kDeepCleanup);
380 fControl->SetWindowName("Run controls");
382 // frame to hold buttons
384 control1 = new TGCompositeFrame(fControl, 50, 50, kVerticalFrame);
388 controlClose = new TGTextButton(control1, "Close", 1);
389 controlClose->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoControlClose()");
390 //controlClose->Resize(300, controlClose->GetDefaultHeight());
392 nextEvent = new TGTextButton(control1, "Next event", 2);
393 nextEvent->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoNextEvent()");
395 previousEvent = new TGTextButton(control1, "Previous event", 3);
396 previousEvent->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoPreviousEvent()");
398 // frame to hold event skip
400 control2 = new TGCompositeFrame(fControl, 50, 50, kHorizontalFrame);
402 // skip to event text field
404 fSkipToEventTxt = new TGTextEntry(control2, fTxtBuffer2 = new TGTextBuffer(5));
406 fTxtBuffer2->AddText(0,fEvString->Data());
408 // skip to event button
410 skipToEvent = new TGTextButton(control2, "Skip to event", 1);
411 skipToEvent->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoSkipToEvent()");
413 // add to event skip frame
415 control2->AddFrame(fSkipToEventTxt,
416 new TGLayoutHints(kLHintsTop |
421 control2->AddFrame(skipToEvent,
422 new TGLayoutHints(kLHintsTop |
429 control1->AddFrame(controlClose,
430 new TGLayoutHints(kLHintsBottom |
435 control1->AddFrame(nextEvent,
436 new TGLayoutHints(kLHintsBottom |
441 control1->AddFrame(previousEvent,
442 new TGLayoutHints(kLHintsBottom |
447 // add to the main frame
449 fControl->AddFrame(control1,
450 new TGLayoutHints(kLHintsBottom |
456 fControl->AddFrame(control2,
457 new TGLayoutHints(kLHintsTop |
462 fControl->MapSubwindows();
464 fControl->MapWindow();
471 fDiMap = new AliMUONTriggerGUIdimap(fLoader,fBoards,gClient->GetRoot(), fMain, 400, 200);
472 } else if (!fDiMap->IsOn()) {
473 fDiMap = new AliMUONTriggerGUIdimap(fLoader,fBoards,gClient->GetRoot(), fMain, 400, 200);
480 Int_t number, over, pos;
481 for (Int_t ib = 0; ib < kNBoards; ib++) {
482 AliMUONTriggerGUIboard *board = GetBoard(ib);
483 board->ClearXDigits();
484 board->ClearYDigits();
486 number = board->GetNumber();
487 pos = board->GetPosition();
488 over = board->GetYOver();
489 for (Int_t io = 1; io <= over; io++) {
490 if (io == pos) continue;
491 board = GetBoard(number+io-pos);
492 board->ClearYDigits();
500 fCircuit = new TGTransientFrame(gClient->GetRoot(), fMain, 50, 50);
501 fCircuit->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseCircuit()");
502 fCircuit->DontCallClose(); // to avoid double deletions.
504 // use hierarchical cleaning
505 fCircuit->SetCleanup(kDeepCleanup);
507 fCircuit->SetWindowName("Board circuit");
511 circuit1 = new TGCompositeFrame(fCircuit, 400, 200, kHorizontalFrame);
512 circuit2 = new TGCompositeFrame(fCircuit, 400, 200, kHorizontalFrame);
516 circuitL1 = new TGLabel(circuit1, new TGString("Circuit number:"));
520 circuitText1 = new TGTextEntry(circuit1, fTxtCircuit = new TGTextBuffer(10));
523 circuitCancel = new TGTextButton(circuit2, "Cancel", 1);
524 circuitCancel->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoCircuitCancel()");
525 //circuitCancel->Resize(100, circuitCancel->GetDefaultHeight());
527 circuitOpen = new TGTextButton(circuit2, "Open", 2);
528 circuitOpen->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoCircuitOpen()");
529 //circuitOpen->Resize(100, circuitOpen->GetDefaultHeight());
533 circuit1->AddFrame(circuitL1,
534 new TGLayoutHints(kLHintsLeft |
539 circuit1->AddFrame(circuitText1,
540 new TGLayoutHints(kLHintsRight |
545 circuit2->AddFrame(circuitCancel,
546 new TGLayoutHints(kLHintsBottom |
551 circuit2->AddFrame(circuitOpen,
552 new TGLayoutHints(kLHintsBottom |
557 fCircuit->AddFrame(circuit1,
558 new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
560 fCircuit->AddFrame(circuit2,
561 new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
563 fCircuit->MapSubwindows();
565 fCircuit->MapWindow();
571 cout << "Trigger with boards digits....." << endl;
572 fTriggerProcessor->FeedBoardsGUI(Boards());
574 nLocalTrigger = fTriggerProcessor->TriggerGUI(trigInfo,kTRUE);
576 cout << "Trigger done with " << nLocalTrigger << " local decisions !" << endl;
578 for (Int_t ilo = 0; ilo < nLocalTrigger; ilo++) {
580 cout << "Local decision " << ilo << endl;
581 cout << "Circuit = " << trigInfo[6*ilo+0] << endl;
582 cout << "LoStripX = " << trigInfo[6*ilo+1] << endl;
583 cout << "LoStripY = " << trigInfo[6*ilo+2] << endl;
584 cout << "LoDev = " << trigInfo[6*ilo+3] << endl;
585 cout << "LoLpt = " << trigInfo[6*ilo+4] << endl;
586 cout << "LoHpt = " << trigInfo[6*ilo+5] << endl;
593 printf("Menu item %d selected\n", id);
600 //__________________________________________________________________________
601 void AliMUONTriggerGUI::CloseRunInput() const
603 /// close the run input frame
609 //__________________________________________________________________________
610 void AliMUONTriggerGUI::CloseError() const
612 /// close the error frame
618 //__________________________________________________________________________
619 void AliMUONTriggerGUI::CloseControl() const
621 /// close the event control frame
625 //gSystem->Exec("cd $PWD/mtrun; aliroot -b -q mtsim.C");
629 //__________________________________________________________________________
630 void AliMUONTriggerGUI::CloseCircuit() const
632 /// close the circuit frame
638 //__________________________________________________________________________
639 void AliMUONTriggerGUI::CloseWindow()
641 /// close the main frame and exit aplication
645 gApplication->Terminate();
649 //__________________________________________________________________________
650 void AliMUONTriggerGUI::DoRunApply()
652 /// apply changes in the run control frame
654 printf("Input 1 = %s \n",fTxtBuffer1->GetString());
656 TString es = TString(fTxtBuffer2->GetString());
659 printf("Input 2 = %s event = %d \n",fTxtBuffer2->GetString(),fEvent);
661 TString error = TString("");;
663 fPath->Form("%s",fTxtBuffer1->GetString());
664 fFileName->Form("%s",fTxtBuffer1->GetString());
665 printf("File location: %s \n",fFileName->Data());
667 if (gSystem->AccessPathName(fFileName->Data()) || !fFileName->EndsWith(".root")) {
669 error.Append("No galice file: ");
670 error.Append(fFileName->Data());
671 DoErrorGUI(error.Data());
675 TFile *ftest = new TFile(fFileName->Data(),"READ");
676 AliRun *galice = (AliRun*)ftest->Get("gAlice");
682 error.Append("No gAlice in file: ");
683 error.Append(fFileName->Data());
684 DoErrorGUI(error.Data());
693 if (fRunLoader) delete fRunLoader;
695 fRunLoader = AliRunLoader::Open(fFileName->Data(),"MUONFolder","READ");
697 if (fRunLoader == 0x0) {
699 DoErrorGUI("No run loader !");
703 fRunLoader->LoadgAlice();
704 gAlice = fRunLoader->GetAliRun();
705 fEventsPerRun = gAlice->GetEventsPerRun();
707 fLoader = fRunLoader->GetLoader("MUONLoader");
708 fLoader->LoadDigits("READ");
709 fRunLoader->GetEvent(fEvent);
711 fRunInput->SendCloseMessage();
718 if (fDiMap->IsOn()) {
719 fDiMap->SetLoader(fLoader);
723 //fTriggerProcessor = new AliMUONTriggerElectronics(fCalibrationData);
730 //__________________________________________________________________________
731 void AliMUONTriggerGUI::DoRunCancel()
733 /// cancel the changes in the run control frame
735 printf("Input 1 = %s \n",fTxtBuffer1->GetString());
737 TString es = TString(fTxtBuffer2->GetString());
740 printf("Input 2 = %s event = %d \n",fTxtBuffer2->GetString(),fEvent);
742 fRunInput->SendCloseMessage();
746 //__________________________________________________________________________
747 void AliMUONTriggerGUI::DoErrorGUI(const Char_t *wt)
749 /// show an error message in a new frame
751 fError = new TGTransientFrame(gClient->GetRoot(), fMain, 50, 50);
752 fError->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseError()");
753 fError->DontCallClose(); // to avoid double deletions.
755 // use hierarchical cleaning
756 fError->SetCleanup(kDeepCleanup);
758 fError->SetWindowName("Error !");
760 TGCompositeFrame *fW = new TGCompositeFrame(fError, 50, 50, kVerticalFrame);
762 TGTextButton *fErrorOK = new TGTextButton(fW, "&Ok", 1);
763 fErrorOK->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoErrorOK()");
765 fW->AddFrame(fErrorOK,
766 new TGLayoutHints(kLHintsBottom |
771 TGLabel *fWL = new TGLabel(fW, new TGString(wt));
774 new TGLayoutHints(kLHintsTop |
780 new TGLayoutHints(kLHintsLeft |
785 fError->MapSubwindows();
791 //__________________________________________________________________________
792 void AliMUONTriggerGUI::DoNextEvent()
794 /// load next event from the file
796 TString error = TString("");
798 if (fEvent < (fEventsPerRun-1)) {
800 fRunLoader->GetEvent(fEvent);
802 fEvString->Form("%d",fEvent);
803 fTxtBuffer2->RemoveText(0,5);
804 fTxtBuffer2->AddText(0,fEvString->Data());
805 fSkipToEventTxt->SetFocus();
808 error.Form("Only %d event(s) in the run !",fEventsPerRun);
809 DoErrorGUI(error.Data());
814 //__________________________________________________________________________
815 void AliMUONTriggerGUI::DoPreviousEvent()
817 /// load previous event from the input file
819 TString error = TString("");
823 fRunLoader->GetEvent(fEvent);
825 fEvString->Form("%d",fEvent);
826 fTxtBuffer2->RemoveText(0,5);
827 fTxtBuffer2->AddText(0,fEvString->Data());
828 fSkipToEventTxt->SetFocus();
831 error.Form("Already at event 0 !");
832 DoErrorGUI(error.Data());
837 //__________________________________________________________________________
838 void AliMUONTriggerGUI::DoSkipToEvent()
840 /// skip to event -input- from the input file
842 TString error = TString("");
844 TString es = TString(fTxtBuffer2->GetString());
847 if (fEvent < 0 || fEvent > (fEventsPerRun-1)) {
848 error.Form("Event number out of range !");
849 DoErrorGUI(error.Data());
851 fRunLoader->GetEvent(fEvent);
853 fRunLoader->LoadKinematics();
855 AliStack* stack = gAlice->Stack();
856 Int_t nParticles = stack->GetNtrack();
857 Int_t nPrimaries = stack->GetNprimary();
862 Double_t px, py, pz, theta, phi;
863 for (Int_t i = 0; i < nPrimaries; i++) {
864 part = stack->Particle(i);
866 if (TMath::Abs(part->GetPdgCode()) == 13) {
868 pdgCode = part->GetPdgCode();
872 theta = part->Theta();
874 printf("Kine %d px %f py %f pz %f th %f ph %f \n",pdgCode,px,py,pz,theta,phi);
882 //__________________________________________________________________________
883 void AliMUONTriggerGUI::DoErrorOK()
885 /// close the error frame
887 fError->SendCloseMessage();
891 //__________________________________________________________________________
892 void AliMUONTriggerGUI::DoControlClose()
894 /// close the event control frame
896 fControl->SendCloseMessage();
900 //__________________________________________________________________________
901 void AliMUONTriggerGUI::DoCircuitCancel()
903 /// close the circuit frame
905 fCircuit->SendCloseMessage();
909 //__________________________________________________________________________
910 void AliMUONTriggerGUI::DoCircuitOpen()
914 TString cs = TString(fTxtCircuit->GetString());
915 Int_t icirc = cs.Atoi();
917 AliMUONTriggerGUIboard *board;
919 for (Int_t ib = 0; ib < kNBoards; ib++) {
921 board = GetBoard(ib);
923 if (board->GetIdCircuit() == icirc) {
928 if (fDiMap->IsOn()) {
929 fDiMap->SelectBoard(ib);
933 fCircuit->SendCloseMessage();
941 //__________________________________________________________________________
942 AliMUONTriggerGUIboard* AliMUONTriggerGUI::GetBoard(Int_t id) const
944 /// return board with "id"
946 if (fBoards == 0) return 0;
947 void * b = fBoards->UncheckedAt(id);
948 if (b == 0) return 0;
950 return (AliMUONTriggerGUIboard*)b;
954 //__________________________________________________________________________
955 void AliMUONTriggerGUI::OpenBoard(Int_t id)
957 /// open board with "id" in a new frame
959 AliMUONTriggerGUIboard *board = GetBoard(id);
960 UShort_t status = board->GetStatus();
961 board->SetOpen(kTRUE);
963 AliMUONTriggerGUIbdmap *bf;
966 bf = new AliMUONTriggerGUIbdmap(gClient->GetRoot(), fMain, 400, 200);
968 if (status & kGood) {
969 sprintf(text,"%s (Circuit %4d) status : working",
970 board->GetBoardName(),board->GetIdCircuit());
973 if (status & kWithProblems) {
974 sprintf(text,"%s (Circuit %4d) status : has problems...",
975 board->GetBoardName(),board->GetIdCircuit());
978 if (status & kNotWorking) {
979 sprintf(text,"%s (Circuit %4d) status : not working",
980 board->GetBoardName(),board->GetIdCircuit());
983 if (status & kUnknown) {
984 sprintf(text,"%s (Circuit %4d) status : unknown",
985 board->GetBoardName(),board->GetIdCircuit());
989 bf->SetBoard(Boards(),id);
990 bf->SetLoader(fLoader);
996 if (fDiMap->IsOn()) {
997 fDiMap->SelectBoard(id);
1003 //__________________________________________________________________________
1004 void AliMUONTriggerGUI::Init()
1006 /// initialize the main GUI frame
1013 AliMUONTriggerGUIboard *board;
1014 for (Int_t ib = 0; ib < kNBoards; ib++) {
1015 board = GetBoard(ib);
1021 //__________________________________________________________________________
1022 void AliMUONTriggerGUI::InitBoards()
1024 /// create board objects and define the sensitive regions in the image map
1026 fBoardsInit = kTRUE;
1028 AliMUONTriggerCrateStore* crateManager = new AliMUONTriggerCrateStore();
1029 crateManager->ReadFromFile();
1031 Int_t nPixelX = 700;
1032 Int_t nPixelY = 676;
1034 Int_t nPixelBorderX = 40; // to guess...
1035 Int_t nPixelBorderY = 40; // to guess...
1037 Float_t boardsX = 2*257.00; // cm
1038 Float_t boardsY = 2*306.61; // cm
1042 Int_t side, col, line, nbx, detElemId = 0;
1043 UShort_t status = 1;
1044 Float_t xCenter, yCenter, zCenter, xWidth, yWidth;
1046 Char_t name[8], text[200];
1051 TString mapspath = gSystem->Getenv("ALICE_ROOT");
1052 mapspath.Append("/MUON/data");
1055 AliMUONTriggerGUIboard *board;
1057 // regions for the image map
1059 sprintf(text,"%s/guimapp11.txt",mapspath.Data());
1060 fmap = fopen(text,"r");
1062 for (Int_t ib = 0; ib < kNBoards; ib++) {
1064 fscanf(fmap,"%d %d %d %d %f %f %f %f %f %s \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]);
1066 //printf("%d %d %d %d %f %f %f %f %f %s \n",side,col,line,nbx,xCenter,yCenter,xWidth,yWidth,zCenter,name);
1068 board = new AliMUONTriggerGUIboard(ib,name);
1071 board->SetStatus(status);
1073 // calculate detElemId%100
1077 if (side == 0) detElemId = 14 - line;
1078 if (side == 1 && line < 5) detElemId = 13 + line;
1079 if (side == 1 && line >= 5) detElemId = line - 5;
1081 board->SetDetElemId(detElemId);
1083 Boards()->Add(board);
1088 x = (Int_t)(nPixelX/2 + xc * (nPixelX - 2*nPixelBorderX)/boardsX);
1089 y = (Int_t)(nPixelY/2 - yc * (nPixelY - 2*nPixelBorderY)/boardsY);
1094 w = (UInt_t)(xWidth*(nPixelX-2*nPixelBorderX)/boardsX);
1095 h = (UInt_t)(yWidth*(nPixelY-2*nPixelBorderY)/boardsY);
1109 reg = new TGRegion(5,xp,yp);
1110 fImageMap->AddRegion(*reg, ib);
1112 if (status & kGood) {
1113 sprintf(text,"%s working",name);
1115 if (status & kWithProblems) {
1116 sprintf(text,"%s has problems...",name);
1118 if (status & kNotWorking) {
1119 sprintf(text,"%s not working",name);
1121 if (status & kUnknown) {
1122 sprintf(text,"%s status unknown",name);
1125 //fImageMap->SetToolTipText(ib, text);
1131 // MT position and dimension in board
1133 for (Int_t imt = 0; imt < kNMT; imt++) {
1135 sprintf(text,"%s/guimapp%2d.txt",mapspath.Data(),11+imt);
1137 fmap = fopen(text,"r");
1139 for (Int_t ib = 0; ib < kNBoards; ib++) {
1141 fscanf(fmap,"%d %d %d %d %f %f %f %f %f %s \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]);
1143 board = GetBoard(ib);
1144 board->SetDimensions(imt,xCenter,yCenter,zCenter,xWidth,yWidth);
1152 // MT x-strips indices and circuit number
1153 Int_t ix, iy1, iy2, sIx, sIy1, cathode, icirc;
1154 sprintf(text,"%s/guimapix11.txt",mapspath.Data());
1156 fmap = fopen(text,"r");
1158 for (Int_t ib = 0; ib < kNBoards; ib++) {
1160 fscanf(fmap,"%d %d %d %d %d %d %d %s \n",&side,&col,&line,&nbx,&ix,&iy1,&iy2,&name[0]);
1162 board = GetBoard(ib);
1163 board->SetXSindex(ix,iy1,iy2);
1165 // set the circuit number
1166 detElemId = board->GetDetElemId();
1167 detElemId += 100 * 11;
1169 sIx = board->GetXSix();
1170 sIy1 = board->GetXSiy1();
1171 const AliMpVSegmentation* seg =
1172 AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode));
1174 AliMpPad pad = seg->PadByIndices(AliMpIntPair(sIx,sIy1),kTRUE);
1175 AliMpIntPair location = pad.GetLocation(0);
1177 Int_t nboard = location.GetFirst();
1178 AliMUONLocalTriggerBoard* b = crateManager->LocalBoard(nboard);
1179 icirc = b->GetNumber();
1180 board->SetBoardName((Char_t*)b->GetName());
1181 board->SetIdCircuit(icirc);
1183 TString crateName = b->GetCrate();
1185 sprintf(text,"%s (crate %s circuit %3d, number %3d)",board->GetBoardName(),crateName.Data(),icirc,ib);
1186 fImageMap->SetToolTipText(ib, text);
1192 // MT y-strips indices
1195 sprintf(text,"%s/guimapiy11.txt",mapspath.Data());
1197 fmap = fopen(text,"r");
1199 for (Int_t ib = 0; ib < kNBoards; ib++) {
1201 fscanf(fmap,"%d %d %d %d %d %d %d %s \n",&side,&col,&line,&nbx,&ix1,&ix2,&iy,&name[0]);
1203 board = GetBoard(ib);
1204 board->SetYSindex(ix1,ix2,iy);
1210 // Extended y-strips over neighbouring boards
1212 sprintf(text,"%s/guimapp11.txt",mapspath.Data());
1214 fmap = fopen(text,"r");
1216 for (Int_t ib = 0; ib < kNBoards; ib++) {
1218 fscanf(fmap,"%d %d %d %d %f %f %f %f %f %s \n",&side,&col,&line,&nbx,&xCenter,&yCenter,&xWidth,&yWidth,&zCenter,&name[0]);
1220 board = GetBoard(ib);
1222 board->SetPosition(nbx);
1224 if ((col == 2 || col == 3) && (line >= 4 && line <= 6)) {
1228 if (col == 1 && (line == 4 || line == 6)) {
1232 if (col == 7 || line == 1 || line == 9) {
1244 // Set coordinates of strips boxes
1246 for (Int_t ib = 0; ib < kNBoards; ib++) {
1248 board = GetBoard(ib);
1249 SetStripBoxes(board);
1255 //__________________________________________________________________________
1256 void AliMUONTriggerGUI::SetStripBoxes(AliMUONTriggerGUIboard *board)
1258 /// set coordinates of strip boxes
1260 gAlice = fRunLoader->GetAliRun();
1261 AliMUON *pMUON = (AliMUON*)gAlice->GetModule("MUON");
1262 const AliMUONGeometryTransformer* kGeomTransformer = pMUON->GetGeometryTransformer();
1264 const AliMpVSegmentation* seg;
1268 Int_t chamber, detElemId, maxX, maxY, ic;
1269 Float_t xpmin, xpmax, ypmin, ypmax;
1270 Float_t xg1, xg2, yg1, yg2, zg1;
1271 Float_t xlocal1, xlocal2, ylocal1, ylocal2;
1272 Float_t xCenter, yCenter, xWidth, yWidth;
1274 for (Int_t i = 0; i < kNMT; i++) {
1278 xCenter = board->GetXCenter(i);
1279 yCenter = board->GetYCenter(i);
1280 xWidth = board->GetXWidth(i);
1281 yWidth = board->GetYWidth(i);
1283 for ( it.First(chamber-1); ! it.IsDone(); it.Next() ) {
1285 detElemId = it.CurrentDEId();
1287 if (detElemId%100 != board->GetDetElemId()) continue;
1289 /*---------- y-pads ic = 2 ----------*/
1292 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(ic-1));
1294 maxX = seg->MaxPadIndexX();
1295 maxY = seg->MaxPadIndexY();
1297 for (Int_t ix = 0; ix <= maxX; ix++) {
1298 for (Int_t iy = 0; iy <= maxY; iy++) {
1300 pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE);
1302 if (!pad.IsValid()) continue;
1304 // get the pad position and dimensions
1305 xlocal1 = pad.Position().X();
1306 ylocal1 = pad.Position().Y();
1307 xlocal2 = pad.Dimensions().X();
1308 ylocal2 = pad.Dimensions().Y();
1310 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
1311 // (no transformation for pad dimensions)
1315 // transform in the monitor coordinate system
1316 //xpmin = -(xg1+xg2);
1317 //xpmax = -(xg1-xg2);
1318 //ypmin = -(yg2-yg1);
1319 //ypmax = +(yg2+yg1);
1331 Int_t iX1, iX2, iY, ixDig;
1332 iX1 = board->GetYSix1();
1333 iX2 = board->GetYSix2();
1334 iY = board->GetYSiy();
1335 if (ix >= iX1 && ix <= iX2 && iy == iY) {
1337 ypmin = -0.5*yWidth;
1338 ypmax = +0.5*yWidth;
1342 board->SetYDigBox(i,ixDig,(Double_t)xpmin,(Double_t)ypmin,
1343 (Double_t)xpmax,(Double_t)ypmax);
1350 /*---------- x-pads ic = 1 ----------*/
1353 seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(ic-1));
1355 maxX = seg->MaxPadIndexX();
1356 maxY = seg->MaxPadIndexY();
1358 for (Int_t ix = 0; ix <= maxX; ix++) {
1359 for (Int_t iy = 0; iy <= maxY; iy++) {
1361 pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE);
1363 if (!pad.IsValid()) continue;
1365 // get the pad position and dimensions
1366 xlocal1 = pad.Position().X();
1367 ylocal1 = pad.Position().Y();
1368 xlocal2 = pad.Dimensions().X();
1369 ylocal2 = pad.Dimensions().Y();
1371 kGeomTransformer->Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
1372 // (no transformation for pad dimensions)
1376 // transform in the monitor coordinate system
1377 //xpmin = -(xg1+xg2);
1378 //xpmax = -(xg1-xg2);
1379 //ypmin = -(yg2-yg1);
1380 //ypmax = +(yg2+yg1);
1392 Int_t iX, iY1, iY2, iyDig;
1393 iX = board->GetXSix();
1394 iY1 = board->GetXSiy1();
1395 iY2 = board->GetXSiy2();
1396 if (ix == iX && iy >= iY1 && iy <= iY2) {
1400 board->SetXDigBox(i,iyDig,(Double_t)xpmin,(Double_t)ypmin,
1401 (Double_t)xpmax,(Double_t)ypmax);