Merge branch 'multipleThreads'
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveHLTEventManagerEditor.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 "AliEveHLTEventManagerEditor.h"
11 #include "AliEveHLTEventManager.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 // AliEveHLTEventManagerEditor
26 //
27
28 ClassImp(AliEveHLTEventManagerEditor)
29
30 AliEveHLTEventManagerEditor::AliEveHLTEventManagerEditor(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   fButtonPrintScreens(NULL),
41   fBoxTriggerSelector(0),
42 //  fBoxEventLoopSpeed(0),
43   fButtonEventLoopText(0),
44   fButtonUpdateEvents(NULL),
45   fButtonEventLoop(0),
46  fEventLoopStarted(kFALSE) 
47 {
48
49   fButtonUpdateEvents = new TGTextButton(this, " Fill buffer.. ");
50   AddFrame(fButtonUpdateEvents); //, new TGLayoutHints(...));
51   fButtonUpdateEvents->Connect("Clicked()", "AliEveHLTEventManagerEditor", this, "PollEvents()");
52
53
54   MakeTitle("AliEveHLTEventManager");
55
56   // Create widgets
57   // fXYZZ = new TGSomeWidget(this, ...);
58   // AddFrame(fXYZZ, new TGLayoutHints(...));
59   // fXYZZ->Connect("SignalName()", "AliEveHLTEventManagerEditor", this, "DoXYZZ()");
60
61   fButtonConnect = new TGTextButton(this, " Reconnect ");
62   AddFrame(fButtonConnect); //, new TGLayoutHints(...));
63   fButtonConnect->Connect("Clicked()", "AliEveHLTEventManagerEditor", this, "ConnectToHLT()");
64
65   fButtonWriteToFile = new TGTextButton(this, " Write to file  ");
66   AddFrame(fButtonWriteToFile); //, new TGLayoutHints(...));
67   fButtonWriteToFile->Connect("Clicked()", "AliEveHLTEventManagerEditor", this, "WriteBlockListToFile()");
68
69
70   fButtonNextEvent = new TGTextButton(this, "  NextEvent  ");
71   AddFrame(fButtonNextEvent); //, new TGLayoutHints(...));
72   fButtonNextEvent->Connect("Clicked()", "AliEveHLTEventManagerEditor", this, "NextEvent()");
73
74   fButtonNavigateBack = new TGTextButton(this, "  Navigate Back  ");
75   AddFrame(fButtonNavigateBack); //, new TGLayoutHints(...));
76   fButtonNavigateBack->Connect("Clicked()", "AliEveHLTEventManagerEditor", this, "NavigateBack()");
77
78   fButtonNavigateFwd = new TGTextButton(this, "  Navigate Fwd  ");
79   AddFrame(fButtonNavigateFwd); //, new TGLayoutHints(...));
80   fButtonNavigateFwd->Connect("Clicked()", "AliEveHLTEventManagerEditor", this, "NavigateFwd()");
81
82
83   fButtonPrintScreens = new TGTextButton(this, "  Save Viewers  ");
84   AddFrame(fButtonPrintScreens); //, new TGLayoutHints(...));
85   fButtonPrintScreens->Connect("Clicked()", "AliEveHLTEventManagerEditor", this, "PrintScreens()");
86
87
88   fBoxTriggerSelector = new TGComboBox(this, "Select Trigger");
89   fBoxTriggerSelector->AddEntry("HLT Global Trigger", 0);
90   fBoxTriggerSelector->AddEntry("Barrel multiplicity trigger", 1);
91   fBoxTriggerSelector->AddEntry("PHOS Geometry trigger", 2);
92   fBoxTriggerSelector->AddEntry("No trigger selection", 3);
93   fBoxTriggerSelector->Connect("Selected(Int_t)","AliEveHLTEventManagerEditor", this, "SetTriggerString(int)");
94   fBoxTriggerSelector->SetWidth(150);
95   fBoxTriggerSelector->SetHeight(25);
96   AddFrame(fBoxTriggerSelector);
97
98   fButtonEventLoopText = new TGTextButton(this, "  Loop Events  ");
99   AddFrame(fButtonEventLoopText); //, new TGLayoutHints(...));
100   fButtonEventLoopText->Connect("Clicked()", "AliEveHLTEventManagerEditor", this, "EventLoop()");
101
102   fButtonEventLoop = new TGPictureButton(this, gClient->GetPicture("$ALICE_ROOT/EVE/hlt-macros/HLT-logo.png"));
103   AddFrame(fButtonEventLoop); //, new TGLayoutHints(...));
104   fButtonEventLoop->Connect("Clicked()", "AliEveHLTEventManagerEditor", this, "EventLoop()");
105 }
106
107 /******************************************************************************/
108
109 void AliEveHLTEventManagerEditor::SetModel(TObject* obj) {
110   fM = dynamic_cast<AliEveHLTEventManager*>(obj);
111 }
112
113 /******************************************************************************/
114
115 void AliEveHLTEventManagerEditor::ConnectToHLT() {
116    // Connects to HOMER sources -> to HLT.
117   fM->ConnectEventBuffer();
118 }
119
120 void AliEveHLTEventManagerEditor::NextEvent() {
121   // call next event from AliEveHOMERManger
122   fM->NextEvent();
123 }
124
125 void AliEveHLTEventManagerEditor::WriteBlockListToFile() {
126   fM->SaveEveryThing();
127 }
128
129
130 void AliEveHLTEventManagerEditor::PrintScreens() {
131   //Print screens
132   fM->PrintScreens();
133 }
134
135 void AliEveHLTEventManagerEditor::NavigateFwd() {
136   // navigate forward
137   if ( !fEventLoopStarted ) {
138     fM->NavigateFwd();
139   }
140 }
141
142 void AliEveHLTEventManagerEditor::NavigateBack() {
143   // navigate back
144   if ( !fEventLoopStarted ) {
145     fM->NavigateBack();
146   }
147 }
148
149 void AliEveHLTEventManagerEditor::PollEvents() {
150   fM->StartBufferMonitor();
151 }
152
153 void AliEveHLTEventManagerEditor::EventLoop() {
154   // Start/stop event loop
155   if ( !fEventLoopStarted ) {
156     fEventLoopStarted = kTRUE;
157     fButtonEventLoopText->SetText(" Stop Loop ");
158     fM->StartLoop();
159   } else {
160     fM->StopLoop();
161     fEventLoopStarted = kFALSE;
162     fButtonEventLoopText->SetText(" Loop Events ");
163   }
164 }
165
166 void AliEveHLTEventManagerEditor::SetTriggerString(int id) {
167
168   if (id < 0 || id > 4) {
169     return;
170   }
171   
172   // TString tsa[4] = {"HLTGlobalTrigger", 
173   //                "BarrelMultiplicityTrigger", 
174   //                "PHOSgeomTrigger",
175   //                "ALL"};
176    
177  
178   // fM->SetTriggerString(tsa[id]);
179     
180 }
181