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