LCOV - code coverage report
Current view: top level - MUON/MUONevaluation - AliMUONTriggerGUI.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 963 0.1 %
Date: 2016-06-14 17:26:59 Functions: 1 41 2.4 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       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             :  **************************************************************************/
      15             : 
      16             : // $Id$
      17             : 
      18             : //-----------------------------------------------------------------------------
      19             : /// \class AliMUONTriggerGUI
      20             : /// Graphical User Interface utility class for the MUON trigger detector
      21             : /// It creates, after initialisation with a data file, a sensitive map
      22             : /// of the trigger boards
      23             : /// \author Bogdan Vulpescu, LPC Clermont-Ferrand
      24             : //-----------------------------------------------------------------------------
      25             : 
      26             : #include "AliMUONTriggerGUI.h"
      27             : #include "AliMUONTriggerGUIboard.h"
      28             : #include "AliMUONTriggerGUIdimap.h"
      29             : #include "AliMUONTriggerGUIbdmap.h"
      30             : 
      31             : #include "AliMpDDLStore.h"
      32             : #include "AliMpSegmentation.h"
      33             : #include "AliMpVSegmentation.h"
      34             : #include "AliMpTriggerSegmentation.h"
      35             : #include "AliMpEncodePair.h"
      36             : #include "AliMpCDB.h"
      37             : #include "AliMpDEManager.h"
      38             : #include "AliMpDEIterator.h"
      39             : 
      40             : #include "AliMUONGeometryTransformer.h"
      41             : #include "AliMUONTriggerCrateStore.h"
      42             : #include "AliMUONLocalTriggerBoard.h"
      43             : #include "AliMUONTriggerElectronics.h"
      44             : #include "AliMUONCalibrationData.h"
      45             : #include "AliMUONMCDataInterface.h"
      46             : #include "AliMUONDigitStoreV1.h"
      47             : #include "AliMUONDigitStoreV2R.h"
      48             : #include "AliMUONTriggerStoreV1.h"
      49             : #include "AliMUONLocalTrigger.h"
      50             : #include "AliMUONRawWriter.h"
      51             : #include "AliMUONDigitMaker.h"
      52             : #include "AliMUONGlobalTrigger.h"
      53             : 
      54             : #include "AliRun.h"
      55             : #include "AliDAQ.h"
      56             : #include "AliRunLoader.h"
      57             : #include "AliCDBManager.h"
      58             : #include "AliRawDataHeaderSim.h"
      59             : #include "AliRawReader.h"
      60             : 
      61             : #include <TSystem.h>
      62             : #include <TGLabel.h>
      63             : #include <TGFrame.h>
      64             : #include <TApplication.h>
      65             : #include <TGDimension.h>
      66             : #include <TString.h>
      67             : #include <TGMenu.h>
      68             : #include <TGTextEntry.h>
      69             : #include <TGButton.h>
      70             : #include <TFile.h>
      71             : #include <TGImageMap.h>
      72             : #include <TGTextBuffer.h>
      73             : 
      74             : #include <cstdio>
      75             : 
      76             : /// \cond CLASSIMP
      77          16 : ClassImp(AliMUONTriggerGUI)
      78             : /// \endcond
      79             : 
      80             : //__________________________________________________________________________
      81             : AliMUONTriggerGUI::AliMUONTriggerGUI(Int_t runNumber)
      82           0 :   : TObject(),
      83           0 :     fMain(0),
      84           0 :     fImageMap(0),
      85           0 :     fTxtBuffer1(0),
      86           0 :     fTxtBuffer2(0),
      87           0 :     fTxtCircuit(0),
      88           0 :     fTxtFETRegOn(0),
      89           0 :     fTxtFETRegOff(0),
      90           0 :     fRunInput(0),
      91           0 :     fError(0),
      92           0 :     fControl(0),
      93           0 :     fCircuit(0),
      94           0 :     fFETRegOn(0),
      95           0 :     fFETRegOff(0),
      96           0 :     fSkipToEventTxt(0),
      97           0 :     fFileName(0),
      98           0 :     fPath(0),
      99           0 :     fEvString(0),
     100           0 :     fChamber(0),
     101           0 :     fEvent(0),
     102           0 :     fEventsPerRun(0),
     103           0 :     fLoader(0),
     104           0 :     fRunLoader(0),
     105           0 :     fCDBManager(0),
     106           0 :     fCalibrationData(0),
     107           0 :     fCrateManager(0),
     108           0 :     fMCDataInterface(0),
     109           0 :     fBoardsInit(0),
     110           0 :     fControlOn(kFALSE),
     111           0 :     fDiMap(0),
     112           0 :     fTriggerProcessor(0),
     113           0 :     fBoards(0),
     114           0 :     fDigitStore(0),
     115           0 :     fTriggerStore(0),
     116           0 :     fTStoreOn(kFALSE),
     117           0 :     fRUNRAW(kFALSE),
     118           0 :     fRawReader(0),
     119           0 :     fCurrentRawEvent(-1),
     120           0 :     fRawDigitStore(0),
     121           0 :     fRawTriggerStore(0)
     122           0 : {
     123             :   /// main GUI frame of the trigger monitor
     124             : 
     125           0 :   fChamber = 0;
     126           0 :   fEvent   = 0;
     127           0 :   fEventsPerRun = 0;
     128           0 :   fRunLoader = 0;
     129           0 :   fDiMap = 0;
     130             : 
     131           0 :   fBoards = 0;
     132           0 :   fFileName = new TString("");
     133           0 :   fEvString = new TString("");
     134           0 :   fPath = new TString("");
     135             : 
     136           0 :   fDigitStore = new AliMUONDigitStoreV2R;
     137           0 :   fDigitStore->Create();
     138             : 
     139           0 :   fTriggerStore = new AliMUONTriggerStoreV1;
     140           0 :   fTriggerStore->Create();
     141             : 
     142           0 :   fRawDigitStore = new AliMUONDigitStoreV1;
     143           0 :   fRawDigitStore->Create();
     144             : 
     145           0 :   fRawTriggerStore = new AliMUONTriggerStoreV1;
     146           0 :   fRawTriggerStore->Create();
     147             : 
     148           0 :   fCDBManager = AliCDBManager::Instance();
     149           0 :   fCDBManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
     150           0 :   fCDBManager->SetRun(runNumber);
     151           0 :   AliMpCDB::LoadDDLStore();
     152           0 :   fCalibrationData = new AliMUONCalibrationData(runNumber);
     153             :   
     154           0 :   fTriggerProcessor = new AliMUONTriggerElectronics(fCalibrationData);
     155             : 
     156             :   // Main frame
     157             : 
     158           0 :   fMain = new TGMainFrame(gClient->GetRoot(), 750, 420);
     159           0 :   fMain->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseWindow()");
     160             : 
     161             :   // Menu bar
     162             :   
     163           0 :   TGMenuBar *menuBar = new TGMenuBar(fMain);
     164             :   
     165             :   // File menu
     166             : 
     167           0 :   TGPopupMenu *menuFile = new TGPopupMenu(gClient->GetRoot());
     168             :   //menuFile->AddLabel("");
     169             : 
     170           0 :   menuFile->AddEntry("Run input", kMFILERUN);
     171           0 :   menuFile->AddEntry("Control",   kMFILECNTRL);
     172           0 :   menuFile->AddEntry("Exit",      kMFILEEXIT);
     173             : 
     174           0 :   menuFile->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this, "HandleMenu(Int_t)");
     175             : 
     176             :   // Circuit menu
     177             : 
     178           0 :   TGPopupMenu *menuCircuit = new TGPopupMenu(gClient->GetRoot());
     179             :   //menuCircuit->AddLabel("");
     180             : 
     181           0 :   menuCircuit->AddEntry("Open",     kMCIRCUITOPEN);
     182             : 
     183           0 :   menuCircuit->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this, "HandleMenu(Int_t)");
     184             : 
     185             :   // Digits map menu
     186             : 
     187           0 :   TGPopupMenu *menuMap = new TGPopupMenu(gClient->GetRoot());
     188             :   //menuMap->AddLabel("");
     189             : 
     190           0 :   menuMap->AddEntry("Digits map",   kMMAPDIGITS);
     191           0 :   menuMap->AddEntry("Reset digits", kMRESETDIGITS);
     192             : 
     193           0 :   menuMap->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this,
     194             :                     "HandleMenu(Int_t)");
     195             : 
     196             :   // Trigger menu
     197             : 
     198           0 :   TGPopupMenu *menuTrigger = new TGPopupMenu(gClient->GetRoot());
     199             : 
     200           0 :   TGPopupMenu *menuTriggerD = new TGPopupMenu(gClient->GetRoot());
     201           0 :   TGPopupMenu *menuTriggerT = new TGPopupMenu(gClient->GetRoot());
     202           0 :   TGPopupMenu *menuTriggerF = new TGPopupMenu(gClient->GetRoot());
     203             : 
     204           0 :   menuTrigger->AddPopup("Digit store",       menuTriggerD);
     205           0 :   menuTrigger->AddSeparator();
     206           0 :   menuTrigger->AddPopup("Trigger store",menuTriggerT);
     207           0 :   menuTrigger->AddSeparator();
     208           0 :   menuTrigger->AddPopup("Front End Test",    menuTriggerF);
     209           0 :   menuTrigger->AddSeparator();
     210             : 
     211           0 :   menuTriggerD->AddEntry("Create", kMDSTORE);
     212           0 :   menuTriggerD->AddEntry("Print",  kMDSTOREP);
     213           0 :   menuTriggerD->AddEntry("Clear",  kMDSTORECL);
     214           0 :   menuTriggerT->AddEntry("Create", kMTSTORE);
     215           0 :   menuTriggerT->AddEntry("Print",  kMTSTOREP);
     216           0 :   menuTriggerT->AddEntry("Clear",  kMTSTORECL);
     217           0 :   menuTriggerF->AddEntry("On",     kMFETON);
     218           0 :   menuTriggerF->AddEntry("Off",    kMFETOFF);
     219           0 :   menuTriggerF->AddEntry("Reg On", kMFETREGON);
     220           0 :   menuTriggerF->AddEntry("Reg Off",kMFETREGOFF);
     221           0 :   menuTrigger->AddEntry("Write raw data", kMTRAWDATA);
     222             : 
     223           0 :   menuTrigger->Connect("Activated(Int_t)", "AliMUONTriggerGUI", this, "HandleMenu(Int_t)");
     224             : 
     225             :   // Add menus to the menu bar
     226             : 
     227           0 :   menuBar->AddPopup("File", menuFile, 
     228           0 :                     new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2)
     229             :                     );
     230             : 
     231           0 :   menuBar->AddPopup("Maps", menuMap, 
     232           0 :                     new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2)
     233             :                     );
     234             : 
     235           0 :   menuBar->AddPopup("Circuit", menuCircuit, 
     236           0 :                     new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2)
     237             :                     );
     238             : 
     239           0 :   menuBar->AddPopup("TriggerDSET", menuTrigger, 
     240           0 :                     new TGLayoutHints(kLHintsTop | kLHintsLeft, 5,5,2,2)
     241             :                     );
     242             : 
     243             :   // Add menu bar to the main frame
     244             : 
     245           0 :   fMain->AddFrame(menuBar,
     246           0 :                   new TGLayoutHints(kLHintsTop | 
     247             :                                     kLHintsLeft | 
     248             :                                     kLHintsExpandX, 
     249             :                                     0, 0, 1, 1)
     250             :                   );
     251             :  
     252             :   // The image map
     253             : 
     254           0 :   fImageMap = new TGImageMap(fMain,"$ALICE_ROOT/MUON/data/guimap.gif");
     255             :   
     256           0 :   fImageMap->Connect("RegionClicked(Int_t)", "AliMUONTriggerGUI", this, "OpenBoard(Int_t)");
     257             : 
     258           0 :   fImageMap->SetToolTipText("Map of the local boards as seen from the I.P.");
     259             : 
     260             :   // Add image map to the main frame
     261             : 
     262           0 :   fMain->AddFrame(fImageMap);
     263           0 :   fMain->SetWindowName("Map of the local boards as seen from the I.P.");
     264             : 
     265             :   // Resize the main frame
     266             :   
     267           0 :   TGDimension size = fMain->GetDefaultSize();
     268           0 :   fMain->Resize(size);
     269             : 
     270           0 :   fMain->MapSubwindows();
     271             : 
     272           0 :   fMain->MapWindow();
     273             : 
     274           0 :   fBoardsInit = kFALSE;
     275             : 
     276           0 :   InitBoards();
     277             :   
     278           0 : }
     279             : 
     280             : //__________________________________________________________________________
     281             : void AliMUONTriggerGUI::HandleMenu(Int_t id)
     282             : {
     283             :   /// handles entry numbers in the available menus (EMenuIdentifiers)
     284             : 
     285             :   TGCompositeFrame *runInput1, *runInput2, *runInput3;
     286             :   TGCompositeFrame *control1, *control2, *circuit1, *circuit2;
     287             :   TGCompositeFrame *fetregon1, *fetregon2;
     288             :   TGCompositeFrame *fetregoff1, *fetregoff2;
     289             :   TGLabel *runL1, *runL2, *circuitL1, *fetregonL1, *fetregoffL1;
     290             :   TGTextEntry *runText1, *runText2, *circuitText1;
     291             :   TGTextEntry *fetregonText1, *fetregoffText1;
     292             :   TGTextButton *runApply1, *runApply2, *runCancel; 
     293             :   TGTextButton *controlClose, *nextEvent, *previousEvent, *skipToEvent;
     294             :   TGTextButton *circuitCancel, *circuitOpen;
     295             :   TGTextButton *fetregonCancel, *fetregoffCancel;
     296             :   TGTextButton *fetregonRun, *fetregoffRun;
     297             : 
     298           0 :   switch (id) {
     299             : 
     300             :   case kMFILEEXIT:
     301             : 
     302           0 :     printf("\nBye. \n");
     303           0 :     CloseWindow();
     304           0 :     break;
     305             :     
     306             :   case kMFILERUN:
     307             : 
     308             :     // input main frame
     309             : 
     310           0 :     fRunInput = new TGTransientFrame(gClient->GetRoot(), fMain, 400, 200);
     311           0 :     fRunInput->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseRunInput()");
     312           0 :     fRunInput->DontCallClose(); // to avoid double deletions.
     313             : 
     314             :     // use hierarchical cleaning
     315           0 :     fRunInput->SetCleanup(kDeepCleanup);
     316             : 
     317           0 :     fRunInput->SetWindowName("Input file and event number");
     318             : 
     319             :     // input galice and event number frames
     320             : 
     321           0 :     runInput1 = new TGCompositeFrame(fRunInput, 400, 200, kHorizontalFrame);
     322           0 :     runInput2 = new TGCompositeFrame(fRunInput, 400, 200, kHorizontalFrame);
     323             : 
     324             :     // .. with labels
     325             : 
     326           0 :     runL1 = new TGLabel(runInput1, new TGString("Full file path:"));
     327           0 :     runL2 = new TGLabel(runInput2, new TGString("Event number:"));
     328             : 
     329             :     // galice text entry
     330             : 
     331           0 :     runText1 = new TGTextEntry(runInput1, fTxtBuffer1 = new TGTextBuffer(100));
     332             : 
     333           0 :     runText1->SetToolTipText("Enter the path to galice.root or the raw data file (root)");
     334           0 :     runText1->Resize(300, runText1->GetDefaultHeight());
     335             : 
     336             :     // event number text entry
     337             : 
     338           0 :     runText2 = new TGTextEntry(runInput2, fTxtBuffer2 = new TGTextBuffer(5));
     339             : 
     340           0 :     fEvString->Form("%d",0);               
     341           0 :     fTxtBuffer2->AddText(0,fEvString->Data());
     342             : 
     343           0 :     runText2->SetToolTipText("Enter the first event number to start with");
     344           0 :     runText2->Resize(300, runText2->GetDefaultHeight());
     345             : 
     346             :     // add to galice frame
     347             : 
     348           0 :     runInput1->AddFrame(runL1,
     349           0 :                          new TGLayoutHints(kLHintsLeft | 
     350             :                                            kLHintsCenterY, 
     351             :                                            3, 5, 0, 0)
     352             :                         );
     353             : 
     354           0 :     runInput1->AddFrame(runText1, 
     355           0 :                         new TGLayoutHints(kLHintsRight | 
     356             :                                           kLHintsCenterY, 
     357             :                                           0, 2, 0, 0)
     358             :                         );
     359             : 
     360             :     // add to event number frame
     361             : 
     362           0 :     runInput2->AddFrame(runL2,
     363           0 :                          new TGLayoutHints(kLHintsLeft | 
     364             :                                            kLHintsCenterY, 
     365             :                                            3, 5, 0, 0)
     366             :                         );
     367             : 
     368           0 :     runInput2->AddFrame(runText2, 
     369           0 :                         new TGLayoutHints(kLHintsRight | 
     370             :                                           kLHintsCenterY, 
     371             :                                           0, 2, 0, 0)
     372             :                         );
     373             : 
     374             :     // add input frames to main input frame
     375             : 
     376           0 :     fRunInput->AddFrame(runInput1, 
     377           0 :                         new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
     378             :     
     379           0 :     fRunInput->AddFrame(runInput2, 
     380           0 :                         new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
     381             :     
     382             :     // frame with buttons
     383             : 
     384           0 :     runInput3 = new TGCompositeFrame(fRunInput, 400, 200, kHorizontalFrame);
     385             : 
     386             :     // buttons
     387             : 
     388           0 :     runApply1 = new TGTextButton(runInput3, "Apply (galice)", 1);
     389           0 :     runApply1->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoRunGalApply()");
     390           0 :     runApply1->SetToolTipText("Apply changes (galice input)");
     391             : 
     392           0 :     runApply2 = new TGTextButton(runInput3, "Apply (raw)", 1);
     393           0 :     runApply2->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoRunRawApply()");
     394           0 :     runApply2->SetToolTipText("Apply changes (raw data input)");
     395             : 
     396           0 :     runCancel = new TGTextButton(runInput3, "Cancel", 2);
     397           0 :     runCancel->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoRunCancel()");    
     398           0 :     runCancel->SetToolTipText("Cancel changes");
     399             : 
     400             :     // add buttons
     401             : 
     402           0 :     runInput3->AddFrame(runApply1, 
     403           0 :                          new TGLayoutHints(kLHintsTop | 
     404             :                                            kLHintsLeft, 
     405             :                                            3, 3, 2, 2)
     406             :                         );
     407             :     
     408           0 :     runInput3->AddFrame(runApply2, 
     409           0 :                          new TGLayoutHints(kLHintsTop | 
     410             :                                            kLHintsLeft, 
     411             :                                            3, 3, 2, 2)
     412             :                         );
     413             :     
     414           0 :     runInput3->AddFrame(runCancel, 
     415           0 :                          new TGLayoutHints(kLHintsTop | 
     416             :                                            kLHintsLeft, 
     417             :                                            3, 3, 2, 2)
     418             :                         );
     419             :     
     420             :     // add to the main input frame
     421             : 
     422           0 :     fRunInput->AddFrame(runInput3, 
     423           0 :                         new TGLayoutHints(kLHintsTop | 
     424             :                                           kLHintsExpandX, 
     425             :                                           2, 2, 3, 0)
     426             :                         );
     427             :     
     428           0 :     fRunInput->MapSubwindows();
     429           0 :     fRunInput->Resize();
     430           0 :     fRunInput->MapWindow();
     431             : 
     432           0 :     break;
     433             :     
     434             :   case kMFILECNTRL:
     435             : 
     436             :     // control main frame
     437             : 
     438           0 :     fControl = new TGTransientFrame(gClient->GetRoot(), fMain, 50, 50);
     439           0 :     fControl->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseControl()");
     440           0 :     fControl->DontCallClose(); // to avoid double deletions.
     441             :   
     442             :     // use hierarchical cleaning
     443           0 :     fControl->SetCleanup(kDeepCleanup);
     444             :   
     445           0 :     fControl->SetWindowName("Run controls");
     446             : 
     447             :     // frame to hold buttons
     448             : 
     449           0 :     control1 = new TGCompositeFrame(fControl, 50, 50, kVerticalFrame);
     450             :   
     451             :     // buttons
     452             : 
     453           0 :     controlClose = new TGTextButton(control1, "Close", 1);
     454           0 :     controlClose->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoControlClose()");
     455             :     //controlClose->Resize(300, controlClose->GetDefaultHeight());  
     456             : 
     457           0 :     nextEvent = new TGTextButton(control1, "Next event", 2);
     458           0 :     nextEvent->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoNextEvent()");
     459             : 
     460           0 :     previousEvent = new TGTextButton(control1, "Previous event", 3);
     461           0 :     previousEvent->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoPreviousEvent()");
     462             :   
     463             :     // frame to hold event skip
     464             : 
     465           0 :     control2 = new TGCompositeFrame(fControl, 50, 50, kHorizontalFrame);
     466             :   
     467             :     // skip to event text field
     468             : 
     469           0 :     fSkipToEventTxt = new TGTextEntry(control2, fTxtBuffer2 = new TGTextBuffer(5));
     470             : 
     471           0 :     fTxtBuffer2->AddText(0,fEvString->Data());
     472             : 
     473             :     // skip to event button
     474             : 
     475           0 :     skipToEvent = new TGTextButton(control2, "Skip to event", 1);
     476           0 :     skipToEvent->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoSkipToEvent()");
     477             : 
     478             :     // add to event skip frame
     479             : 
     480           0 :     control2->AddFrame(fSkipToEventTxt, 
     481           0 :                        new TGLayoutHints(kLHintsTop | 
     482             :                                          kLHintsRight, 
     483             :                                          10, 10, 5, 5)
     484             :                        );
     485             :   
     486           0 :     control2->AddFrame(skipToEvent, 
     487           0 :                        new TGLayoutHints(kLHintsTop | 
     488             :                                          kLHintsRight, 
     489             :                                          10, 10, 5, 5)
     490             :                        );
     491             :   
     492             :     // add buttons
     493             :   
     494           0 :     control1->AddFrame(controlClose, 
     495           0 :                  new TGLayoutHints(kLHintsBottom | 
     496             :                                    kLHintsExpandX, 
     497             :                                    10, 10, 5, 5)
     498             :                  );
     499             :   
     500           0 :     control1->AddFrame(nextEvent, 
     501           0 :                  new TGLayoutHints(kLHintsBottom | 
     502             :                                    kLHintsExpandX, 
     503             :                                    10, 10, 5, 5)
     504             :                  );
     505             :   
     506           0 :     control1->AddFrame(previousEvent, 
     507           0 :                  new TGLayoutHints(kLHintsBottom | 
     508             :                                    kLHintsExpandX, 
     509             :                                    10, 10, 5, 5)
     510             :                  );
     511             :   
     512             :     // add to the main frame
     513             : 
     514           0 :     fControl->AddFrame(control1,
     515           0 :                        new TGLayoutHints(kLHintsBottom |
     516             :                                          kLHintsLeft | 
     517             :                                          kLHintsCenterY, 
     518             :                                          3, 5, 0, 0)
     519             :                        );
     520             :     
     521           0 :     fControl->AddFrame(control2,
     522           0 :                        new TGLayoutHints(kLHintsTop | 
     523             :                                          kLHintsCenterX, 
     524             :                                          3, 5, 0, 0)
     525             :                        );
     526             :     
     527           0 :     fControl->MapSubwindows();
     528           0 :     fControl->Resize();
     529           0 :     fControl->MapWindow();
     530             : 
     531           0 :     fControlOn = kTRUE;
     532             :    
     533           0 :     break;
     534             : 
     535             :   case kMMAPDIGITS:
     536             :     
     537           0 :     if (fDiMap == 0) {
     538           0 :       fDiMap = new AliMUONTriggerGUIdimap(fBoards,gClient->GetRoot(), fMain, 400, 200);
     539           0 :       fDiMap->SetLoader(fLoader);
     540           0 :       if (fRUNRAW) {
     541           0 :         fDiMap->SetRawDigitStore(fRawDigitStore);
     542           0 :       } else {
     543           0 :         fDiMap->SetMCDataInterface(fMCDataInterface);
     544             :       }
     545           0 :       fDiMap->DrawAllMaps();
     546           0 :     } else if (!fDiMap->IsOn()) {
     547           0 :       fDiMap = new AliMUONTriggerGUIdimap(fBoards,gClient->GetRoot(), fMain, 400, 200);
     548           0 :       fDiMap->SetLoader(fLoader);
     549           0 :       if (fRUNRAW) {
     550           0 :         fDiMap->SetRawDigitStore(fRawDigitStore);
     551           0 :       } else {
     552           0 :         fDiMap->SetMCDataInterface(fMCDataInterface);
     553             :       }
     554           0 :       fDiMap->DrawAllMaps();
     555           0 :     }
     556             : 
     557             :     break;
     558             :     
     559             :   case kMRESETDIGITS:
     560             :     
     561             :     Int_t number, over, pos;
     562           0 :     for (Int_t ib = 0; ib < kNBoards; ib++) {
     563           0 :       AliMUONTriggerGUIboard *board = GetBoard(ib);
     564           0 :       board->ClearXDigits();
     565           0 :       board->ClearYDigits();
     566             :       // extended y-strips
     567           0 :       number = board->GetNumber();
     568           0 :       pos    = board->GetPosition();
     569           0 :       over   = board->GetYOver();
     570           0 :       for (Int_t io = 1; io <= over; io++) {
     571           0 :         if (io == pos) continue;
     572           0 :         board = GetBoard(number+io-pos);
     573           0 :         board->ClearYDigits();
     574           0 :       }
     575             :     }
     576             : 
     577           0 :     break;
     578             :     
     579             :   case kMCIRCUITOPEN:
     580             : 
     581           0 :     fCircuit = new TGTransientFrame(gClient->GetRoot(), fMain, 50, 50);
     582           0 :     fCircuit->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseCircuit()");
     583           0 :     fCircuit->DontCallClose(); // to avoid double deletions.
     584             :   
     585             :     // use hierarchical cleaning
     586           0 :     fCircuit->SetCleanup(kDeepCleanup);
     587             :   
     588           0 :     fCircuit->SetWindowName("Board circuit");
     589             : 
     590             :     // sub-frames
     591             : 
     592           0 :     circuit1 = new TGCompositeFrame(fCircuit, 400, 200, kHorizontalFrame);
     593           0 :     circuit2 = new TGCompositeFrame(fCircuit, 400, 200, kHorizontalFrame);
     594             : 
     595             :     // labels
     596             : 
     597           0 :     circuitL1 = new TGLabel(circuit1, new TGString("Circuit number:"));
     598             :     
     599             :     // text entry
     600             :     
     601           0 :     circuitText1 = new TGTextEntry(circuit1, fTxtCircuit = new TGTextBuffer(10));
     602             :     // buttons
     603             : 
     604           0 :     circuitCancel = new TGTextButton(circuit2, "Cancel", 1);
     605           0 :     circuitCancel->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoCircuitCancel()");
     606             :     //circuitCancel->Resize(100, circuitCancel->GetDefaultHeight());  
     607             : 
     608           0 :     circuitOpen = new TGTextButton(circuit2, "Open", 2);
     609           0 :     circuitOpen->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoCircuitOpen()");
     610             :     //circuitOpen->Resize(100, circuitOpen->GetDefaultHeight());  
     611             : 
     612             :     // adding
     613             : 
     614           0 :     circuit1->AddFrame(circuitL1,
     615           0 :                        new TGLayoutHints(kLHintsLeft | 
     616             :                                          kLHintsCenterY, 
     617             :                                          5, 5, 2, 2)
     618             :                        );
     619             :     
     620           0 :     circuit1->AddFrame(circuitText1, 
     621           0 :                        new TGLayoutHints(kLHintsRight | 
     622             :                                          kLHintsCenterY, 
     623             :                                          0, 2, 2, 2)
     624             :                        );
     625             :     
     626           0 :     circuit2->AddFrame(circuitCancel, 
     627           0 :                  new TGLayoutHints(kLHintsBottom | 
     628             :                                    kLHintsCenterY, 
     629             :                                    5, 5, 2, 2)
     630             :                  );
     631             :   
     632           0 :     circuit2->AddFrame(circuitOpen, 
     633           0 :                  new TGLayoutHints(kLHintsBottom | 
     634             :                                    kLHintsCenterY, 
     635             :                                    5, 5, 2, 2)
     636             :                  );
     637             :   
     638           0 :     fCircuit->AddFrame(circuit1, 
     639           0 :                        new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
     640             :     
     641           0 :     fCircuit->AddFrame(circuit2, 
     642           0 :                        new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
     643             :     
     644           0 :     fCircuit->MapSubwindows();
     645           0 :     fCircuit->Resize();
     646           0 :     fCircuit->MapWindow();
     647             : 
     648           0 :     break;
     649             : 
     650             :   case kMDSTORE:
     651           0 :     CreateDigitStore();
     652           0 :     break;
     653             : 
     654             :   case kMDSTOREP:
     655           0 :     PrintDigitStore();
     656           0 :     break;
     657             : 
     658             :   case kMDSTORECL:
     659           0 :     ClearDigitStore();
     660           0 :     break;
     661             : 
     662             :   case kMTSTORE:
     663           0 :     CreateTriggerStore();
     664           0 :     break;
     665             : 
     666             :   case kMTSTOREP:
     667           0 :     PrintTriggerStore();
     668           0 :     break;
     669             : 
     670             :   case kMTSTORECL:
     671           0 :     ClearTriggerStore();
     672           0 :     break;
     673             : 
     674             :   case kMTRAWDATA:
     675           0 :     WriteTriggerRawData();
     676           0 :     break;
     677             : 
     678             :   case kMFETON:
     679           0 :     FET(1);
     680           0 :     break;
     681             : 
     682             :   case kMFETOFF:
     683           0 :     FET(0);
     684           0 :     break;
     685             : 
     686             :   case kMFETREGON:
     687             : 
     688           0 :     fFETRegOn = new TGTransientFrame(gClient->GetRoot(), fMain, 50, 50);
     689           0 :     fFETRegOn->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseFETRegOn()");
     690           0 :     fFETRegOn->DontCallClose(); // to avoid double deletions.
     691             :   
     692             :     // use hierarchical cleaning
     693           0 :     fFETRegOn->SetCleanup(kDeepCleanup);
     694             :   
     695           0 :     fFETRegOn->SetWindowName("FET ON regional crate");
     696             : 
     697             :     // sub-frames
     698             : 
     699           0 :     fetregon1 = new TGCompositeFrame(fFETRegOn, 400, 200, kHorizontalFrame);
     700           0 :     fetregon2 = new TGCompositeFrame(fFETRegOn, 400, 200, kHorizontalFrame);
     701             : 
     702             :     // labels
     703             : 
     704           0 :     fetregonL1 = new TGLabel(fetregon1, new TGString("Regional crate name:"));
     705             :     
     706             :     // text entry
     707             :     
     708           0 :     fetregonText1 = new TGTextEntry(fetregon1, fTxtFETRegOn = new TGTextBuffer(10));
     709             :     // buttons
     710             : 
     711           0 :     fetregonCancel = new TGTextButton(fetregon2, "Cancel", 1);
     712           0 :     fetregonCancel->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoFETRegOnCancel()");
     713             :     //fetregonCancel->Resize(100, fetregonCancel->GetDefaultHeight());  
     714             : 
     715           0 :     fetregonRun = new TGTextButton(fetregon2, "Run FET", 2);
     716           0 :     fetregonRun->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoFETRegOnRun()");
     717             :     //fetregonRun->Resize(100, fetregonRun->GetDefaultHeight());  
     718             : 
     719             :     // adding
     720             : 
     721           0 :     fetregon1->AddFrame(fetregonL1,
     722           0 :                        new TGLayoutHints(kLHintsLeft | 
     723             :                                          kLHintsCenterY, 
     724             :                                          5, 5, 2, 2)
     725             :                        );
     726             :     
     727           0 :     fetregon1->AddFrame(fetregonText1, 
     728           0 :                        new TGLayoutHints(kLHintsRight | 
     729             :                                          kLHintsCenterY, 
     730             :                                          0, 2, 2, 2)
     731             :                        );
     732             :     
     733           0 :     fetregon2->AddFrame(fetregonCancel, 
     734           0 :                  new TGLayoutHints(kLHintsBottom | 
     735             :                                    kLHintsCenterY, 
     736             :                                    5, 5, 2, 2)
     737             :                  );
     738             :   
     739           0 :     fetregon2->AddFrame(fetregonRun, 
     740           0 :                  new TGLayoutHints(kLHintsBottom | 
     741             :                                    kLHintsCenterY, 
     742             :                                    5, 5, 2, 2)
     743             :                  );
     744             :   
     745           0 :     fFETRegOn->AddFrame(fetregon1, 
     746           0 :                        new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
     747             :     
     748           0 :     fFETRegOn->AddFrame(fetregon2, 
     749           0 :                        new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
     750             :     
     751           0 :     fFETRegOn->MapSubwindows();
     752           0 :     fFETRegOn->Resize();
     753           0 :     fFETRegOn->MapWindow();
     754             : 
     755           0 :     break;
     756             : 
     757             :   case kMFETREGOFF:
     758             : 
     759           0 :     fFETRegOff = new TGTransientFrame(gClient->GetRoot(), fMain, 50, 50);
     760           0 :     fFETRegOff->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseFETRegOff()");
     761           0 :     fFETRegOff->DontCallClose(); // to avoid double deletions.
     762             :   
     763             :     // use hierarchical cleaning
     764           0 :     fFETRegOff->SetCleanup(kDeepCleanup);
     765             :   
     766           0 :     fFETRegOff->SetWindowName("FET OFF regional crate");
     767             : 
     768             :     // sub-frames
     769             : 
     770           0 :     fetregoff1 = new TGCompositeFrame(fFETRegOff, 400, 200, kHorizontalFrame);
     771           0 :     fetregoff2 = new TGCompositeFrame(fFETRegOff, 400, 200, kHorizontalFrame);
     772             : 
     773             :     // labels
     774             : 
     775           0 :     fetregoffL1 = new TGLabel(fetregoff1, new TGString("Regional crate name:"));
     776             :     
     777             :     // text entry
     778             :     
     779           0 :     fetregoffText1 = new TGTextEntry(fetregoff1, fTxtFETRegOff = new TGTextBuffer(10));
     780             :     // buttons
     781             : 
     782           0 :     fetregoffCancel = new TGTextButton(fetregoff2, "Cancel", 1);
     783           0 :     fetregoffCancel->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoFETRegOffCancel()");
     784             :     //fetregoffCancel->Resize(100, fetregoffCancel->GetDefaultHeight());  
     785             : 
     786           0 :     fetregoffRun = new TGTextButton(fetregoff2, "Run FET", 2);
     787           0 :     fetregoffRun->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoFETRegOffRun()");
     788             :     //fetregoffRun->Resize(100, fetregoffRun->GetDefaultHeight());  
     789             : 
     790             :     // adding
     791             : 
     792           0 :     fetregoff1->AddFrame(fetregoffL1,
     793           0 :                        new TGLayoutHints(kLHintsLeft | 
     794             :                                          kLHintsCenterY, 
     795             :                                          5, 5, 2, 2)
     796             :                        );
     797             :     
     798           0 :     fetregoff1->AddFrame(fetregoffText1, 
     799           0 :                        new TGLayoutHints(kLHintsRight | 
     800             :                                          kLHintsCenterY, 
     801             :                                          0, 2, 2, 2)
     802             :                        );
     803             :     
     804           0 :     fetregoff2->AddFrame(fetregoffCancel, 
     805           0 :                  new TGLayoutHints(kLHintsBottom | 
     806             :                                    kLHintsCenterY, 
     807             :                                    5, 5, 2, 2)
     808             :                  );
     809             :   
     810           0 :     fetregoff2->AddFrame(fetregoffRun, 
     811           0 :                  new TGLayoutHints(kLHintsBottom | 
     812             :                                    kLHintsCenterY, 
     813             :                                    5, 5, 2, 2)
     814             :                  );
     815             :   
     816           0 :     fFETRegOff->AddFrame(fetregoff1, 
     817           0 :                        new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
     818             :     
     819           0 :     fFETRegOff->AddFrame(fetregoff2, 
     820           0 :                        new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0));
     821             :     
     822           0 :     fFETRegOff->MapSubwindows();
     823           0 :     fFETRegOff->Resize();
     824           0 :     fFETRegOff->MapWindow();
     825             : 
     826           0 :     break;
     827             : 
     828             :   default:
     829           0 :     printf("Menu item %d selected\n", id);
     830           0 :     break;
     831             :     
     832             :   }
     833             : 
     834           0 : }
     835             : 
     836             : //__________________________________________________________________________
     837             : void AliMUONTriggerGUI::CloseRunInput() const
     838             : {
     839             :   /// close the run input frame
     840             : 
     841           0 :   delete fRunInput;
     842             : 
     843           0 : }
     844             : 
     845             : //__________________________________________________________________________
     846             : void AliMUONTriggerGUI::CloseError() const
     847             : {
     848             :   /// close the error frame
     849             : 
     850           0 :   delete fError;
     851             : 
     852           0 : }
     853             : 
     854             : //__________________________________________________________________________
     855             : void AliMUONTriggerGUI::CloseControl() const
     856             : {
     857             :   /// close the event control frame
     858             : 
     859           0 :   delete fControl;
     860             : 
     861             :   //gSystem->Exec("cd $PWD/mtrun; aliroot -b -q mtsim.C");
     862             : 
     863           0 : }
     864             : 
     865             : //__________________________________________________________________________
     866             : void AliMUONTriggerGUI::CloseCircuit() const
     867             : {
     868             :   /// close the circuit frame
     869             : 
     870           0 :   delete fCircuit;
     871             : 
     872           0 : }
     873             : 
     874             : //__________________________________________________________________________
     875             : void AliMUONTriggerGUI::CloseFETRegOn() const
     876             : {
     877             :   /// close the FET regional on frame
     878             : 
     879           0 :   delete fFETRegOn;
     880             : 
     881           0 : }
     882             : 
     883             : //__________________________________________________________________________
     884             : void AliMUONTriggerGUI::CloseFETRegOff() const
     885             : {
     886             :   /// close the FET regional off frame
     887             : 
     888           0 :   delete fFETRegOff;
     889             : 
     890           0 : }
     891             : 
     892             : //__________________________________________________________________________
     893             : void AliMUONTriggerGUI::CloseWindow() 
     894             : {
     895             :   /// close the main frame and exit aplication
     896             : 
     897           0 :   delete fRunLoader;
     898           0 :   delete fMCDataInterface;
     899           0 :   printf("\n"); 
     900           0 :   gApplication->Terminate(); 
     901             : 
     902           0 : }
     903             : 
     904             : //__________________________________________________________________________
     905             : void AliMUONTriggerGUI::DoRunGalApply()
     906             : {
     907             :   /// apply changes in the run control frame for galice input
     908             : 
     909           0 :   if (fRUNRAW) {
     910           0 :     printf("This is a run with raw data input.\n");
     911           0 :     return;
     912             :   }
     913             : 
     914           0 :   TString es = TString(fTxtBuffer2->GetString());
     915           0 :   fEvent = es.Atoi();
     916             : 
     917           0 :   printf("Galice input = %s event = %d \n",fTxtBuffer1->GetString(),fEvent);
     918             : 
     919           0 :   TString error = TString("");;
     920             : 
     921           0 :   fPath->Form("%s",fTxtBuffer1->GetString());
     922           0 :   fFileName->Form("%s",fTxtBuffer1->GetString());
     923             : 
     924           0 :   if (gSystem->AccessPathName(fFileName->Data()) || !fFileName->EndsWith(".root")) {
     925             : 
     926           0 :     error.Append("No galice file: ");
     927           0 :     error.Append(fFileName->Data());
     928           0 :     DoErrorGUI(error.Data());
     929             : 
     930             :   } else {
     931             : 
     932           0 :     TFile *ftest = new TFile(fFileName->Data(),"READ");
     933           0 :     AliRun *galice = (AliRun*)ftest->Get("gAlice");
     934           0 :     if (galice == 0) {
     935             : 
     936           0 :       ftest->Close();
     937           0 :       delete ftest;
     938             :       
     939           0 :       error.Append("No gAlice in file: ");
     940           0 :       error.Append(fFileName->Data());
     941           0 :       DoErrorGUI(error.Data());
     942             : 
     943           0 :       return;
     944             : 
     945             :     } else {
     946           0 :       ftest->Close();
     947           0 :       delete ftest;
     948             :     }
     949             : 
     950           0 :     if (fRunLoader) {
     951           0 :       delete fRunLoader;
     952           0 :       delete fMCDataInterface;
     953             :     }
     954             : 
     955           0 :     fRunLoader = AliRunLoader::Open(fFileName->Data(),"MUONFolder","READ");
     956             : 
     957           0 :     if (fRunLoader == 0x0) {
     958             : 
     959           0 :       DoErrorGUI("No run loader !");
     960             : 
     961             :     } else {
     962             :       
     963           0 :       fRunLoader->LoadgAlice();
     964           0 :       gAlice = fRunLoader->GetAliRun();
     965           0 :       fEventsPerRun = AliRunLoader::Instance()->GetNumberOfEvents();
     966             :       
     967           0 :       fLoader = fRunLoader->GetLoader("MUONLoader");
     968           0 :       fRunLoader->GetEvent(fEvent);
     969             :            
     970           0 :       fMCDataInterface = new AliMUONMCDataInterface(fFileName->Data());
     971             : 
     972           0 :       fRunInput->SendCloseMessage();
     973             :       
     974           0 :       if (!fBoardsInit) {
     975           0 :         InitBoards();
     976             :       }
     977             :       
     978           0 :       if (fDiMap) {
     979           0 :         if (fDiMap->IsOn()) {
     980           0 :           fDiMap->SetLoader(fLoader);
     981           0 :           fDiMap->SetMCDataInterface(fMCDataInterface);
     982           0 :         }
     983             :       }
     984             :       
     985             :     }
     986             : 
     987           0 :   }
     988             : 
     989           0 : }
     990             : 
     991             : //__________________________________________________________________________
     992             : void AliMUONTriggerGUI::DoRunRawApply()
     993             : {
     994             :   /// apply changes in the run control frame for raw date input
     995             : 
     996           0 :   if (fControlOn) DoControlClose();
     997             : 
     998           0 :   if (fRunLoader != 0) {
     999           0 :     printf("This is a run with galice input.\n");
    1000           0 :     return;
    1001             :   }
    1002             : 
    1003           0 :   TString es = TString(fTxtBuffer2->GetString());
    1004           0 :   fEvent = es.Atoi();
    1005             : 
    1006           0 :   printf("Raw data input = %s event = %d \n",fTxtBuffer1->GetString(),fEvent);
    1007             : 
    1008           0 :   TString error = TString("");;
    1009             : 
    1010           0 :   fPath->Form("%s",fTxtBuffer1->GetString());
    1011           0 :   fFileName->Form("%s",fTxtBuffer1->GetString());
    1012             : 
    1013           0 :   if (gSystem->AccessPathName(fFileName->Data()) || !fFileName->EndsWith(".root")) {
    1014             : 
    1015           0 :     error.Append("No raw data file: ");
    1016           0 :     error.Append(fFileName->Data());
    1017           0 :     DoErrorGUI(error.Data());
    1018             : 
    1019             :   } else {
    1020             : 
    1021           0 :     if (fRawReader == 0) {
    1022           0 :       fRawReader = AliRawReader::Create(fFileName->Data());
    1023           0 :     } else {
    1024           0 :       delete fRawReader;
    1025           0 :       fRawReader = AliRawReader::Create(fFileName->Data());
    1026             :     }
    1027           0 :     if (fRawReader == 0) {
    1028           0 :       error.Append("Not a valid raw data file: ");
    1029           0 :       error.Append(fFileName->Data());
    1030           0 :       DoErrorGUI(error.Data());
    1031           0 :       return;
    1032             :     }
    1033             : 
    1034           0 :     fRawReader->GotoEvent(fEvent);
    1035           0 :     fCurrentRawEvent = fEvent;
    1036             : 
    1037           0 :     AliMUONDigitMaker digitMaker;
    1038           0 :     digitMaker.SetMakeTriggerDigits(kTRUE);
    1039           0 :     digitMaker.Raw2Digits(fRawReader,fRawDigitStore,fRawTriggerStore);
    1040             : 
    1041           0 :     fRunInput->SendCloseMessage();
    1042             :       
    1043           0 :     if (!fBoardsInit) {
    1044           0 :       InitBoards();
    1045             :     }
    1046             :     
    1047           0 :     if (fDiMap) {
    1048           0 :       if (fDiMap->IsOn()) {
    1049           0 :         fDiMap->SetRawDigitStore(fRawDigitStore);
    1050           0 :       }
    1051             :     }
    1052             : 
    1053           0 :     fRUNRAW = kTRUE;
    1054             : 
    1055           0 :   }
    1056             :     
    1057           0 : }
    1058             : 
    1059             : //__________________________________________________________________________
    1060             : void AliMUONTriggerGUI::DoRunCancel()
    1061             : {
    1062             :   /// cancel the changes in the run control frame
    1063             : 
    1064           0 :   fRunInput->SendCloseMessage();
    1065             : 
    1066           0 : }
    1067             : 
    1068             : //__________________________________________________________________________
    1069             : void AliMUONTriggerGUI::DoErrorGUI(const Char_t *wt)
    1070             : {
    1071             :   /// show an error message in a new frame
    1072             : 
    1073           0 :   fError = new TGTransientFrame(gClient->GetRoot(), fMain, 50, 50);
    1074           0 :   fError->Connect("CloseWindow()", "AliMUONTriggerGUI", this, "CloseError()");
    1075           0 :   fError->DontCallClose(); // to avoid double deletions.
    1076             :   
    1077             :   // use hierarchical cleaning
    1078           0 :   fError->SetCleanup(kDeepCleanup);
    1079             :   
    1080           0 :   fError->SetWindowName("Error !");
    1081             : 
    1082           0 :   TGCompositeFrame *fW = new TGCompositeFrame(fError, 50, 50, kVerticalFrame);
    1083             :   
    1084           0 :   TGTextButton *fErrorOK = new TGTextButton(fW, "&Ok", 1);
    1085           0 :   fErrorOK->Connect("Clicked()", "AliMUONTriggerGUI", this, "DoErrorOK()");
    1086             :   
    1087           0 :   fW->AddFrame(fErrorOK, 
    1088           0 :                new TGLayoutHints(kLHintsBottom | 
    1089             :                                  kLHintsCenterX, 
    1090             :                                  5, 5, 5, 5)
    1091             :                );
    1092             :   
    1093           0 :   TGLabel *fWL = new TGLabel(fW, new TGString(wt));
    1094             :   
    1095           0 :   fW->AddFrame(fWL,
    1096           0 :                new TGLayoutHints(kLHintsTop | 
    1097             :                                  kLHintsCenterX, 
    1098             :                                  5, 5, 5, 5)
    1099             :                );
    1100             :   
    1101           0 :   fError->AddFrame(fW,
    1102           0 :                    new TGLayoutHints(kLHintsLeft | 
    1103             :                                      kLHintsCenterY, 
    1104             :                                      5, 5, 5, 5)
    1105             :                    );
    1106             :   
    1107           0 :   fError->MapSubwindows();
    1108           0 :   fError->Resize();
    1109           0 :   fError->MapWindow();
    1110             :    
    1111           0 : }
    1112             : 
    1113             : //__________________________________________________________________________
    1114             : void AliMUONTriggerGUI::DoNextEvent()
    1115             : {
    1116             :   /// load next event from the file
    1117             : 
    1118           0 :   TString error = TString("");
    1119             : 
    1120           0 :   if (!fRUNRAW) {
    1121           0 :     if (fEvent < (fEventsPerRun-1)) {
    1122           0 :       fEvent++;
    1123           0 :       fRunLoader->GetEvent(fEvent);
    1124             :       
    1125           0 :       fEvString->Form("%d",fEvent);               
    1126           0 :       fTxtBuffer2->RemoveText(0,5);
    1127           0 :       fTxtBuffer2->AddText(0,fEvString->Data());
    1128           0 :       fSkipToEventTxt->SetFocus();
    1129             :       
    1130             :     } else {
    1131           0 :       error.Form("Only %d event(s) in the run !",fEventsPerRun);
    1132           0 :       DoErrorGUI(error.Data());
    1133             :     }
    1134             :   } else {
    1135           0 :     if (fRawReader->NextEvent()) {
    1136           0 :       fCurrentRawEvent++;
    1137             : 
    1138           0 :       AliMUONDigitMaker digitMaker;
    1139           0 :       digitMaker.SetMakeTriggerDigits(kTRUE);
    1140           0 :       digitMaker.Raw2Digits(fRawReader,fRawDigitStore,fRawTriggerStore);
    1141             :       
    1142           0 :       fEvString->Form("%d",fCurrentRawEvent);               
    1143           0 :       fTxtBuffer2->RemoveText(0,5);
    1144           0 :       fTxtBuffer2->AddText(0,fEvString->Data());
    1145           0 :       fSkipToEventTxt->SetFocus();
    1146             :       
    1147           0 :     }
    1148             : 
    1149             :   }
    1150             : 
    1151           0 : }
    1152             : 
    1153             : //__________________________________________________________________________
    1154             : void AliMUONTriggerGUI::DoPreviousEvent()
    1155             : {
    1156             :   /// load previous event from the input file
    1157             : 
    1158           0 :   TString error = TString("");
    1159             : 
    1160           0 :   if (!fRUNRAW) {
    1161           0 :     if (fEvent > 0) {
    1162           0 :       fEvent--;
    1163           0 :       fRunLoader->GetEvent(fEvent);
    1164             :       
    1165           0 :       fEvString->Form("%d",fEvent);               
    1166           0 :       fTxtBuffer2->RemoveText(0,5);
    1167           0 :       fTxtBuffer2->AddText(0,fEvString->Data());
    1168           0 :       fSkipToEventTxt->SetFocus();
    1169             :       
    1170             :     } else {
    1171           0 :       error.Form("Already at event 0 !");
    1172           0 :       DoErrorGUI(error.Data());
    1173             :     }
    1174             :   } else {
    1175           0 :     if (fCurrentRawEvent > 0) {
    1176           0 :       fCurrentRawEvent--;
    1177           0 :       fRawReader->GotoEvent(fCurrentRawEvent);
    1178             : 
    1179           0 :       AliMUONDigitMaker digitMaker;
    1180           0 :       digitMaker.SetMakeTriggerDigits(kTRUE);
    1181           0 :       digitMaker.Raw2Digits(fRawReader,fRawDigitStore,fRawTriggerStore);
    1182             :       
    1183           0 :       fEvString->Form("%d",fCurrentRawEvent);               
    1184           0 :       fTxtBuffer2->RemoveText(0,5);
    1185           0 :       fTxtBuffer2->AddText(0,fEvString->Data());
    1186           0 :       fSkipToEventTxt->SetFocus();
    1187             :     
    1188           0 :     }
    1189             : 
    1190             :   }
    1191             : 
    1192           0 : }
    1193             : 
    1194             : //__________________________________________________________________________
    1195             : void AliMUONTriggerGUI::DoSkipToEvent()
    1196             : {
    1197             :   /// skip to event -input- from the input file
    1198             : 
    1199           0 :   TString error = TString("");
    1200             : 
    1201           0 :   TString es = TString(fTxtBuffer2->GetString());
    1202           0 :   fEvent = es.Atoi();
    1203             : 
    1204           0 :   if (!fRUNRAW) {
    1205           0 :     if (fEvent < 0 || fEvent > (fEventsPerRun-1)) {
    1206           0 :       error.Form("Event number out of range !");
    1207           0 :       DoErrorGUI(error.Data());
    1208             :     } else {
    1209           0 :       fRunLoader->GetEvent(fEvent);
    1210             :     }
    1211             :   } else {
    1212           0 :     if (fRawReader->GotoEvent(fEvent)) {
    1213           0 :       fCurrentRawEvent = fEvent;
    1214             : 
    1215           0 :       AliMUONDigitMaker digitMaker;
    1216           0 :       digitMaker.SetMakeTriggerDigits(kTRUE);
    1217           0 :       digitMaker.Raw2Digits(fRawReader,fRawDigitStore,fRawTriggerStore);
    1218             :       
    1219           0 :       fEvString->Form("%d",fCurrentRawEvent);               
    1220           0 :       fTxtBuffer2->RemoveText(0,5);
    1221           0 :       fTxtBuffer2->AddText(0,fEvString->Data());
    1222           0 :       fSkipToEventTxt->SetFocus();
    1223           0 :     }
    1224             : 
    1225             :   }
    1226             : 
    1227           0 : }
    1228             : 
    1229             : //__________________________________________________________________________
    1230             : void AliMUONTriggerGUI::DoErrorOK()
    1231             : {
    1232             :   /// close the error frame
    1233             : 
    1234           0 :   fError->SendCloseMessage();
    1235             : 
    1236           0 : }
    1237             : 
    1238             : //__________________________________________________________________________
    1239             : void AliMUONTriggerGUI::DoControlClose()
    1240             : {
    1241             :   /// close the event control frame
    1242             : 
    1243           0 :   fControl->SendCloseMessage();
    1244           0 :   fControlOn = kFALSE;
    1245             : 
    1246           0 : }
    1247             : 
    1248             : //__________________________________________________________________________
    1249             : void AliMUONTriggerGUI::DoCircuitCancel()
    1250             : {
    1251             :   /// close the circuit frame
    1252             : 
    1253           0 :   fCircuit->SendCloseMessage();
    1254             : 
    1255           0 : }
    1256             : 
    1257             : //__________________________________________________________________________
    1258             : void AliMUONTriggerGUI::DoFETRegOnCancel()
    1259             : {
    1260             :   /// close the FET regional on window
    1261             : 
    1262           0 :   fFETRegOn->SendCloseMessage();
    1263             : 
    1264           0 : }
    1265             : 
    1266             : //__________________________________________________________________________
    1267             : void AliMUONTriggerGUI::DoFETRegOffCancel()
    1268             : {
    1269             :   /// close the FET regional off window
    1270             : 
    1271           0 :   fFETRegOff->SendCloseMessage();
    1272             : 
    1273           0 : }
    1274             : 
    1275             : //__________________________________________________________________________
    1276             : void AliMUONTriggerGUI::DoFETRegRun(Int_t onoff)
    1277             : {
    1278             :   /// FET ON/OFF for the regional crate
    1279             : 
    1280           0 :   TString crateName;
    1281           0 :   if (onoff == 1) 
    1282           0 :     crateName = TString(fTxtFETRegOn->GetString());
    1283           0 :   if (onoff == 0) 
    1284           0 :     crateName = TString(fTxtFETRegOff->GetString());
    1285             : 
    1286             :   AliMUONTriggerGUIboard *board;
    1287             :   Int_t amp = onoff;
    1288             : 
    1289           0 :   for (Int_t ib = 0; ib < kNBoards; ib++) {
    1290           0 :     board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
    1291           0 :     if (strcmp(board->GetCrateName(),crateName.Data()) != 0) continue;
    1292           0 :     FETboard(ib,amp);
    1293             :   }
    1294             : 
    1295           0 : }
    1296             : 
    1297             : //__________________________________________________________________________
    1298             : void AliMUONTriggerGUI::DoFETRegOnRun()
    1299             : {
    1300             :   /// FET ON for the regional crate
    1301             : 
    1302           0 :   DoFETRegRun(1);
    1303           0 :   fFETRegOn->SendCloseMessage();
    1304             : 
    1305           0 : }
    1306             : 
    1307             : //__________________________________________________________________________
    1308             : void AliMUONTriggerGUI::DoFETRegOffRun()
    1309             : {
    1310             :   /// FET ON for the regional crate
    1311             : 
    1312           0 :   DoFETRegRun(0);
    1313           0 :   fFETRegOff->SendCloseMessage();
    1314             : 
    1315           0 : }
    1316             : 
    1317             : //__________________________________________________________________________
    1318             : void AliMUONTriggerGUI::DoCircuitOpen()
    1319             : {
    1320             :   /// open a circuit
    1321             : 
    1322           0 :   TString cs = TString(fTxtCircuit->GetString());
    1323           0 :   Int_t icirc = cs.Atoi();
    1324             : 
    1325             :   AliMUONTriggerGUIboard *board;
    1326             : 
    1327           0 :   for (Int_t ib = 0; ib < kNBoards; ib++) {
    1328             : 
    1329           0 :     board = GetBoard(ib);
    1330             : 
    1331           0 :     if (board->GetIdCircuit() == icirc) {
    1332             : 
    1333           0 :       OpenBoard(ib);
    1334             : 
    1335           0 :       if (fDiMap) {
    1336           0 :         if (fDiMap->IsOn()) {
    1337           0 :           fDiMap->SelectBoard(ib);
    1338             :         }
    1339             :       }
    1340             :       
    1341           0 :       fCircuit->SendCloseMessage();
    1342           0 :       return;
    1343             :     }
    1344             : 
    1345             :   }
    1346             : 
    1347           0 : }
    1348             : 
    1349             : //__________________________________________________________________________
    1350             : AliMUONTriggerGUIboard* AliMUONTriggerGUI::GetBoard(Int_t id) const
    1351             : {
    1352             :   /// return board with "id"
    1353             : 
    1354           0 :   if (fBoards == 0) return 0;
    1355           0 :   void * b = fBoards->UncheckedAt(id);
    1356           0 :   if (b == 0) return 0;
    1357             : 
    1358           0 :   return (AliMUONTriggerGUIboard*)b;
    1359             : 
    1360           0 : }
    1361             : 
    1362             : //__________________________________________________________________________
    1363             : void AliMUONTriggerGUI::OpenBoard(Int_t id)
    1364             : {
    1365             :   /// open board with "id" in a new frame
    1366             :    
    1367           0 :   AliMUONTriggerGUIboard *board = GetBoard(id);
    1368           0 :   UShort_t status = board->GetStatus();
    1369           0 :   board->SetOpen(kTRUE);
    1370             : 
    1371             :   AliMUONTriggerGUIbdmap *bf;
    1372           0 :   Char_t text[200];
    1373             : 
    1374           0 :   bf = new AliMUONTriggerGUIbdmap(gClient->GetRoot(), fMain, 400, 200);
    1375             : 
    1376           0 :   if (status & kGood) {
    1377           0 :     snprintf(text,200,"%s (Circuit %4d) status : working",
    1378           0 :             board->GetBoardName(),board->GetIdCircuit());
    1379           0 :   }
    1380             : 
    1381           0 :   if (status & kWithProblems) {
    1382           0 :     snprintf(text,200,"%s (Circuit %4d)  status : has problems...",
    1383           0 :             board->GetBoardName(),board->GetIdCircuit());
    1384           0 :   }
    1385             : 
    1386           0 :   if (status & kNotWorking) {
    1387           0 :     snprintf(text,200,"%s (Circuit %4d)  status : not working",
    1388           0 :             board->GetBoardName(),board->GetIdCircuit());
    1389           0 :   }
    1390             : 
    1391           0 :   if (status & kUnknown) {
    1392           0 :     snprintf(text,200,"%s (Circuit %4d)  status : unknown",
    1393           0 :             board->GetBoardName(),board->GetIdCircuit());
    1394           0 :   }
    1395             : 
    1396           0 :   bf->SetName(text);
    1397           0 :   bf->SetBoard(Boards(),id);
    1398           0 :   bf->SetLoader(fLoader);
    1399           0 :   bf->SetCrateManager(fCrateManager);
    1400           0 :   if (fRUNRAW) {
    1401           0 :     bf->SetRawDigitStore(fRawDigitStore);
    1402           0 :     bf->SetRawTriggerStore(fRawTriggerStore);
    1403           0 :   } else {
    1404           0 :     bf->SetMCDataInterface(fMCDataInterface);
    1405             :   }
    1406           0 :   bf->Init();
    1407             : 
    1408           0 :   bf->Show();
    1409             : 
    1410           0 :   if (fDiMap) {
    1411           0 :     if (fDiMap->IsOn()) {
    1412           0 :       fDiMap->SelectBoard(id);
    1413           0 :     }
    1414             :   }
    1415             : 
    1416           0 : }
    1417             : 
    1418             : //__________________________________________________________________________
    1419             : void AliMUONTriggerGUI::Init()
    1420             : {
    1421             :   /// initialize the main GUI frame
    1422             :   
    1423           0 :   if (!fBoardsInit) {
    1424           0 :     InitBoards();
    1425           0 :   }
    1426             : 
    1427             :   /*
    1428             :   AliMUONTriggerGUIboard *board;
    1429             :   for (Int_t ib = 0; ib < kNBoards; ib++) {
    1430             :     board = GetBoard(ib);
    1431             :     board->Dump();
    1432             :   }
    1433             :   */
    1434           0 : }
    1435             : 
    1436             : //__________________________________________________________________________
    1437             : void AliMUONTriggerGUI::InitBoards()
    1438             : {
    1439             :   /// create board objects and define the sensitive regions in the image map
    1440             :   
    1441           0 :   fBoardsInit = kTRUE;
    1442             : 
    1443             :   // used by bdmap
    1444           0 :   if (fCrateManager == 0x0) {
    1445           0 :     fCrateManager = new AliMUONTriggerCrateStore();
    1446           0 :     fCrateManager->ReadFromFile(fCalibrationData);
    1447           0 :   }
    1448             : 
    1449             :   // create boards geometry from the mapping
    1450             :   AliMUONTriggerGUIboard *board;
    1451           0 :   for (Int_t ib = 0; ib < kNBoards; ib++) {
    1452           0 :     Boards()->Add(new AliMUONTriggerGUIboard());
    1453             :   }
    1454             :   
    1455             :   // circuit number to board number in array
    1456           0 :   Int_t cIdtobId[235];
    1457           0 :   for (Int_t i = 0; i < 235; i++) cIdtobId[i] = -1;
    1458             : 
    1459           0 :   AliMpDEIterator it;
    1460             :   Int_t boardId = -1;
    1461             :   Int_t manuIdPrev, ich, idet, boardIdTmp = -1;
    1462           0 :   for (Int_t chamber = 0; chamber < kNMT; chamber++) {
    1463           0 :     for ( it.First(); ! it.IsDone(); it.Next() ) {
    1464             :       
    1465           0 :       if (it.CurrentDEId()/100 < 11) continue;
    1466             :       
    1467           0 :       ich = it.CurrentDEId()/100 - 11;
    1468           0 :       if (ich != chamber) continue;
    1469           0 :       idet = it.CurrentDEId()%100;
    1470             :       
    1471           0 :       const AliMpVSegmentation* seg0 = AliMpSegmentation::Instance()->GetMpSegmentation(it.CurrentDEId(), AliMp::kCath0);
    1472           0 :       const AliMpVSegmentation* seg1 = AliMpSegmentation::Instance()->GetMpSegmentation(it.CurrentDEId(), AliMp::kCath1);
    1473             : 
    1474             :       // x-strips
    1475             :       manuIdPrev = 0;
    1476           0 :       for (Int_t ix = 0; ix <= seg0->MaxPadIndexX(); ix++) {
    1477           0 :         for (Int_t iy = 0; iy <= seg0->MaxPadIndexY(); iy++) {
    1478           0 :           AliMpPad pad = seg0->PadByIndices(ix,iy,kFALSE);
    1479           0 :           if (pad.IsValid()) {
    1480           0 :             Int_t manuId = pad.GetLocalBoardId(0);
    1481           0 :             if (manuId != manuIdPrev) {
    1482           0 :               AliMpLocalBoard *mpboard = AliMpDDLStore::Instance()->GetLocalBoard(manuId);
    1483             :               manuIdPrev = manuId;
    1484           0 :               if (ich == 0) {
    1485           0 :                 boardId++;
    1486           0 :               } else {
    1487           0 :                 boardId = cIdtobId[manuId];
    1488             :               }
    1489           0 :               board = GetBoard(boardId);
    1490           0 :               if (board->GetNumber() == -1)
    1491           0 :                 board->SetNumber(boardId);
    1492           0 :               if (board->GetDetElemId() == -1) 
    1493           0 :                 board->SetDetElemId(idet);
    1494           0 :               if (!strcmp(board->GetBoardName(),""))
    1495           0 :                 board->SetBoardName(mpboard->GetName());
    1496           0 :               cIdtobId[manuId] = boardId;
    1497           0 :             }
    1498           0 :             GetBoard(boardId)->AddPadX(pad,ich);
    1499           0 :           }
    1500           0 :         }
    1501             :       }  // end plane 0 (x-strips)
    1502             :          
    1503             :       // y-strips
    1504             :       manuIdPrev = 0;
    1505           0 :       for (Int_t ix = 0; ix <= seg1->MaxPadIndexX(); ix++) {
    1506           0 :         for (Int_t iy = 0; iy <= seg1->MaxPadIndexY(); iy++) {
    1507           0 :           AliMpPad pad = seg1->PadByIndices(ix,iy,kFALSE);
    1508           0 :           if (pad.IsValid()) {
    1509           0 :             Int_t nloc = pad.GetNofLocations();
    1510           0 :             for (Int_t iloc = 0; iloc < nloc; iloc++) {
    1511           0 :               Int_t manuId = pad.GetLocalBoardId(iloc);
    1512           0 :               if (manuId != manuIdPrev) {
    1513             :                 manuIdPrev = manuId;
    1514           0 :                 boardIdTmp = cIdtobId[manuId];
    1515           0 :               }
    1516           0 :               GetBoard(boardIdTmp)->AddPadY(pad,ich);
    1517             :             }
    1518           0 :           }
    1519           0 :         }
    1520             :       }  // end plane 1 (y-strips)
    1521             :       
    1522           0 :     } // end det elem loop
    1523             :   } // end chamber loop
    1524             :   
    1525           0 :   for (Int_t ib = 0; ib < kNBoards; ib++) {
    1526           0 :     board = GetBoard(ib);
    1527           0 :     board->MakeGeometry();
    1528           0 :     AliMUONLocalTriggerBoard* b = fCrateManager->LocalBoard(board->GetIdCircuit());
    1529           0 :     board->SetCrateName((b->GetCrate()).Data());
    1530             :   }
    1531             :   
    1532             :   // create the sensitive map
    1533             : 
    1534             :   Int_t nPixelX = 700;
    1535             :   Int_t nPixelY = 676;
    1536             : 
    1537             :   Int_t nPixelBorderX = 40;  // to guess...
    1538             :   Int_t nPixelBorderY = 40;  // to guess...
    1539             : 
    1540             :   // boards limits
    1541             :   Float_t boardsX = 2*257.00;  // cm
    1542             :   Float_t boardsY = 2*306.61;  // cm
    1543             : 
    1544             :   UShort_t status = 1;
    1545             :   Float_t xc, yc, xw, yw;
    1546           0 :   Char_t text[256];
    1547             :   Int_t x, y;
    1548             :   UInt_t w, h;
    1549           0 :   Int_t xp[5];
    1550           0 :   Int_t yp[5];
    1551             : 
    1552             :   TGRegion *reg;
    1553             : 
    1554             :   // regions for the image map (from MT11)
    1555             : 
    1556           0 :   for (Int_t ib = 0; ib < kNBoards; ib++) {
    1557             : 
    1558           0 :     board = GetBoard(ib);
    1559             : 
    1560             :     status = 1;
    1561           0 :     board->SetStatus(status);
    1562             : 
    1563           0 :     xc = board->GetXCenter(0);
    1564           0 :     yc = board->GetYCenter(0);
    1565           0 :     xw = board->GetXWidth(0);
    1566           0 :     yw = board->GetYWidth(0);
    1567             : 
    1568           0 :     x = (Int_t)(nPixelX/2 + xc * (nPixelX - 2*nPixelBorderX)/boardsX);
    1569           0 :     y = (Int_t)(nPixelY/2 - yc * (nPixelY - 2*nPixelBorderY)/boardsY);
    1570             : 
    1571           0 :     if (x < 0) x = 0;
    1572           0 :     if (y < 0) y = 0;
    1573             : 
    1574           0 :     w = (UInt_t)(xw*(nPixelX-2*nPixelBorderX)/boardsX);
    1575           0 :     h = (UInt_t)(yw*(nPixelY-2*nPixelBorderY)/boardsY);
    1576             :     
    1577           0 :     xp[0] = x-w/2;
    1578           0 :     xp[1] = x+w/2;
    1579           0 :     xp[2] = x+w/2;
    1580           0 :     xp[3] = x-w/2;
    1581           0 :     xp[4] = x-w/2;
    1582             :     
    1583           0 :     yp[0] = y-h/2;
    1584           0 :     yp[1] = y-h/2;
    1585           0 :     yp[2] = y+h/2;
    1586           0 :     yp[3] = y+h/2;
    1587           0 :     yp[4] = y-h/2;
    1588             : 
    1589           0 :     reg = new TGRegion(5,xp,yp);
    1590           0 :     fImageMap->AddRegion(*reg, ib);
    1591             : 
    1592           0 :     snprintf(text,256,"%s (crate %s circuit %3d, number %3d)",board->GetBoardName(),board->GetCrateName(),board->GetIdCircuit(),board->GetNumber());
    1593           0 :     fImageMap->SetToolTipText(ib, text);
    1594             : 
    1595             :     // Set coordinates of strips boxes
    1596             :     
    1597           0 :     SetStripBoxes(board);
    1598             :     
    1599             :     //board->PrintBoard();
    1600             :     
    1601             :   }
    1602             :   
    1603           0 : }
    1604             : 
    1605             : //__________________________________________________________________________
    1606             : void AliMUONTriggerGUI::SetStripBoxes(AliMUONTriggerGUIboard *board) 
    1607             : {
    1608             :   /// set coordinates of strip boxes
    1609             : 
    1610           0 :   AliMUONGeometryTransformer transformer;
    1611           0 :   transformer.LoadGeometryData("transform.dat");
    1612             : 
    1613             :   const AliMpVSegmentation* seg;
    1614           0 :   AliMpPad pad;
    1615           0 :   AliMpDEIterator it;
    1616             : 
    1617             :   Int_t chamber, detElemId, maxX, maxY;
    1618             :   Float_t xpmin, xpmax, ypmin, ypmax;
    1619           0 :   Float_t xg1, xg2, yg1, yg2, zg1;
    1620             :   Float_t xlocal1, xlocal2, ylocal1, ylocal2;
    1621             :   Float_t xCenter, yCenter, xWidth, yWidth;
    1622             : 
    1623           0 :   for (Int_t i = 0; i < kNMT; i++) {
    1624             : 
    1625           0 :     chamber = 11+i;
    1626             : 
    1627           0 :     xCenter = board->GetXCenter(i);
    1628           0 :     yCenter = board->GetYCenter(i);
    1629           0 :     xWidth  = board->GetXWidth(i);
    1630           0 :     yWidth  = board->GetYWidth(i);
    1631             : 
    1632           0 :     for ( it.First(chamber-1); ! it.IsDone(); it.Next() ) {
    1633             :     
    1634           0 :       detElemId = it.CurrentDEId();
    1635             :     
    1636           0 :       if (detElemId%100 != board->GetDetElemId()) continue;
    1637             : 
    1638             :       /*---------- y-pads cath = 1 ----------*/
    1639             :       
    1640           0 :       seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::kCath1);
    1641             : 
    1642           0 :       maxX = seg->MaxPadIndexX();
    1643           0 :       maxY = seg->MaxPadIndexY();
    1644             :       
    1645           0 :       for (Int_t ix = 0; ix <= maxX; ix++) {
    1646           0 :         for (Int_t iy = 0; iy <= maxY; iy++) {
    1647             :           
    1648           0 :           pad = seg->PadByIndices(ix,iy,kFALSE);
    1649             :           
    1650           0 :           if (!pad.IsValid()) continue;
    1651             :           
    1652             :           // get the pad position and dimensions
    1653           0 :           xlocal1 = pad.GetPositionX();
    1654           0 :           ylocal1 = pad.GetPositionY();
    1655           0 :           xlocal2 = pad.GetDimensionX();
    1656           0 :           ylocal2 = pad.GetDimensionY();
    1657             :           
    1658           0 :           transformer.Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
    1659             :           // (no transformation for pad dimensions)
    1660             :           xg2 = xlocal2;
    1661             :           yg2 = ylocal2;
    1662             :           
    1663             :           // transform in the monitor coordinate system
    1664             :           // ALICE SC
    1665           0 :           xpmin = +(xg1-xg2);
    1666           0 :           xpmax = +(xg1+xg2);
    1667           0 :           ypmin = -(yg2-yg1);
    1668           0 :           ypmax = +(yg2+yg1);
    1669             :           
    1670           0 :           xpmin -= xCenter;
    1671           0 :           xpmax -= xCenter;
    1672             :           ypmin -= yCenter;
    1673             :           ypmax -= yCenter;
    1674             :           
    1675             :           Int_t iX1, iX2, iY, ixDig;
    1676           0 :           iX1 = board->GetYSix1();
    1677           0 :           iX2 = board->GetYSix2();
    1678           0 :           iY  = board->GetYSiy();
    1679           0 :           if (ix >= iX1 && ix <= iX2 && iy == iY) {
    1680             :             
    1681           0 :             ypmin = -0.5*yWidth;
    1682           0 :             ypmax = +0.5*yWidth;
    1683             : 
    1684           0 :             ixDig = ix - iX1;
    1685             : 
    1686           0 :             board->SetYDigBox(i,ixDig,(Double_t)xpmin,(Double_t)ypmin,
    1687           0 :                                       (Double_t)xpmax,(Double_t)ypmax);
    1688             : 
    1689             :           }
    1690             : 
    1691           0 :         }  // end maxY
    1692             :       }  // end maxX
    1693             : 
    1694             :       /*---------- x-pads cath = 0 ----------*/
    1695             :       
    1696           0 :       seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::kCath0);
    1697             : 
    1698           0 :       maxX = seg->MaxPadIndexX();
    1699           0 :       maxY = seg->MaxPadIndexY();
    1700             :             
    1701           0 :       for (Int_t ix = 0; ix <= maxX; ix++) {
    1702           0 :         for (Int_t iy = 0; iy <= maxY; iy++) {
    1703             :           
    1704           0 :           pad = seg->PadByIndices(ix,iy,kFALSE);
    1705             :           
    1706           0 :           if (!pad.IsValid()) continue;
    1707             :           
    1708             :           // get the pad position and dimensions
    1709           0 :           xlocal1 = pad.GetPositionX();
    1710           0 :           ylocal1 = pad.GetPositionY();
    1711           0 :           xlocal2 = pad.GetDimensionX();
    1712           0 :           ylocal2 = pad.GetDimensionY();
    1713             :           
    1714           0 :           transformer.Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
    1715             :           // (no transformation for pad dimensions)
    1716             :           xg2 = xlocal2;
    1717             :           yg2 = ylocal2;
    1718             :           
    1719             :           // transform in the monitor coordinate system
    1720             :           // ALICE SC
    1721           0 :           xpmin = +(xg1+xg2);
    1722           0 :           xpmax = +(xg1-xg2);
    1723           0 :           ypmin = -(yg2-yg1);
    1724           0 :           ypmax = +(yg2+yg1);
    1725             :           
    1726           0 :           xpmin -= xCenter;
    1727           0 :           xpmax -= xCenter;
    1728           0 :           ypmin -= yCenter;
    1729           0 :           ypmax -= yCenter;
    1730             : 
    1731             :           Int_t iX, iY1, iY2, iyDig;
    1732           0 :           iX  = board->GetXSix();
    1733           0 :           iY1 = board->GetXSiy1();
    1734           0 :           iY2 = board->GetXSiy2();
    1735           0 :           if (ix == iX && iy >= iY1 && iy <= iY2) {
    1736             : 
    1737           0 :             iyDig = iy - iY1;
    1738             : 
    1739           0 :             board->SetXDigBox(i,iyDig,(Double_t)xpmin,(Double_t)ypmin,
    1740           0 :                                       (Double_t)xpmax,(Double_t)ypmax);
    1741             : 
    1742             :           }
    1743             : 
    1744           0 :         }  // end maxY
    1745             :       }  // end maxX
    1746             : 
    1747           0 :     }  // end detElemId
    1748             : 
    1749             :   }  // end kNMT loop
    1750             :         
    1751           0 : }
    1752             : 
    1753             : //__________________________________________________________________________
    1754             : void AliMUONTriggerGUI::CreateDigitStore() 
    1755             : {
    1756             :   /// create memory resident digits store with set strips
    1757             : 
    1758             :   Int_t nstripX, nstripY, detElemId, charge, ix, iy, iX1, iY1;
    1759             :   Int_t cathode, maxX, maxY;
    1760             :   Int_t manuId, manuChannel;
    1761             :   const AliMpVSegmentation* seg;
    1762           0 :   AliMpPad pad;
    1763             :   AliMUONTriggerGUIboard* board;
    1764             :   AliMUONVDigit *dig;
    1765             : 
    1766           0 :   for (Int_t ib = 0; ib < kNBoards; ib++) {
    1767             : 
    1768           0 :     board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
    1769           0 :     if (board == 0) continue;
    1770             : 
    1771           0 :     nstripX = board->GetNStripX();
    1772           0 :     nstripY = board->GetNStripY();
    1773           0 :     for (Int_t ichamber = 11; ichamber <= 14; ichamber++) {
    1774             :       
    1775           0 :       detElemId = ichamber * 100 + board->GetDetElemId();
    1776             :       // x strips
    1777             :       cathode = 0;
    1778           0 :       for (Int_t isx = 0; isx < nstripX; isx++) {
    1779             :         
    1780           0 :         charge = (Int_t)board->GetXDig(ichamber-11,isx);
    1781           0 :         if (charge == 0) continue;
    1782           0 :         ix  = board->GetXSix();
    1783           0 :         iY1 = board->GetXSiy1();
    1784           0 :         iy  = isx + iY1;
    1785           0 :         seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cathode));
    1786           0 :         maxX = seg->MaxPadIndexX();
    1787           0 :         maxY = seg->MaxPadIndexY();
    1788           0 :         if (ix > maxX) printf("Index x > maximum!\n");
    1789           0 :         if (iy > maxY) printf("Index y > maximum!\n");
    1790           0 :         pad = seg->PadByIndices(ix,iy,kTRUE);
    1791           0 :         manuId = pad.GetLocalBoardId(0);
    1792           0 :         manuChannel = pad.GetLocalBoardChannel(0);
    1793             : 
    1794           0 :         dig = fDigitStore->Add(detElemId,manuId,manuChannel,cathode,AliMUONVDigitStore::kAllow);
    1795           0 :         dig->SetCharge(charge);
    1796           0 :         dig->SetPadXY(ix,iy);
    1797             :         //printf("Cathode 0: ix %3d iy %3d manuId %3d manuChannel %3d \n",ix,iy,manuId,manuChannel);
    1798             : 
    1799             :       }  // end x strips
    1800             : 
    1801             :       // y strips
    1802             :       cathode = 1;
    1803           0 :       for (Int_t isy = 0; isy < nstripY; isy++) {
    1804             :         
    1805           0 :         charge = board->GetYDig(ichamber-11,isy);
    1806           0 :         if (charge == 0) continue;
    1807           0 :         iX1 = board->GetYSix1();
    1808           0 :         ix  = isy + iX1;
    1809           0 :         iy  = board->GetYSiy();
    1810           0 :         seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cathode));
    1811           0 :         maxX = seg->MaxPadIndexX();
    1812           0 :         maxY = seg->MaxPadIndexY();
    1813           0 :         if (ix > maxX) printf("Index x > maximum!\n");
    1814           0 :         if (iy > maxY) printf("Index y > maximum!\n");
    1815           0 :         pad = seg->PadByIndices(ix,iy,kTRUE);
    1816           0 :         manuId = pad.GetLocalBoardId(0);
    1817           0 :         manuChannel = pad.GetLocalBoardChannel(0);
    1818             : 
    1819           0 :         dig = fDigitStore->Add(detElemId,manuId,manuChannel,cathode,AliMUONVDigitStore::kAllow);
    1820           0 :         dig->SetCharge(charge);
    1821           0 :         dig->SetPadXY(ix,iy);
    1822             :         //printf("Cathode 1: ix %3d iy %3d manuId %3d manuChannel %3d \n",ix,iy,manuId,manuChannel);
    1823             : 
    1824             :       }  // end y strips
    1825             : 
    1826             :     }  // end chambers
    1827             : 
    1828           0 :   }  // end boards
    1829             : 
    1830           0 : }
    1831             : 
    1832             : //__________________________________________________________________________
    1833             : void AliMUONTriggerGUI::PrintDigitStore() const
    1834             : {
    1835             :   /// Print the digits created in the GUI
    1836             : 
    1837             :   const AliMpVSegmentation* seg;
    1838           0 :   AliMpPad pad;
    1839             :   Int_t ix, iy, charge, detElemId, cathode;
    1840             : 
    1841             :   Int_t chamber;
    1842           0 :   for (Int_t i = 0; i < kNMT; i++) {
    1843             : 
    1844           0 :     chamber = 11+i;
    1845             : 
    1846           0 :     MpPair_t deRange = AliMpDEManager::GetDetElemIdRange(chamber-1);
    1847           0 :     TIter next(fDigitStore->CreateIterator(AliMp::PairFirst(deRange),AliMp::PairSecond(deRange)));
    1848             :     AliMUONVDigit *mdig;
    1849             : 
    1850           0 :     while ( ( mdig = static_cast<AliMUONVDigit*>(next())) )
    1851             :     {
    1852           0 :       cathode = mdig->Cathode();
    1853             :       
    1854           0 :       ix = mdig->PadX();
    1855           0 :       iy = mdig->PadY();
    1856           0 :       detElemId = mdig->DetElemId(); 
    1857           0 :       charge = (Int_t)mdig->Charge();
    1858             : 
    1859           0 :       seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cathode));  
    1860           0 :       pad = seg->PadByIndices(ix,iy,kTRUE);
    1861             :  
    1862           0 :       printf("Digit: detElemId %4d cath %1d ix %2d iy %3d charge %1d \n",detElemId,cathode,ix,iy,charge);
    1863             :       
    1864             :     }
    1865             : 
    1866           0 :   }
    1867             : 
    1868           0 : }
    1869             : 
    1870             : //__________________________________________________________________________
    1871             : void AliMUONTriggerGUI::CreateTriggerStore() 
    1872             : {
    1873             :   /// Process the DSET digit store and fill the trigger store
    1874             : 
    1875           0 :   if (fDigitStore->GetSize() == 0) {
    1876           0 :     printf("The digit store is empty...\n");
    1877           0 :     return;
    1878             :   }
    1879           0 :   fTStoreOn = kTRUE;
    1880             : 
    1881           0 :   AliMUONVDigitStore *digitStore = static_cast<AliMUONVDigitStore*>(fDigitStore);
    1882             : 
    1883           0 :   fTriggerProcessor->Digits2Trigger(*digitStore,*fTriggerStore);
    1884             : 
    1885           0 : }
    1886             : 
    1887             : //__________________________________________________________________________
    1888             : void AliMUONTriggerGUI::PrintTriggerStore() const
    1889             : {
    1890             :   /// Print the trigger output for DSET digits store
    1891             : 
    1892           0 :   if (!fTStoreOn) return;
    1893             : 
    1894           0 :   TIter next(fTriggerStore->CreateLocalIterator());
    1895             :   
    1896             :   UShort_t x2m, x2u, x2d;
    1897             :   Int_t loStripX, loStripY, loDev, loCircuit, iStripX, iStripY, loLpt, loHpt;
    1898             :   AliMUONLocalTrigger *mlt;
    1899           0 :   while ( ( mlt = static_cast<AliMUONLocalTrigger*>(next()) ) )
    1900             :   {    
    1901           0 :     loCircuit = mlt->LoCircuit();
    1902             : 
    1903           0 :     AliMUONLocalTriggerBoard* ltb = fCrateManager->LocalBoard(loCircuit);
    1904           0 :     x2d = ltb->GetSwitch(0);
    1905           0 :     x2m = ltb->GetSwitch(1);
    1906           0 :     x2u = ltb->GetSwitch(2);
    1907             :     
    1908           0 :     loStripX = mlt->LoStripX();
    1909           0 :     loStripY = mlt->LoStripY();
    1910           0 :     loDev    = mlt->LoDev();
    1911           0 :     loLpt    = mlt->LoLpt();
    1912           0 :     loHpt    = mlt->LoHpt();
    1913             : 
    1914           0 :     iStripX = loStripX/2;
    1915           0 :     if ((x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) {
    1916           0 :       iStripY = loStripY/2;
    1917           0 :     } else {
    1918             :       iStripY = loStripY;
    1919             :     }
    1920             :     
    1921           0 :     printf("Circ %3d Xs %2d (%2d) Ys %2d (%2d) Dev %2d Lpt %1d Hpt %1d \n",loCircuit,loStripX,iStripX,loStripY,iStripY,loDev,loLpt,loHpt);
    1922             : 
    1923           0 :     AliMUONGlobalTrigger *globalTrigger = fTriggerStore->Global();
    1924           0 :     globalTrigger->Print();
    1925             : 
    1926             :   }
    1927             : 
    1928           0 : }
    1929             : 
    1930             : //__________________________________________________________________________
    1931             : void AliMUONTriggerGUI::WriteTriggerRawData() 
    1932             : {
    1933             :   /// Write raw data (DATE and ROOT) for the trigger store from 
    1934             :   /// the DSET digit store
    1935             : 
    1936           0 :   if (!fTStoreOn) {
    1937           0 :     printf("The trigger store is empty... \n");
    1938           0 :     return;
    1939             :   }
    1940             : 
    1941             :   // raw data (ddl)
    1942             : 
    1943           0 :   AliMUONRawWriter *rawWriter = new AliMUONRawWriter();
    1944           0 :   AliRawDataHeaderSim header;
    1945           0 :   rawWriter->SetHeader(header);
    1946           0 :   rawWriter->Digits2Raw(0,fTriggerStore);
    1947             : 
    1948           0 :   delete rawWriter;
    1949             : 
    1950             :   // raw data (ddl) to date
    1951             :   // AliSimulation::ConvertRawFilesToDate
    1952             : 
    1953           0 :   char command[256];
    1954           0 :   char dateFileName[256];
    1955           0 :   snprintf(dateFileName,256,"TriggerGUI.date");
    1956           0 :   snprintf(command, 256,"dateStream -c -s -D -o %s -# %d -C -run %d",
    1957             :           dateFileName, 1, 0);
    1958           0 :   FILE* pipe = gSystem->OpenPipe(command, "w");
    1959             : 
    1960             :   UInt_t detectorPattern = 0;
    1961           0 :   fprintf(pipe, "GDC DetectorPattern %u\n", detectorPattern);
    1962             :   Float_t ldc = 0;
    1963             :   Int_t prevLDC = -1;
    1964             :   
    1965             :   // loop over detectors and DDLs
    1966           0 :   for (Int_t iDet = 0; iDet < AliDAQ::kNDetectors; iDet++) {
    1967           0 :     for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls(iDet); iDDL++) {
    1968             :       
    1969           0 :       Int_t ddlID = AliDAQ::DdlID(iDet,iDDL);
    1970           0 :       Int_t ldcID = Int_t(ldc + 0.0001);
    1971           0 :       ldc += AliDAQ::NumberOfLdcs(iDet) / AliDAQ::NumberOfDdls(iDet);
    1972             :       
    1973           0 :       char rawFileName[256];
    1974           0 :       snprintf(rawFileName, 256,"%s",AliDAQ::DdlFileName(iDet,iDDL));
    1975             :       // check existence and size of raw data file
    1976           0 :       FILE* file = fopen(rawFileName, "rb");
    1977           0 :       if (!file) continue;
    1978           0 :       fseek(file, 0, SEEK_END);
    1979           0 :       unsigned long size = ftell(file);
    1980           0 :       fclose(file);
    1981           0 :       if (!size) continue;
    1982             : 
    1983           0 :       if (ldcID != prevLDC) {
    1984           0 :         fprintf(pipe, " LDC Id %d\n", ldcID);
    1985             :         prevLDC = ldcID;
    1986           0 :       }
    1987           0 :       fprintf(pipe, "  Equipment Id %d Payload %s\n", ddlID, rawFileName);
    1988           0 :     }
    1989             :   }
    1990           0 :   Int_t result = gSystem->ClosePipe(pipe);
    1991           0 :   printf("ClosePipe: %d \n",result);
    1992             : 
    1993             :   // raw data (date) to root
    1994             :   // AliSimulation::ConvertDateToRoot
    1995             : 
    1996           0 :   char rootFileName[256];
    1997           0 :   snprintf(rootFileName,256,"TriggerGUI.root");
    1998             : 
    1999             :   // ALIMDC setup
    2000             :   const Int_t kDBSize = 2000000000;
    2001             :   const Int_t kTagDBSize = 1000000000;
    2002             :   const Bool_t kFilter = kFALSE;
    2003             :   const Int_t kCompression = 1;
    2004             : 
    2005           0 :   char* path = gSystem->Which(gSystem->Getenv("PATH"), "alimdc");
    2006           0 :   if (!path) {
    2007           0 :     printf("the program alimdc was not found\n");
    2008           0 :     return;
    2009             :   } else {
    2010           0 :     delete[] path;
    2011             :   }
    2012             : 
    2013           0 :   printf("converting DATE file %s to root file %s \n",
    2014             :                dateFileName, rootFileName);
    2015             : 
    2016             :   const char* rawDBFS[2] = { "/tmp/mdc1", "/tmp/mdc2" };
    2017             :   const char* tagDBFS    = "/tmp/mdc1/tags";
    2018             : 
    2019             :   // User defined file system locations
    2020           0 :   if (gSystem->Getenv("ALIMDC_RAWDB1"))
    2021           0 :     rawDBFS[0] = gSystem->Getenv("ALIMDC_RAWDB1");
    2022           0 :   if (gSystem->Getenv("ALIMDC_RAWDB2"))
    2023           0 :     rawDBFS[1] = gSystem->Getenv("ALIMDC_RAWDB2");
    2024           0 :   if (gSystem->Getenv("ALIMDC_TAGDB"))
    2025           0 :     tagDBFS = gSystem->Getenv("ALIMDC_TAGDB");
    2026             : 
    2027           0 :   gSystem->Exec(Form("rm -rf %s",rawDBFS[0]));
    2028           0 :   gSystem->Exec(Form("rm -rf %s",rawDBFS[1]));
    2029           0 :   gSystem->Exec(Form("rm -rf %s",tagDBFS));
    2030             : 
    2031           0 :   gSystem->Exec(Form("mkdir %s",rawDBFS[0]));
    2032           0 :   gSystem->Exec(Form("mkdir %s",rawDBFS[1]));
    2033           0 :   gSystem->Exec(Form("mkdir %s",tagDBFS));
    2034             : 
    2035           0 :   result = gSystem->Exec(Form("alimdc %d %d %d %d %s",
    2036             :                               kDBSize, kTagDBSize, kFilter, kCompression,
    2037             :                               dateFileName));
    2038           0 :   gSystem->Exec(Form("mv %s/*.root %s", rawDBFS[0], rootFileName));
    2039             : 
    2040           0 :   gSystem->Exec(Form("rm -rf %s",rawDBFS[0]));
    2041           0 :   gSystem->Exec(Form("rm -rf %s",rawDBFS[1]));
    2042           0 :   gSystem->Exec(Form("rm -rf %s",tagDBFS));
    2043             : 
    2044           0 : }
    2045             : 
    2046             : //__________________________________________________________________________
    2047             : void AliMUONTriggerGUI::FETboard(Int_t ib, Int_t amp) 
    2048             : {
    2049             :   /// Front End test set all strips for board with index "ib"
    2050             :   /// AliMUONTriggerGUIbdmap::DoDigits()
    2051             : 
    2052             :   AliMUONTriggerGUIboard *board;
    2053             :   AliMUONTriggerGUIboard *btmp;
    2054             :   Int_t pos, over, number, nStripX, nStripY;
    2055             : 
    2056           0 :   board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
    2057           0 :   if (board == 0) return;
    2058             :   
    2059           0 :   nStripX = board->GetXSiy2() - board->GetXSiy1() + 1;
    2060           0 :   nStripY = board->GetYSix2() - board->GetYSix1() + 1;
    2061             :   
    2062           0 :   number = board->GetNumber();
    2063           0 :   pos    = board->GetPosition();
    2064           0 :   over   = board->GetYOver();
    2065             :   
    2066           0 :   for (Int_t imt = 0; imt < kNMT; imt++) {
    2067             :     
    2068           0 :     for (Int_t ix = 0; ix < nStripX; ix++) {
    2069           0 :       board->SetDigitX(imt,ix,amp);
    2070             :     }
    2071             :     
    2072           0 :     for (Int_t iy = 0; iy < nStripY; iy++) {
    2073           0 :       board->SetDigitY(imt,iy,amp);
    2074             :       
    2075             :       // extended y-strips
    2076           0 :       for (Int_t io = 1; io <= over; io++) {
    2077           0 :         if (io == pos) continue;
    2078           0 :         btmp = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
    2079           0 :         btmp->SetDigitY(imt,iy,amp);
    2080           0 :       }
    2081             :       
    2082             :     }
    2083             :     
    2084             :   }
    2085             :   
    2086           0 : }
    2087             : 
    2088             : //__________________________________________________________________________
    2089             : void AliMUONTriggerGUI::FET(Int_t onoff) 
    2090             : {
    2091             :   /// Front End test set all strips for all boards
    2092             :   /// AliMUONTriggerGUIbdmap::DoDigits()
    2093             : 
    2094             :   Int_t amp = onoff;
    2095             : 
    2096           0 :   for (Int_t ib = 0; ib < kNBoards; ib++) {
    2097           0 :     FETboard(ib,amp);
    2098             :   }
    2099             : 
    2100           0 : }
    2101             : 
    2102             : //__________________________________________________________________________
    2103             : void AliMUONTriggerGUI::ClearDigitStore() 
    2104             : {
    2105             :   /// Clear the DSET digit store
    2106             : 
    2107           0 :   fDigitStore->Clear();
    2108             : 
    2109           0 : }
    2110             : 
    2111             : //__________________________________________________________________________
    2112             : void AliMUONTriggerGUI::ClearTriggerStore() 
    2113             : {
    2114             :   /// Clear the trigger store from the DSET digit store
    2115             : 
    2116           0 :   fTriggerStore->Clear();
    2117           0 :   fTStoreOn = kFALSE;
    2118             : 
    2119           0 : }

Generated by: LCOV version 1.11