24be889aa8fcfb29ae82983f5835f34096aadb67
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveHOMERManagerEditor.cxx
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 #include "AliEveHOMERManagerEditor.h"
11 #include "AliEveHOMERManager.h"
12
13 #include <TVirtualPad.h>
14 #include <TColor.h>
15 #include <TROOT.h>
16
17 #include <TGLabel.h>
18 #include <TGButton.h>
19 #include <TGNumberEntry.h>
20 #include <TGColorSelect.h>
21 #include <TGDoubleSlider.h>
22 #include <TGComboBox.h>
23
24 //______________________________________________________________________________
25 // AliEveHOMERManagerEditor
26 //
27
28 ClassImp(AliEveHOMERManagerEditor)
29
30 AliEveHOMERManagerEditor::AliEveHOMERManagerEditor(const TGWindow *p, Int_t width, Int_t height,
31              UInt_t options, Pixel_t back) :
32   
33 TGedFrame(p, width, height, options | kVerticalFrame, back),
34   fM(0),
35   fButtonConnect(NULL),
36   fButtonWriteToFile(0),
37   fButtonNextEvent(0),
38   fButtonNavigateBack(0),
39   fButtonNavigateFwd(0),
40   fBoxTriggerSelector(0),
41   fButtonEventLoopText(0),
42 //  fBoxEventLoopSpeed(0),
43   fButtonEventLoop(0),
44   fButtonPrintScreens(NULL),
45  fEventLoopStarted(kFALSE) 
46 {
47   
48   MakeTitle("AliEveHOMERManager");
49
50   // Create widgets
51   // fXYZZ = new TGSomeWidget(this, ...);
52   // AddFrame(fXYZZ, new TGLayoutHints(...));
53   // fXYZZ->Connect("SignalName()", "AliEveHOMERManagerEditor", this, "DoXYZZ()");
54
55   fButtonConnect = new TGTextButton(this, " Reconnect ");
56   AddFrame(fButtonConnect); //, new TGLayoutHints(...));
57   fButtonConnect->Connect("Clicked()", "AliEveHOMERManagerEditor", this, "ConnectToHLT()");
58
59   fButtonWriteToFile = new TGTextButton(this, " Write to file  ");
60   AddFrame(fButtonWriteToFile); //, new TGLayoutHints(...));
61   fButtonWriteToFile->Connect("Clicked()", "AliEveHOMERManagerEditor", this, "WriteBlockListToFile()");
62
63
64   fButtonNextEvent = new TGTextButton(this, "  NextEvent  ");
65   AddFrame(fButtonNextEvent); //, new TGLayoutHints(...));
66   fButtonNextEvent->Connect("Clicked()", "AliEveHOMERManagerEditor", this, "NextEvent()");
67
68   fButtonNavigateBack = new TGTextButton(this, "  Navigate Back  ");
69   AddFrame(fButtonNavigateBack); //, new TGLayoutHints(...));
70   fButtonNavigateBack->Connect("Clicked()", "AliEveHOMERManagerEditor", this, "NavigateBack()");
71
72   fButtonNavigateFwd = new TGTextButton(this, "  Navigate Fwd  ");
73   AddFrame(fButtonNavigateFwd); //, new TGLayoutHints(...));
74   fButtonNavigateFwd->Connect("Clicked()", "AliEveHOMERManagerEditor", this, "NavigateFwd()");
75
76   fBoxTriggerSelector = new TGComboBox(this, "Select Trigger");
77   fBoxTriggerSelector->AddEntry("HLT Global Trigger", 0);
78   fBoxTriggerSelector->AddEntry("Barrel multiplicity trigger", 1);
79   fBoxTriggerSelector->AddEntry("PHOS Geometry trigger", 2);
80   fBoxTriggerSelector->AddEntry("No trigger selection", 3);
81   fBoxTriggerSelector->Connect("Selected(Int_t)","AliEveHOMERManagerEditor", this, "SetTriggerString(int)");
82   fBoxTriggerSelector->SetWidth(150);
83   fBoxTriggerSelector->SetHeight(25);
84   AddFrame(fBoxTriggerSelector);
85
86   fButtonEventLoopText = new TGTextButton(this, "  Loop Events  ");
87   AddFrame(fButtonEventLoopText); //, new TGLayoutHints(...));
88   fButtonEventLoopText->Connect("Clicked()", "AliEveHOMERManagerEditor", this, "EventLoop()");
89
90
91   fButtonPrintScreens = new TGTextButton(this, "  Save Viewers  ");
92   AddFrame(fButtonPrintScreens); //, new TGLayoutHints(...));
93   fButtonPrintScreens->Connect("Clicked()", "AliEveHOMERManagerEditor", this, "PrintScreens()");
94
95   fButtonEventLoop = new TGPictureButton(this, gClient->GetPicture("$ALICE_ROOT/EVE/hlt-macros/HLT-logo.png"));
96   AddFrame(fButtonEventLoop); //, new TGLayoutHints(...));
97   fButtonEventLoop->Connect("Clicked()", "AliEveHOMERManagerEditor", this, "EventLoop()");
98 }
99
100 /******************************************************************************/
101
102 void AliEveHOMERManagerEditor::SetModel(TObject* obj) {
103   fM = dynamic_cast<AliEveHOMERManager*>(obj);
104
105   // Set values of widgets
106   // fXYZZ->SetValue(fM->GetXYZZ());
107 }
108
109 /******************************************************************************/
110
111 void AliEveHOMERManagerEditor::ConnectToHLT() {
112    // Connects to HOMER sources -> to HLT.
113   fM->ReConnectHOMER();
114 }
115
116 void AliEveHOMERManagerEditor::NextEvent() {
117   // call next event from AliEveHOMERManger
118   fM->NextHOMEREvent();
119 }
120
121 void AliEveHOMERManagerEditor::WriteBlockListToFile() {
122   gROOT->ProcessLineFast("writeToFile();");
123
124 }
125
126
127 void AliEveHOMERManagerEditor::PrintScreens() {
128   //Print screens
129   fM->PrintScreens();
130 }
131
132 void AliEveHOMERManagerEditor::NavigateFwd() {
133   // navigate forward
134   
135   if ( !fEventLoopStarted ) {
136     if ( fM->NavigateEventBufferFwd() == -1 )
137       return;
138
139     fM->ProcessEvent();
140     //    gROOT->ProcessLineFast("processEvent();");
141   }
142   return;
143 }
144
145 void AliEveHOMERManagerEditor::NavigateBack() {
146   // navigate back
147
148   if ( !fEventLoopStarted ) {
149     if ( fM->NavigateEventBufferBack() == -1 )
150       return;
151     
152     fM->ProcessEvent();
153     //gROOT->ProcessLineFast("processEvent();");
154   }
155   return;
156 }
157
158 void AliEveHOMERManagerEditor::EventLoop() {
159   // Start/stop event loop
160   if ( !fEventLoopStarted ) {
161     fEventLoopStarted = kTRUE;
162     fButtonEventLoopText->SetText(" Stop Loop ");
163     //fM->SetEventLoopStarted(kTRUE);
164     fM->StartLoop();
165     
166     //    gROOT->ProcessLineFast("loopEvent();");
167   
168   } else {
169     
170     //gROOT->ProcessLineFast("stopLoopEvent();");
171     fM->StopLoop();
172     fEventLoopStarted = kFALSE;
173     //fM->SetEventLoopStarted(kFALSE);
174     fButtonEventLoopText->SetText(" Loop Events ");
175   }
176 }
177
178 void AliEveHOMERManagerEditor::SetTriggerString(int id) {
179
180   if (id < 0 || id > 4) {
181     return;
182   }
183   
184   TString tsa[4] = {"HLTGlobalTrigger", 
185                     "BarrelMultiplicityTrigger", 
186                     "PHOSgeomTrigger",
187                     "ALL"};
188    
189  
190   fM->SetTriggerString(tsa[id]);
191     
192 }
193