]>
Commit | Line | Data |
---|---|---|
1 | // Author: Mihai Niculescu 2013 | |
2 | ||
3 | /************************************************************************** | |
4 | * Copyright(c) 1998-2013, ALICE Experiment at CERN, all rights reserved. * | |
5 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
6 | * full copyright notice. * | |
7 | **************************************************************************/ | |
8 | ||
9 | #include <TEnv.h> | |
10 | #include <TObjString.h> | |
11 | #include <TString.h> | |
12 | #include <TSystem.h> | |
13 | ||
14 | #include <TGButton.h> | |
15 | #include <TGLabel.h> | |
16 | #include <TGMsgBox.h> | |
17 | #include <TGTab.h> | |
18 | #include <TGTextEntry.h> | |
19 | ||
20 | #include <AliReconstruction.h> | |
21 | ||
22 | #include "AliEventServerUtil.h" | |
23 | #include "AliEventServerPreferencesWindow.h" | |
24 | ||
25 | //_________________________________________________________ | |
26 | ClassImp(AliEventServerPreferencesWindow) | |
27 | AliEventServerPreferencesWindow::AliEventServerPreferencesWindow(const TGWindow* p, const char* window_title) | |
28 | : TGTransientFrame(gClient->GetRoot(), p), | |
29 | fTab(0), | |
30 | fEntryServerHost(0), | |
31 | fEntryServerPort(0), | |
32 | fEntryCDBDefaultStorage(0), | |
33 | fEntryCDBSpecStoragePath1(0), | |
34 | fEntryCDBSpecStorageValue1(0), | |
35 | fEntryCDBSpecStoragePath2(0), | |
36 | fEntryCDBSpecStorageValue2(0), | |
37 | fEntryCDBSpecStoragePath3(0), | |
38 | fEntryCDBSpecStorageValue3(0), | |
39 | fEntryRecoRunQA(0), | |
40 | fEntryRecoQARefDefStorage(0), | |
41 | fChkRecoRunGlobalQA(0), | |
42 | fChkRecoRunPlaneEff(0), | |
43 | fChkRecoWriteESDf(0), | |
44 | fChkRecoWriteAlignment(0), | |
45 | fChkRecoCleanESD(0), | |
46 | fDetectors(0), | |
47 | fEntryLogbookHost(0), | |
48 | fEntryLogbookPort(0), | |
49 | fEntryLogbookDB(0), | |
50 | fEntryLogbookUser(0), | |
51 | fEntryLogbookPass(0) | |
52 | { | |
53 | SetCleanup(kDeepCleanup); | |
54 | SetWindowName(window_title); | |
55 | ||
56 | // Tab Preferences | |
57 | fTab = new TGTab(this); | |
58 | TGCompositeFrame* tab1 = fTab->AddTab("Server"); | |
59 | TGCompositeFrame* tab2 = fTab->AddTab("Reconstruction"); | |
60 | TGCompositeFrame* tab3 = fTab->AddTab("Logbook"); | |
61 | ||
62 | SetupServerTab(tab1); | |
63 | SetupRecoTab(tab2); | |
64 | SetupLogbookTab(tab3); | |
65 | ||
66 | // dialog buttons | |
67 | TGHorizontalFrame* hf = new TGHorizontalFrame(this); | |
68 | TGTextButton* btDefaults = new TGTextButton(hf, "Restore Defaults"); | |
69 | TGTextButton* btCancel = new TGTextButton(hf, "Cancel"); | |
70 | TGTextButton* btApply = new TGTextButton(hf, "Apply"); | |
71 | ||
72 | btDefaults->Connect("Clicked()", "AliEventServerPreferencesWindow", this, "onRestoreDefaults()"); | |
73 | btCancel->Connect("Clicked()", "AliEventServerPreferencesWindow", this, "onCancel()"); | |
74 | btApply->Connect("Clicked()", "AliEventServerPreferencesWindow", this, "onApply()"); | |
75 | ||
76 | hf->AddFrame(btDefaults, new TGLayoutHints(kLHintsNormal) ); | |
77 | hf->AddFrame(btApply, new TGLayoutHints(kLHintsRight) ); | |
78 | hf->AddFrame(btCancel, new TGLayoutHints(kLHintsRight) ); | |
79 | ||
80 | ||
81 | // Add Tab Widget and Dialog buttons to Main Window | |
82 | AddFrame(fTab, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY)); | |
83 | AddFrame(hf, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
84 | ||
85 | if(ReadSettings()!=0) Info("AliEventServerPreferencesWindow::AliEventServerPreferencesWindow", "Problems while reading settings from file!\n"); | |
86 | ||
87 | SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize | | |
88 | kMWMDecorMinimize | kMWMDecorMenu, | |
89 | kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize | | |
90 | kMWMFuncMinimize, | |
91 | kMWMInputModeless); | |
92 | ||
93 | MapSubwindows(); | |
94 | Resize(); | |
95 | MapWindow(); | |
96 | ||
97 | gClient->WaitFor(this); | |
98 | } | |
99 | ||
100 | AliEventServerPreferencesWindow::~AliEventServerPreferencesWindow() | |
101 | { | |
102 | delete fDetectors; | |
103 | fDetectors=0; | |
104 | } | |
105 | ||
106 | /*********************/ | |
107 | /* Server Settings Tab */ | |
108 | /*********************/ | |
109 | void AliEventServerPreferencesWindow::SetupServerTab(TGCompositeFrame* tab) | |
110 | { | |
111 | TGHorizontalFrame *t2hf = new TGHorizontalFrame(tab, 1, 20); | |
112 | TGLabel* lbServerHost = new TGLabel(t2hf, "Host:"); | |
113 | t2hf->AddFrame(lbServerHost, new TGLayoutHints(kLHintsCenterY)); | |
114 | ||
115 | fEntryServerHost = new TGTextEntry(t2hf, "tcp://*"); | |
116 | t2hf->AddFrame(fEntryServerHost, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
117 | ||
118 | TGLabel* lbServerPort = new TGLabel(t2hf, "Port:"); | |
119 | t2hf->AddFrame(lbServerPort, new TGLayoutHints(kLHintsCenterY)); | |
120 | ||
121 | fEntryServerPort = new TGTextEntry(t2hf, "5024"); | |
122 | fEntryServerPort->SetMaxLength(5); | |
123 | t2hf->AddFrame(fEntryServerPort, new TGLayoutHints(kLHintsNormal)); | |
124 | ||
125 | tab->AddFrame(t2hf, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
126 | } | |
127 | ||
128 | /*******************/ | |
129 | /* Reco Settings Tab */ | |
130 | /*******************/ | |
131 | void AliEventServerPreferencesWindow::SetupRecoTab(TGCompositeFrame* tab) | |
132 | { | |
133 | /* CDB Manager Group Frame */ | |
134 | TGGroupFrame* grCDBMan = new TGGroupFrame(tab, "CDB Manager"); | |
135 | // Default Storage Frame | |
136 | TGHorizontalFrame *hfCDBDefaultStorage = new TGHorizontalFrame(grCDBMan, 1, 20); | |
137 | TGLabel* lbCDBDefaultStorage = new TGLabel(hfCDBDefaultStorage, "Default Storage:"); | |
138 | fEntryCDBDefaultStorage = new TGTextEntry(hfCDBDefaultStorage, "local:///local/cdb"); | |
139 | ||
140 | hfCDBDefaultStorage->AddFrame(lbCDBDefaultStorage, new TGLayoutHints(kLHintsCenterY)); | |
141 | hfCDBDefaultStorage->AddFrame(fEntryCDBDefaultStorage, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
142 | ||
143 | // Specific Storage 1 Frame | |
144 | TGHorizontalFrame *hfCDBSpecStorage1 = new TGHorizontalFrame(grCDBMan, 1, 20); | |
145 | TGLabel* lbCDBSpecStorage1 = new TGLabel(hfCDBSpecStorage1, "Specific Storage:"); | |
146 | fEntryCDBSpecStoragePath1 = new TGTextEntry(hfCDBSpecStorage1, "GRP/GRP/Data"); | |
147 | fEntryCDBSpecStorageValue1 = new TGTextEntry(hfCDBSpecStorage1, ""); | |
148 | ||
149 | hfCDBSpecStorage1->AddFrame(lbCDBSpecStorage1, new TGLayoutHints(kLHintsCenterY)); | |
150 | hfCDBSpecStorage1->AddFrame(fEntryCDBSpecStoragePath1, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
151 | hfCDBSpecStorage1->AddFrame(fEntryCDBSpecStorageValue1, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
152 | ||
153 | // Specific Storage 2 Frame | |
154 | TGHorizontalFrame *hfCDBSpecStorage2 = new TGHorizontalFrame(grCDBMan, 1, 20); | |
155 | TGLabel* lbCDBSpecStorage2 = new TGLabel(hfCDBSpecStorage2, "Specific Storage:"); | |
156 | fEntryCDBSpecStoragePath2 = new TGTextEntry(hfCDBSpecStorage2, "GRP/CTP/Config"); | |
157 | fEntryCDBSpecStorageValue2 = new TGTextEntry(hfCDBSpecStorage2, ""); | |
158 | ||
159 | hfCDBSpecStorage2->AddFrame(lbCDBSpecStorage2, new TGLayoutHints(kLHintsCenterY)); | |
160 | hfCDBSpecStorage2->AddFrame(fEntryCDBSpecStoragePath2, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
161 | hfCDBSpecStorage2->AddFrame(fEntryCDBSpecStorageValue2, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
162 | ||
163 | // Specific Storage 3 Frame | |
164 | TGHorizontalFrame *hfCDBSpecStorage3 = new TGHorizontalFrame(grCDBMan, 1, 20); | |
165 | TGLabel* lbCDBSpecStorage3 = new TGLabel(hfCDBSpecStorage3, "Specific Storage:"); | |
166 | fEntryCDBSpecStoragePath3 = new TGTextEntry(hfCDBSpecStorage3, ""); | |
167 | fEntryCDBSpecStorageValue3 = new TGTextEntry(hfCDBSpecStorage3, ""); | |
168 | ||
169 | hfCDBSpecStorage3->AddFrame(lbCDBSpecStorage3, new TGLayoutHints(kLHintsCenterY)); | |
170 | hfCDBSpecStorage3->AddFrame(fEntryCDBSpecStoragePath3, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
171 | hfCDBSpecStorage3->AddFrame(fEntryCDBSpecStorageValue3, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
172 | ||
173 | grCDBMan->AddFrame(hfCDBDefaultStorage, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
174 | grCDBMan->AddFrame(hfCDBSpecStorage1, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
175 | grCDBMan->AddFrame(hfCDBSpecStorage2, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
176 | grCDBMan->AddFrame(hfCDBSpecStorage3, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
177 | ||
178 | tab->AddFrame(grCDBMan, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
179 | grCDBMan->Resize(); | |
180 | ||
181 | /* Reconstruction Settings Group Frame */ | |
182 | TGGroupFrame* grRecoFrame = new TGGroupFrame(tab, "Reconstruction"); | |
183 | // SetRunQA | |
184 | TGHorizontalFrame *hfRecoRunQA = new TGHorizontalFrame(grRecoFrame, 1, 20); | |
185 | TGLabel* lbRecoRunQA = new TGLabel(hfRecoRunQA, "Run QA:"); | |
186 | fEntryRecoRunQA = new TGTextEntry(hfRecoRunQA, ":"); | |
187 | ||
188 | hfRecoRunQA->AddFrame( lbRecoRunQA, new TGLayoutHints(kLHintsCenterY)); | |
189 | hfRecoRunQA->AddFrame( fEntryRecoRunQA, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
190 | ||
191 | // QARef Default Storage | |
192 | TGHorizontalFrame *hfRecoQARefDefStorage = new TGHorizontalFrame(grRecoFrame, 1, 20); | |
193 | TGLabel* lbRecoQARefDefStorage= new TGLabel(hfRecoQARefDefStorage, "QARef Default Storage:"); | |
194 | fEntryRecoQARefDefStorage = new TGTextEntry(hfRecoQARefDefStorage, "local://$ALICE_ROOT/QAref"); | |
195 | ||
196 | hfRecoQARefDefStorage->AddFrame( lbRecoQARefDefStorage, new TGLayoutHints(kLHintsCenterY)); | |
197 | hfRecoQARefDefStorage->AddFrame( fEntryRecoQARefDefStorage, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
198 | ||
199 | // RunGlobalQA | |
200 | fChkRecoRunGlobalQA = new TGCheckButton(grRecoFrame, "Run Global QA"); | |
201 | ||
202 | // Plane Efficiency Evalution | |
203 | fChkRecoRunPlaneEff= new TGCheckButton(grRecoFrame, "Plane Efficiency Evaluation"); | |
204 | ||
205 | // Write ESD Friend | |
206 | fChkRecoWriteESDf= new TGCheckButton(grRecoFrame, "Write ESD friend"); | |
207 | ||
208 | // Write Alignement Data | |
209 | fChkRecoWriteAlignment= new TGCheckButton(grRecoFrame, "Write Alignment Data"); | |
210 | ||
211 | // Clean ESD | |
212 | fChkRecoCleanESD= new TGCheckButton(grRecoFrame, "Clean ESD"); | |
213 | ||
214 | // Participating Detectors | |
215 | TGGroupFrame* grRecoDetFrame = new TGGroupFrame(grRecoFrame, "Participating Detectors"); | |
216 | TGHorizontalFrame *hfRecoDets = new TGHorizontalFrame(grRecoDetFrame, 1, 20); | |
217 | TGTextButton* btRecoCheckAll = new TGTextButton(hfRecoDets, "Check All"); | |
218 | TGTextButton* btRecoUnCheckAll = new TGTextButton(hfRecoDets, "Uncheck All"); | |
219 | ||
220 | btRecoCheckAll->Connect("Clicked()", "AliEventServerPreferencesWindow", this, "onCheckAllDetectors()"); | |
221 | btRecoUnCheckAll->Connect("Clicked()", "AliEventServerPreferencesWindow", this, "onUnCheckAllDetectors()"); | |
222 | ||
223 | hfRecoDets->AddFrame( btRecoCheckAll, new TGLayoutHints(kLHintsNormal)); | |
224 | hfRecoDets->AddFrame( btRecoUnCheckAll, new TGLayoutHints(kLHintsNormal)); | |
225 | ||
226 | grRecoDetFrame->AddFrame(hfRecoDets, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
227 | ||
228 | // get detectors names from AliReconstruction | |
229 | const char** detnames= AliReconstruction::GetDetectorNames(); | |
230 | TGCompositeFrame* cfDetectors = new TGCompositeFrame(grRecoDetFrame); | |
231 | cfDetectors->SetLayoutManager(new TGMatrixLayout(cfDetectors, 0, 4, 10)); | |
232 | ||
233 | fDetectors = new TObjArray; | |
234 | for(int i=0; i< AliReconstruction::kNDetectors; i++){ | |
235 | TGCheckButton* chkRecoDet = new TGCheckButton(cfDetectors, detnames[i]); | |
236 | cfDetectors->AddFrame(chkRecoDet, new TGLayoutHints(kLHintsNormal)); | |
237 | fDetectors->Add(chkRecoDet); | |
238 | } | |
239 | ||
240 | grRecoDetFrame->AddFrame(cfDetectors, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
241 | grRecoDetFrame->Resize(); | |
242 | ||
243 | grRecoFrame->AddFrame(hfRecoRunQA, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
244 | grRecoFrame->AddFrame(hfRecoQARefDefStorage, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
245 | grRecoFrame->AddFrame(fChkRecoRunGlobalQA, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
246 | grRecoFrame->AddFrame(fChkRecoRunPlaneEff, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
247 | grRecoFrame->AddFrame(fChkRecoWriteESDf, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
248 | grRecoFrame->AddFrame(fChkRecoWriteAlignment, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
249 | grRecoFrame->AddFrame(fChkRecoCleanESD, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
250 | grRecoFrame->AddFrame(grRecoDetFrame, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
251 | ||
252 | tab->AddFrame(grRecoFrame, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY)); | |
253 | grRecoFrame->Resize(); | |
254 | } | |
255 | ||
256 | ||
257 | /***********************/ | |
258 | /* Logbook Settings Tab */ | |
259 | /***********************/ | |
260 | void AliEventServerPreferencesWindow::SetupLogbookTab(TGCompositeFrame* tab) | |
261 | { | |
262 | // host and port | |
263 | TGCompositeFrame* cfLogbook = new TGCompositeFrame(tab); | |
264 | cfLogbook->SetLayoutManager(new TGMatrixLayout(cfLogbook, 0, 2)); | |
265 | ||
266 | TGLabel* lbLogbookHost = new TGLabel(cfLogbook, "Host:"); | |
267 | fEntryLogbookHost = new TGTextEntry(cfLogbook, "pcaldbl501"); | |
268 | fEntryLogbookHost->Resize(150,0); | |
269 | TGLabel* lbLogbookPort = new TGLabel(cfLogbook, "Port:"); | |
270 | fEntryLogbookPort = new TGTextEntry(cfLogbook, "3306"); | |
271 | fEntryLogbookPort->SetMaxLength(5); | |
272 | ||
273 | // database name | |
274 | TGLabel* lbLogbookDB = new TGLabel(cfLogbook, "Database:"); | |
275 | fEntryLogbookDB = new TGTextEntry(cfLogbook, "logbook"); | |
276 | fEntryLogbookDB->Resize(150,0); | |
277 | ||
278 | // username | |
279 | TGLabel* lbLogbookUser = new TGLabel(cfLogbook, "User:"); | |
280 | fEntryLogbookUser = new TGTextEntry(cfLogbook, "dqm"); | |
281 | fEntryLogbookUser->Resize(150,0); | |
282 | ||
283 | // password | |
284 | TGLabel* lbLogbookPass = new TGLabel(cfLogbook, "Password:"); | |
285 | fEntryLogbookPass = new TGTextEntry(cfLogbook, "dqm123"); | |
286 | fEntryLogbookPass->SetEchoMode(TGTextEntry::kPassword); | |
287 | fEntryLogbookPass->Resize(150,0); | |
288 | ||
289 | cfLogbook->AddFrame(lbLogbookHost, new TGLayoutHints(kLHintsCenterY)); | |
290 | cfLogbook->AddFrame(fEntryLogbookHost, new TGLayoutHints(kLHintsNormal | kLHintsExpandX)); | |
291 | cfLogbook->AddFrame(lbLogbookPort, new TGLayoutHints(kLHintsCenterY)); | |
292 | cfLogbook->AddFrame(fEntryLogbookPort, new TGLayoutHints(kLHintsNormal)); | |
293 | cfLogbook->AddFrame(lbLogbookDB, new TGLayoutHints(kLHintsCenterY)); | |
294 | cfLogbook->AddFrame(fEntryLogbookDB, new TGLayoutHints(kLHintsNormal)); | |
295 | cfLogbook->AddFrame(lbLogbookUser, new TGLayoutHints(kLHintsCenterY)); | |
296 | cfLogbook->AddFrame(fEntryLogbookUser, new TGLayoutHints(kLHintsNormal)); | |
297 | cfLogbook->AddFrame(lbLogbookPass, new TGLayoutHints(kLHintsCenterY)); | |
298 | cfLogbook->AddFrame(fEntryLogbookPass, new TGLayoutHints(kLHintsNormal)); | |
299 | ||
300 | tab->AddFrame(cfLogbook, new TGLayoutHints(kLHintsNormal)); | |
301 | } | |
302 | ||
303 | void AliEventServerPreferencesWindow::onRestoreDefaults() | |
304 | { | |
305 | int retCode; | |
306 | const char* messageInfo = "Are you sure you want to restore the default settings?\n"; | |
307 | ||
308 | new TGMsgBox(gClient->GetRoot(), this, "Restore Default Settings?", messageInfo, kMBIconQuestion, kMBNo|kMBYes, &retCode); | |
309 | ||
310 | if(retCode==kMBNo) return; | |
311 | RestoreDefaults(); | |
312 | } | |
313 | ||
314 | void AliEventServerPreferencesWindow::onCancel() | |
315 | { | |
316 | SendCloseMessage(); | |
317 | } | |
318 | ||
319 | void AliEventServerPreferencesWindow::onApply() | |
320 | { | |
321 | if(WriteSettings()==0){// success! | |
322 | const char* messageInfo = "The changes were saved.\n" | |
323 | "Notice: They will take effect when a new run starts or\n" | |
324 | "after the reconstruction is restarted (if it is already running)"; | |
325 | ||
326 | new TGMsgBox(gClient->GetRoot(), this, "New Settings Notice", messageInfo, kMBIconExclamation, kMBOk); | |
327 | ||
328 | SendCloseMessage(); | |
329 | } | |
330 | else{ | |
331 | const char* messageInfo = "The changes could not be saved!\n" | |
332 | "Check if you have permissions to write to that location."; | |
333 | ||
334 | new TGMsgBox(gClient->GetRoot(), this, "New Settings Notice", messageInfo, kMBIconExclamation, kMBOk); | |
335 | } | |
336 | ||
337 | } | |
338 | ||
339 | void AliEventServerPreferencesWindow::onCheckAllDetectors() | |
340 | { | |
341 | for(int i=0; i<fDetectors->GetEntries(); ++i){ | |
342 | TGCheckButton* bt = (TGCheckButton*)fDetectors->At(i); | |
343 | bt->SetOn(kTRUE); | |
344 | } | |
345 | } | |
346 | ||
347 | void AliEventServerPreferencesWindow::onUnCheckAllDetectors() | |
348 | { | |
349 | for(int i=0; i<fDetectors->GetEntries(); ++i){ | |
350 | TGCheckButton* bt = (TGCheckButton*)fDetectors->At(i); | |
351 | bt->SetOn(kFALSE); | |
352 | } | |
353 | } | |
354 | ||
355 | Int_t AliEventServerPreferencesWindow::ReadSettings() | |
356 | { | |
357 | TEnv settings; | |
358 | int readStatus = settings.ReadFile(AliEventServerUtil::GetPathToServerConf(), kEnvUser); | |
359 | //check if there was an error reading the file | |
360 | if(readStatus!=0) return readStatus; | |
361 | ||
362 | // server settings | |
363 | fEntryServerHost->SetText( settings.GetValue("server.host", DEFAULT_SERVER_HOST), kFALSE); | |
364 | fEntryServerPort->SetText( Form("%d", settings.GetValue("server.port", DEFAULT_SERVER_PORT)), kFALSE); | |
365 | ||
366 | // reco settings | |
367 | fEntryCDBDefaultStorage->SetText( settings.GetValue( "cdb.defaultStorage", DEFAULT_CDB_STORAGE), kFALSE); | |
368 | fEntryCDBSpecStoragePath1->SetText( settings.GetValue( "cdb.specificStoragePath1", DEFAULT_CDB_SPEC_STORAGE_PATH1), kFALSE); | |
369 | fEntryCDBSpecStorageValue1->SetText( settings.GetValue( "cdb.specificStorageValue1", DEFAULT_CDB_SPEC_STORAGE_VALUE1), kFALSE); | |
370 | fEntryCDBSpecStoragePath2->SetText( settings.GetValue( "cdb.specificStoragePath2", DEFAULT_CDB_SPEC_STORAGE_PATH2), kFALSE); | |
371 | fEntryCDBSpecStorageValue2->SetText(settings.GetValue( "cdb.specificStorageValue2", DEFAULT_CDB_SPEC_STORAGE_VALUE2), kFALSE); | |
372 | fEntryCDBSpecStoragePath3->SetText( settings.GetValue( "cdb.specificStoragePath3", DEFAULT_CDB_SPEC_STORAGE_PATH3), kFALSE); | |
373 | fEntryCDBSpecStorageValue3->SetText(settings.GetValue( "cdb.specificStorageValue3", DEFAULT_CDB_SPEC_STORAGE_VALUE3), kFALSE); | |
374 | fEntryRecoRunQA->SetText( settings.GetValue( "qa.runDetectors", DEFAULT_QA_RUN), kFALSE ); | |
375 | fEntryRecoQARefDefStorage->SetText(settings.GetValue( "qa.defaultStorage",DEFAULT_QAREF_STORAGE), kFALSE); | |
376 | fChkRecoRunGlobalQA->SetOn(settings.GetValue( "qa.runGlobal", DEFAULT_QA_RUN_GLOBAL), kFALSE); | |
377 | fChkRecoRunPlaneEff->SetOn(settings.GetValue( "reco.runPlaneEff", DEFAULT_RECO_RUN_PLANE_EFF), kFALSE); | |
378 | fChkRecoWriteESDf->SetOn(settings.GetValue( "reco.writeESDfriend", DEFAULT_RECO_WRITE_ESDF), kFALSE); | |
379 | fChkRecoWriteAlignment->SetOn(settings.GetValue( "reco.writeAlignment",DEFAULT_RECO_WRITE_ALIGN), kFALSE); | |
380 | fChkRecoCleanESD->SetOn(settings.GetValue( "reco.cleanESD",DEFAULT_RECO_CLEAN_ESD), kFALSE); | |
381 | ||
382 | // parse reco run detectors from string | |
383 | TString strRunDetectors(settings.GetValue( "reco.detectors", DEFAULT_RECO_DETECTORS) ); | |
384 | TObjArray* arrRecoDets = strRunDetectors.Tokenize(" "); | |
385 | ||
386 | for(int i=0; i<arrRecoDets->GetEntries(); ++i){ | |
387 | TObjString* objStr = (TObjString*)arrRecoDets->At(i); | |
388 | if(objStr->GetString().BeginsWith("-")){ // detector is disabled | |
389 | for(int j=0; j<fDetectors->GetEntries();++j){ | |
390 | TGCheckButton* bt = (TGCheckButton*)fDetectors->At(j); | |
391 | TString btTitle(Form("-%s",bt->GetTitle())); | |
392 | if(btTitle.CompareTo(objStr->GetString())==0) {// match | |
393 | bt->SetOn(kFALSE); // uncheck detector button | |
394 | break; | |
395 | } | |
396 | } | |
397 | } | |
398 | else if(objStr->GetString().CompareTo("ALL")==0){ | |
399 | onCheckAllDetectors(); | |
400 | } | |
401 | else{ // detector is enabled | |
402 | for(int j=0; j<fDetectors->GetEntries();++j){ | |
403 | TGCheckButton* bt = (TGCheckButton*)fDetectors->At(j); | |
404 | TString btTitle(bt->GetTitle()); | |
405 | if(btTitle.CompareTo(objStr->GetString())==0) {// match | |
406 | bt->SetOn(kTRUE); // check detector | |
407 | break; | |
408 | } | |
409 | } | |
410 | } | |
411 | } | |
412 | ||
413 | // logbook settings | |
414 | fEntryLogbookHost->SetText( settings.GetValue("logbook.host", DEFAULT_LOGBOOK_HOST), kFALSE); | |
415 | fEntryLogbookPort->SetText( Form("%d", settings.GetValue("logbook.port", DEFAULT_LOGBOOK_PORT)), kFALSE); | |
416 | fEntryLogbookDB->SetText( settings.GetValue("logbook.db", DEFAULT_LOGBOOK_DB), kFALSE); | |
417 | fEntryLogbookUser->SetText( settings.GetValue("logbook.user", DEFAULT_LOGBOOK_USER), kFALSE); | |
418 | fEntryLogbookPass->SetText( settings.GetValue("logbook.pass", DEFAULT_LOGBOOK_PASS), kFALSE); | |
419 | ||
420 | return readStatus; | |
421 | } | |
422 | ||
423 | // write settings to a rootrc file | |
424 | // returns 0 in case of success, -1 in case of error | |
425 | Int_t AliEventServerPreferencesWindow::WriteSettings() | |
426 | { | |
427 | TEnv settings; | |
428 | // server settings | |
429 | settings.SetValue("server.host", fEntryServerHost->GetText()); | |
430 | settings.SetValue("server.port", TString(fEntryServerPort->GetText()).Atoi()); | |
431 | ||
432 | // reco settings | |
433 | settings.SetValue( "cdb.defaultStorage", fEntryCDBDefaultStorage->GetText()); | |
434 | settings.SetValue( "cdb.specificStoragePath1", fEntryCDBSpecStoragePath1->GetText()); | |
435 | settings.SetValue( "cdb.specificStorageValue1", fEntryCDBSpecStorageValue1->GetText()); | |
436 | settings.SetValue( "cdb.specificStoragePath2", fEntryCDBSpecStoragePath2->GetText()); | |
437 | settings.SetValue( "cdb.specificStorageValue2", fEntryCDBSpecStorageValue2->GetText()); | |
438 | settings.SetValue( "cdb.specificStoragePath3", fEntryCDBSpecStoragePath3->GetText()); | |
439 | settings.SetValue( "cdb.specificStorageValue3", fEntryCDBSpecStorageValue3->GetText()); | |
440 | settings.SetValue( "qa.runDetectors", fEntryRecoRunQA->GetText()); | |
441 | settings.SetValue( "qa.defaultStorage", fEntryRecoQARefDefStorage->GetText()); | |
442 | settings.SetValue( "qa.runGlobal", fChkRecoRunGlobalQA->IsOn()); | |
443 | settings.SetValue( "reco.runPlaneEff", fChkRecoRunPlaneEff->IsOn()); | |
444 | settings.SetValue( "reco.writeESDfriend", fChkRecoWriteESDf->IsOn()); | |
445 | settings.SetValue( "reco.writeAlignment", fChkRecoWriteAlignment->IsOn()); | |
446 | settings.SetValue( "reco.cleanESD", fChkRecoCleanESD->IsOn()); | |
447 | ||
448 | // will write reco run detectors as a single string | |
449 | TObjArray checkedDetectors; | |
450 | TObjArray uncheckedDetectors; | |
451 | TString strRunDetectors; | |
452 | ||
453 | for(int i=0; i<fDetectors->GetEntries(); ++i){ | |
454 | TGCheckButton* bt = (TGCheckButton*)fDetectors->At(i); | |
455 | if(bt->IsOn()){ | |
456 | checkedDetectors.Add(bt); | |
457 | } | |
458 | else{ | |
459 | uncheckedDetectors.Add(bt); | |
460 | } | |
461 | } | |
462 | ||
463 | int nChkDets = checkedDetectors.GetEntries(); | |
464 | int nUnChkDets = uncheckedDetectors.GetEntries(); | |
465 | if(nChkDets>=nUnChkDets){ | |
466 | strRunDetectors="ALL "; | |
467 | for(int i=0; i<nUnChkDets; ++i ){ | |
468 | strRunDetectors.Append( Form(" -%s",uncheckedDetectors.At(i)->GetTitle()) ); | |
469 | } | |
470 | } | |
471 | else { | |
472 | for(int i=0; i<nChkDets; ++i ){ | |
473 | strRunDetectors.Append( Form(" %s",checkedDetectors.At(i)->GetTitle()) ); | |
474 | } | |
475 | } | |
476 | ||
477 | settings.SetValue( "reco.detectors", strRunDetectors.Data()); | |
478 | ||
479 | // logbook settings | |
480 | settings.SetValue("logbook.host", fEntryLogbookHost->GetText()); | |
481 | settings.SetValue("logbook.port", TString(fEntryLogbookPort->GetText()).Atoi()); | |
482 | settings.SetValue("logbook.db", fEntryLogbookDB->GetText()); | |
483 | settings.SetValue("logbook.user", fEntryLogbookUser->GetText()); | |
484 | settings.SetValue("logbook.pass", fEntryLogbookPass->GetText()); | |
485 | ||
486 | printf("Writting settings to file: %s\n", Form("%s/MONITOR/%s", gSystem->Getenv("ALICE_ROOT"), ALIEVENTSERVER_CONF) ); | |
487 | ||
488 | return settings.WriteFile(AliEventServerUtil::GetPathToServerConf()); | |
489 | } | |
490 | ||
491 | void AliEventServerPreferencesWindow::RestoreDefaults() | |
492 | { | |
493 | // server settings | |
494 | fEntryServerHost->SetText( DEFAULT_SERVER_HOST, kFALSE); | |
495 | fEntryServerPort->SetText( Form("%d", DEFAULT_SERVER_PORT), kFALSE); | |
496 | ||
497 | // reco settings | |
498 | fEntryCDBDefaultStorage->SetText( DEFAULT_CDB_STORAGE, kFALSE); | |
499 | fEntryCDBSpecStoragePath1->SetText( DEFAULT_CDB_SPEC_STORAGE_PATH1, kFALSE); | |
500 | fEntryCDBSpecStorageValue1->SetText( DEFAULT_CDB_SPEC_STORAGE_VALUE1, kFALSE); | |
501 | fEntryCDBSpecStoragePath2->SetText( DEFAULT_CDB_SPEC_STORAGE_PATH2, kFALSE); | |
502 | fEntryCDBSpecStorageValue2->SetText(DEFAULT_CDB_SPEC_STORAGE_VALUE2, kFALSE); | |
503 | fEntryCDBSpecStoragePath3->SetText( DEFAULT_CDB_SPEC_STORAGE_PATH3, kFALSE); | |
504 | fEntryCDBSpecStorageValue3->SetText( DEFAULT_CDB_SPEC_STORAGE_VALUE3, kFALSE); | |
505 | fEntryRecoRunQA->SetText( DEFAULT_QA_RUN, kFALSE ); | |
506 | fEntryRecoQARefDefStorage->SetText(DEFAULT_QAREF_STORAGE, kFALSE); | |
507 | fChkRecoRunGlobalQA->SetOn(DEFAULT_QA_RUN_GLOBAL, kFALSE); | |
508 | fChkRecoRunPlaneEff->SetOn(DEFAULT_RECO_RUN_PLANE_EFF, kFALSE); | |
509 | fChkRecoWriteESDf->SetOn(DEFAULT_RECO_WRITE_ESDF, kFALSE); | |
510 | fChkRecoWriteAlignment->SetOn(DEFAULT_RECO_WRITE_ALIGN, kFALSE); | |
511 | fChkRecoCleanESD->SetOn(DEFAULT_RECO_CLEAN_ESD, kFALSE); | |
512 | ||
513 | // parse reco run detectors from string | |
514 | TString strRunDetectors( DEFAULT_RECO_DETECTORS ); | |
515 | TObjArray* arrRecoDets = strRunDetectors.Tokenize(" "); | |
516 | ||
517 | for(int i=0; i<arrRecoDets->GetEntries(); ++i){ | |
518 | TObjString* objStr = (TObjString*)arrRecoDets->At(i); | |
519 | if(objStr->GetString().BeginsWith("-")){ // detector is disabled | |
520 | for(int j=0; j<fDetectors->GetEntries();++j){ | |
521 | TGCheckButton* bt = (TGCheckButton*)fDetectors->At(j); | |
522 | TString btTitle(Form("-%s",bt->GetTitle())); | |
523 | if(btTitle.CompareTo(objStr->GetString())==0) {// match | |
524 | bt->SetOn(kFALSE); // uncheck detector button | |
525 | break; | |
526 | } | |
527 | } | |
528 | } | |
529 | else if(objStr->GetString().CompareTo("ALL")==0){ | |
530 | onCheckAllDetectors(); | |
531 | } | |
532 | else{ // detector is enabled | |
533 | for(int j=0; j<fDetectors->GetEntries();++j){ | |
534 | TGCheckButton* bt = (TGCheckButton*)fDetectors->At(j); | |
535 | TString btTitle(bt->GetTitle()); | |
536 | if(btTitle.CompareTo(objStr->GetString())==0) {// match | |
537 | bt->SetOn(kTRUE); // check detector | |
538 | break; | |
539 | } | |
540 | } | |
541 | } | |
542 | } | |
543 | ||
544 | // logbook settings | |
545 | fEntryLogbookHost->SetText( DEFAULT_LOGBOOK_HOST, kFALSE); | |
546 | fEntryLogbookPort->SetText( Form("%d", DEFAULT_LOGBOOK_PORT), kFALSE); | |
547 | fEntryLogbookDB->SetText( DEFAULT_LOGBOOK_DB, kFALSE); | |
548 | fEntryLogbookUser->SetText( DEFAULT_LOGBOOK_USER, kFALSE); | |
549 | fEntryLogbookPass->SetText( DEFAULT_LOGBOOK_PASS, kFALSE); | |
550 | } |