KaliVeda
Toolkit for HIC analysis
KVINDRARunSheetGUI.cpp
1 #include "KVINDRARunSheetGUI.h"
2 #include "Riostream.h"
3 #include "TGFileDialog.h"
4 #include "TPad.h"
5 #include <TGMsgBox.h>
6 #include <TTimer.h>
7 #include <TClass.h>
8 #include <TROOT.h>
9 #include <TGLayout.h>
10 #include <TCanvas.h>
11 #include "KVINDRADB.h"
12 #include "KVINDRADBRun.h"
13 #include "KVInputDialog.h"
14 #include "TFile.h"
15 #include "KVDataSet.h"
16 #include "TApplication.h"
17 #include "TSystem.h"
18 #include "KVDataSetManager.h"
19 #include "KVDataRepositoryManager.h"
20 #include "KVDBSystemDialog.h"
21 
22 using namespace std;
23 
25 
26 // BEGIN_HTML <!--
28 /* -->
29 <h2>KVDataBaseGUI</h2>
30 <h4>KaliVeda run/system database configuration tool</h4>
31 <img style="width: 910px; height: 627px;" alt=""
32 src="http://indra.in2p3.fr/KaliVedaDoc/images/kvdatabasegui.png"><br>
33 <h4>DIRECTORY</h4>
34 Set path to directory containing runsheets<br>
35 <h4>FILENAME</h4>
36 Set format for runsheet filenames, e.g. RUN_%04d.TXT if runsheets files
37 are called RUN_0001.TXT, RUN_0002.TXT, etc.<br>
38 <h4>Make TTree</h4>
39 If ticked, when runsheets are read (by clicking Read runsheets button),
40 a TTree is created and filled with all information contained in
41 runsheets (run number, start date/time, scalers, etc.)<br>
42 <h4>View Tree<br>
43 </h4>
44 Launch TTree browser. There is a branch/leaf for each information read
45 from the runsheets:<br>
46 <br>
47 <img style="width: 663px; height: 398px;" alt=""
48 src="http://indra.in2p3.fr/KaliVedaDoc/images/kvdatabasegui_treeviewer.gif"><br>
49 <br>
50 Here is an example plot: dead time ("temps_mort") vs. run number:<br>
51 <br>
52 <img style="width: 810px; height: 510px;" alt=""
53 src="http://indra.in2p3.fr/KaliVedaDoc/images/kvdatabasegui_TMplot.gif"><br>
54 <h4>Change dataset</h4>
55 Choose a different dataset to work with<br>
56 <h4>Read runsheets</h4>
57 Read all runsheets in directory shown, if they have the right filename
58 format. Informations stored in TTree, if Make TTree is ticked.<br>
59 <h4>Save</h4>
60 Save all informations in database files:
61 $KVROOT/KVFiles/[dataset]/DataBase.root,
62 $KVROOT/KVFiles/[dataset]/Systems.dat and
63 $KVROOT/KVFiles/[dataset]/Runlist.csv.<br>
64 <h4>Quit</h4>
65 Quits the application (without saving informations).<br>
66 <h4>Systems</h4>
67 Opens Systems dialog box to create, modify, delete systems or associate
68 them with selected run(s): see <a href="#Setting_systems_properties">below</a>.<br>
69 <h4>Unset systems</h4>
70 Unassociates selected run(s) from any systems.<br>
71 <h4>Add comment</h4>
72 Add comment for selected run(s).<br>
73 <h4>Logbook</h4>
74 Add a reference to the experiment logbook for selected run(s).<br>
75 <h4>Set Trigger</h4>
76 Set multiplicity trigger of INDRA Selector for selected run(s).<br>
77 <h4>Print run<br>
78 </h4>
79 Print all information on selected run (1 only) in terminal window.<br>
80 <br>
81 <h3><a name="Setting_systems_properties"></a>Setting systems properties<br>
82 </h3>
83 <img style="width: 404px; height: 385px;" alt=""
84 src="http://indra.in2p3.fr/KaliVedaDoc/images/kvdatabasegui_systems.gif"><br>
85 <br>
86 Choose an existing system in the drop-down list:<br>
87 <ul>
88 <li>modify its properties (press 'Return' key after entering data in
89 each numeric/text field; see below for Target properties)<br>
90 </li>
91 <li>delete it (press "Delete")<br>
92 </li>
93 <li>associate it to the selected runs (press "Set Runs"; only active
94 if runs were selected in main interface)<br>
95 </li>
96 </ul>
97 Press "Save" to save your changes to systems.<br>
98 <br>
99 Creating a new system:<br>
100 <ul>
101 <li>select NEW SYSTEM in the drop-down list</li>
102 <li>enter required properties (tick "Projectile" to enter projectile
103 properties, see below for Target)</li>
104 <li>press "Create"</li>
105 <li>System name dialog box appears:</li>
106 </ul>
107 <img style="width: 280px; height: 112px;" alt=""
108 src="http://indra.in2p3.fr/KaliVedaDoc/images/kvdatabasegui_systemname.gif"><br>
109 <ul>
110 <li>modify as required, then press "OK"</li>
111 <li>Target Z dialog box appears:</li>
112 </ul>
113 <img style="width: 280px; height: 112px;" alt=""
114 src="http://indra.in2p3.fr/KaliVedaDoc/images/kvdatabasegui_Ztarget.gif"><br>
115 <ul>
116 <li>modify as necessary, then press "OK"</li>
117 <li>Target A dialog box appears:</li>
118 </ul>
119 <img style="width: 280px; height: 112px;" alt=""
120 src="http://indra.in2p3.fr/KaliVedaDoc/images/kvdatabasegui_Atarget.gif"><br>
121 <ul>
122 <li>modify as necessary, then press "OK"</li>
123 </ul>
124 The new system is automatically saved in the database files.<br>
125 <br>
126 <span style="font-weight: bold;">Modifying Target Properties</span><br>
127 To change target properties, select the required layer in the "Layer"
128 drop-down list,<br>
129 then modify (press 'Return' key after entering data in each
130 numeric/text field).To add a<br>
131 new layer, select a material in the "Add new layer" materials list,
132 then press "Add".<br>
133 Then select the new layer in the "Layer" list of the target to set its
134 properties.<!-- */
135 // --> END_HTML
137 
138 #ifdef __WITHOUT_TGBUTTON_SETENABLED
139 #define SetEnabled(flag) \
140  SetState( flag ? kButtonUp : kButtonDisabled )
141 #endif
142 
143 
145 
147  300)
148 {
149 
150  GUIenv = new TEnv(".KVDataBaseGUIrc");
151 
152  fFirstRun = 0;
153  fLastRun = -1;
154  fSelectedRun = 0;
155  fSelectedEntries = 0;
156  fButList = new TList;
157 
158  //create new manager GUI
159 
160  //Label with name of run sheet directory
161  fHframe = new TGHorizontalFrame(this, 10, 10);
162  TGTextButton* tb = new TGTextButton(fHframe, "DIRECTORY");
163  tb->SetToolTipText("Set path to directory containing run sheets");
164  tb->Connect("Clicked()", "KVINDRARunSheetGUI", this,
165  "SetRunSheetDir()");
166  fHframe->AddFrame(tb,
168  2, 2));
169 
170  fDirLabel = new TGLabel(fHframe, "./");
171  fHframe->AddFrame(fDirLabel,
173  2, 2));
174 
175  tb = new TGTextButton(fHframe, "FILENAME");
176  tb->SetToolTipText("Set format for run sheet filenames");
177  tb->Connect("Clicked()", "KVINDRARunSheetGUI", this, "SetFileFormat()");
178  fHframe->AddFrame(tb,
180  2, 2));
181 
182  fReader.SetFileFormat(GUIenv->GetValue("KVDataBaseGUI.FileFormat", "RUN_%04d.TXT"));
183 
184  if (strcmp(fReader.GetFileFormat(), "")) {
185  fFormLabel = new TGLabel(fHframe, fReader.GetFileFormat());
186  }
187  else
188  fFormLabel = new TGLabel(fHframe, "************");
189 
190 // fFormLabel->SetTextColor( (TColor*)gROOT->GetListOfColors()->FindObject("green") );
191  fHframe->AddFrame(fFormLabel,
193  2, 2));
194 
195  TGCheckButton* cb = new TGCheckButton(fHframe, "Make TTree");
196  cb->SetDown(kFALSE);
197  cb->Connect("Toggled(Bool_t)", "KVINDRARunSheetReader", &fReader,
198  "SetMakeTree(Bool_t)");
199  cb->SetToolTipText
200  ("Check this to fill a TTree with all infos read from runsheet");
201  fHframe->AddFrame(cb,
203  2, 2));
204 
205  tb = new TGTextButton(fHframe, "View Tree");
206  tb->SetToolTipText("Start Tree viewer");
207  tb->Connect("Clicked()", "KVINDRARunSheetGUI", this,
208  "StartTreeViewer()");
209  tb->SetEnabled(kFALSE);
210 #ifdef __WITHOUT_TGBUTTON_SETENABLED
211  cb->Connect("Toggled(Bool_t)", "KVINDRARunSheetGUI", this, "SetViewTreeEnabled(Bool_t)");
212  fViewTreeButton = tb;
213 #else
214  cb->Connect("Toggled(Bool_t)", "TGTextButton", tb, "SetEnabled(Bool_t)");
215 #endif
216  fHframe->AddFrame(tb,
218  2, 2));
219 
220  AddFrame(fHframe,
221  new TGLayoutHints(kLHintsTop | kLHintsCenterX, 2, 2, 5, 5));
222 
223 
224  ULong_t red, cyan, green, yellow, magenta; // will reflect user color changes
225  gClient->GetColorByName("#ff00ff", magenta);
226  gClient->GetColorByName("#ff0000", red);
227  gClient->GetColorByName("#00ff00", green);
228  gClient->GetColorByName("#00ffff", cyan);
229  gClient->GetColorByName("#ffff00", yellow);
230 
231  fHframe = new TGHorizontalFrame(this, 10, 10);
232  //2 vertical frames for buttons
233  TGVerticalFrame* vf = new TGVerticalFrame(fHframe, 10, 10);
234  fButtonsFrame = new TGVButtonGroup(vf, "");
235  fChangeDataSet = new TGTextButton(fButtonsFrame, "Change dataset");
236  fChangeDataSet->SetToolTipText("Select set of experimental data to work on");
237  fChangeDataSet->Connect("Clicked()", "KVINDRARunSheetGUI", this,
238  "ChangeDataSet()");
239  fButList->Add(fChangeDataSet);
240 
241  fUpdate = new TGTextButton(fButtonsFrame, "Read runsheets");
242  fUpdate->SetToolTipText("Read all runsheets in directory, adding informations to database");
243  fUpdate->Connect("Clicked()", "KVINDRARunSheetGUI", this,
244  "UpdateList()");
245  fUpdate->ChangeBackground(green);
246  fButList->Add(fUpdate);
247 
248  fSaveDB = new TGTextButton(fButtonsFrame, "Save");
249  fSaveDB->
250  SetToolTipText("Save all informations in database");
251  fSaveDB->Connect("Clicked()", "KVINDRARunSheetGUI", this, "SaveAll()");
252  fButList->Add(fSaveDB);
253 
254  fQuit = new TGTextButton(fButtonsFrame, "Quit");
255  fQuit->
256  SetToolTipText("Exit the application");
257  fButList->Add(fQuit);
258  fQuit->ChangeBackground(red);
259  fQuit->Connect("Clicked()", "KVINDRARunSheetGUI", this, "CloseWindow()");
260  //make all buttons same width
261  fButtonsFrame->
262  SetLayoutHints(new
264  kLHintsTop, 2, 2, 0, 0));
265  fButtonsFrame->Show();
266  fButtonsFrame->Resize(fButtonsFrame->GetDefaultWidth(),
267  fButtonsFrame->GetDefaultHeight());
268  vf->AddFrame(fButtonsFrame,
269  new TGLayoutHints(kLHintsTop | kLHintsCenterX, 0, 0, 0,
270  10));
271 
272  fButtonsFrame = new TGVButtonGroup(vf, "");
273  fSetSystem = new TGTextButton(fButtonsFrame, "Systems");
274  fSetSystem->SetToolTipText("Modify reaction systems or set system for the selected run(s)");
275  fSetSystem->Connect("Clicked()", "KVINDRARunSheetGUI", this,
276  "SetSystem()");
277  fSetSystem->ChangeBackground(cyan);
278  fButList->Add(fSetSystem);
279  fUnSetSystem = new TGTextButton(fButtonsFrame, "Unset System");
280  fUnSetSystem->SetToolTipText("Unset the reaction system for the selected run(s)");
281  fUnSetSystem->ChangeBackground(cyan);
282  fUnSetSystem->Connect("Clicked()", "KVINDRARunSheetGUI", this,
283  "UnsetSystem()");
284  fButList->Add(fUnSetSystem);
285  fAddComment = new TGTextButton(fButtonsFrame, "Add comment");
286  fAddComment->SetToolTipText("Add a comment to selected run");
287  fAddComment->Connect("Clicked()", "KVINDRARunSheetGUI", this,
288  "SetRunComment()");
289  fAddComment->ChangeBackground(yellow);
290  fButList->Add(fAddComment);
291  fAddCahier = new TGTextButton(fButtonsFrame, "Logbook");
292  fAddCahier->
293  SetToolTipText
294  ("Add a reference to the experiment logbook for selected run");
295  fAddCahier->Connect("Clicked()", "KVINDRARunSheetGUI", this,
296  "SetRunCahier()");
297  fAddCahier->ChangeBackground(yellow);
298  fButList->Add(fAddCahier);
299  fSetTrigger = new TGTextButton(fButtonsFrame, "Set Trigger");
300  fSetTrigger->
301  SetToolTipText
302  ("Set the multiplicity trigger for the selected run(s)");
303  fSetTrigger->Connect("Clicked()", "KVINDRARunSheetGUI", this,
304  "SetRunTrigger()");
305  fSetTrigger->ChangeBackground(yellow);
306  fButList->Add(fSetTrigger);
307  fPrintRun = new TGTextButton(fButtonsFrame, "Print run");
308  fPrintRun->SetToolTipText("Print all informations on selected run");
309  fPrintRun->Connect("Clicked()", "KVINDRARunSheetGUI", this,
310  "PrintRun()");
311  fPrintRun->ChangeBackground(magenta);
312  fButList->Add(fPrintRun);
313  //make all buttons same width
314  fButtonsFrame->
315  SetLayoutHints(new
317  kLHintsTop, 2, 2, 0, 0));
318  fButtonsFrame->Show();
319  fButtonsFrame->Resize(fButtonsFrame->GetDefaultWidth(),
320  fButtonsFrame->GetDefaultHeight());
321  vf->AddFrame(fButtonsFrame,
322  new TGLayoutHints(kLHintsTop | kLHintsCenterX, 0, 0, 0,
323  0));
324 
325  fHframe->AddFrame(vf,
327  10, 2, 2));
328 
329  //disable all buttons
330  DisableButtons();
331 
332  //list view for runs
333  fRunList = new KVListView(KVINDRADBRun::Class(), fHframe, 350, 250);
334  fRunList->SetDataColumns(9);
335  fRunList->SetDataColumn(0, "Run", "GetNumber", kTextRight);
336  fRunList->SetDataColumn(1, "Events", "", kTextRight);
337  fRunList->SetDataColumn(2, "System", "GetSystemName");
338  fRunList->SetDataColumn(3, "Start", "GetStartDatime");
340  fRunList->SetDataColumn(4, "End", "GetEndDatime");
342  fRunList->SetDataColumn(5, "Trigger", "GetTriggerString");
343  fRunList->SetDataColumn(6, "DeadTime (%)", "GetTMpercent");
344  fRunList->SetDataColumn(7, "Comments", "", kTextLeft);
345  fRunList->SetDataColumn(8, "Logbook", "", kTextLeft);
346  fRunList->ActivateSortButtons();
347  // disable context menu & Browse functions
348  fRunList->AllowBrowse(kFALSE);
349  fRunList->AllowContextMenu(kFALSE);
350 
351  fRunList->Connect("SelectionChanged()", "KVINDRARunSheetGUI", this,
352  "SelectionChanged()");
353 
354  fHframe->AddFrame(fRunList,
357  10, 10, 10));
358 
359  AddFrame(fHframe,
361  0));
362 
363  SetWindowName("KVDataBaseGUI");
364 
365  //layout & draw window
366  MapSubwindows();
368  MapWindow();
369  SetWMSize(900, 600);
370 
371  //initialise data repository manager if needed
372  if (!gDataRepositoryManager) {
374  gDataRepositoryManager->Init();
375  }
376  //open last used dataset
377  KVString dataset = GUIenv->GetValue("KVDataBaseGUI.DataSet", "");
378  if (dataset == "") {
379  //open dataset dialog box - user must choose dataset
380  new KVIRSGChooseDataSetDialog(gClient->GetRoot(), this, 10, 10);
381  GUIenv->SetValue("KVDataBaseGUI.DataSet", gDataSet->GetName());
382  GUIenv->SaveLevel(kEnvUser);
383  }
384  else {
385  // check dataset exists
386  KVDataSet* ds = gDataSetManager->GetDataSet(dataset.Data());
387  if (ds) ds->cd();
388  else {
389  //open dataset dialog box - user must choose dataset
390  new KVIRSGChooseDataSetDialog(gClient->GetRoot(), this, 10, 10);
391  GUIenv->SetValue("KVDataBaseGUI.DataSet", gDataSet->GetName());
392  GUIenv->SaveLevel(kEnvUser);
393  }
394  }
395  //initialise list of runs
397 
398  //set directory for runsheets
399  fReader.SetRunSheetDir(
400  GUIenv->GetValue(Form("KVDataBaseGUI.RunSheetDir.%s", gDataSet->GetName()), "./")
401  );
402  fDirLabel->SetText(fReader.GetRunSheetDir());
403 }
404 
405 
406 
409 
411 {
412  //open dialog to choose dataset
413  new KVIRSGChooseDataSetDialog(gClient->GetRoot(), this, 10, 10);
414  GUIenv->SetValue("KVDataBaseGUI.DataSet", gDataSet->GetName());
415  GUIenv->SaveLevel(kEnvUser);
416  //set directory for runsheets
417  fReader.SetRunSheetDir(
418  GUIenv->GetValue(Form("KVDataBaseGUI.RunSheetDir.%s", gDataSet->GetName()), "./")
419  );
420  fDirLabel->SetText(fReader.GetRunSheetDir());
421  //initialise list of runs
423 }
424 
425 
426 
429 
430 KVINDRARunSheetGUI::~KVINDRARunSheetGUI()
431 {
432  //close window
433  UnmapWindow();
434  if (fSelectedEntries) delete fSelectedEntries;
435  delete fButList;
436  fButList = 0;
437  if (GUIenv) delete GUIenv;
438 }
439 
440 
441 
444 
446 {
447  //close viewer
449 }
450 
451 
452 
455 
457 {
458  //Disable all buttons
459  fButList->R__FOR_EACH(TGTextButton, SetEnabled)(kFALSE);
460 }
461 
462 
463 
469 
471 {
472  //Enable buttons when a run is selected, depending on how many are selected
473  //"Read runsheets" only enabled if directory and file format have been given
474  //"Save DB"/"Create runlist" only if some runs are in the runlist
475  //"Load DB" active if no dataset/base defined
476  if (strcmp(fReader.GetRunSheetDir(), "")
477  && strcmp(fReader.GetFileFormat(), "")) {
478  fUpdate->SetEnabled(kTRUE);
479  }
480  else {
481  fUpdate->SetEnabled(kFALSE);
482  }
483  if (fLastRun >= fFirstRun) {
484  fSaveDB->SetEnabled(kTRUE);
485  }
486  else {
487  fSaveDB->SetEnabled(kFALSE);
488  }
489  if (GetNSelected() == 1) {
490  fPrintRun->SetEnabled(kTRUE);
491  }
492  else
493  fPrintRun->SetEnabled(kFALSE);
494  if (GetNSelected() >= 1) {
495  fAddComment->SetEnabled(kTRUE);
496  fAddCahier->SetEnabled(kTRUE);
497  fSetTrigger->SetEnabled(kTRUE);
498  fUnSetSystem->SetEnabled(kTRUE);
499  }
500  fSetSystem->SetEnabled(kTRUE);
501  fChangeDataSet->SetEnabled(kTRUE);
502  fQuit->SetEnabled(kTRUE);
503 }
504 
505 
506 
508 
510 {
511  static TString dir(".");
512  TGFileInfo fi;
513  fi.fIniDir = StrDup(dir);
514  new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
515  if (fi.fFilename) {
516  dir = fi.fIniDir;
517  cout << "directory = " << dir.Data() << endl;
518  fReader.SetRunSheetDir(dir.Data());
519  GUIenv->SetValue(
520  Form("KVDataBaseGUI.RunSheetDir.%s", gDataSet->GetName()),
521  dir.Data());
522  GUIenv->SaveLevel(kEnvUser);
523  //update directory label field
524  fDirLabel->SetText(dir.Data());
525  Layout(); //needed according to doc for TGLabel::SetText
526  EnableButtons();
527  }
528 }
529 
530 
531 
535 
537 {
538  // if gINDRADB exists, we use it to fill the list box with each run in the database,
539  // sorted according to increasing run number
540 
541  if (gIndraDB && gIndraDB->GetRuns() && gIndraDB->GetRuns()->GetSize()) {
542 
543  fRunList->Display(gIndraDB->GetRuns());
544  // sort runs
545  fRunList->Sort(0);
546  fFirstRun = ((KVINDRADBRun*)fRunList->GetFirstInList())->GetNumber();
547  fLastRun = ((KVINDRADBRun*)fRunList->GetLastInList())->GetNumber();
548  if (fFirstRun > fLastRun) {
549  // sorting was in reverse order
550  fRunList->Sort(0);
551  fFirstRun = ((KVINDRADBRun*)fRunList->GetFirstInList())->GetNumber();
552  fLastRun = ((KVINDRADBRun*)fRunList->GetLastInList())->GetNumber();
553  }
554  }
555 }
556 
557 
558 
561 
563 {
564  //remove all entries from grid list box
565 
566  fRunList->RemoveAll();
567  fFirstRun = 0;
568  fLastRun = -1;
569  fSelectedRun = 0;
570  if (fSelectedEntries) {
571  delete fSelectedEntries;
572  fSelectedEntries = 0;
573  }
574 }
575 
576 
577 
581 
583 {
584  //fill list from gIndraDB
585  //buttons are disabled, as any selected run is deselected
586  ClearListOfRuns();
587  FillListOfRuns();
589 }
590 
591 
592 
600 
602 {
603  //called when "Update list" button is pressed
604  //KVINDRARunSheetReader is used to read all available runsheets
605  //then displayed list is updated
606  //File format is first read from the text entry field
607  //Database runlist is saved
608  //We also update the list of raw data files in the repository
609  Int_t read = fReader.ReadAllRunSheets() ;
610  cout << "Read " << read << " runsheets" << endl;
611  cout << "fReader.IsMakeTree()=" << fReader.IsMakeTree() << endl;
612  gExpDB->Save("Runlist");
613  ClearListOfRuns();
614  gDataSet->UpdateAvailableRuns("raw");
615  FillListOfRuns();
617 }
618 
619 
620 
628 
630 {
631  //called any time the selection of runs changes
632  //each time, we update:
633  //fSelectedEntries : the list of all selected runs (KVINDRADBRun objects)
634  //GetNSelected() : the number of selected entries
635  //fSelectedRun : the last selected run (=the only run selected if GetNSelected==1)
636  //The buttons' state is modified according to the number of selected runs
637 
638  if (fSelectedEntries) {
639  delete fSelectedEntries;
640  fSelectedEntries = 0;
641  }
642  fSelectedEntries = fRunList->GetSelectedObjects();
643  if (fSelectedEntries->GetEntries())
644  fSelectedRun = (KVINDRADBRun*)fRunList->GetLastSelectedObject();
645  else fSelectedRun = 0;
646  DisableButtons();
647  EnableButtons();
648 }
649 
650 
651 
654 
656 {
657  //returns current number of selected items in grid list
658  return (fSelectedEntries ? fSelectedEntries->GetSize() : 0);
659 }
660 
661 
662 
666 
668 {
669  //Write the Runlist.csv, Systems.dat and update (and save)
670  //the database
671  gIndraDB->Save("Systems");
672  gIndraDB->Save("Runlist");
673  ClearListOfRuns();
674  gDataSet->GetDataBase("update");
676 }
677 
678 
679 
681 
683 {
684  fInputString = "";
685  if (fSelectedRun)
686  fInputString = fSelectedRun->GetComments();
687  Bool_t ok;
688  new KVInputDialog(this, "Enter comment for run(s)", &fInputString, &ok);
689  if (ok) {
690  if (GetNSelected() == 1)
691  fSelectedRun->SetComments(fInputString.Data());
692  else if (GetNSelected() > 1) {
693  //multiselection
694  TIter next(fSelectedEntries);
695  KVINDRADBRun* run;
696  while ((run = (KVINDRADBRun*)next())) run->SetComments(fInputString.Data());
697  }
698  }
699 }
700 
701 
702 
704 
706 {
707  fInputString = "";
708  if (fSelectedRun)
709  fInputString = fSelectedRun->GetCahier();
710  Bool_t ok;
711  new KVInputDialog(this, "Enter log-book reference for run(s)",
712  &fInputString, &ok);
713  if (ok) {
714  if (GetNSelected() == 1)
715  fSelectedRun->SetCahier(fInputString.Data());
716  else if (GetNSelected() > 1) {
717  //multiselection
718  TIter next(fSelectedEntries);
719  KVINDRADBRun* run;
720  while ((run = (KVINDRADBRun*)next())) run->SetCahier(fInputString.Data());
721  }
722  }
723 }
724 
725 
726 
728 
730 {
731  fInputString = "";
732  if (fSelectedRun)
733  fInputString.Form("%d", fSelectedRun->GetTrigger());
734  Bool_t ok;
735  new KVInputDialog(this, "Enter multiplicity trigger for run(s)",
736  &fInputString, &ok,
737  "Enter minimum multiplicity, i.e. for M>=4 type '4'");
738  if (ok && fInputString.IsDigit()) {
739  Int_t trig = fInputString.Atoi();
740  if (GetNSelected() == 1)
741  fSelectedRun->SetTrigger(trig);
742  else if (GetNSelected() > 1) {
743  //multiselection
744  TIter next(fSelectedEntries);
745  KVINDRADBRun* run;
746  while ((run = (KVINDRADBRun*)next())) {
747  run->BlockSignals();
748  run->SetTrigger(trig);
749  run->BlockSignals(0);
750  }
752  }
753  }
754 }
755 
756 
757 
759 
761 {
762  fInputString = fReader.GetFileFormat();
763  Bool_t ok;
764  new KVInputDialog(this, "Enter format string for runsheet filenames",
765  &fInputString, &ok,
766  "e.g. RUN_%04d.TXT for filenames such as RUN_0123.TXT");
767  if (ok) {
768  fReader.SetFileFormat(fInputString.Data());
769  GUIenv->SetValue("KVDataBaseGUI.FileFormat", fInputString.Data());
770  GUIenv->SaveLevel(kEnvUser);
771  EnableButtons();
772  fFormLabel->SetText(fInputString.Data());
773  Layout();
774  }
775 }
776 
777 
778 
780 
782 {
783  fReader.StartTreeViewer();
784 }
785 
786 
787 
789 
791 {
792  if (fSelectedRun)
793  fSelectedRun->Print();
794 }
795 
796 
797 
800 
802 {
803  //Open dialog box for setting system properties for runs
804  KVDBSystem* run_system = 0;
805  if (fSelectedRun) run_system = fSelectedRun->GetSystem();
806  KVNumberList runlist;
807  if (GetNSelected() == 1)
808  runlist.Add(fSelectedRun->GetNumber());
809  else if (GetNSelected() > 1) {
810  //multiselection
811  TIter next(fSelectedEntries);
812  KVINDRADBRun* run;
813  while ((run = (KVINDRADBRun*)next())) runlist.Add(run->GetNumber());
814  }
815  new KVDBSystemDialog(gClient->GetRoot(), this, run_system, runlist, 10, 10);
816 }
817 
818 
819 
823 
825 {
826  //Unset the system for selected runs
827  //new Systems.dat file will be saved
828  if (GetNSelected() == 1) {
829  if (fSelectedRun->GetSystem()) {
830  cout << "Unsetting system (" << fSelectedRun->GetSystem()->GetName() << " for run " << fSelectedRun->GetNumber() << endl;
831  fSelectedRun->UnsetSystem();
832  }
833  }
834  else if (GetNSelected() > 1) {
835  //multiselection
836  TIter next(fSelectedEntries);
837  KVINDRADBRun* run;
838  while ((run = (KVINDRADBRun*)next())) {
839  if (run->GetSystem()) {
840  cout << "Unsetting system (" << run->GetSystem()->GetName() << " for run " << run->GetNumber() << endl;
841  run->UnsetSystem();
842  }
843  }
844  }
845  gExpDB->Save("Systems");
847 }
848 
849 
850 
852 
853 
854 
858 (const TGWindow* p, const TGWindow* main, UInt_t w, UInt_t h)
859 {
860 
861  // main frame
862  fMain = new TGTransientFrame(p, main, w, h);
863  fMain->SetLayoutBroken(kTRUE);
864  fMain->Connect("CloseWindow()", "KVIRSGChooseDataSetDialog", this,
865  "DoClose()");
866  fMain->DontCallClose(); // to avoid double deletions.
867  // use hierarchical cleaning
868  fMain->SetCleanup(kDeepCleanup);
869 
870  fLabel = new TGLabel(fMain, "Choose dataset:");
871  fLabel->SetTextJustify(36);
872  fMain->AddFrame(fLabel,
873  new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2,
874  2));
875  fLabel->MoveResize(8, 8, 208, 24);
876 
877  gClient->GetColorByName("#ffffff", ucolor);
878 
879  // combo box
880  fComboBox = new TGComboBox(fMain);
881 
882  //fill list of datasets
883  if (gDataSetManager) {
884  for (int i = 0; i < gDataSetManager->GetNtotal(); i++) {
885  fComboBox->AddEntry(gDataSetManager->GetDataSet(i)->GetName(), i);
886  }
887  }
888 
889  fComboBox->Connect("Selected(Int_t)", "KVIRSGChooseDataSetDialog", this,
890  "SetDataSet(Int_t)");
891  fComboBox->Resize(208, 22);
892  fComboBox->Select(0);
893  fDataSetIndex = -1;
894  fMain->AddFrame(fComboBox,
895  new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2,
896  2));
897  fComboBox->MoveResize(8, 40, 208, 22);
898 
899  TGTextButton* fTextButton = new TGTextButton(fMain, "OK");
900  fTextButton->SetTextJustify(36);
901  fTextButton->Resize(80, 24);
902  fMain->AddFrame(fTextButton,
903  new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2,
904  2));
905  fTextButton->MoveResize(72, 72, 80, 24);
906 
907  fTextButton->Connect("Clicked()", "KVIRSGChooseDataSetDialog", this,
908  "YouPressedOK()");
909 
910  fMain->MapSubwindows();
911 
912  fMain->Resize(fMain->GetDefaultSize());
913  fMain->CenterOnParent();
914  fMain->SetWindowName("Choose dataset dialog box");
915  fMain->MapWindow();
916  fMain->Resize(223, 110);
917  //nothing happens until window closes
918  gClient->WaitFor(fMain);
919 }
920 
921 
922 
925 
926 KVIRSGChooseDataSetDialog::~KVIRSGChooseDataSetDialog()
927 {
928  //Delete all widgets
929 
930  if (fMain) {
931  delete fMain;
932  fMain = 0;
933  }
934 }
935 
936 
937 
939 
941 {
942  TTimer::SingleShot(150, "KVIRSGChooseDataSetDialog", this,
943  "CloseWindow()");
944 }
945 
946 
947 
949 
951 {
952  delete this;
953 }
954 
955 
956 
959 
961 {
962  //Called when OK button is pressed
963  if (fDataSetIndex > -1) gDataSetManager->GetDataSet(fDataSetIndex)->cd();
964  DoClose();
965 }
966 
967 #ifdef __WITHOUT_TGBUTTON_SETENABLED
968 #undef SetEnabled
969 #endif
970 
int Int_t
unsigned int UInt_t
unsigned long ULong_t
bool Bool_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
R__EXTERN TApplication * gApplication
kEnvUser
#define gClient
kFDOpen
kDeepCleanup
kLHintsExpandY
kLHintsLeft
kLHintsCenterY
kLHintsCenterX
kLHintsTop
kLHintsExpandX
kTextLeft
kTextRight
winID w
winID h TVirtualViewer3D TVirtualGLPainter p
char * Form(const char *fmt,...)
char * StrDup(const char *str)
virtual Int_t GetNumber() const
Definition: KVDBRecord.h:73
void Print(Option_t *option="") const override
Definition: KVDBRun.cpp:61
void SetComments(const KVString &comments)
Definition: KVDBRun.h:272
KVDBSystem * GetSystem() const
Definition: KVDBRun.cpp:240
Int_t GetTrigger() const
Definition: KVDBRun.h:249
void BlockSignals(Bool_t yes=kTRUE)
Definition: KVDBRun.h:175
void SetTrigger(Int_t trig)
Definition: KVDBRun.h:244
const Char_t * GetComments() const
Definition: KVDBRun.h:263
Dialog box for setting system parameters associated to runs.
Database class used to store information on different colliding systems studied during an experiment....
Definition: KVDBSystem.h:51
Manages access to one or more data repositories.
Int_t GetNtotal() const
KVDataSet * GetDataSet(Int_t) const
Return pointer to DataSet using index in list of all datasets, index>=0.
Manage an experimental dataset corresponding to a given experiment or campaign.
Definition: KVDataSet.h:146
KVExpDB * GetDataBase(const TString &opt="") const
Definition: KVDataSet.cpp:288
void cd() const
Definition: KVDataSet.cpp:778
void UpdateAvailableRuns(const KVString &type)
Definition: KVDataSet.cpp:1103
@ kGANACQ
Definition: KVDatime.h:47
virtual KVSeqCollection * GetRuns() const
Definition: KVExpDB.h:140
virtual void Save(const Char_t *)
Definition: KVExpDB.cpp:547
Database entry for each run of an INDRA experiment.
Definition: KVINDRADBRun.h:30
void SetCahier(const Char_t *log)
Definition: KVINDRADBRun.h:59
void UnsetSystem() override
const Char_t * GetCahier() const
Definition: KVINDRADBRun.h:45
_________________________________________________//
void CloseWindow() override
close viewer
void ChangeDataSet()
open dialog to choose dataset
void DisableButtons()
Disable all buttons.
void SetSystem()
Open dialog box for setting system properties for runs.
void ClearListOfRuns()
remove all entries from grid list box
Int_t GetNSelected()
returns current number of selected items in grid list
const Char_t * GetRunSheetDir()
Int_t ReadAllRunSheets(Int_t first=1, Int_t last=9999)
void SetFileFormat(const Char_t *fmt)
const Char_t * GetFileFormat()
void SetRunSheetDir(const Char_t *dir)
_________________________________________________//
void YouPressedOK()
Called when OK button is pressed.
General purpose dialog box asking for some input in the form of a string.
Definition: KVInputDialog.h:24
virtual void SetIsDateTime(KVDatime::EKVDateFormat fmt=KVDatime::kCTIME, Bool_t with_reference=kTRUE)
Enhanced version of ROOT TGListView widget.
Definition: KVListView.h:147
virtual void ActivateSortButtons()
Definition: KVListView.cpp:72
virtual void SetDataColumns(Int_t ncolumns)
Definition: KVListView.cpp:91
virtual void Sort(Int_t column)
Definition: KVListView.h:181
TObject * GetLastInList() const
Definition: KVListView.h:276
void AllowBrowse(Bool_t on=kTRUE)
Definition: KVListView.h:287
virtual KVLVColumnData * GetDataColumn(Int_t index) const
Definition: KVListView.h:169
virtual void Display(const TCollection *l)
Definition: KVListView.h:174
KVUnownedList GetSelectedObjects() const
Definition: KVListView.h:253
TObject * GetLastSelectedObject() const
Definition: KVListView.h:239
TObject * GetFirstInList() const
Definition: KVListView.h:271
virtual void RemoveAll()
Definition: KVListView.h:194
void AllowContextMenu(Bool_t on=kTRUE)
Definition: KVListView.h:292
virtual void SetDataColumn(Int_t index, const Char_t *name, const Char_t *method="", Int_t mode=kTextCenterX)
Definition: KVListView.cpp:106
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
void Add(Int_t)
Add value 'n' to the list.
Int_t GetSize() const override
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
virtual void Terminate(Int_t status=0)
virtual Int_t GetEntries() const
virtual Int_t GetSize() const
virtual const char * GetValue(const char *name, const char *dflt) const
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
virtual void SaveLevel(EEnvLevel level)
static TClass * Class()
virtual void Show()
virtual void SetToolTipText(const char *text, Long_t delayms=400)
virtual void SetDown(Bool_t on=kTRUE, Bool_t emit=kFALSE)
virtual void SetEnabled(Bool_t e=kTRUE)
TGDimension GetDefaultSize() const override
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
UInt_t GetDefaultWidth() const override
void MapSubwindows() override
UInt_t GetDefaultHeight() const override
void Layout() override
char * fFilename
char * fIniDir
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
virtual void Resize(TGDimension size)
void MapWindow() override
virtual void ChangeBackground(Pixel_t back)
void UnmapWindow() override
void SetText(const char *newText)
void SetWMSize(UInt_t w, UInt_t h)
void SetWindowName(const char *name=nullptr) override
virtual void SetTextJustify(Int_t tmode)
void Add(TObject *obj) override
const char * GetName() const override
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Int_t Atoi() const
const char * Data() const
Bool_t IsDigit() const
void Form(const char *fmt,...)
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
int main(int argc, char **argv)
TH1 * h
ClassImp(TPyArg)