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