KaliVeda
Toolkit for HIC analysis
KVDataAnalysisLauncher.cpp
1 #include "KVDataAnalysisLauncher.h"
2 #include "TGLabel.h"
3 #include "TGMsgBox.h"
4 #include "TColor.h"
5 #include "TGButtonGroup.h"
6 #include "TGFileDialog.h"
7 #include "TObjString.h"
8 #include "TDatime.h"
9 #include "TApplication.h"
10 #include "TSocket.h"
11 #include "TGToolTip.h"
12 #include "TGFileDialog.h"
13 #include "Riostream.h"
14 #include "TClass.h"
15 #include "KVDataRepositoryManager.h"
16 #include "KVDataSetRepository.h"
17 #include "KVDataSetManager.h"
18 #include "KVDataSet.h"
19 #include "KVDataAnalysisTask.h"
20 #include "KV2Body.h"
21 #include "KVNucleus.h"
22 #include "KVExpDB.h"
23 #include "KVBatchSystemManager.h"
24 #include "TSystemDirectory.h"
25 #include "KVInputDialog.h"
26 #include "KVBatchSystemGUI.h"
27 #include "KVBatchSystemParametersGUI.h"
28 #include <KVRunFile.h>
29 #include <optional>
30 
31 #define TTDELAY 750
32 
33 //maximum length of runlist shown next to "Selected Runs :"
34 #define MAX_LENGTH_SELECTED_RUNS 40
35 
36 //#define KVDAL_DEBUG
37 
38 using namespace std;
39 
41 
42 //__________________________________________
43 
44 
47 void KVGFileList::Init(const TString& fileList, const TString& title)
48 {
49  // Init window
50  TGLayoutHints* eXeY = new TGLayoutHints(kLHintsLeft | kLHintsTop |
51  kLHintsExpandX | kLHintsExpandY,
52  1, 1, 1, 1);
53  TGLayoutHints* eX = new TGLayoutHints(kLHintsLeft | kLHintsTop |
54  kLHintsExpandX,
55  1, 1, 1, 1);
56 
57  // File list TGListBox
58  lbFileList = new TGListBox(this, LB_Files);
59  lbFileList->SetMultipleSelections(kTRUE);
60  lbFileList->Resize(350, 96);
61  this->AddFrame(lbFileList, eXeY);
62 
63  // File Name TGTextEntry
64  teFileName = new TGTextEntry(this, "");
65  this->AddFrame(teFileName, eX);
66 
67  // buttons
68  TGCompositeFrame* cf = new TGCompositeFrame(this, 1200, 350, kHorizontalFrame);
69  boutAdd = new TGTextButton(cf, "Add File");
70  boutAdd->SetToolTipText("Add a file to the list", TTDELAY);
71  boutAdd->Connect("Clicked()",
72  "KVGFileList",
73  this,
74  "AddFile()");
75  cf->AddFrame(boutAdd, eX);
76 
77  boutRem = new TGTextButton(cf, "Remove File");
78  boutRem->SetToolTipText("Remove the selected file from the list", TTDELAY);
79  boutRem->Connect("Clicked()",
80  "KVGFileList",
81  this,
82  "RemoveFiles()");
83  cf->AddFrame(boutRem, eX);
84 
85  boutAllRem = new TGTextButton(cf, "Remove All File");
86  boutAllRem->SetToolTipText("Remove all files from the list", TTDELAY);
87  boutAllRem->Connect("Clicked()",
88  "KVGFileList",
89  this,
90  "RemoveAllFiles()");
91  cf->AddFrame(boutAllRem, eX);
92 
93  this->AddFrame(cf, eX);
94 
95  TGTextButton* bout = new TGTextButton(this, "Done");
96  bout->SetToolTipText("Close window", TTDELAY);
97  bout->Connect("Clicked()",
98  "KVGFileList",
99  this,
100  "Done()");
101  this->AddFrame(bout, eX);
102 
103  // Map all widgets
104  MapSubwindows();
105  Resize(GetDefaultSize());
106  SetWindowName(title);
107  SetIconName(title);
108 
109  fileListString = fileList;
110  fileDialogDir = gSystem->Getenv("PWD");
111 
112  entryMax = 0;
113 }
114 
115 
116 
119 
120 KVGFileList::KVGFileList(const TString& fileList, const TString& title,
121  const TGWindow* p, const TGWindow* main,
122  Bool_t ok):
123  TGTransientFrame(p, main, 10, 10)
124 {
125  // Createur
126 
127  if (ok) {
128  Init(fileList, title);
129  InitFileList();
130  MapRaised();
131  fClient->WaitFor(this);
132  }
133 }
134 
135 
136 
139 
141 {
142  // Destructeur
143  delete lbFileList;
144  delete teFileName;
145  delete boutAdd;
146  delete boutRem;
147  delete boutAllRem;
148 }
149 
150 
151 
155 
156 void KVGFileList::InitFileList()
157 {
158  // Init the file name list box from a TString. Add all fields separated by a
159  // white space.
160 
161  fileListString.Begin(" ");
162 
163 
164  while (!fileListString.End()) {
165  auto fileName = fileListString.Next();
166  if (fileName.Length() && !lbFileList->FindEntry(fileName)) {
167  lbFileList->AddEntry(new TGString(fileName), entryMax);
168  entryMax++;
169  }
170  }
171 
172  lbFileList->MapSubwindows();
173  lbFileList->Layout();
174 }
175 
176 
177 
181 
183 {
184  // Add a file to the listbox. If the TGTextEntry is ampty, a file open dialog
185  // appears
186  TString fileName = teFileName->GetText();
187  if (!fileName.Length())
188  fileName = GetFileFromDialog();
189  if (fileName.Length() &&
190  !lbFileList->FindEntry(fileName) &&
191  CanAdd(fileName)) {
192  lbFileList->AddEntry(new TGString(fileName), entryMax);
193  entryMax++;
194  }
195  lbFileList->MapSubwindows();
196  lbFileList->Layout();
197 }
198 
199 
200 
203 
205 {
206  // Remove all the selected files from the TGListBox
207 
208  TList sel;
209  lbFileList->GetSelectedEntries(&sel);
210  TIter next(&sel);
211  TGLBEntry* e = nullptr;
212  while ((e = (TGLBEntry*)next())) {
213  gSystem->Unload(((TGTextLBEntry*)e)->GetText()->GetString());
214  lbFileList->RemoveEntry(e->EntryId());
215  }
216  lbFileList->MapSubwindows();
217  lbFileList->Layout();
218 }
219 
220 
221 
224 
226 {
227  // Remove all the files from the TGListBox
228  lbFileList->RemoveEntries(0, entryMax);
229  entryMax = 0;
230  lbFileList->MapSubwindows();
231  lbFileList->Layout();
232 }
233 
234 
235 
238 
240 {
241  // build the file list string from the content of the TGListBox
242  fileListString = "";
243  for (Int_t i = 0; i < entryMax; i++) {
244  if (TGTextLBEntry* e = (TGTextLBEntry*)lbFileList->GetEntry(i)) {
245  if (fileListString.Length()) fileListString += " ";
246  fileListString += e->GetText()->GetString();
247  }
248  }
249  CloseWindow();
250 }
251 
252 
253 
256 
258 {
259  // Gets the file name from a TGFileDialog
260  TGFileInfo fil;
261  const char* filTypes[] = {"Shared Object Files", "*.so",
262  0, 0
263  };
264  fil.fFileTypes = filTypes;
265  fil.fIniDir = StrDup(fileDialogDir.Data());
266  new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fil);
267  fileDialogDir = fil.fIniDir;
268  if (fil.fFilename)
269  return fil.fFilename;
270  return {};
271 }
272 
273 
274 
277 
279 {
280  // tells whether the file in ths string fn can be added to the list box
281  Bool_t ok = kTRUE;
282 
283  FileStat_t fs;
284  auto tmp = fn;
285  gSystem->ExpandPathName(tmp);
286  if (gSystem->GetPathInfo(tmp, fs)) {
287  ok = kFALSE;
288  new TGMsgBox(gClient->GetRoot(), this,
289  "File does not exist",
290  Form("The file \"%s\" does not exist. Nothing added.",
291  fn.Data()),
293  }
294  else {
295  auto fname = fn;
296  if (!fname.EndsWith(".so")) {
297  ok = kFALSE;
298  new TGMsgBox(gClient->GetRoot(), this,
299  "Not a share object",
300  Form("The file \"%s\" is not a shared object. Nothing added.",
301  fn.Data()),
303 
304  }
305  }
306  return ok;
307 }
308 
309 
310 
312 
313 
314 
317 void KVGDirectoryList::Init(const TString& fileList, const TString& title)
318 {
319  // init window
320  KVGFileList::Init(fileList, title);
321 
322  boutAdd->SetText("Add Directory");
323  boutAdd->SetToolTipText("Add a directory to the list.", TTDELAY);
324  boutAdd->Layout();
325 
326  boutRem->SetText("Remove Directory");
327  boutRem->SetToolTipText("Remove the selected directories from the list.", TTDELAY);
328  boutRem->Layout();
329 
330  boutAllRem->SetText("Remove All Directories");
331  boutAllRem->SetToolTipText("Remove all directories from the list.", TTDELAY);
332  boutAllRem->Layout();
333 }
334 
335 
336 
339 
340 KVGDirectoryList::KVGDirectoryList(const TString& fileList, const TString& title,
341  const TGWindow* p, const TGWindow* main,
342  Bool_t ok):
343  KVGFileList(fileList, title, p, main, kFALSE)
344 {
345  // Createur
346 
347  if (ok) {
348  Init(fileList, title);
349  InitFileList();
350  MapRaised();
351  fClient->WaitFor(this);
352  }
353 }
354 
355 
356 
359 
361 {
362  // Gets the file name from a TGFileDialog
363  TGFileInfo fil;
364  const char* filTypes[] = {"Include Files", "*.[h,H]*",
365  0, 0
366  };
367  fil.fFileTypes = filTypes;
368  fil.fIniDir = StrDup(fileDialogDir.Data());
369  new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fil);
370  fileDialogDir = fil.fIniDir;
371  if (fil.fFilename)
372  return fil.fIniDir;
373  return {};
374 }
375 
376 
377 
380 
382 {
383  // tells whether the file in ths string fn can be added to the list box
384  Bool_t ok = kTRUE;
385 
386  FileStat_t fs;
387  TString tmp = fn;
388  gSystem->ExpandPathName(tmp);
389  if (gSystem->GetPathInfo(tmp.Data(), fs)) {
390  ok = kFALSE;
391  new TGMsgBox(gClient->GetRoot(), this,
392  "Directory does not exist",
393  Form("The directory \"%s\" does not exist. Nothing added.",
394  fn.Data()),
396  }
397  else {
398  if (!(fs.fMode & kS_IFDIR)) {
399  ok = kFALSE;
400  new TGMsgBox(gClient->GetRoot(), this,
401  "Not a directory",
402  Form("The path \"%s\" is not a directory. Nothing added.",
403  fn.Data()),
405 
406  }
407  }
408  return ok;
409 }
410 
411 
413 
414 
415 
423 {
424  // Main window width and height can be set using .kvrootrc variables:
425  // KaliVedaGUI.MainGUIWidth: 800
426  // KaliVedaGUI.MainGUIHeight: 600
427  // Maximum column width of runlist can be set using:
428  // KaliVedaGUI.MaxColWidth: 500
429 
430  entryMax = -1;
431  //Initialisation of resource file
432  GUIenv = new TEnv(".KVDataAnalysisGUIrc");
433  //initialisation of list used by Get/SetResource
434  ResourceNames.Add(new TNamed("Repository", ""));
435  ResourceNames.Add(new TNamed("DataSet", ""));
436  ResourceNames.Add(new TNamed("Task", ""));
437  NbResNames = ResourceNames.GetEntries();
438 
439  // list of user analysis classes present in working directory
440  UserClassNames = new TList;
441  UserClassNames->SetOwner(kTRUE);
442 
443  //initialise repositories, datasets, etc.
444  if (!gDataRepositoryManager) {
446  gDataRepositoryManager->Init();
447  }
448  if (gDataRepositoryManager->GetListOfRepositories()->GetEntries() == 0) {
449  exit(1);
450  }
451  ia = 0;
452  GetDataAnalyser();//this will set up gBatchSystemManager
453  gBatchSystemManager->GetDefaultBatchSystem()->cd();
454 
455  // Creation de l'environnement d'affichage et ajout des 2 boutons a cet
456  // environnement
457 
460  1, 1, 1, 1);
463  1, 1, 1, 1);
465  1, 1, 1, 1);
467  1, 1, 1, 1);
468  fMainGuiWidth = gEnv->GetValue("KaliVedaGUI.MainGUIWidth", 400);
469  fMainGuiHeight = gEnv->GetValue("KaliVedaGUI.MainGUIHeight", 600);
470 
471  // Creation des 3 frames dans la fenetre
472  TGCompositeFrame* cfSelect = new TGCompositeFrame(this, fMainGuiWidth, 350, kVerticalFrame);
473 
474  Int_t justMode = kTextBottom | kTextRight;
475  TGCompositeFrame* cf = new TGCompositeFrame(cfSelect, fMainGuiWidth, 350, kHorizontalFrame);
476  // Label du Repository
477  TGLabel* lab = new TGLabel(cf, "DATA REPOSITORY : ");
478  lab->Resize(150, 20);
479  lab->SetTextJustify(justMode);
480  cf->AddFrame(lab);
481  // ComboBox du Repository
482  cbRepository = new TGComboBox(cf, CB_DataRepository);
483  cbRepository->Select(-1);
484  cbRepository->Resize(150, 20);
485  cbRepository->Connect("Selected(Int_t)",
486  "KVDataAnalysisLauncher",
487  this,
488  "SelectedRepository(Int_t)");
489  cf->AddFrame(cbRepository, LHtopleft);
490 
491  // Label du Data Set
492  lab = new TGLabel(cf, "DATASET : ");
493  lab->Resize(150, 20);
494  lab->SetTextJustify(justMode);
496  20, 1, 1, 1));
497  // ComboBox du Data Set
498  cbDataSet = new TGComboBox(cf, CB_DataSet);
499  cbDataSet->Select(-1);
500  cbDataSet->Resize(150, 20);
501  cbDataSet->Connect("Selected(Int_t)",
502  "KVDataAnalysisLauncher",
503  this,
504  "SelectedDataSet(Int_t)");
505  cf->AddFrame(cbDataSet, LHtopleft);
506  cfSelect->AddFrame(cf, centerX);
507 
508  cf = new TGCompositeFrame(cfSelect, fMainGuiWidth, 350, kHorizontalFrame);
509  // Label du Task
510  lab = new TGLabel(cf, "ANALYSIS TASK : ");
511  lab->SetTextJustify(justMode);
512  lab->Resize(150, 20);
514  1, 1, 1, 1));
515  // ComboBox du Task
516  cbTask = new TGComboBox(cf, CB_AnalysisTask);
517  cbTask->Select(-1);
518  cbTask->Resize(350, 20);
519  cbTask->Connect("Selected(int)",
520  "KVDataAnalysisLauncher",
521  this,
522  "SetSystemList(int)");
523  cf->AddFrame(cbTask, LHtopleft);
524  cfSelect->AddFrame(cf, centerX);
525 
526  AddFrame(cfSelect, new TGLayoutHints(kLHintsLeft | kLHintsTop
528  10, 10, 1, 1));
529  // Systems list
530  lvSystems = new KVListView(KVDBSystem::Class(), this, fMainGuiWidth, 250);
531  lvSystems->SetDataColumns(6);
532  lvSystems->SetMaxColumnSize(gEnv->GetValue("KaliVedaGUI.MaxColWidth", 200));
533  lvSystems->SetDataColumn(1, "Zproj");
534  lvSystems->SetDataColumn(2, "Ztarget");
535  lvSystems->SetDataColumn(3, "Ebeam");
536  lvSystems->GetDataColumn(3)->SetDataFormat("%4.1lf");
537  lvSystems->SetDataColumn(4, "Runs", "GetNumberRuns");
538  lvSystems->SetDataColumn(5, "Events");
539  lvSystems->SetDataColumn(0, "System", "GetName");
540  lvSystems->ActivateSortButtons();
541  // disable context menu, Browse & multi-select functions
542  lvSystems->AllowBrowse(kFALSE);
543  lvSystems->AllowContextMenu(kFALSE);
544  lvSystems->AllowMultipleSelection(kTRUE);
545  lvSystems->Connect("SelectionChanged()", "KVDataAnalysisLauncher", this, "SystemSelectionChanged()");
546  AddFrame(lvSystems, new TGLayoutHints(kLHintsExpandX,
547  10, 10, 15, 15));
548 
549  // Frame pour la liste des runs
550 
551  TGCompositeFrame* cfRuns = new TGCompositeFrame(this, fMainGuiWidth, 400, kVerticalFrame);
552  lvRuns = new KVListView(KVRunFile::Class(), cfRuns, fMainGuiWidth, 300);
553  lvRuns->SetDataColumns(8);
554  lvRuns->SetMaxColumnSize(gEnv->GetValue("KaliVedaGUI.MaxColWidth", 200));
555  int iicc = 0;
556  lvRuns->SetDataColumn(iicc++, "Run/Index", "GetRunIndexString");
557  lvRuns->SetDataColumn(iicc++, "Events", "", kTextRight);
558  lvRuns->SetDataColumn(iicc++, "File", "GetName");
559  lvRuns->SetDataColumn(iicc, "Date", "GetFileWrittenDatime");
560  lvRuns->GetDataColumn(iicc++)->SetIsDateTime();
561  lvRuns->SetDataColumn(iicc++, "Comments", "", kTextLeft);
562  lvRuns->SetDataColumn(iicc++, "Trigger", "");
563  lvRuns->SetDataColumn(iicc++, "Version");
564  lvRuns->SetDataColumn(iicc++, "User");
565  lvRuns->ActivateSortButtons();
566  // disable context menu & Browse functions
567  lvRuns->AllowBrowse(kFALSE);
568  lvRuns->AllowContextMenu(kFALSE);
569  lvRuns->Connect("SelectionChanged()", "KVDataAnalysisLauncher", this, "UpdateListOfSelectedRuns()");
570  cfRuns->AddFrame(lvRuns, new TGLayoutHints(kLHintsLeft | kLHintsTop |
572  10, 10, 15, 15));
573 
574  // Boutons de selection
575  TGCompositeFrame* cfSelAll = new TGCompositeFrame(cfRuns, fMainGuiWidth, 20, kHorizontalFrame);
576  auto BrefreshDir = new TGPictureButton(cfSelAll, gClient->GetPicture("refresh2.xpm"));
577  BrefreshDir->Resize(20, 20);
578  cfSelAll->AddFrame(BrefreshDir, eX);
579  BrefreshDir->SetToolTipText("Update available runfiles for this datatype");
580  BrefreshDir->Connect("Clicked()", "KVDataAnalysisLauncher", this, "UpdateAvailableRuns()");
581  TGTextButton* bout = new TGTextButton(cfSelAll, "Select All");
582  bout->SetToolTipText("Select all runs for the analysis.", TTDELAY);
583  bout->Connect("Clicked()",
584  "KVDataAnalysisLauncher",
585  this,
586  "SelectAll()");
587  cfSelAll->AddFrame(bout, eX);
588  bout = new TGTextButton(cfSelAll, "Deselect All");
589  bout->SetToolTipText("Deselect all runs.", TTDELAY);
590  bout->Connect("Clicked()",
591  "KVDataAnalysisLauncher",
592  this,
593  "DeselectAll()");
594  cfSelAll->AddFrame(bout, eX);
595  bout = new TGTextButton(cfSelAll, "Runlist");
596  bout->SetToolTipText("Enter list of runs to analyse.", TTDELAY);
597  bout->Connect("Clicked()",
598  "KVDataAnalysisLauncher",
599  this,
600  "EnterRunlist()");
601  cfSelAll->AddFrame(bout, eX);
602  bStageSelect = new TGTextButton(cfSelAll, "Stage selection");
603  bStageSelect->SetToolTipText("Select all unconverted runs", TTDELAY);
604  // bStageSelect->Connect("Clicked()",
605  // "KVDataAnalysisLauncher",
606  // this,
607  // "SelectAllUnconvertedRuns()");
608  bStageSelect->Connect("Clicked()",
609  "KVDataAnalysisLauncher",
610  this,
611  "DoStageSelection()");
612  bStageSelect->SetEnabled(false);
613  cfSelAll->AddFrame(bStageSelect, eX);
614  cfRuns->AddFrame(cfSelAll, eX);
615 
616  TGHorizontalFrame* runs_and_nbevents = new TGHorizontalFrame(cfRuns, fMainGuiWidth, 20);
617  selectedRuns = new TGLabel(runs_and_nbevents, " ");
618  runs_and_nbevents->AddFrame(selectedRuns, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY, 2, 2, 0, 0));
619  TGHorizontalFrame* bidule = new TGHorizontalFrame(runs_and_nbevents);
620  TGLabel* nevents = new TGLabel(bidule, "Events : ");
621  bidule->AddFrame(nevents, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 2, 0, 0));
622  teNbToRead = new TGNumberEntry(bidule, 0);
623 #ifdef __WITHOUT_TGNUMBERENTRY_SETNUMSTYLE
624  teNbToRead->SetFormat(TGNumberFormat::kNESInteger, teNbToRead->GetNumAttr());
625 #else
626  teNbToRead->SetNumStyle(TGNumberFormat::kNESInteger);
627 #endif
628 #ifdef __WITHOUT_TGNUMBERENTRY_SETNUMATTR
629  teNbToRead->SetFormat(teNbToRead->GetNumStyle(), TGNumberFormat::kNEANonNegative);
630 #else
631  teNbToRead->SetNumAttr(TGNumberFormat::kNEANonNegative);
632 #endif
633  teNbToRead->GetNumberEntry()->SetToolTipText("Number of events to read [0 => all events]", TTDELAY);
634  teNbToRead->Resize(150, 20);
635  bidule->AddFrame(teNbToRead, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 2, 2, 0, 0));
636  runs_and_nbevents->AddFrame(bidule, new TGLayoutHints(kLHintsRight, 2, 2, 0, 0));
637  cfRuns->AddFrame(runs_and_nbevents, eX);
638 
639  AddFrame(cfRuns, eXeY);
640 
641  // UserClass
642  cfAnalysis = new TGCompositeFrame(this, fMainGuiWidth, 20, kVerticalFrame);
643  cf = new TGCompositeFrame(cfAnalysis, fMainGuiWidth, 20, kHorizontalFrame);
644  // Label for User Class name
645  fUserClassLabel = new TGLabel(cf, "User Class");
646  cf->AddFrame(fUserClassLabel, eX);
647  // Label du Task
648  lab = new TGLabel(cf, "User class options");
649  cf->AddFrame(lab, eX);
650 
651  cfAnalysis->AddFrame(cf, eX);
652 
653  cf = new TGCompositeFrame(cfAnalysis, fMainGuiWidth, 20, kHorizontalFrame);
654  cbUserClass = new TGComboBox(cf);
655  cbUserClass->Select(-1);
656  cbUserClass->Resize(150, 20);
657  cf->AddFrame(cbUserClass, eX);
658  cbUserClass->Connect("Selected(Int_t)", "KVDataAnalysisLauncher", this,
659  "SelectedUserClass(Int_t)");
660  btEditClass = new TGPictureButton(cf, "query_new.xpm");
661  btEditClass->SetEnabled(kFALSE);
662  btEditClass->Connect("Clicked()", "KVDataAnalysisLauncher", this, "EditUserClassFiles()");
663  btEditClass->SetToolTipText(Form("Open analysis class source files in %s", gSystem->Getenv("EDITOR")), TTDELAY);
664  cf->AddFrame(btEditClass, new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2));
665 
666  teUserOptions = new TGTextEntry(cf, "");
667  teUserOptions->SetToolTipText("Comma-separated list of options for user analysis class: PAR1=VAL1,PAR2=VAL2,etc.", TTDELAY);
668  cf->AddFrame(teUserOptions, eX);
669 
670  cfAnalysis->AddFrame(cf, eX);
671 
672  AddFrame(cfAnalysis, eX);
673 
674  cf = new TGCompositeFrame(this, fMainGuiWidth, 20, kHorizontalFrame);
675  // Frame for the user's libraries
676  bout = new TGTextButton(cf, "User's libraries", B_Libs);
677  bout->Connect("Clicked()",
678  "KVDataAnalysisLauncher",
679  this,
680  "SetUserLibraries()");
681  cf->AddFrame(bout, eX);
682 
683  bout = new TGTextButton(cf, "User's includes", B_Incs);
684  bout->Connect("Clicked()",
685  "KVDataAnalysisLauncher",
686  this,
687  "SetUserIncludes()");
688  cf->AddFrame(bout, eX);
689 
690  this->AddFrame(cf, eX);
691 
692  // Process et Quit
693 #ifdef KVDAL_DEBUG
694  cout << "Creation Process/Quit" << endl;
695 #endif
696  TGCompositeFrame* cfProcess = new TGCompositeFrame(this, fMainGuiWidth, 20, kHorizontalFrame);
697  withBatch = new TGTextButton(cfProcess, "BatchMode");
698  withBatch->SetToolTipText(gBatchSystem->GetTitle());
699  withBatch->AllowStayDown(kTRUE);
700  withBatch->Connect("Clicked()", "KVDataAnalysisLauncher", this, "SetBatch()");
701  cfProcess->AddFrame(withBatch, eX);
702  doBatchParams = new TGTextButton(cfProcess, "Batch Parameters");
703  doBatchParams->SetToolTipText("Set parameters of batch jobs");
704  doBatchParams->Connect("Clicked()", "KVDataAnalysisLauncher", this, "SetBatchParameters()");
705  cfProcess->AddFrame(doBatchParams, eX);
706  // Bouton de process
707  bout = new TGTextButton(cfProcess, "&Process", B_Process);
708  bout->SetToolTipText("Run the analysis.", TTDELAY);
709  bout->Connect("Clicked()", "KVDataAnalysisLauncher", this, "Process()");
710  // bout->Associate(this);
711  cfProcess->AddFrame(bout, eX);
712  // Bouton de sortie
713  bout = new TGTextButton(cfProcess, "&Quit", B_Quit);
714  bout->SetToolTipText("Close GUI and quit.", TTDELAY);
715  bout->Connect("Clicked()", "KVDataAnalysisLauncher", this, "Exit()");
716  // bout->Associate(this);
717  cfProcess->AddFrame(bout, eX);
718 
719  this->AddFrame(cfProcess, eX);
720  // On affiche tout le monde maintenant
721  MapSubwindows();
722 
723  Resize(GetDefaultSize());
724 
725  SetWindowName(Form("KaliVeda Analysis Launcher on %s", gSystem->HostName()));
726  SetIconName(Form("KaliVeda Analysis Launcher on %s", gSystem->HostName()));
727 
728  MapWindow();
729  SetWMSize(fMainGuiWidth, fMainGuiHeight);
730 
731  SetRepositoryList();
732 
733  FillListOfUserClasses();
734  //fill drop down list of user classes in working directory
735  SetUserClassList();
736  checkCompilation = kFALSE;
737 
738  // Reset last known state of interface
739  TString tmp(GetResource("Repository", ""));
740  SetRepository(tmp.Data());
741 
742  if (GUIenv->GetValue("KVDataAnalysisLauncher.Batch", kFALSE))
743  withBatch->SetState(kButtonDown);
744  else
745  withBatch->SetState(kButtonUp);
746  SetBatch();
747 
748  fUserLibraries = GUIenv->GetValue("KVDataAnalysisLauncher.UserLibraries", "");
749  fUserIncludes = GUIenv->GetValue("KVDataAnalysisLauncher.UserIncludes", "");
750 
751 }
752 
753 
754 
757 
759 {
760  // Destructeur
761  if (ia) delete ia;
762  if (GUIenv) delete GUIenv;
763  delete UserClassNames;
764 }
765 
766 
767 
770 
772 {
773  // Sets the list of all possible repositories in the repository combo box
774 #ifdef __WITHOUT_TGCOMBOBOX_REMOVEALL
775  RemoveAll(cbRepository);
776 #else
777  cbRepository->RemoveAll();
778 #endif
779  cbRepository->Select(-1);
780  TIter next((TList*)gDataRepositoryManager->GetListOfRepositories());
781  TObject* o = 0;
782  Int_t i = 0;
783  while ((o = next())) {
784  cbRepository->AddEntry(o->GetName(), i);
785  i++;
786  }
787 
788  cbRepository->Layout();
789 
790 }
791 
792 
793 
798 
800 {
801  // Called when repository is selected in drop-down list
802  //
803  // Calls SetDataSetList() to fill list of available datasets for given repository
804 
805  auto sel = cbRepository->GetSelectedEntry();
806  if (sel)
807  SetDataSetList(sel->GetTitle());
808 }
809 
810 
811 
814 
816 {
817  // Sets the list of all available data sets in the data sets combo box
818  if (!gDataRepositoryManager->GetRepository(repository)) {
819  KVError::Warning(this, "SetDataSetList", "Called for undefined repository '%s'", repository.Data());
820  return;
821  }
822 
823  SetResource("Repository", repository);
824 
825  TString ds = GetSavedResource("DataSet", "");
826 
827 #ifdef __WITHOUT_TGCOMBOBOX_REMOVEALL
828  RemoveAll(cbDataSet);
829 #else
830  cbDataSet->RemoveAll();
831 #endif
832  cbDataSet->Select(-1);
833  gDataRepositoryManager->GetRepository(repository)->cd();
834  Int_t nbds = gDataSetManager->GetNavailable();
835  Int_t i = 0;
836  while (i < nbds) {
837  cbDataSet->AddEntry(gDataSetManager->GetAvailableDataSet(i + 1)->GetName(), i);
838  i++;
839  }
840 
841  cbDataSet->Layout();
842 
843  if (ds.Length()) {
844  SetDataSet(ds.Data());
845  }
846  else {
847  SetTask();
848  }
849 
850 }
851 
852 
853 
858 
860 {
861  // Called when dataset is selected in drop-down list
862  //
863  // Calls SetTaskList() to fill list of available tasks for given dataset
864 
865  auto sel = cbDataSet->GetSelectedEntry();
866  // allow list to close & GUI to relax before e.g. building database for new dataset
868  if (sel)
869  SetTaskList(sel->GetTitle());
870 }
871 
872 
873 
877 
879 {
880  // Sets the list of all possible tasks in the tasks combo box
881  // Called when a new dataset is selected in the dropdown list
882 
883  SetResource("DataSet", dataset);
884 
885  TString ds = GetSavedResource("Task", "");
886 
887 #ifdef __WITHOUT_TGCOMBOBOX_REMOVEALL
888  RemoveAll(cbTask);
889 #else
890  cbTask->RemoveAll();
891 #endif
892  cbTask->Select(-1);
893 #ifdef KVDAL_DEBUG
894  cout << "DataSet : [" << dataset << "]" << endl;
895 #endif
896  current_dataset = gDataSetManager->GetDataSet(dataset);
897  // don't block GUI building full database, just need systems & runs
898  current_database = current_dataset->GetDataBase("minimal");
899  Int_t nbt = current_dataset->GetNtasks();
900 
901  GetDataAnalyser()->SetDataSet(current_dataset);
902 
903  noSystems = (!current_database || !current_database->GetSystems()->GetSize());
904  if (noSystems) lvSystems->RemoveAll();
905 
906  Int_t i = 0;
907  while (i < nbt) {
908  cbTask->AddEntry(current_dataset->GetAnalysisTask(i + 1)->GetType(), i);
909  i++;
910  }
911 
912  cbTask->Layout();
913 
914  if (ds.Length()) {
915  SetTask(ds.Data());
916  }
917  else {
918  SetSystem();
919  }
920 }
921 
922 
923 
927 
928 KVDataSetAnalyser* KVDataAnalysisLauncher::GetDataAnalyser(KVDataAnalysisTask* task)
929 {
930  //Get analyser for task
931  //If task = 0 we return the current analyser
932 
933  if (!task) {
934  if (!ia) ia = new KVDataSetAnalyser;
935  }
936  else {
937  if (ia) delete ia;
939  if (!ia) ia = new KVDataSetAnalyser;
940  ia->SetAnalysisTask(task);
941  }
942  return ia;
943 }
944 
945 
946 
957 
959 {
960  // Sets the list of all possible systems in the system list.
961  // Called every time a task is selected.
962  //
963  // The choice of task may lead to a change of batch system:
964  // - if the current system is PROOFLite but the data to be read by the task is
965  // not in a TFile (i.e. not in a TTree) then we switch to Xterm batch system.
966  // - if the current system is Xterm but the data to be read by the task *is*
967  // in a TFile (i.e. in a TTree) then we switch to PROOFLite batch system
968 
969  // allow list to close & GUI to relax before e.g. building database for new dataset
971 
972  KVDataAnalysisTask* task = current_dataset->GetAnalysisTask(itask + 1);
973 
974  TString current_batch = gBatchSystem->GetName();
975  auto data_reader = current_dataset->GetDataSetEnv<TString>(Form("DataSet.RunFileClass.%s", task->GetPrereq()));
976 
977  if (current_batch == "PROOFLite" && data_reader != "TFile") {
978  gBatchSystemManager->GetBatchSystem("Xterm")->cd();
979  withBatch->SetToolTipText(gBatchSystem->GetTitle());
980  Info("SetSystemList", "Switched batch system to %s: %s", gBatchSystem->GetName(), gBatchSystem->GetTitle());
981  }
982 #ifdef WITH_PROOF
983  else if (current_batch == "Xterm" && data_reader == "TFile") {
984  gBatchSystemManager->GetBatchSystem("PROOFLite")->cd();
985  withBatch->SetToolTipText(gBatchSystem->GetTitle());
986  Info("SetSystemList", "Switched batch system to %s: %s", gBatchSystem->GetName(), gBatchSystem->GetTitle());
987  }
988 #endif
989 
990  GetDataAnalyser(task);
991 
992  SetResource("Task", task->GetTitle());
993 
994  if (!task->WithUserClass()) {
995  //no user class required
996  DisableUserClassList();
997  }
998  else {
999  //user class required
1000  EnableUserClassList();
1001  }
1002 
1003  source_type = task->GetPrereq();
1004  // conversion task? if so, enable stage selection
1005  if (!task->GetOutputDataType().IsNull()) {
1006  output_type = task->GetOutputDataType();
1007  bStageSelect->SetEnabled();
1008  }
1009  else {
1010  bStageSelect->SetEnabled(false);
1011  }
1012 
1013  //update display
1014  cfAnalysis->Layout();
1015 
1016  TString ds = GetSavedResource("System", "");
1017  lastSelectedSystem = 0;
1018  if (!noSystems) {
1019  auto sys_list = current_dataset->GetListOfAvailableSystems(task);
1020  if (!sys_list.IsEmpty()) {
1021  lvSystems->Display(&sys_list);
1022  }
1023  }
1024  if (ds.Length()) {
1025  SetSystem(ds.Data());
1026  }
1027  else {
1028  SetRunsList();
1029  }
1030 }
1031 
1032 
1033 
1037 
1039 {
1040  // Sets the list of all available runs in the runs list box
1041 
1042 // SetResource("Trigger", "All");
1043  listOfRuns.Clear();
1044  listOfSystemRuns.Clear();
1045  if (entryMax > -1) {
1046  lvRuns->RemoveAll();
1047  list_of_runs.Clear();
1048  entryMax = -1;
1049  }
1050 
1051  KVDataAnalysisTask* task = current_dataset->GetAnalysisTask(cbTask->GetSelected() + 1);
1052  KVDBSystem* system = 0;
1053  if (!noSystems || !strcmp(task->GetPrereq(), "*")) {
1054  // case where systems are defined for dataset and user has
1055  // selected a specific system
1056  // OR for online analysis (prereq data type="*")
1057  system = lastSelectedSystem;
1058  GetDataAnalyser()->SetSystem(system);
1059  if (!system) {
1060  // no system selected
1061  // clear runs list
1062  SetRuns();
1063  return;
1064  }
1065  }
1066 
1067  //Setting name of system in ressources file
1068  if (!noSystems) {
1069  // dataset with defined systems
1070  if (system) {
1071  // user has chosen a system
1072  SetResource("System", system->GetName());
1073  }
1074  else {
1075  // user chose "All" for system
1076  SetResource("System", "All");
1077  }
1078  }
1079  else {
1080  // no systems defined for dataset
1081  SetResource("System", "Unknown");
1082  }
1083 
1084  // loop over selected systems, add all runs to run list
1085  lvRuns->RemoveAll();
1086  list_of_runs.Clear();
1087  run_index_list run_list;
1088  for (auto sys_p : listofSelectedSystems) {
1089  auto system = (KVDBSystem*)sys_p;
1090  auto rl = current_dataset->GetRunList(task->GetPrereq(), system);
1091  run_list.Add(rl);
1092  auto lor = current_dataset->GetListOfAvailableRunFilesForSystem(task, system);
1093  list_of_runs.AddAll(&lor);
1094  lor.Clear("nodelete");
1095  }
1096  entryMax = list_of_runs.GetEntries();
1097  listOfSystemRuns = run_list;
1098  lvRuns->Display(&list_of_runs);
1099 
1100  SetRuns("");
1101 
1102  // Set saved user class, number of events for current
1103  // repository, dataset, task, system, trigger & runs
1104  auto ds = GetSavedResource("UserClass", "");
1105  SetUserClass(ds);
1106  ds = GetSavedResource("NbEventsToRead", "");
1107  teNbToRead->SetIntNumber(ds.Atoi());
1108 }
1109 
1110 
1111 
1116 
1118 {
1119  // Called when user analysis class is selected in drop-down list
1120  //
1121  // Calls UserClassSelected() with name of class
1122 
1123  auto sel = cbUserClass->GetSelectedEntry();
1124  if (sel)
1125  UserClassSelected(sel->GetTitle());
1126 }
1127 
1128 
1129 
1130 
1133 
1135 {
1136  // Select all runs currently in the displayed list of runs
1137  lvRuns->SelectAll();
1139 }
1140 
1141 
1142 
1145 
1147 {
1148  // Deselect all runs currently in the displayed list of runs
1149  lvRuns->UnSelectAll();
1151 }
1152 
1153 
1154 
1157 
1159 {
1160  // Run the analysis task
1161 
1162  TString oriIncludePath = gSystem->GetIncludePath();
1163 
1164  KVDataAnalysisTask* task = current_dataset->GetAnalysisTask(cbTask->GetSelected() + 1);
1165  KVDataSetAnalyser* datan = GetDataAnalyser(task);
1166  bool online_analysis = !strcmp(task->GetPrereq(), "*");
1167 
1168  //set global pointer to analyser
1169  gDataAnalyser = datan;
1170 
1171  datan->SetDataSet(current_dataset);
1172  datan->SetAnalysisTask(task);
1173  if (listOfRuns.GetNValues()) {
1174  datan->SetRuns(listOfRuns, kFALSE);
1175  datan->SetFullRunList(listOfRuns);
1176  }
1177  else if (!online_analysis) {
1178  WarningBox("Empty Run List", "The list of runs to process is empty.");
1179  return;
1180  }
1181 
1182  if (fUserIncludes.Length()) {
1183  datan->SetUserIncludes(fUserIncludes.Data());
1184  }
1185  if (fUserLibraries.Length()) {
1186  datan->SetUserLibraries(fUserLibraries.Data());
1187  }
1188 
1189  //Need a user class for the analysis ?
1190  TString kvs(GetUserClass());
1191  if (task->WithUserClass()) {
1192  //read user's class name from input box
1193  if (kvs.Length()) {
1194  datan->SetUserClassOptions(teUserOptions->GetText());
1195  datan->SetUserClass({kvs}, checkCompilation);
1196  if (datan->IsUserClassValid())
1197  checkCompilation = kFALSE;
1198  else {
1199  // compilation failed. abort processing.
1200  delete ia;
1201  ia = 0;
1202  checkCompilation = kTRUE;
1203  if (WarningBox("Compilation failed", "Please correct mistakes in user analysis class", kTRUE)) EditUserClassFiles();
1204  return;
1205  }
1206  }
1207  else {
1208  delete ia;
1209  ia = 0;
1210  checkCompilation = kTRUE;
1211  WarningBox("No User Class", "Please enter the user analysis class name.");
1212  return;
1213  }
1214  }
1215  else if (strcmp(task->GetUserBaseClass(), "")) {
1216  //task with default "user" class (i.e. UserClass=no but UserClass.BaseClass!="")
1217  datan->SetUserClass({task->GetUserBaseClass()}, kFALSE);
1218  }
1219  Long64_t nbEventRead = (Long64_t)teNbToRead->GetIntNumber();
1220  // if in batch and nbEventRead>0, ask confirmation
1221  if (IsBatch() && nbEventRead) {
1222  if (!WarningBox("Read all events in batch mode?",
1223  "This will submit batch jobs which will not read all events.\nAre you sure that is what you want?",
1224  kTRUE)) {
1225  delete ia;
1226  ia = 0;
1227  return;
1228  }
1229  }
1230  // check batch parameters have been set
1231  if (IsBatch()
1232  && (!fBatchParameters.GetNpar() // never set
1233  // previously set with MultiJobsMode turned off (perhaps to read a single run), whereas we now have many runs to read
1234  || (fBatchParameters.HasBoolParameter("MultiJobsMode") && !fBatchParameters.GetBoolValue("MultiJobsMode") && listOfRuns.GetNValues() > 1))
1235  ) {
1236  if (!SetBatchParameters()) return; //abort analysis if user pressed cancel
1237  }
1238  datan->SetNbEventToRead((Long64_t)teNbToRead->GetIntNumber());
1239  SetResource("RunsList", listOfRuns.AsString());
1240  SetResource("UserClassOptions", teUserOptions->GetText());
1241  SetResource("NbEventsToRead", Form("%.0f", teNbToRead->GetNumber()));
1242  GUIenv->SaveLevel(kEnvUser);
1243 
1244  // before submitting the job(s), we make sure that the database for the current dataset
1245  // has been fully built, we don't want each job trying to do it (especially for batch/PROOFlite jobs)
1246  // Of course this will invalidate all pointers to objects in or associated with the database...
1247  if(current_dataset!=gDataSet || current_database->IsMinimal())
1248  {
1249  std::vector<std::string> selected_system_names;
1250  for (auto it : listofSelectedSystems) {
1251  selected_system_names.push_back(it->GetName());
1252  }
1253  listofSelectedSystems.Clear();
1254  auto list_of_runs_backup = listOfRuns;
1255  current_dataset->cd();
1256  current_database = gExpDB;
1257  // we now have (potentially) a new database with all new objects & pointers...
1258  SetTask(GetSavedResource("Task", ""));// this will update the list of systems & runs
1259  for(auto& sys_name : selected_system_names){
1260  //listofSelectedSystems.Add(gExpDB->GetSystem(sys_name.c_str()));
1261  SetSystem(sys_name.c_str());
1262  }
1263  SetRuns(list_of_runs_backup.AsString());
1264  Process();
1265  return;
1266  }
1267 
1268  // submit jobs for each selected system
1269  for (auto it : listofSelectedSystems) {
1270  auto sys = (KVDBSystem*)it;
1271 
1272  // build up runfile list for system
1273  run_index_list sys_run_list;
1274  for (auto it_r : sys->GetRuns()) {
1275  // keep all system runfiles in user's selection
1276  auto runfiles_for_run = dynamic_cast<KVDBRun*>(it_r)->GetRunIndexList();
1277  sys_run_list += runfiles_for_run && listOfRuns;
1278  }
1279  if (sys_run_list) {
1280  if (IsBatch()) {
1281  gBatchSystem->Clear();
1282  gBatchSystem->SetBatchSystemParameters(fBatchParameters);
1283  datan->SetBatchSystem(gBatchSystem);
1284  }
1285  else {
1286  datan->SetBatchSystem(nullptr);
1287  }
1288  std::cout << "data_analyser dataset before SetRuns = " << datan->GetDataSet() << std::endl;
1289  datan->SetRuns(sys_run_list, false);
1290  datan->Run();
1291  }
1292  }
1293 
1294  gSystem->SetIncludePath(oriIncludePath.Data());
1295 }
1296 
1297 
1298 
1300 
1302 {
1303  if (TGTextLBEntry* e = (TGTextLBEntry*)cbRepository->GetSelectedEntry()) {
1304  return e->GetText()->GetString();
1305  }
1306  else {
1307  return "";
1308  }
1309 }
1310 
1311 
1312 
1314 
1316 {
1317  if (TGTextLBEntry* e = (TGTextLBEntry*)cbDataSet->GetSelectedEntry()) {
1318  return e->GetText()->GetString();
1319  }
1320  else {
1321  return "";
1322  }
1323 }
1324 
1325 
1326 
1328 
1330 {
1331  if (TGTextLBEntry* e = (TGTextLBEntry*)cbTask->GetSelectedEntry()) {
1332  return e->GetText()->GetString();
1333  }
1334  else {
1335  return "";
1336  }
1337 }
1338 
1339 
1340 
1342 
1344 {
1345  if (noSystems) return "";
1346  KVDBSystem* sys = (KVDBSystem*)lvSystems->GetLastSelectedObject();
1347  if (sys)
1348  return sys->GetName();
1349  else
1350  return "";
1351 }
1352 
1353 
1354 
1355 
1357 
1359 {
1360  return listOfRuns.AsString();
1361 }
1362 
1363 
1364 
1366 
1368 {
1369  TGLBEntry* e = 0;
1370  if ((e = cbRepository->FindEntry(r))) {
1371  Int_t i = e->EntryId();
1372 #ifdef __WITHOUT_TGCOMBOBOX_SELECT_BOOL_T
1373  cbRepository->Select(i);
1374 #else
1375  cbRepository->Select(i, kFALSE);
1376 #endif
1377  SetDataSetList(r);
1378  }
1379  else {
1380  SetDataSet();
1381  }
1382 }
1383 
1384 
1385 
1387 
1389 {
1390  if (r.IsNull()) {
1391  //remove all datasets because no repository has been chosen yet
1392 #ifdef __WITHOUT_TGCOMBOBOX_REMOVEALL
1393  RemoveAll(cbDataSet);
1394 #else
1395  cbDataSet->RemoveAll();
1396 #endif
1397  cbDataSet->Select(-1);
1398  SetResource("Repository", "");
1399  SetTask();
1400  }
1401  else {
1402  TGLBEntry* e = 0;
1403  if ((e = cbDataSet->FindEntry(r))) {
1404  Int_t i = e->EntryId();
1405 #ifdef __WITHOUT_TGCOMBOBOX_SELECT_BOOL_T
1406  cbDataSet->Select(i);
1407 #else
1408  cbDataSet->Select(i, kFALSE);
1409 #endif
1410  SetTaskList(r);
1411  }
1412  else {
1413  SetTask();
1414  }
1415  }
1416 }
1417 
1418 
1419 
1421 
1423 {
1424  if (r.IsNull()) {
1425  //remove all tasks from list because no dataset chosen yet
1426 #ifdef __WITHOUT_TGCOMBOBOX_REMOVEALL
1427  RemoveAll(cbTask);
1428 #else
1429  cbTask->RemoveAll();
1430 #endif
1431  cbTask->Select(-1);
1432  SetResource("DataSet", "");
1433  SetSystem();
1434  }
1435  else {
1436  TGLBEntry* e = 0;
1437  if ((e = cbTask->FindEntry(r))) {
1438  Int_t i = e->EntryId();
1439 #ifdef __WITHOUT_TGCOMBOBOX_SELECT_BOOL_T
1440  cbTask->Select(i);
1441 #else
1442  cbTask->Select(i, kFALSE);
1443 #endif
1444  SetSystemList(i);
1445  }
1446  else {
1447  SetSystem();
1448  }
1449  }
1450 }
1451 
1452 
1453 
1455 
1457 {
1458  if (r.IsNull()) {
1459  //remove all systems from list because no task chosen yet
1460  lvSystems->RemoveAll();
1461  SetResource("Task", "");
1462  //empty list of analysis classes and disable it
1463  DisableUserClassList();
1464  SetRuns();
1465  lvRuns->RemoveAll();
1466  list_of_runs.Clear();
1467  }
1468  else {
1469  lvSystems->ActivateItemWithColumnData("System", r);
1471  }
1472 }
1473 
1474 
1475 
1481 
1483 {
1484  //KVDBSystem* system = (KVDBSystem*)lvSystems->GetLastSelectedObject();
1485  //if (system == lastSelectedSystem) return;
1486  //lastSelectedSystem = system;
1487  //GetDataAnalyser()->SetSystem(system);
1488  listofSelectedSystems = lvSystems->GetSelectedObjects();
1489  if (listofSelectedSystems.IsEmpty())
1490  lastSelectedSystem = nullptr;
1491  else
1492  lastSelectedSystem = (KVDBSystem*)lvSystems->GetLastSelectedObject();
1493  SetRunsList();
1494 }
1495 
1496 
1497 
1499 
1501 {
1502  if (r.IsNull()) {
1504  SetResource("Trigger", "All");
1505  SetResource("RunsList", "");
1506  }
1507  else {
1508  listOfRuns = current_database->SetRunIndexListFromString(r);
1509  if (listOfRuns.GetNValues()) {
1510  lvRuns->ActivateItemsWithColumnData("Run/Index", listOfRuns);
1511  SetResource("RunsList", listOfRuns.AsString());
1512  }
1514  }
1515 }
1516 
1517 
1518 
1522 
1524 {
1525  // Set the resource KVDataAnalysisLauncher.Batch according
1526  // to whether button 'Batch' is down or up
1527 
1528  if (IsBatch()) withBatch->SetText("BatchMode: On");
1529  else withBatch->SetText("BatchMode: Off");
1530  GUIenv->SetValue("KVDataAnalysisLauncher.Batch", IsBatch());
1531  doBatchParams->SetEnabled(IsBatch());
1532  GUIenv->SaveLevel(kEnvUser);
1533 }
1534 
1535 
1536 
1540 
1542 {
1543  // Open dialog to set batch parameters for job
1544  // returns kFALSE if cancel is pressed
1545 
1546  gBatchSystem->GetBatchSystemParameterList(fBatchParameters);
1547  // use saved values of batch parameters
1548  fBatchParameters.SetFromEnv(GUIenv, "KVDataAnalysisLauncher");
1549  Bool_t cancel;
1550  // make sure runlist is set in analyser (controls multijobs mode)
1551  GetDataAnalyser()->SetDataSet(current_dataset);
1552  GetDataAnalyser()->SetRuns(listOfRuns, kFALSE);
1553  new KVBatchSystemParametersGUI(this, &fBatchParameters, GetDataAnalyser(), &cancel);
1554  if (!cancel) {
1555  // update saved batch parameter resources
1556  fBatchParameters.WriteToEnv(GUIenv, "KVDataAnalysisLauncher");
1557  GUIenv->SaveLevel(kEnvUser);
1558  }
1559  return !cancel;
1560 }
1561 
1562 
1563 
1564 
1567 
1569 {
1570  // Set the User's libraries
1571  TString ori = fUserLibraries.Data();
1572  new KVGFileList(fUserLibraries, "User's Libraries",
1573  gClient->GetRoot(), this);
1574  GUIenv->SetValue("KVDataAnalysisLauncher.UserLibraries", fUserLibraries.Data());
1575  GUIenv->SaveLevel(kEnvUser);
1576  checkCompilation = ori.CompareTo(fUserLibraries);
1577 }
1578 
1579 
1580 
1583 
1585 {
1586  // Set the User's includes
1587  TString ori = fUserIncludes.Data();
1588  new KVGDirectoryList(fUserIncludes, "User's Includes",
1589  gClient->GetRoot(), this);
1590  GUIenv->SetValue("KVDataAnalysisLauncher.UserIncludes", fUserIncludes.Data());
1591  GUIenv->SaveLevel(kEnvUser);
1592  checkCompilation = ori.CompareTo(fUserIncludes);
1593 }
1594 
1595 
1596 
1597 
1603 
1604 Bool_t KVDataAnalysisLauncher::WarningBox(const char* title, const char* msg, Bool_t confirm)
1605 {
1606  // Warning box in case of problems
1607  // if confirm=kTRUE we ask for a yes/no answer from the user:
1608  // if 'yes' is pressed, we return kTRUE, if 'no', kFALSE.
1609  // by default, only a 'dismiss' button is shown, and this method always returns kTRUE.
1610 
1611  Bool_t reply = kTRUE;
1612  if (!confirm)
1613  new TGMsgBox(gClient->GetRoot(), this, title, msg, kMBIconExclamation);
1614  else {
1615  Int_t ret_code = 0;
1616  new TGMsgBox(gClient->GetRoot(), this, title, msg, kMBIconExclamation, kMBYes | kMBNo, &ret_code);
1617  reply = (ret_code & kMBYes);
1618  }
1619  return reply;
1620 }
1621 
1622 
1623 
1624 #ifdef __WITHOUT_TGCOMBOBOX_REMOVEALL
1625 
1628 
1630 {
1631  //replaces functionality of TGComboBox::RemoveAll for ROOT versions < 5.11/02
1632 
1633  Int_t n = box->GetListBox()->GetNumberOfEntries();
1634  if (n) box->RemoveEntries(0, n - 1);
1635  if (box->GetSelectedEntry()) {
1636  ((TGTextLBEntry*)box->GetSelectedEntry())->SetTitle("");
1637  fClient->NeedRedraw(box->GetSelectedEntry());
1638  }
1639  else {
1640  box->GetTextEntry()->SetTitle("");
1641  fClient->NeedRedraw(box->GetTextEntry());
1642  }
1643 }
1644 
1646 
1647 
1650 {
1651  //replaces functionality of TGListBox::RemoveAll for ROOT versions < 5.11/02
1652 
1653  Int_t n = box->GetNumberOfEntries();
1654  if (n) box->RemoveEntries(0, n - 1);
1655  if (box->GetSelectedEntry()) {
1656  ((TGTextLBEntry*)box->GetSelectedEntry())->SetTitle("");
1657  fClient->NeedRedraw(box->GetSelectedEntry());
1658  }
1659 }
1660 
1661 #endif
1662 
1663 
1664 
1695 
1696 void KVDataAnalysisLauncher::SetResource(const TString& name, const TString& value)
1697 {
1698  // Handles resource file ".KVDataAnalysisGUIrc"
1699  // We store the current state of the interface using the following resource names:
1700  //
1701  // Repository KVDataAnalysisLauncher.Repository
1702  // DataSet KVDataAnalysisLauncher.DataSet
1703  // Task KVDataAnalysisLauncher.Task
1704  // System KVDataAnalysisLauncher.System
1705  // Trigger KVDataAnalysisLauncher.Trigger
1706  // RunsList KVDataAnalysisLauncher.RunsList
1707  // UserClass KVDataAnalysisLauncher.UserClass
1708  // KVDataSelector KVDataAnalysisLauncher.KVDataSelector
1709  // NbEventsToRead KVDataAnalysisLauncher.NbEventsToRead
1710  //
1711  // We also keep a "memory" of all selected configurations using the following
1712  // resource names:
1713  //
1714  // DataSet KVDataAnalysisLauncher.DataSet.[repository]
1715  // Task KVDataAnalysisLauncher.Task.[repository].[dataset]
1716  // System KVDataAnalysisLauncher.System.[repository].[dataset].[task]
1717  // Trigger KVDataAnalysisLauncher.Trigger.[repository].[dataset].[task].[system]
1718  // RunsList KVDataAnalysisLauncher.RunsList.[repository].[dataset].[task].[system].[trigger]
1719  // UserClass KVDataAnalysisLauncher.UserClass.[repository].[dataset].[task].[system].[trigger]
1720  // KVDataSelector KVDataAnalysisLauncher.KVDataSelector.[repository].[dataset].[task].[system].[trigger]
1721  // NbEventsToRead KVDataAnalysisLauncher.NbEventsToRead.[repository].[dataset].[task].[system].[trigger]
1722  //
1723  // N.B. [task]: it is the NAME of the task which is used in the resource name.
1724  // N.B.2. [system]: it is the name given by SystemBatchName() which is used in the resource name.
1725  // N.B.3. [trigger]: for the resource name we take "M > 4", "M>=8" "All" etc. and replace all ' ', '>' or '=' by ''
1726  // to give "M4", "M8", "All", etc.
1727 
1728  TString res, ful_res;
1729 
1730  BuildResourceName(name, res, ful_res);
1731 
1732  // save current value of resource
1733  GUIenv->SetValue(res.Data(), value);
1734 
1735  // save resource for future use if possible
1736  if (ful_res.Length()) GUIenv->SetValue(ful_res.Data(), value);
1737 
1738  GUIenv->SaveLevel(kEnvUser);
1739 }
1740 
1741 
1742 
1743 
1748 
1749 TString KVDataAnalysisLauncher::GetResource(const TString& name, const TString& defaultvalue)
1750 {
1751  // Handles resource file ".KVDataAnalysisGUIrc"
1752  //
1753  // We return the current value of the resource "name"
1754 
1755  TString res = name;
1756  res.Prepend("KVDataAnalysisLauncher.");
1757  return GUIenv->GetValue(res.Data(), defaultvalue);
1758 }
1759 
1760 
1761 
1762 
1775 
1777 {
1778  // Handles resource file ".KVDataAnalysisGUIrc"
1779  //
1780  // We look for a stored value of the resource "name" corresponding to the current
1781  // values of all the resources which come before "name" in the list :
1782  // Repository
1783  // DataSet
1784  // Task
1785  // These values are stored in resources with names like:
1786  // KVDataAnalysisLauncher.[name].[repository].[dataset]...
1787  //
1788  // If no stored value is found, the defaultvalue is returned
1789 
1790  TString res, ful_res;
1791 
1792  BuildResourceName(name, res, ful_res);
1793 
1794  if (!ful_res.Length()) {
1795  return GUIenv->GetValue(res.Data(), defaultvalue);
1796  }
1797 
1798  return GUIenv->GetValue(ful_res.Data(), defaultvalue);
1799 }
1800 
1801 
1802 
1803 
1806 
1807 TString KVDataAnalysisLauncher::SystemBatchName(void)
1808 {
1809  // Get the system name for the batch name
1810 
1811  TString tmp = GetSystem();
1812  if (tmp == "All") return GetSystem();
1813  return GetDataAnalyser()->SystemBatchName();
1814 }
1815 
1816 
1817 
1818 
1845 
1846 void KVDataAnalysisLauncher::BuildResourceName(const TString& name, TString& cur_res, TString& saved_res)
1847 {
1848  // Build the full resource names for storing DataSet, Task, etc.
1849  //
1850  // We store the current state of the interface using the following resource names:
1851  //
1852  // "name" "cur_res"
1853  // Repository KVDataAnalysisLauncher.Repository
1854  // DataSet KVDataAnalysisLauncher.DataSet
1855  // Task KVDataAnalysisLauncher.Task
1856  // UserClass KVDataAnalysisLauncher.UserClass
1857  // UserClassOptions KVDataAnalysisLauncher.UserClassOptions
1858  // NbEventsToRead KVDataAnalysisLauncher.NbEventsToRead
1859  //
1860  // We also keep a "memory" of all selected configurations using the following
1861  // resource names:
1862  //
1863  // "name" "saved_res"
1864  // DataSet KVDataAnalysisLauncher.DataSet.[repository]
1865  // Task KVDataAnalysisLauncher.Task.[repository].[dataset]
1866  //
1867  // N.B. [task]: it is the NAME of the task which is used in the resource name.
1868  //
1869  // If name = "Repository", saved_res="" as we do not save it.
1870  // If the resource cannot be saved because one of the resources that is needed to form the
1871  // full resource name has not been set, saved_res="".
1872 
1873  //Resource name for current value
1874  cur_res = name;
1875  cur_res.Prepend("KVDataAnalysisLauncher.");
1876 
1877  //Build full name for save
1878  Int_t index = -1;
1879  saved_res = "";
1880  // look for resource name in list ResourceNames
1881  TObject* resource = 0;
1882  if ((resource = ResourceNames.FindObject(name))) {
1883  //get index in resource table
1884  index = ResourceNames.IndexOf(resource);
1885  }
1886 
1887  if (index == 0) { // resource name = "Repository"; nothing more to do
1888  return;
1889  }
1890 
1891  if (index == -1) index = NbResNames; // force loop to end of list
1892 
1893  // resource name is written in format KVDataAnalysisLauncher.[name].[repository]....
1894  // where the suffixed resource values are all those in the list before the named resource
1895  // i.e. for name = "Task" we write the resource KVDataAnalysisLauncher.Task.[repository].[dataset]
1896 
1897  saved_res = cur_res;
1898  TIter next_res(&ResourceNames);
1899  Int_t i = 0;
1900  Bool_t ok = kTRUE;
1901 
1902  while ((resource = next_res()) && (i++ < index)) {
1903 
1904  TString tmp(GetResource(resource->GetName()));
1905  TString res;
1906  if (tmp == "") {
1907  // one of required resources is not set - none of following resources will be set either
1908  // we cannot save this resource
1909  ok = kFALSE;
1910  break;
1911  }
1912  if (!strcmp(resource->GetName(), "Task") && current_dataset) {
1913  // translate title to name for task
1914  KVDataAnalysisTask* tsk = current_dataset->GetAnalysisTask(tmp.Data());
1915  if (tsk) res.Form(".%s", tsk->GetName());
1916  }
1917  else {
1918  res = GetResource(resource->GetName()).Prepend(".");
1919  }
1920  saved_res += res;
1921  }
1922  if (name == "UserClassOptions") {
1923  if (GetResource("UserClass", "").Length())
1924  saved_res += GetResource("UserClass", "").Prepend(".");
1925  else ok = kFALSE;
1926  }
1927 
1928  if (!ok) saved_res = "";
1929 }
1930 
1931 
1932 
1933 
1941 
1942 void KVDataAnalysisLauncher::FillListOfUserClasses()
1943 {
1944  // Look at files in working directory & deduce list of user analysis classes.
1945  // We look for any file ending in '.h'. If we can find a corresponding '.cpp' or '.C' or '.cxx',
1946  // we consider that it is a user analysis class. This list is used to fill the "User Class"
1947  // drop-down list.
1948  // We add "[NEW]" at the end of the list: if selected, this will generate a new user analysis
1949  // class for the currently selected data & analysis task
1950 
1951  TSystemDirectory dir("LocDir", ".");
1952  unique_ptr<TList> lf(dir.GetListOfFiles());
1953  if (!lf.get()) return;
1954  UserClassNames->Clear();
1955  //loop over file names
1956  TIter next(lf.get());
1957  while (TObject* file = next()) {
1958 
1959  // fill list with all '.h' files
1960  TString tmp(file->GetName());
1961  if (tmp.EndsWith(".h")) {
1962  //strip '.h' from filename
1963  tmp.Remove(tmp.Index(".h"));
1964  UserClassNames->Add(new TNamed(tmp.Data(), tmp.Data()));
1965  }
1966 
1967  }
1968 
1969  // now check that implementation files exist for all '.h' we found
1970  TIter next_cl(UserClassNames);
1971  KVString imp, dec;
1972  while (TNamed* clh = (TNamed*)next_cl()) {
1973  if (!KVBase::FindClassSourceFiles(clh->GetName(), imp, dec)) clh->SetName("_INVALID_");
1974  }
1975  // remove all invalid class names
1976  while (TObject* obj = UserClassNames->FindObject("_INVALID_")) {
1977  UserClassNames->Remove(obj);
1978  delete obj;
1979  }
1980  // add [NEW] to list
1981  UserClassNames->Add(new TNamed("[NEW]", "[NEW]"));
1982 }
1983 
1984 
1985 
1986 
1989 
1990 void KVDataAnalysisLauncher::SetUserClassList()
1991 {
1992  // Sets the list of all available user classes in the drop down list
1993 
1994 #ifdef __WITHOUT_TGCOMBOBOX_REMOVEALL
1995  RemoveAll(cbUserClass);
1996 #else
1997  cbUserClass->RemoveAll();
1998 #endif
1999  cbUserClass->Select(-1);
2000 
2001  Int_t nbcl = UserClassNames->GetEntries();
2002  Int_t i = 0;
2003  cbUserClass->AddEntry("", i++);
2004  while (i < nbcl + 1) {
2005  cbUserClass->AddEntry(UserClassNames->At(i - 1)->GetName(), i);
2006  i++;
2007  }
2008  cbUserClass->Layout();
2009 }
2010 
2011 
2012 
2013 
2017 
2019 {
2020  // Called when a user class is selected in the combo box.
2021  // Updates batch name if 'auto batch name' is selected.
2022 
2023  if (class_name == "[NEW]") {
2024  GenerateNewUserClass();
2025  return;
2026  }
2027 
2028  // save resource
2029  SetResource("UserClassOptions", teUserOptions->GetText());
2030  SetResource("UserClass", class_name);
2031  teUserOptions->SetText(GetSavedResource("UserClassOptions", ""));
2032  SetResource("UserClassOptions", teUserOptions->GetText());
2033  if (strcmp("", class_name)) {
2034  btEditClass->SetEnabled(kTRUE);
2035  GetDataAnalyser()->SetUserClass(KVDataAnalyser::UserClass{class_name}, kFALSE);
2036  }
2037  else btEditClass->SetEnabled(kFALSE);
2038  checkCompilation = kTRUE;
2039 }
2040 
2041 
2042 
2049 
2050 void KVDataAnalysisLauncher::GenerateNewUserClass()
2051 {
2052  // called when user selects [NEW] in user class list
2053  // we generate a new analysis class for currently selected data & task
2054  // the source files are opened in the $EDITOR
2055  // the new class is selected for the analysis
2056 
2057  // Get name of new class
2058  TString classname;
2059  Bool_t ok;
2060  new KVInputDialog(this, "Enter name of new analysis class", &classname, &ok, "Enter name of new analysis class");
2061  // check new classname is not name of existing class
2062  KVString impfile, decfile;
2063  if (KVBase::FindClassSourceFiles(classname, impfile, decfile)) {
2064  ok = ok && WarningBox("Replacing existing class",
2065  Form("%s is the name of an existing class defined in [%s,%s].\nDo you want to overwrite this class?\n(All existing code will be lost)",
2066  classname.Data(), decfile.Data(), impfile.Data()),
2067  kTRUE);
2068  }
2069  if (ok) {
2070  // user class generation depends on gDataSet being set
2071  gDataSet=current_dataset;
2072  current_dataset->MakeAnalysisClass(GetTask(), classname);
2073  FillListOfUserClasses();
2074  }
2075  SetUserClassList();
2076  if (ok) {
2077  SetUserClass(classname);
2079  }
2080 }
2081 
2082 
2083 
2084 
2089 
2090 void KVDataAnalysisLauncher::SetUserClass(const Char_t* class_name)
2091 {
2092  // Sets selected user class in combo box according to e.g. a previously stored resource value.
2093  // We update the resource corresponding to the current state of the interface.
2094 
2095  // look for user class in list
2096  TGLBEntry* e = cbUserClass->FindEntry(class_name);
2097 
2098  if (e) {
2099  Int_t i = e->EntryId();
2100 #ifdef __WITHOUT_TGCOMBOBOX_SELECT_BOOL_T
2101  cbUserClass->Select(i);
2102 #else
2103  cbUserClass->Select(i, kFALSE);
2104 #endif
2105  // save current user class options
2106  // save current user class
2107  SetResource("UserClass", class_name);
2108  teUserOptions->SetText(GetSavedResource("UserClassOptions", ""));
2109  btEditClass->SetEnabled(kTRUE);
2110  }
2111 
2112  else
2113  // unknown user class
2114  {
2115  cbUserClass->Select(-1);
2116  SetResource("UserClass", "");
2117 
2118  btEditClass->SetEnabled(kFALSE);
2119  }
2120  checkCompilation = kTRUE;
2121 }
2122 
2123 
2124 
2125 
2128 
2129 TString KVDataAnalysisLauncher::GetUserClass()
2130 {
2131  // Returns currently selected user class name
2132 
2133  if (TGTextLBEntry* e = (TGTextLBEntry*)cbUserClass->GetSelectedEntry()) {
2134  return e->GetText()->GetString();
2135  }
2136  else {
2137  return "";
2138  }
2139 }
2140 
2141 
2142 
2143 
2146 
2147 void KVDataAnalysisLauncher::DisableUserClassList()
2148 {
2149  // Remove all entries from user class combo box & disable text entry
2150 
2151 #ifdef __WITHOUT_TGCOMBOBOX_REMOVEALL
2152  RemoveAll(cbUserClass);
2153 #else
2154  cbUserClass->RemoveAll();
2155 #endif
2156  cbUserClass->Select(-1);
2157  cbUserClass->SetEnabled(kFALSE);
2158  teUserOptions->SetEnabled(kFALSE);
2159 }
2160 
2161 
2162 
2163 
2168 
2169 void KVDataAnalysisLauncher::EnableUserClassList()
2170 {
2171  // Reenable user class combo box & text entry,
2172  // fill list with all known user classes & select the one corresponding
2173  // to the current environment
2174 
2175 
2176  SetUserClassList();
2177  SetUserClass(GetSavedResource("UserClass", ""));
2178  cbUserClass->SetEnabled(kTRUE);
2179  teUserOptions->SetEnabled(kTRUE);
2180 }
2181 
2182 
2183 
2188 
2190 {
2191  // If environment variable $EDITOR is set, and if the currently selected
2192  // user class has available source files, we open them in the
2193  // user's favourite editor
2194 
2195  TString editor = gSystem->Getenv("EDITOR");
2196  if (editor == "") return;
2197  TString uclass = GetUserClass();
2198  if (uclass == "") return;
2199  KVString imp, dec;
2200  if (!KVBase::FindClassSourceFiles(uclass, imp, dec)) return;
2201  gSystem->Exec(Form("%s %s %s &", editor.Data(), imp.Data(), dec.Data()));
2202 }
2203 
2204 
2205 
2210 
2212 {
2213  // For analysis tasks which perform data conversions (raw -> recon, dst -> recon, ...)
2214  // clicking on this button will select all of the runs of the currently selected system(s)
2215  // which have not yet been converted.
2216 
2217  auto stage_sel = current_dataset->GetRunList_StageSelection(output_type, source_type, listofSelectedSystems);
2218  DeselectAll();
2219  if (stage_sel) {
2220  lvRuns->ActivateItemsWithColumnData("Run/Index", stage_sel);
2222  }
2223 }
2224 
2225 
2226 
2234 
2236 {
2237  // Called when 'Stage selection' button is pressed, for conversion jobs
2238  // which generate 'target' files from 'source' files.
2239  //
2240  // Open small GUI for user to choose:
2241  // - stage selection (i.e. select all 'source' files for which no 'target' file exists)
2242  // - date selection (i.e. select all 'source ' files for which 'target' file is outside given date range)
2243 
2244  if (fStageSelections.IsEmpty()) {
2245  fStageSelections.SetValue("Missing", true);
2246  fStageSelections.SetValue("Date", false);
2247  fStageSelections.SetValue(" - earliest", KVDatime().AsSQLString());
2248  fStageSelections.SetValue(" - latest", KVDatime().AsSQLString());
2249  }
2250  Bool_t cancel = false;
2251  auto param_gui = new KVNameValueListGUI(this, &fStageSelections, &cancel);
2252  param_gui->MutuallyExclusive({"Missing", "Date"});
2253  param_gui->EnableDependingOnBool(" - earliest", "Date");
2254  param_gui->EnableDependingOnBool(" - latest", "Date");
2255  param_gui->DisplayDialog();
2256  if (!cancel) {
2257  if (fStageSelections.GetBoolValue("Date")) {
2258  std::optional<KVDatime> Dmin, Dmax;
2259  if (!fStageSelections.GetTStringValue(" - earliest").IsWhitespace())
2260  Dmin = KVDatime(fStageSelections.GetTStringValue(" - earliest"), KVDatime::kSQL);
2261  if (!fStageSelections.GetTStringValue(" - latest").IsWhitespace())
2262  Dmax = KVDatime(fStageSelections.GetTStringValue(" - latest"), KVDatime::kSQL);
2263  auto stage_sel = current_dataset->GetRunList_DateSelection(output_type, listofSelectedSystems, Dmin, Dmax);
2264  DeselectAll();
2265  if (stage_sel) {
2266  lvRuns->ActivateItemsWithColumnData("Run/Index", stage_sel);
2268  }
2269  }
2270  else if (fStageSelections.GetBoolValue("Missing")) {
2272  }
2273  }
2274 }
2275 
2276 
2277 
2280 
2282 {
2283  // Update available runs for current selected task (=datatype)
2284 
2285  current_dataset->UpdateAvailableRuns(source_type);
2286  // this will cause system list to be refilled in accordance with new available runfiles
2287  SetTask(GetTask());
2288 }
2289 
2290 
2291 
2292 
2297 
2299 {
2300  // Called when user presses "Runlist" button.
2301  // Open dialogue box in which a runlist can be entered.
2302  // The runs in the runlist will be selected.
2303 
2304  TString runs = listOfRuns.AsString();
2305  Bool_t ok = kFALSE;
2306  new KVInputDialog(this, "Enter list of runs", &runs, &ok);
2307  if (ok) {
2308  DeselectAll();
2309  SetRuns(runs.Data());
2310  }
2311 }
2312 
2313 
2314 
2315 
2320 
2322 {
2323  // Called when the selected runs in TGListView lvRuns change.
2324  // We update the run_index_list listOfRuns according to the current selection
2325  // we modify the limits of the 'runs per job' widget
2326 
2327  listOfRuns.Clear();
2328  auto novolist = lvRuns->GetSelectedObjects();
2329  if (novolist.GetEntries() > 0) {
2330  TIter nxt(&novolist);
2331  KVRunFile* s = 0;
2332  while ((s = (KVRunFile*)nxt())) listOfRuns.Add(s->GetRunIndex());
2333  }
2334 
2335  SetResource("RunsList", listOfRuns.AsString());
2336  if (listOfRuns.GetNValues())
2337  selectedRuns->SetText(Form("%d Selected Run%s : %s",
2338  listOfRuns.GetNValues(),
2339  listOfRuns.GetNValues() > 1 ? "s" : "",
2340  listOfRuns.AsString(MAX_LENGTH_SELECTED_RUNS).Data()));
2341  else
2342  selectedRuns->SetText(" ");
2343  fClient->NeedRedraw(selectedRuns);
2344 }
2345 
2346 
2347 
2348 
2351 
2353 {
2354  // Empty displayed list of selected runs
2355  listOfRuns.Clear();
2356  SetResource("RunsList", "");
2357  selectedRuns->SetText(" ");
2358  fClient->NeedRedraw(selectedRuns);
2359 }
2360 
2361 
int Int_t
unsigned int UInt_t
kVerticalFrame
kHorizontalFrame
ROOT::R::TRInterface & r
#define e(i)
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
R__EXTERN TEnv * gEnv
kEnvUser
kButtonDown
kButtonUp
#define gClient
kFDOpen
kLHintsRight
kLHintsExpandY
kLHintsLeft
kLHintsCenterY
kLHintsCenterX
kLHintsTop
kLHintsExpandX
kMBNo
kMBYes
kMBIconExclamation
kTextLeft
kTextBottom
kTextRight
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t sel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
char name[80]
char * Form(const char *fmt,...)
char * StrDup(const char *str)
R__EXTERN TSystem * gSystem
kS_IFDIR
virtual const Char_t * GetType() const
Definition: KVBase.h:177
static Bool_t FindClassSourceFiles(const KVString &class_name, KVString &imp_file, KVString &dec_file, const KVString &dir_name=".")
Definition: KVBase.cpp:1095
KVBatchSystem * GetDefaultBatchSystem() const
KVBatchSystem * GetBatchSystem(const Char_t *name)
Get batch system by name.
Utility GUI used for setting batch system parameters.
void Clear(Option_t *opt="") override
void cd()
Make this the default batch system.
virtual void SetBatchSystemParameters(const KVNameValueList &)
Use the parameters in the list to set all relevant parameters for batch system.
virtual void GetBatchSystemParameterList(KVNameValueList &)
Description of an experimental run in database ,,.
Definition: KVDBRun.h:41
Database class used to store information on different colliding systems studied during an experiment....
Definition: KVDBSystem.h:51
virtual void Run()
Check all task variables, then run analyser.
void SetBatchSystem(KVBatchSystem *bs)
void SetUserClassOptions(const Char_t *o="")
void SetUserLibraries(const Char_t *libs=0)
void SetAnalysisTask(KVDataAnalysisTask *at)
void SetUserClass(const UserClass &kvs, Bool_t check=kTRUE)
static KVDataAnalyser * GetAnalyser(const Char_t *plugin)
void SetUserIncludes(const Char_t *incDirs=0)
Bool_t IsUserClassValid() const
void SetNbEventToRead(Long64_t nb=0)
GUI for running data analysis tasks.
void SetRepositoryList(void)
Sets the list of all possible repositories in the repository combo box.
void DeselectAll(void)
Deselect all runs currently in the displayed list of runs.
void SetSystem(const TString &s="")
void Process(void)
Run the analysis task.
void SetTaskList(const TString &s)
void SetDataSet(const TString &ds="")
void UpdateAvailableRuns()
Update available runs for current selected task (=datatype)
void SetUserIncludes(void)
Set the User's includes.
void SetTask(const TString &t="")
void SetDataSetList(const TString &repository)
Sets the list of all available data sets in the data sets combo box.
void UserClassSelected(const TString &)
void ClearListOfSelectedRuns()
Empty displayed list of selected runs.
TString GetSavedResource(const TString &name, const TString &defaultvalue="")
Bool_t WarningBox(const char *title="Warning", const char *msg="Warning", Bool_t confirm=kFALSE)
void SelectAll(void)
Select all runs currently in the displayed list of runs.
void SetRuns(const TString &s="")
void SetUserLibraries(void)
Set the User's libraries.
void SetRepository(const TString &r="")
Define and manage data analysis tasks.
KVString GetOutputDataType() const
virtual Bool_t WithUserClass() const
virtual const Char_t * GetDataAnalyser() const
virtual const Char_t * GetUserBaseClass() const
virtual const Char_t * GetPrereq() const
Manages access to one or more data repositories.
const KVSeqCollection * GetListOfRepositories() const
KVDataSetRepository * GetRepository(const TString &name) const
Pilots user analysis of experimental data.
void SetDataSet(KVDataSet *ds)
void SetRuns(const run_index_list &nl, Bool_t check=kTRUE)
const KVDataSet * GetDataSet() const
void SetSystem(KVDBSystem *syst)
Set the System used in the analysis.
TString SystemBatchName() const
void SetFullRunList(const run_index_list &nl)
Int_t GetNavailable() const
KVDataSet * GetDataSet(Int_t) const
Return pointer to DataSet using index in list of all datasets, index>=0.
KVDataSet * GetAvailableDataSet(Int_t) const
run_index_list GetRunList(const Char_t *data_type, const KVDBSystem *sys=0) const
Definition: KVDataSet.cpp:1795
run_index_list GetRunList_DateSelection(const TString &type, const KVUnownedList &systems, std::optional< KVDatime > min_date=std::nullopt, std::optional< KVDatime > max_date=std::nullopt)
Definition: KVDataSet.cpp:1235
KVDataAnalysisTask * GetAnalysisTask(Int_t) const
Definition: KVDataSet.cpp:584
KVList GetListOfAvailableRunFilesForSystem(const TString &datatype, KVDBSystem *systol)
Definition: KVDataSet.cpp:639
Int_t GetNtasks() const
Definition: KVDataSet.cpp:569
KVExpDB * GetDataBase(const TString &opt="") const
Definition: KVDataSet.cpp:288
run_index_list GetRunList_StageSelection(const TString &other_type, const TString &base_type, KVDBSystem *sys=0, Bool_t OnlyCol=kFALSE)
Definition: KVDataSet.cpp:1289
void cd() const
Definition: KVDataSet.cpp:778
void UpdateAvailableRuns(const KVString &type)
Definition: KVDataSet.cpp:1103
bool MakeAnalysisClass(const Char_t *task, const Char_t *classname)
Definition: KVDataSet.cpp:2052
ValType GetDataSetEnv(const Char_t *type, const ValType &defval={}) const
Definition: KVDataSet.h:270
KVUnownedList GetListOfAvailableSystems(const TString &datatype)
Definition: KVDataSet.cpp:599
Extension of TDatime to handle various useful date formats.
Definition: KVDatime.h:35
@ kSQL
Definition: KVDatime.h:48
Bool_t IsMinimal() const
Definition: KVExpDB.h:271
virtual KVSeqCollection * GetSystems() const
Definition: KVExpDB.h:168
run_index_list SetRunIndexListFromString(const TString &, bool interpret_run_number_as_whole_run=false) const
Definition: KVExpDB.cpp:922
Directory dialogue box for KVDataAnalysisLauncher.
KVGDirectoryList(const TString &st, const TString &titre="File list", const TGWindow *p=0, const TGWindow *main=0, Bool_t ok=kTRUE)
Createur.
TString GetFileFromDialog(void) override
Gets the file name from a TGFileDialog.
Bool_t CanAdd(const TString &s) override
tells whether the file in ths string fn can be added to the list box
File dialogue box for KVDataAnalysisLauncher.
KVGFileList(const TString &st, const TString &titre="File list", const TGWindow *p=0, const TGWindow *main=0, Bool_t ok=kTRUE)
Createur.
void RemoveFiles()
Remove all the selected files from the TGListBox.
~KVGFileList()
Destructeur.
virtual TString GetFileFromDialog()
Gets the file name from a TGFileDialog.
void Done()
build the file list string from the content of the TGListBox
void RemoveAllFiles()
Remove all the files from the TGListBox.
virtual Bool_t CanAdd(const TString &s)
tells whether the file in ths string fn can be added to the list box
General purpose dialog box asking for some input in the form of a string.
Definition: KVInputDialog.h:24
Enhanced version of ROOT TGListView widget.
Definition: KVListView.h:147
virtual void SelectAll()
Definition: KVListView.h:186
virtual void UnSelectAll()
Definition: KVListView.h:190
void ActivateItemsWithColumnData(const Char_t *colname, const KVNumberList &data, Bool_t activate=kTRUE)
Definition: KVListView.h:231
virtual void Display(const TCollection *l)
Definition: KVListView.h:174
KVUnownedList GetSelectedObjects() const
Definition: KVListView.h:253
TObject * GetLastSelectedObject() const
Definition: KVListView.h:239
void ActivateItemWithColumnData(const Char_t *colname, const Char_t *data, Bool_t activate=kTRUE)
Definition: KVListView.h:219
virtual void RemoveAll()
Definition: KVListView.h:194
GUI for setting KVNameValueList parameters.
void SetValue(const Char_t *name, value_type value)
void SetFromEnv(TEnv *tenv, const TString &prefix="")
Int_t GetNpar() const
return the number of stored parameters
Bool_t IsEmpty() const
Bool_t HasBoolParameter(const Char_t *name) const
Bool_t GetBoolValue(const Char_t *name) const
TString GetTStringValue(const Char_t *name) const
void WriteToEnv(TEnv *tenv, const TString &prefix="")
Description of an individual data file in an experimental dataset.
Definition: KVRunFile.h:19
TObject * FindObject(const char *name) const override
Int_t GetSize() const override
void Clear(Option_t *option="") override
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
void Begin(TString delim) const
Definition: KVString.cpp:565
Bool_t End() const
Definition: KVString.cpp:634
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:695
virtual void AddAll(const TCollection *col)
virtual Int_t GetEntries() const
virtual void SetOwner(Bool_t enable=kTRUE)
virtual Bool_t IsEmpty() 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 SetToolTipText(const char *text, Long_t delayms=400)
virtual void SetEnabled(Bool_t e=kTRUE)
void WaitFor(TGWindow *w)
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
virtual Int_t GetSelected() const
void Layout() override
void RemoveAll() override
virtual TGLBEntry * GetSelectedEntry() const
virtual void Select(Int_t id, Bool_t emit=kTRUE)
virtual void SetEnabled(Bool_t on=kTRUE)
virtual TGLBEntry * FindEntry(const char *s) const
virtual void AddEntry(const char *s, Int_t id)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
void MapSubwindows() override
void Layout() override
virtual void RemoveAll()
char * fFilename
const char ** fFileTypes
char * fIniDir
virtual void Resize(TGDimension size)
void MapRaised() override
void SetTextJustify(Int_t tmode)
void SetText(const char *newText)
virtual void RemoveEntry(Int_t id=-1)
virtual void AddEntry(const char *s, Int_t id)
void Layout() override
virtual TGLBEntry * GetEntry(Int_t id) const
virtual void GetSelectedEntries(TList *selected)
virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
virtual TGLBEntry * FindEntry(const char *s) const
virtual void CloseWindow()
virtual void SetIntNumber(Long_t val, Bool_t emit=kTRUE)
virtual Long_t GetIntNumber() const
virtual Double_t GetNumber() const
TGClient * fClient
virtual void SetText(const TString &new_label)
const char * GetText() const
void SetEnabled(Bool_t flag=kTRUE)
virtual void SetText(const char *text, Bool_t emit=kTRUE)
void Clear(Option_t *option="") override
TObject * FindObject(const char *name) const override
void Add(TObject *obj) override
TObject * Remove(const TObjLinkPtr_t &lnk)
TObject * At(Int_t idx) const override
const char * GetName() const override
const char * GetTitle() const override
static TClass * Class()
virtual const char * GetName() const
virtual void Info(const char *method, const char *msgfmt,...) const
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
virtual Int_t IndexOf(const TObject *obj) const
Ssiz_t Length() const
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
const char * Data() const
Bool_t IsNull() const
TString & Prepend(char c, Ssiz_t rep=1)
Bool_t IsWhitespace() const
void Form(const char *fmt,...)
TString & Remove(EStripType s, char c)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual void Unload(const char *module)
virtual const char * Getenv(const char *env)
virtual const char * GetIncludePath()
virtual Int_t Exec(const char *shellcmd)
virtual void SetIncludePath(const char *includePath)
virtual int GetPathInfo(const char *path, FileStat_t &buf)
virtual const char * HostName()
virtual char * ExpandPathName(const char *path)
virtual Bool_t ProcessEvents()
List of runfiles specified by run number and file index ,.
TString AsString(Int_t maxlen=0) const
Int_t GetNValues() const
void Add(const run_index_t &r)
long long Long64_t
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
int main(int argc, char **argv)
const Int_t n
void Warning(UserClass p, const char *location, const char *va_(fmt),...)
Definition: KVError.h:125
ClassImp(TPyArg)