]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTriggerGUI.cxx
New class for AOD<->MC association
[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 = gAlice->GetEventsPerRun();
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       const AliMpTriggerSegmentation *trigseg0 = static_cast<const AliMpTriggerSegmentation*>(seg0);
1465       for (Int_t ix = 0; ix <= seg0->MaxPadIndexX(); ix++) {
1466         for (Int_t iy = 0; iy <= seg0->MaxPadIndexY(); iy++) {
1467           AliMpIntPair indices(ix,iy);
1468           AliMpPad pad = trigseg0->PadByIndices(indices,kFALSE);
1469           if (pad.IsValid()) {
1470             AliMpIntPair loc = pad.GetLocation(0);
1471             Int_t manuId = loc.GetFirst();
1472             if (manuId != manuIdPrev) {
1473               AliMpLocalBoard *mpboard = AliMpDDLStore::Instance()->GetLocalBoard(manuId);
1474               manuIdPrev = manuId;
1475               if (ich == 0) {
1476                 boardId++;
1477               } else {
1478                 boardId = cIdtobId[manuId];
1479               }
1480               board = GetBoard(boardId);
1481               if (board->GetNumber() == -1)
1482                 board->SetNumber(boardId);
1483               if (board->GetDetElemId() == -1) 
1484                 board->SetDetElemId(idet);
1485               if (!strcmp(board->GetBoardName(),""))
1486                 board->SetBoardName(mpboard->GetName());
1487               cIdtobId[manuId] = boardId;
1488             }
1489             GetBoard(boardId)->AddPadX(pad,ich);
1490           }
1491         }
1492       }  // end plane 0 (x-strips)
1493          
1494       // y-strips
1495       manuIdPrev = 0;
1496       const AliMpTriggerSegmentation *trigseg1 = static_cast<const AliMpTriggerSegmentation*>(seg1);
1497       for (Int_t ix = 0; ix <= seg1->MaxPadIndexX(); ix++) {
1498         for (Int_t iy = 0; iy <= seg1->MaxPadIndexY(); iy++) {
1499           AliMpIntPair indices(ix,iy);
1500           AliMpPad pad = trigseg1->PadByIndices(indices,kFALSE);
1501           if (pad.IsValid()) {
1502             Int_t nloc = pad.GetNofLocations();
1503             for (Int_t iloc = 0; iloc < nloc; iloc++) {
1504               AliMpIntPair loc = pad.GetLocation(iloc);
1505               Int_t manuId = loc.GetFirst();
1506               if (manuId != manuIdPrev) {
1507                 manuIdPrev = manuId;
1508                 boardIdTmp = cIdtobId[manuId];
1509               }
1510               GetBoard(boardIdTmp)->AddPadY(pad,ich);
1511             }
1512           }
1513         }
1514       }  // end plane 1 (y-strips)
1515       
1516     } // end det elem loop
1517   } // end chamber loop
1518   
1519   for (Int_t ib = 0; ib < kNBoards; ib++) {
1520     board = GetBoard(ib);
1521     board->MakeGeometry();
1522     AliMUONLocalTriggerBoard* b = fCrateManager->LocalBoard(board->GetIdCircuit());
1523     board->SetCrateName((b->GetCrate()).Data());
1524   }
1525   
1526   // create the sensitive map
1527
1528   Int_t nPixelX = 700;
1529   Int_t nPixelY = 676;
1530
1531   Int_t nPixelBorderX = 40;  // to guess...
1532   Int_t nPixelBorderY = 40;  // to guess...
1533
1534   // boards limits
1535   Float_t boardsX = 2*257.00;  // cm
1536   Float_t boardsY = 2*306.61;  // cm
1537
1538   UShort_t status = 1;
1539   Float_t xc, yc, xw, yw;
1540   Char_t text[256];
1541   Int_t x, y;
1542   UInt_t w, h;
1543   Int_t xp[5];
1544   Int_t yp[5];
1545
1546   TGRegion *reg;
1547
1548   // regions for the image map (from MT11)
1549
1550   for (Int_t ib = 0; ib < kNBoards; ib++) {
1551
1552     board = GetBoard(ib);
1553
1554     status = 1;
1555     board->SetStatus(status);
1556
1557     xc = board->GetXCenter(0);
1558     yc = board->GetYCenter(0);
1559     xw = board->GetXWidth(0);
1560     yw = board->GetYWidth(0);
1561
1562     x = (Int_t)(nPixelX/2 + xc * (nPixelX - 2*nPixelBorderX)/boardsX);
1563     y = (Int_t)(nPixelY/2 - yc * (nPixelY - 2*nPixelBorderY)/boardsY);
1564
1565     if (x < 0) x = 0;
1566     if (y < 0) y = 0;
1567
1568     w = (UInt_t)(xw*(nPixelX-2*nPixelBorderX)/boardsX);
1569     h = (UInt_t)(yw*(nPixelY-2*nPixelBorderY)/boardsY);
1570     
1571     xp[0] = x-w/2;
1572     xp[1] = x+w/2;
1573     xp[2] = x+w/2;
1574     xp[3] = x-w/2;
1575     xp[4] = x-w/2;
1576     
1577     yp[0] = y-h/2;
1578     yp[1] = y-h/2;
1579     yp[2] = y+h/2;
1580     yp[3] = y+h/2;
1581     yp[4] = y-h/2;
1582
1583     reg = new TGRegion(5,xp,yp);
1584     fImageMap->AddRegion(*reg, ib);
1585
1586     sprintf(text,"%s (crate %s circuit %3d, number %3d)",board->GetBoardName(),board->GetCrateName(),board->GetIdCircuit(),board->GetNumber());
1587     fImageMap->SetToolTipText(ib, text);
1588
1589     // Set coordinates of strips boxes
1590     
1591     SetStripBoxes(board);
1592     
1593     //board->PrintBoard();
1594     
1595   }
1596   
1597 }
1598
1599 //__________________________________________________________________________
1600 void AliMUONTriggerGUI::SetStripBoxes(AliMUONTriggerGUIboard *board) 
1601 {
1602   /// set coordinates of strip boxes
1603
1604   AliMUONGeometryTransformer transformer;
1605   transformer.LoadGeometryData("transform.dat");
1606
1607   const AliMpVSegmentation* seg;
1608   AliMpPad pad;
1609   AliMpDEIterator it;
1610
1611   Int_t chamber, detElemId, maxX, maxY;
1612   Float_t xpmin, xpmax, ypmin, ypmax;
1613   Float_t xg1, xg2, yg1, yg2, zg1;
1614   Float_t xlocal1, xlocal2, ylocal1, ylocal2;
1615   Float_t xCenter, yCenter, xWidth, yWidth;
1616
1617   for (Int_t i = 0; i < kNMT; i++) {
1618
1619     chamber = 11+i;
1620
1621     xCenter = board->GetXCenter(i);
1622     yCenter = board->GetYCenter(i);
1623     xWidth  = board->GetXWidth(i);
1624     yWidth  = board->GetYWidth(i);
1625
1626     for ( it.First(chamber-1); ! it.IsDone(); it.Next() ) {
1627     
1628       detElemId = it.CurrentDEId();
1629     
1630       if (detElemId%100 != board->GetDetElemId()) continue;
1631
1632       /*---------- y-pads cath = 1 ----------*/
1633       
1634       seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::kCath1);
1635
1636       maxX = seg->MaxPadIndexX();
1637       maxY = seg->MaxPadIndexY();
1638       
1639       for (Int_t ix = 0; ix <= maxX; ix++) {
1640         for (Int_t iy = 0; iy <= maxY; iy++) {
1641           
1642           pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE);
1643           
1644           if (!pad.IsValid()) continue;
1645           
1646           // get the pad position and dimensions
1647           xlocal1 = pad.Position().X();
1648           ylocal1 = pad.Position().Y();
1649           xlocal2 = pad.Dimensions().X();
1650           ylocal2 = pad.Dimensions().Y();
1651           
1652           transformer.Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
1653           // (no transformation for pad dimensions)
1654           xg2 = xlocal2;
1655           yg2 = ylocal2;
1656           
1657           // transform in the monitor coordinate system
1658           // ALICE SC
1659           xpmin = +(xg1-xg2);
1660           xpmax = +(xg1+xg2);
1661           ypmin = -(yg2-yg1);
1662           ypmax = +(yg2+yg1);
1663           
1664           xpmin -= xCenter;
1665           xpmax -= xCenter;
1666           ypmin -= yCenter;
1667           ypmax -= yCenter;
1668           
1669           Int_t iX1, iX2, iY, ixDig;
1670           iX1 = board->GetYSix1();
1671           iX2 = board->GetYSix2();
1672           iY  = board->GetYSiy();
1673           if (ix >= iX1 && ix <= iX2 && iy == iY) {
1674             
1675             ypmin = -0.5*yWidth;
1676             ypmax = +0.5*yWidth;
1677
1678             ixDig = ix - iX1;
1679
1680             board->SetYDigBox(i,ixDig,(Double_t)xpmin,(Double_t)ypmin,
1681                                       (Double_t)xpmax,(Double_t)ypmax);
1682
1683           }
1684
1685         }  // end maxY
1686       }  // end maxX
1687
1688       /*---------- x-pads cath = 0 ----------*/
1689       
1690       seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::kCath0);
1691
1692       maxX = seg->MaxPadIndexX();
1693       maxY = seg->MaxPadIndexY();
1694             
1695       for (Int_t ix = 0; ix <= maxX; ix++) {
1696         for (Int_t iy = 0; iy <= maxY; iy++) {
1697           
1698           pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE);
1699           
1700           if (!pad.IsValid()) continue;
1701           
1702           // get the pad position and dimensions
1703           xlocal1 = pad.Position().X();
1704           ylocal1 = pad.Position().Y();
1705           xlocal2 = pad.Dimensions().X();
1706           ylocal2 = pad.Dimensions().Y();
1707           
1708           transformer.Local2Global(detElemId, xlocal1, ylocal1, 0, xg1, yg1, zg1);
1709           // (no transformation for pad dimensions)
1710           xg2 = xlocal2;
1711           yg2 = ylocal2;
1712           
1713           // transform in the monitor coordinate system
1714           // ALICE SC
1715           xpmin = +(xg1+xg2);
1716           xpmax = +(xg1-xg2);
1717           ypmin = -(yg2-yg1);
1718           ypmax = +(yg2+yg1);
1719           
1720           xpmin -= xCenter;
1721           xpmax -= xCenter;
1722           ypmin -= yCenter;
1723           ypmax -= yCenter;
1724
1725           Int_t iX, iY1, iY2, iyDig;
1726           iX  = board->GetXSix();
1727           iY1 = board->GetXSiy1();
1728           iY2 = board->GetXSiy2();
1729           if (ix == iX && iy >= iY1 && iy <= iY2) {
1730
1731             iyDig = iy - iY1;
1732
1733             board->SetXDigBox(i,iyDig,(Double_t)xpmin,(Double_t)ypmin,
1734                                       (Double_t)xpmax,(Double_t)ypmax);
1735
1736           }
1737
1738         }  // end maxY
1739       }  // end maxX
1740
1741     }  // end detElemId
1742
1743   }  // end kNMT loop
1744         
1745 }
1746
1747 //__________________________________________________________________________
1748 void AliMUONTriggerGUI::CreateDigitStore() 
1749 {
1750   /// create memory resident digits store with set strips
1751
1752   Int_t nstripX, nstripY, detElemId, charge, ix, iy, iX1, iY1;
1753   Int_t cathode, maxX, maxY;
1754   Int_t manuId, manuChannel;
1755   const AliMpVSegmentation* seg;
1756   AliMpPad pad;
1757   AliMUONTriggerGUIboard* board;
1758   AliMUONVDigit *dig;
1759
1760   for (Int_t ib = 0; ib < kNBoards; ib++) {
1761
1762     board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
1763     if (board == 0) continue;
1764
1765     nstripX = board->GetNStripX();
1766     nstripY = board->GetNStripY();
1767     for (Int_t ichamber = 11; ichamber <= 14; ichamber++) {
1768       
1769       detElemId = ichamber * 100 + board->GetDetElemId();
1770       // x strips
1771       cathode = 0;
1772       for (Int_t isx = 0; isx < nstripX; isx++) {
1773         
1774         charge = (Int_t)board->GetXDig(ichamber-11,isx);
1775         if (charge == 0) continue;
1776         ix  = board->GetXSix();
1777         iY1 = board->GetXSiy1();
1778         iy  = isx + iY1;
1779         seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cathode));
1780         maxX = seg->MaxPadIndexX();
1781         maxY = seg->MaxPadIndexY();
1782         if (ix > maxX) printf("Index x > maximum!\n");
1783         if (iy > maxY) printf("Index y > maximum!\n");
1784         pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
1785         manuId = pad.GetLocation(0).GetFirst();
1786         manuChannel = pad.GetLocation(0).GetSecond();
1787
1788         dig = fDigitStore->Add(detElemId,manuId,manuChannel,cathode,AliMUONVDigitStore::kAllow);
1789         dig->SetCharge(charge);
1790         dig->SetPadXY(ix,iy);
1791         //printf("Cathode 0: ix %3d iy %3d manuId %3d manuChannel %3d \n",ix,iy,manuId,manuChannel);
1792
1793       }  // end x strips
1794
1795       // y strips
1796       cathode = 1;
1797       for (Int_t isy = 0; isy < nstripY; isy++) {
1798         
1799         charge = board->GetYDig(ichamber-11,isy);
1800         if (charge == 0) continue;
1801         iX1 = board->GetYSix1();
1802         ix  = isy + iX1;
1803         iy  = board->GetYSiy();
1804         seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cathode));
1805         maxX = seg->MaxPadIndexX();
1806         maxY = seg->MaxPadIndexY();
1807         if (ix > maxX) printf("Index x > maximum!\n");
1808         if (iy > maxY) printf("Index y > maximum!\n");
1809         pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
1810         manuId = pad.GetLocation(0).GetFirst();
1811         manuChannel = pad.GetLocation(0).GetSecond();
1812
1813         dig = fDigitStore->Add(detElemId,manuId,manuChannel,cathode,AliMUONVDigitStore::kAllow);
1814         dig->SetCharge(charge);
1815         dig->SetPadXY(ix,iy);
1816         //printf("Cathode 1: ix %3d iy %3d manuId %3d manuChannel %3d \n",ix,iy,manuId,manuChannel);
1817
1818       }  // end y strips
1819
1820     }  // end chambers
1821
1822   }  // end boards
1823
1824 }
1825
1826 //__________________________________________________________________________
1827 void AliMUONTriggerGUI::PrintDigitStore() const
1828 {
1829   /// Print the digits created in the GUI
1830
1831   const AliMpVSegmentation* seg;
1832   AliMpPad pad;
1833   Int_t ix, iy, charge, detElemId, cathode;
1834
1835   Int_t chamber;
1836   for (Int_t i = 0; i < kNMT; i++) {
1837
1838     chamber = 11+i;
1839
1840     AliMpIntPair deRange = AliMpDEManager::GetDetElemIdRange(chamber-1);
1841     TIter next(fDigitStore->CreateIterator(deRange.GetFirst(),deRange.GetSecond()));
1842     AliMUONVDigit *mdig;
1843
1844     while ( ( mdig = static_cast<AliMUONVDigit*>(next())) )
1845     {
1846       cathode = mdig->Cathode();
1847       
1848       ix = mdig->PadX();
1849       iy = mdig->PadY();
1850       detElemId = mdig->DetElemId(); 
1851       charge = (Int_t)mdig->Charge();
1852
1853       seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cathode));  
1854       pad = seg->PadByIndices(AliMpIntPair(ix,iy),kTRUE);
1855       AliMpIntPair ind = pad.GetIndices();
1856
1857       printf("Digit: detElemId %4d cath %1d ix %2d iy %3d charge %1d \n",detElemId,cathode,ix,iy,charge);
1858       
1859     }
1860
1861   }
1862
1863 }
1864
1865 //__________________________________________________________________________
1866 void AliMUONTriggerGUI::CreateTriggerStore() 
1867 {
1868   /// Process the DSET digit store and fill the trigger store
1869
1870   if (fDigitStore->GetSize() == 0) {
1871     printf("The digit store is empty...\n");
1872     return;
1873   }
1874   fTStoreOn = kTRUE;
1875
1876   AliMUONVDigitStore *digitStore = static_cast<AliMUONVDigitStore*>(fDigitStore);
1877
1878   fTriggerProcessor->Digits2Trigger(*digitStore,*fTriggerStore);
1879
1880 }
1881
1882 //__________________________________________________________________________
1883 void AliMUONTriggerGUI::PrintTriggerStore() const
1884 {
1885   /// Print the trigger output for DSET digits store
1886
1887   if (!fTStoreOn) return;
1888
1889   TIter next(fTriggerStore->CreateLocalIterator());
1890   
1891   UShort_t x2m, x2u, x2d;
1892   Int_t loStripX, loStripY, loDev, loCircuit, iStripX, iStripY, loLpt, loHpt;
1893   AliMUONLocalTrigger *mlt;
1894   while ( ( mlt = static_cast<AliMUONLocalTrigger*>(next()) ) )
1895   {    
1896     loCircuit = mlt->LoCircuit();
1897
1898     AliMUONLocalTriggerBoard* ltb = fCrateManager->LocalBoard(loCircuit);
1899     x2d = ltb->GetSwitch(0);
1900     x2m = ltb->GetSwitch(1);
1901     x2u = ltb->GetSwitch(2);
1902     
1903     loStripX = mlt->LoStripX();
1904     loStripY = mlt->LoStripY();
1905     loDev    = mlt->LoDev();
1906     loLpt    = mlt->LoLpt();
1907     loHpt    = mlt->LoHpt();
1908
1909     iStripX = loStripX/2;
1910     if ((x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) {
1911       iStripY = loStripY/2;
1912     } else {
1913       iStripY = loStripY;
1914     }
1915     
1916     printf("Circ %3d Xs %2d Ys %2d Dev %2d Lpt %1d Hpt %1d \n",loCircuit,loStripX,loStripY,loDev,loLpt,loHpt);
1917
1918     AliMUONGlobalTrigger *globalTrigger = fTriggerStore->Global();
1919     globalTrigger->Print();
1920
1921   }
1922
1923 }
1924
1925 //__________________________________________________________________________
1926 void AliMUONTriggerGUI::WriteTriggerRawData() 
1927 {
1928   /// Write raw data (DATE and ROOT) for the trigger store from 
1929   /// the DSET digit store
1930
1931   if (!fTStoreOn) {
1932     printf("The trigger store is empty... \n");
1933     return;
1934   }
1935
1936   // raw data (ddl)
1937
1938   AliMUONRawWriter *rawWriter = new AliMUONRawWriter();
1939   AliRawDataHeaderSim header;
1940   rawWriter->SetHeader(header);
1941   rawWriter->Digits2Raw(0,fTriggerStore);
1942
1943   delete rawWriter;
1944
1945   // raw data (ddl) to date
1946   // AliSimulation::ConvertRawFilesToDate
1947
1948   char command[256];
1949   char dateFileName[256];
1950   sprintf(dateFileName,"TriggerGUI.date");
1951   sprintf(command, "dateStream -c -s -D -o %s -# %d -C -run %d",
1952           dateFileName, 1, 0);
1953   FILE* pipe = gSystem->OpenPipe(command, "w");
1954
1955   UInt_t detectorPattern = 0;
1956   fprintf(pipe, "GDC DetectorPattern %u\n", detectorPattern);
1957   Float_t ldc = 0;
1958   Int_t prevLDC = -1;
1959   
1960   // loop over detectors and DDLs
1961   for (Int_t iDet = 0; iDet < AliDAQ::kNDetectors; iDet++) {
1962     for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls(iDet); iDDL++) {
1963       
1964       Int_t ddlID = AliDAQ::DdlID(iDet,iDDL);
1965       Int_t ldcID = Int_t(ldc + 0.0001);
1966       ldc += AliDAQ::NumberOfLdcs(iDet) / AliDAQ::NumberOfDdls(iDet);
1967       
1968       char rawFileName[256];
1969       sprintf(rawFileName, "%s",AliDAQ::DdlFileName(iDet,iDDL));
1970       // check existence and size of raw data file
1971       FILE* file = fopen(rawFileName, "rb");
1972       if (!file) continue;
1973       fseek(file, 0, SEEK_END);
1974       unsigned long size = ftell(file);
1975       fclose(file);
1976       if (!size) continue;
1977
1978       if (ldcID != prevLDC) {
1979         fprintf(pipe, " LDC Id %d\n", ldcID);
1980         prevLDC = ldcID;
1981       }
1982       fprintf(pipe, "  Equipment Id %d Payload %s\n", ddlID, rawFileName);
1983     }
1984   }
1985   Int_t result = gSystem->ClosePipe(pipe);
1986
1987   // raw data (date) to root
1988   // AliSimulation::ConvertDateToRoot
1989
1990   char rootFileName[256];
1991   sprintf(rootFileName,"TriggerGUI.root");
1992
1993   // ALIMDC setup
1994   const Int_t kDBSize = 2000000000;
1995   const Int_t kTagDBSize = 1000000000;
1996   const Bool_t kFilter = kFALSE;
1997   const Int_t kCompression = 1;
1998
1999   char* path = gSystem->Which(gSystem->Getenv("PATH"), "alimdc");
2000   if (!path) {
2001     printf("the program alimdc was not found\n");
2002     return;
2003   } else {
2004     delete[] path;
2005   }
2006
2007   printf("converting DATE file %s to root file %s \n",
2008                dateFileName, rootFileName);
2009
2010   const char* rawDBFS[2] = { "/tmp/mdc1", "/tmp/mdc2" };
2011   const char* tagDBFS    = "/tmp/mdc1/tags";
2012
2013   // User defined file system locations
2014   if (gSystem->Getenv("ALIMDC_RAWDB1"))
2015     rawDBFS[0] = gSystem->Getenv("ALIMDC_RAWDB1");
2016   if (gSystem->Getenv("ALIMDC_RAWDB2"))
2017     rawDBFS[1] = gSystem->Getenv("ALIMDC_RAWDB2");
2018   if (gSystem->Getenv("ALIMDC_TAGDB"))
2019     tagDBFS = gSystem->Getenv("ALIMDC_TAGDB");
2020
2021   gSystem->Exec(Form("rm -rf %s",rawDBFS[0]));
2022   gSystem->Exec(Form("rm -rf %s",rawDBFS[1]));
2023   gSystem->Exec(Form("rm -rf %s",tagDBFS));
2024
2025   gSystem->Exec(Form("mkdir %s",rawDBFS[0]));
2026   gSystem->Exec(Form("mkdir %s",rawDBFS[1]));
2027   gSystem->Exec(Form("mkdir %s",tagDBFS));
2028
2029   result = gSystem->Exec(Form("alimdc %d %d %d %d %s",
2030                               kDBSize, kTagDBSize, kFilter, kCompression,
2031                               dateFileName));
2032   gSystem->Exec(Form("mv %s/*.root %s", rawDBFS[0], rootFileName));
2033
2034   gSystem->Exec(Form("rm -rf %s",rawDBFS[0]));
2035   gSystem->Exec(Form("rm -rf %s",rawDBFS[1]));
2036   gSystem->Exec(Form("rm -rf %s",tagDBFS));
2037
2038 }
2039
2040 //__________________________________________________________________________
2041 void AliMUONTriggerGUI::FETboard(Int_t ib, Int_t amp) 
2042 {
2043   /// Front End test set all strips for board with index "ib"
2044   /// AliMUONTriggerGUIbdmap::DoDigits()
2045
2046   AliMUONTriggerGUIboard *board;
2047   AliMUONTriggerGUIboard *btmp;
2048   Int_t pos, over, number, nStripX, nStripY;
2049
2050   board = (AliMUONTriggerGUIboard*)fBoards->At(ib);
2051   if (board == 0) return;
2052   
2053   nStripX = board->GetXSiy2() - board->GetXSiy1() + 1;
2054   nStripY = board->GetYSix2() - board->GetYSix1() + 1;
2055   
2056   number = board->GetNumber();
2057   pos    = board->GetPosition();
2058   over   = board->GetYOver();
2059   
2060   for (Int_t imt = 0; imt < kNMT; imt++) {
2061     
2062     for (Int_t ix = 0; ix < nStripX; ix++) {
2063       board->SetDigitX(imt,ix,amp);
2064     }
2065     
2066     for (Int_t iy = 0; iy < nStripY; iy++) {
2067       board->SetDigitY(imt,iy,amp);
2068       
2069       // extended y-strips
2070       for (Int_t io = 1; io <= over; io++) {
2071         if (io == pos) continue;
2072         btmp = (AliMUONTriggerGUIboard*)fBoards->UncheckedAt(number+io-pos);
2073         btmp->SetDigitY(imt,iy,amp);
2074       }
2075       
2076     }
2077     
2078   }
2079   
2080 }
2081
2082 //__________________________________________________________________________
2083 void AliMUONTriggerGUI::FET(Int_t onoff) 
2084 {
2085   /// Front End test set all strips for all boards
2086   /// AliMUONTriggerGUIbdmap::DoDigits()
2087
2088   Int_t amp = onoff;
2089
2090   for (Int_t ib = 0; ib < kNBoards; ib++) {
2091     FETboard(ib,amp);
2092   }
2093
2094 }
2095
2096 //__________________________________________________________________________
2097 void AliMUONTriggerGUI::ClearDigitStore() 
2098 {
2099   /// Clear the DSET digit store
2100
2101   fDigitStore->Clear();
2102
2103 }
2104
2105 //__________________________________________________________________________
2106 void AliMUONTriggerGUI::ClearTriggerStore() 
2107 {
2108   /// Clear the trigger store from the DSET digit store
2109
2110   fTriggerStore->Clear();
2111   fTStoreOn = kFALSE;
2112
2113 }