KaliVeda
Toolkit for HIC analysis
KVSimDirGUI.cpp
1 //Created by KVClassFactory on Wed Jul 18 11:55:11 2012
2 //Author: John Frankland,,,
3 
4 #include "KVUnownedList.h"
5 #include "KVSimDirGUI.h"
6 #include "KVDataSetManager.h"
7 #include "KVBatchSystemManager.h"
8 #include "KVDataSet.h"
9 #include "KVDBSystem.h"
10 #include "KVDBRun.h"
11 #include "KVSimFile.h"
12 #include "KVFileDialog.h"
13 #include "KVInputDialog.h"
14 #include "KV2Body.h"
15 #include "TGLabel.h"
16 #include "TGButtonGroup.h"
17 #include "TGMsgBox.h"
18 #include "TSystem.h"
19 #include <KVDataAnalyser.h>
20 #include <KVSimDirFilterAnalyser.h>
21 #include <KVSimReader.h>
22 #include <iostream>
23 using namespace std;
24 
25 #include "KVBatchSystemParametersGUI.h"
26 #include "KVDropDownDialog.h"
27 
29 
30 #ifdef WITH_RSQLITE
31 
34 
36 {
37  // Add a new dataset table for the given KVSimDir object
38 
39  TString ds_table_name = Form("Table_%d", ds_table_number);
40  KVSQLite::table DStable(ds_table_name);
41  DStable.add_primary_key("Id");
42  DStable.add_column("FileName", KVSQLite::column_type::TEXT);
43  DStable.add_column("TreeInfo", KVSQLite::column_type::TEXT);
44  DStable.add_column("Filtered", KVSQLite::column_type::INTEGER);
45  DStable.add_column("Events", KVSQLite::column_type::INTEGER);
46  DStable.add_column("DataSet", KVSQLite::column_type::TEXT);
47  DStable.add_column("System", KVSQLite::column_type::TEXT);
49  DStable.add_column("GeoType", KVSQLite::column_type::TEXT);
50  DStable.add_column("TreeName", KVSQLite::column_type::TEXT);
51  DStable.add_column("BranchName", KVSQLite::column_type::TEXT);
52  DStable.add_column("OrigFile", KVSQLite::column_type::TEXT);
53  DStable.add_column("FiltType", KVSQLite::column_type::TEXT);
54  DStable.add_column("Gemini", KVSQLite::column_type::INTEGER);
55  DStable.add_column("GemDecayPerEvent", KVSQLite::column_type::INTEGER);
56  fConfigDB.add_table(DStable);
57  // update name of dataset table in main table
58  fConfigDB["Datasets"]["Table"] = ds_table_name;
59  fConfigDB.update("Datasets", "Table", Form("Name=\"%s\"", sd->GetName()));
60  return ds_table_name;
61 }
62 
63 
64 
66 
68 {
69  fConfigDB.prepare_data_insertion(ds_table_name);
70  KVSQLite::table& dstable = fConfigDB[ds_table_name];
71  if (sd->GetSimDataList()->GetEntries()) {
72  TIter it1(sd->GetSimDataList());
73  KVSimFile* sf = nullptr;
74  while ((sf = (KVSimFile*)it1())) {
75  dstable["Id"].set_null();
76  dstable["FileName"] = sf->GetName();
77  dstable["TreeInfo"] = sf->GetTitle();
78  dstable["Filtered"] = 0;
79  dstable["Events"] = (Int_t)sf->GetEvents();
80  dstable["TreeName"] = sf->GetTreeName();
81  dstable["BranchName"] = sf->GetBranchName();
82  fConfigDB.insert_data_row();
83  }
84  }
85  if (sd->GetFiltDataList()->GetEntries()) {
86  TIter it1(sd->GetFiltDataList());
87  KVSimFile* sf = nullptr;
88  while ((sf = (KVSimFile*)it1())) {
89  dstable["Id"].set_null();
90  dstable["FileName"] = sf->GetName();
91  dstable["TreeInfo"] = sf->GetTitle();
92  dstable["Filtered"] = 1;
93  dstable["Events"] = (Int_t)sf->GetEvents();
94  dstable["TreeName"] = sf->GetTreeName();
95  dstable["BranchName"] = sf->GetBranchName();
96  dstable["DataSet"] = sf->GetDataSet();
97  dstable["System"] = sf->GetSystem();
98  dstable["Run"] = sf->GetRun();
99  dstable["GeoType"] = sf->GetGeometry();
100  dstable["FiltType"] = sf->GetFilterType();
101  dstable["OrigFile"] = sf->GetOriginalFile();
102  dstable["Gemini"] = sf->IsGemini();
103  dstable["GemDecayPerEvent"] = sf->GetGemDecayPerEvent();
104  fConfigDB.insert_data_row();
105  }
106  }
107  fConfigDB.end_data_insertion();
108 }
109 
110 #endif
111 
112 
116 
118  : fGuirc(".kvsimdirguirc")
119 #ifdef WITH_RSQLITE
120  , fConfigDB(gSystem->ExpandPathName("$(HOME)/.kvsimdirguidb"))
121 #endif
122 {
123  // Default constructor
124  // main frame
125 
126  fSelectedSimDir = nullptr;
127  fWithPROOF = kFALSE;
128 
129  // make Aclic create all *.so *.d files in separate temporary directories
130  //this is to avoid problems with KVParticleCondition when using PROOF
132 
133  MainFrame = new TGMainFrame(gClient->GetRoot(), 10, 10, kMainFrame | kVerticalFrame);
134  MainFrame->SetName("KaliVedaSim GUI");
135  MainFrame->SetWindowName("KaliVedaSim GUI");
136  MainFrame->Connect("CloseWindow()", "KVSimDirGUI", this, "Exit()");
137 
139 
140  TGCompositeFrame* vf = new TGVerticalFrame(hftop, 200, 500, kVerticalFrame);
141  // sim dir buttons
142  TGCompositeFrame* hf = new TGHorizontalFrame(vf, 10, 10, kHorizontalFrame);
143  BaddDir = new TGPictureButton(hf, gClient->GetPicture("package_add.xpm"));
144  hf->AddFrame(BaddDir, new TGLayoutHints(kLHintsLeft | kLHintsTop, 3, 2, 2, 2));
145  BaddDir->Resize(40, 40);
146  BaddDir->SetToolTipText("Add dataset");
147  BaddDir->Connect("Clicked()", "KVSimDirGUI", this, "AddSimDir()");
148  BimpSim = new TGPictureButton(hf, gClient->GetPicture("bld_text.xpm"));
149  hf->AddFrame(BimpSim, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
150  BimpSim->Resize(40, 40);
151  BimpSim->SetToolTipText("Import simulation");
152  BimpSim->Connect("Clicked()", "KVSimDirGUI", this, "ImportSimulation()");
153  BremDir = new TGPictureButton(hf, gClient->GetPicture("package_delete.xpm"));
154  hf->AddFrame(BremDir, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
155  BremDir->Resize(40, 40);
156  BremDir->SetToolTipText("Remove dataset");
157  BremDir->Connect("Clicked()", "KVSimDirGUI", this, "RemSimDir()");
158  BrefreshDir = new TGPictureButton(hf, gClient->GetPicture("refresh2.xpm"));
159  hf->AddFrame(BrefreshDir, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
160  BrefreshDir->Resize(40, 40);
161  BrefreshDir->SetToolTipText("Update");
162  BrefreshDir->Connect("Clicked()", "KVSimDirGUI", this, "RefreshSimDir()");
166 
167  vf->AddFrame(hf, new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2));
168 
169  // canvas widget
170  fDirListCanvas = new TGCanvas(vf, 172, 400);
171  // canvas viewport
173  // list tree
175 
176  popen = gClient->GetPicture("package_add.xpm");
177  pclose = gClient->GetPicture("package_add.xpm");
178 
182  fDirListTree->Connect("Clicked(TGListTreeItem*,Int_t)", "KVSimDirGUI", this, "SelectSimDir(TGListTreeItem*,Int_t)");
186 
187  hftop->AddFrame(vf, new TGLayoutHints(kLHintsExpandY | kLHintsTop, 2, 2, 2, 2));
188 
189  /* lists of data in simdir */
190  vf = new TGVerticalFrame(hftop, 600, 500, kVerticalFrame);
191  TGGroupFrame* group = new TGGroupFrame(vf, "Simulations");
192  fLVsimData = new KVListView(KVSimFile::Class(), group, 550, 200);
194  fLVsimData->SetDataColumn(0, "Name");
195  fLVsimData->SetDataColumn(1, "Info", "GetTitle");
196  fLVsimData->SetDataColumn(2, "Events");
199  group->AddFrame(fLVsimData, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 5, 5, 10, 10));
201  group = new TGGroupFrame(vf, "Filtered Simulations");
202  fLVfiltData = new KVListView(KVSimFile::Class(), group, 550, 200);
204  fLVfiltData->SetDataColumn(0, "Simulation", "GetOriginalFile");
205  fLVfiltData->SetDataColumn(1, "DataSet");
206  fLVfiltData->SetDataColumn(2, "System");
207  fLVfiltData->SetDataColumn(3, "Run");
208  fLVfiltData->SetDataColumn(4, "Gemini", "IsGemini");
209  fLVfiltData->SetDataColumn(5, "Decay/event", "GetGemDecayPerEvent");
210  fLVfiltData->SetDataColumn(6, "FilterType");
211  fLVfiltData->SetDataColumn(7, "Events");
214  group->AddFrame(fLVfiltData, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 5, 5, 10, 10));
216 
217  hftop->AddFrame(vf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10, 10, 10, 10));
218  MainFrame->AddFrame(hftop, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 1, 1, 1, 1));
219 
221  /* Analysis Tab */
222  fAnalTab = fAnalysisTabs->AddTab("Data Analysis");
224  vf = new TGVerticalFrame(fAnalTab, 600, 200, kVerticalFrame);
225  hf = new TGHorizontalFrame(vf, 10, 10, kHorizontalFrame);
226  TGLabel* lab = new TGLabel(hf, "Analysis class : ");
227  hf->AddFrame(lab, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 2, 2, 2));
231  TGPictureButton* change_class = new TGPictureButton(hf, gClient->GetPicture("bld_open.png"));
233  change_class->SetToolTipText("Change class");
234  change_class->Connect("Clicked()", "KVSimDirGUI", this, "SelectAnalysisClass()");
235  hf->AddFrame(change_class, new TGLayoutHints(kLHintsCenterY | kLHintsRight, 2, 2, 2, 2));
236  vf->AddFrame(hf, new TGLayoutHints(kLHintsTop | kLHintsExpandY, 2, 2, 2, 2));
237  hf = new TGHorizontalFrame(vf, 10, 10, kHorizontalFrame);
238 
239  TGTextButton* new_anal_class = new TGTextButton(hf, "New simulated analysis class");
240  new_anal_class->Connect("Clicked()", "KVSimDirGUI", this, "NewSimulatedAnalysisClass()");
241  hf->AddFrame(new_anal_class, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 10));
242  TGTextButton* new_filt_class = new TGTextButton(hf, "New filtered analysis class");
243  new_filt_class->Connect("Clicked()", "KVSimDirGUI", this, "NewFilteredAnalysisClass()");
244  hf->AddFrame(new_filt_class, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
245 
246  vf->AddFrame(hf, new TGLayoutHints(kLHintsTop | kLHintsExpandY, 2, 2, 2, 2));
247  // fCBAllEvents->Connect("Toggled(Bool_t)", "KVSimDirGUI", this, "EnableEventNumberEntry(Bool_t)");
248  // fCBAllEvents->SetState(kButtonDown, kTRUE);
249 
251 
252  /* Filter Tab */
253  fFiltTab = fAnalysisTabs->AddTab("Filtering");
255  vf = new TGHorizontalFrame(fFiltTab, 600, 200, kHorizontalFrame);
256 
257 
258  /*system and dataset*/
259  hf = new TGGroupFrame(vf, "Experimental conditions", kVerticalFrame);
260  // new TGGroupFrame()
261  // lab = new TGLabel(hf, "Experimental conditions : ");
262  // hf->AddFrame(lab, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 2, 2, 2));
263 
264  TGCompositeFrame* tmpf = new TGHorizontalFrame(hf, 600, 200, kHorizontalFrame);
265  fCBdataset = new TGComboBox(tmpf);
266  if (!gDataSetManager) {
268  dsm->Init();
269  }
270  // fill list of datasets
271  Int_t ndatasets = gDataSetManager->GetNtotal();
272  fCBdataset->AddEntry("Choose dataset...", 0);
273  for (int i = 1; i <= ndatasets; i++) {
274  fCBdataset->AddEntry(gDataSetManager->GetDataSet(i - 1)->GetName(), i);
275  }
276  fCBdataset->Layout();
277  fCBdataset->Resize(200, 20);
278  fCBdataset->Select(0, kFALSE);
279 
280  tmpf->AddFrame(fCBdataset, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
281  fCBdataset->Connect("Selected(const char*)", "KVSimDirGUI", this, "SelectDataSet(const char*)");
282 
283  auto text_label = new TGLabel(tmpf, "[determines detection setup i.e. detector array geometry]");
284  tmpf->AddFrame(text_label, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 10, 2, 2, 2));
285 
286  hf->AddFrame(tmpf, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 0, 0));
287 
288  tmpf = new TGHorizontalFrame(hf, 600, 200, kHorizontalFrame);
289  fCBsystem = new TGComboBox(tmpf);
290  fCBsystem->AddEntry("Choose system...", 0);
291  fCBsystem->Layout();
292  fCBsystem->Resize(400, 20);
293  fCBsystem->Select(0, kFALSE);
294  tmpf->AddFrame(fCBsystem, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
295  fCBsystem->Connect("Selected(const char*)", "KVSimDirGUI", this, "SelectSystem(const char*)");
296 
297  text_label = new TGLabel(tmpf, "[system + run number determine...");
298  tmpf->AddFrame(text_label, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 10, 2, 2, 2));
299 
300  hf->AddFrame(tmpf, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 0, 0));
301 
302  tmpf = new TGHorizontalFrame(hf, 600, 200, kHorizontalFrame);
303  fCBrun = new TGComboBox(tmpf);
304  fCBrun->AddEntry("Choose run...", 0);
305  fCBrun->Layout();
306  fCBrun->Resize(100, 20);
307  fCBrun->Select(0, kFALSE);
308  tmpf->AddFrame(fCBrun, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
309  fCBrun->Connect("Selected(const char*)", "KVSimDirGUI", this, "SelectRun(const char*)");
310 
311  text_label = new TGLabel(tmpf, "...run-specific parameters (which id, calibs are set/working, gas pressures, ...)]");
312  tmpf->AddFrame(text_label, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 10, 2, 2, 2));
313 
314  hf->AddFrame(tmpf, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 0, 0));
315 
316  tmpf = new TGHorizontalFrame(hf, 600, 200, kHorizontalFrame);
317 
318  custom_kinematics_check = new TGCheckButton(tmpf, "Ad hoc reaction kinematics:");
319  custom_kinematics_check->Connect("Toggled(Bool_t)", "KVSimDirGUI", this, "SetCustomKinematics(Bool_t)");
320  custom_kinematics_check->SetToolTipText("Define ad hoc reaction kinematics for lab/CM transformation");
324 
325  fTESystem = new TGTextEntry(tmpf, new TGTextBuffer(400));
327  fTESystem->SetToolTipText("[Projectile_Symbol]+[Target_Symbol]@[Incident_Energy]MeV/A (ex: 129Xe+119Sn@50.0MeV/A)");
328  tmpf->AddFrame(fTESystem, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 10, 2, 2, 2));
329  fTESystem->Connect("TextChanged(const char*)", "KVSimDirGUI", this, "UpdateSystemText(const char*)");
331  hf->AddFrame(tmpf, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 0, 0));
332 
333  vf->AddFrame(hf, new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 10, 2));
334 
335 
336  hf = new TGHorizontalFrame(vf, 10, 10, kHorizontalFrame);
337 
338  TGButtonGroup* bgroup = new TGButtonGroup(hf, "Filter type");
339 
340  TGRadioButton* radiob = new TGRadioButton(bgroup, "Geometric");
341  radiob->SetToolTipText("Use geometrical filter: no thresholds; only deadzones");
342  radiob = new TGRadioButton(bgroup, "Geometry+Thresholds");
343  radiob->SetToolTipText("Use geometry + theoretical thresholds for detection/identification, nominal performances of all detectors/identifications");
344 // radiob->SetState(kButtonDown);
345  radiob = new TGRadioButton(bgroup, "Full");
346  radiob->SetToolTipText("As Geo+Thresh, but detectors/identifications/calibrations which work depend on the run number (as for experiment)");
347  radiob->SetState(kButtonDown);
348  bgroup->Connect("Clicked(Int_t)", "KVSimDirGUI", this, "FilterType(Int_t)");
350 // fFilterType = kFTSeuils;
351  hf->AddFrame(bgroup, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 2, 2, 2, 2));
352 
353  TGVerticalFrame* vf1 = new TGVerticalFrame(hf, 30, 30);
354  bgroup = new TGButtonGroup(vf1, "Options");
355  phi_rotation_check = new TGCheckButton(bgroup, "Random phi");
356  phi_rotation_check->Connect("Toggled(Bool_t)", "KVSimDirGUI", this, "SetRandomPhi(Bool_t)");
357  phi_rotation_check->SetToolTipText("Random rotation around beam axis before detection");
358  fRandomPhi = kTRUE;
360 #ifdef WITH_GEMINI
361  gemini_decay = new TGCheckButton(bgroup, "Gemini++ decay");
362  gemini_decay->Connect("Toggled(Bool_t)", "KVSimDirGUI", this, "SetGeminiDecay(Bool_t)");
363  gemini_decay->SetToolTipText("Use Gemini++ to calculate statistical decay before detection");
365  //
366  TGHorizontalFrame* hhf = new TGHorizontalFrame(vf1, 20);
367  TGLabel* gemini_label = new TGLabel(hhf, "Decays/evt.:");
368  hhf->AddFrame(gemini_label, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5, 2, 2, 2));
370  gemini_decays->GetNumberEntry()->SetToolTipText("Number of times to decay each event with Gemini++");
373  //
374  TGHorizontalFrame* hhhf = new TGHorizontalFrame(vf1, 20);
375  gemini_add_rot_energy = new TGCheckButton(hhhf, "Add rotational energy");
376  gemini_add_rot_energy->Connect("Toggled(Bool_t)", "KVSimDirGUI", this, "SetGeminiDecayAddRotEnergy(Bool_t)");
377  gemini_add_rot_energy->SetToolTipText("Add the rotational energy to the excitation energy for each nucleus");
378  //gemini_add_rot_energy->SetState(kButtonDown);
381  //
382 #endif
383  fGemDecay = kFALSE;
385  fGeoType = kGTROOT;
386  vf1->AddFrame(bgroup, new TGLayoutHints(kLHintsTop, 1, 1, 1, 5));
387 #ifdef WITH_GEMINI
388  vf1->AddFrame(hhf, new TGLayoutHints(kLHintsBottom, 2, 2, 2, 2));
389  vf1->AddFrame(hhhf, new TGLayoutHints(kLHintsBottom, 3, 3, 2, 4));
390 #endif
391  hf->AddFrame(vf1, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
392 
393  bgroup = new TGButtonGroup(hf, "Kinematics");
394  radiob = new TGRadioButton(bgroup, "CM");
395  radiob->SetToolTipText("Simulation in CM frame: will be transformed to lab frame for detection");
396  radiob->SetState(kButtonDown);
397  radiob = new TGRadioButton(bgroup, "Lab");
398  radiob->SetToolTipText("Simulation in lab frame: no kinematical transformation");
399  radiob = new TGRadioButton(bgroup, "Projectile");
400  radiob->SetToolTipText("Simulation in projectile frame: will be transformed to lab frame for detection");
401  bgroup->Connect("Clicked(Int_t)", "KVSimDirGUI", this, "Kinematics(Int_t)");
402  fKine = kKCM;
403  hf->AddFrame(bgroup, new TGLayoutHints(kLHintsTop | kLHintsLeft, 20, 2, 2, 2));
404  // proof_analysis_filt = new TGPictureButton(hf, gClient->GetPicture("proof_base.xpm"));
405  // proof_analysis_filt->Connect("Pressed()", "KVSimDirGUI", this, "EnableProof()");
406  // proof_analysis_filt->Connect("Released()", "KVSimDirGUI", this, "DisableProof()");
407  // proof_analysis_filt->SetToolTipText("Enable PROOF");
408  // proof_analysis_filt->Resize(40, 40);
409  // proof_analysis_filt->AllowStayDown(kTRUE);
410  // hf->AddFrame(proof_analysis_filt, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 250, 2, 2, 2));
411  // launch_analysis = new TGPictureButton(hf, gClient->GetPicture("query_submit.xpm"));
413  // launch_analysis->Connect("Clicked()", "KVSimDirGUI", this, "Run()");
414  // launch_analysis->SetToolTipText("Run filter");
415  // launch_analysis->Resize(40, 40);
416  // hf->AddFrame(launch_analysis, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 5, 2, 2, 2));
417  vf->AddFrame(hf, new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 10, 2));
418 
419  // hf = new TGHorizontalFrame(vf, 10, 10, kHorizontalFrame);
420  // lab= new TGLabel(hf, "Output directory : ");
421  // hf->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2));
422  // fTEOutputDir = new TGTextEntry(hf, new TGTextBuffer(256));
423  // fTEOutputDir->SetText(gSystem->pwd());
424  // fTEOutputDir->Resize(650, fTEOutputDir->GetDefaultHeight());
425  // hf->AddFrame(fTEOutputDir, new TGLayoutHints(kLHintsCenterY|kLHintsLeft, 2,2,2,2));
426  // change_class = new TGPictureButton(hf,gClient->GetPicture("bld_open.png"));
427  // change_class->Resize(fTEOutputDir->GetDefaultHeight(),fTEOutputDir->GetDefaultHeight());
428  // change_class->SetToolTipText("Change directory");
429  // change_class->Connect("Clicked()", "KVSimDirGUI", this, "ChangeOutputDirectory()");
430  // hf->AddFrame(change_class,new TGLayoutHints(kLHintsCenterY|kLHintsLeft, 2,2,2,2));
431  // vf->AddFrame(hf, new TGLayoutHints(kLHintsTop|kLHintsExpandY,2,2,2,2));
432 
434 
438 
440 
441 
442 
443  vf = new TGVerticalFrame(MainFrame, 600, 200, kVerticalFrame);
444  hf = new TGHorizontalFrame(vf, 600, 200, kHorizontalFrame);
445 
446  lab = new TGLabel(hf, "Events : ");
447  hf->AddFrame(lab, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2, 2, 2, 2));
448  fCBAllEvents = new TGCheckButton(hf, "all");
452  fCBAllEvents->Connect("Toggled(Bool_t)", "KVSimDirGUI", this, "EnableEventNumberEntry(Bool_t)");
454 
455 
456  proof_analysis = new TGPictureButton(hf, gClient->GetPicture("proof_base.xpm"));
457  proof_analysis->Connect("Pressed()", "KVSimDirGUI", this, "EnableProof()");
458  proof_analysis->Connect("Released()", "KVSimDirGUI", this, "DisableProof()");
459  if (!gBatchSystemManager) new KVBatchSystemManager;
460  gBatchSystemManager->GetDefaultBatchSystem()->cd();
461  proof_analysis->SetToolTipText(gBatchSystem->GetTitle());
462  proof_analysis->Resize(40, 40);
464 
465  TGPictureButton* launch_analysis = new TGPictureButton(hf, gClient->GetPicture("query_submit.xpm"));
466  launch_analysis->Connect("Clicked()", "KVSimDirGUI", this, "Run()");
467  launch_analysis->SetToolTipText("Run analysis/filter");
468  launch_analysis->Resize(40, 40);
469 
470  hf->AddFrame(launch_analysis, new TGLayoutHints(kLHintsCenterY | kLHintsRight, 5, 2, 2, 2));
472 
473  vf->AddFrame(hf, new TGLayoutHints(kLHintsExpandX | kLHintsTop, 0, 0, 0, 0));
474  MainFrame->AddFrame(vf, new TGLayoutHints(kLHintsExpandX | kLHintsTop, 10, 10, 15, 10));
475 
476 
478  kMWMFuncAll,
481 
483  MainFrame->MapWindow();
484  // MainFrame->Resize(200,500);
485 #ifdef WITH_RSQLITE
486  // define tables in DB if not already done
487  bool sqlite_conversion = false;
489  sqlite_conversion = true;
490  KVSQLite::table datasets("Datasets");
491  datasets.add_primary_key("Id");
492  datasets.add_column("Name", "TEXT");
493  datasets.add_column("Directory", "TEXT");
494  datasets.add_column("Table", "TEXT");
495  fConfigDB.add_table(datasets);
496  }
497  if (!sqlite_conversion) {
498  // use existing sqlite database to reconstruct simdirs
500  FillTreeList();
501  return;
502  }
503 #endif
504  // use .guirc to fill the list of sim dirs
505  KVString simdirs = fGuirc.GetValue("SimDirs", "");
506  if (simdirs != "") {
507 #ifdef WITH_RSQLITE
508  if (sqlite_conversion) {
509  // we are converting from the old TEnv back end to sqlite
510  // need to fill table of Datasets
511  fConfigDB.prepare_data_insertion("Datasets");
512  }
513  int ds_table = 0;
514 #endif
515  simdirs.Begin(" ");
516  while (!simdirs.End()) {
517  KVString simdir = simdirs.Next();
518  KVString simdirectory = fGuirc.GetValue(Form("%s.Directory", simdir.Data()), "");
519  KVSimDir* sd = new KVSimDir(simdir, simdirectory);
520 #ifdef WITH_RSQLITE
521  if (sqlite_conversion) {
522  fConfigDB["Datasets"]["Name"] = simdir;
523  fConfigDB["Datasets"]["Directory"] = simdirectory;
525  }
526 #endif
527  sd->AnalyseDirectory();
528  fListOfDirs.Add(sd);
529  }
530 #ifdef WITH_RSQLITE
531  if (sqlite_conversion) {
533  TIter itdir(&fListOfDirs);
534  KVSimDir* sd = nullptr;
535  while ((sd = (KVSimDir*)itdir())) {
536  // add table for dataset
537  TString ds_table_name = AddTableForDataSet(sd, ds_table);
538  // fill table with infos
539  FillDataSetTableWithInfos(ds_table_name, sd);
540  ++ds_table;
541  }
542  }
543 #endif
544  FillTreeList();
545  }
546 }
547 
548 
549 
550 
557 
559 {
560  // Copy constructor
561  // This ctor is used to make a copy of an existing object (for example
562  // when a method returns an object), and it is always a good idea to
563  // implement it.
564  // If your class allocates memory in its constructor(s) then it is ESSENTIAL :-)
565 
566  obj.Copy(*this);
567 }
568 
569 
570 
573 
575 {
576  // Destructor
577 }
578 
579 
580 
581 
589 
590 void KVSimDirGUI::Copy(TObject& obj) const
591 {
592  // This method copies the current state of 'this' object into 'obj'
593  // You should add here any member variables, for example:
594  // (supposing a member variable KVSimDirGUI::fToto)
595  // CastedObj.fToto = fToto;
596  // or
597  // CastedObj.SetToto( GetToto() );
598 
599  KVBase::Copy(obj);
600  //KVSimDirGUI& CastedObj = (KVSimDirGUI&)obj;
601 }
602 
603 
604 
606 
608 {
609  EmptyTreeList();
610  TIter next(&fListOfDirs);
611  TObject* o;
612  while ((o = next())) {
613  TGListTreeItem* item0 = fDirListTree->AddItem(NULL, o->GetName());
614  item0->SetPictures(popen, pclose);
615  fDirListTree->CloseItem(item0);
616  }
617 }
618 
619 
620 
622 
624 {
626  while (first) {
629  }
633 }
634 
635 
636 
638 
640 {
641  static TString dir(".");
642  TGFileInfo fi;
643  fi.fIniDir = StrDup(dir);
644  new KVFileDialog(gClient->GetDefaultRoot(), MainFrame, kKVFDDirectory, &fi);
645  if (fi.fFilename) {
646  TString simdirname;
647  Bool_t ok;
648  TString quest;
649  quest.Form("Enter name for dataset %s", fi.fIniDir);
650  new KVInputDialog(MainFrame, quest, &simdirname, &ok);
651  simdirname.ReplaceAll(" ", "_"); //no spaces in name
652  if (ok) {
653  KVSimDir* sd = new KVSimDir(simdirname, fi.fIniDir);
654  sd->AnalyseDirectory();
655  fListOfDirs.Add(sd);
656  FillTreeList();
659  // add to guirc file
660  TString simdirs = fGuirc.GetValue("SimDirs", "");
661  if (simdirs != "") simdirs += " ";
662  simdirs += simdirname;
663  fGuirc.SetValue("SimDirs", simdirs);
664  fGuirc.SetValue(Form("%s.Directory", simdirname.Data()), sd->GetDirectory());
666 #ifdef WITH_RSQLITE
667  //update database
668  int ds_table_num = 0;
669  if (fConfigDB.count("Datasets")) {
670  // get name/number of last dataset table
671  KVNameValueList table_names = fConfigDB.get_name_value_list("Datasets", "Name", "Table");
672  sscanf(table_names.GetParameter(table_names.GetNpar() - 1)->GetString(),
673  "Table_%d", &ds_table_num);
674  ++ds_table_num;
675  }
676  fConfigDB.prepare_data_insertion("Datasets");
677  fConfigDB["Datasets"]["Id"].set_null();
678  fConfigDB["Datasets"]["Name"] = simdirname;
679  fConfigDB["Datasets"]["Directory"] = sd->GetDirectory();
682  TString table_name = AddTableForDataSet(sd, ds_table_num);
683  FillDataSetTableWithInfos(table_name, sd);
684 #endif
685  }
686  }
687  dir = fi.fIniDir;
688 }
689 
690 
691 
693 
695 {
696  if (!fSelectedSimDir) return;
700 #ifdef WITH_RSQLITE
701  fConfigDB.select_data("Datasets", "Table", Form("Name=\"%s\"", fSelectedSimDir->GetName()));
702  TString ds_table_name;
703  while (fConfigDB.get_next_result()) ds_table_name = fConfigDB["Datasets"]["Table"].get_data<TString>();
704  fConfigDB.clear_table(ds_table_name);
706 #endif
707 }
708 
709 
710 
712 
714 {
715  if (!fSelectedSimDir) return;
717  // there is no way of removing a name-value pair from a TEnv!!
718  fGuirc.SetValue(Form("%s.Directory", fSelectedSimDir->GetName()), "");
719 #ifdef WITH_RSQLITE
720  // remove from datasets table
721  fConfigDB.select_data("Datasets", "Table", Form("Name=\"%s\"", fSelectedSimDir->GetName()));
722  TString ds_table_name;
723  while (fConfigDB.get_next_result()) ds_table_name = fConfigDB["Datasets"]["Table"].get_data<TString>();
724  fConfigDB.delete_data("Datasets", Form("Name=\"%s\"", fSelectedSimDir->GetName()));
725  // and delete table with dataset data
726 #endif
727  delete fSelectedSimDir;
728  fSelectedSimDir = nullptr;
729  FillTreeList();
732  // update guirc file
733  TString simdirs = "";
734  TIter next(&fListOfDirs);
735  KVSimDir* togo;
736  while ((togo = (KVSimDir*)next())) {
737  if (simdirs != "") simdirs += " ";
738  simdirs += togo->GetName();
739  fGuirc.SetValue(Form("%s.Directory", togo->GetName()), togo->GetDirectory());
740  }
741  fGuirc.SetValue("SimDirs", simdirs);
743 }
744 
745 
746 
748 
750 {
752  if (fSelectedSimDir) {
755  BremDir->SetEnabled();
756  BimpSim->SetEnabled();
758  }
759  else {
763  }
764 }
765 
766 
767 
769 
771 {
772  static TString dir(".");
773  const char* filetypes[] = {
774  "Class header files", "*.h",
775  0, 0
776  };
777  TGFileInfo fi;
778  fi.fIniDir = StrDup(dir);
779  fi.fFileTypes = filetypes;
780  new KVFileDialog(gClient->GetDefaultRoot(), MainFrame, kKVFDOpen, &fi);
781  if (fi.fFilename) {
783  Int_t idot = fAnalClassName.Index(".");
784  if (idot < 0) return;
785  fAnalClassName.Remove(idot, 2);
788  fAnalClassDir = fi.fIniDir;
789  cout << "Found class header " << gSystem->BaseName(fAnalClassHeader) << " and implementation "
790  << gSystem->BaseName(fAnalClassImp) << " in " << fAnalClassDir << endl;
791  }
792  }
793  dir = fi.fIniDir;
794 }
795 
796 
797 
799 
801 {
803 }
804 
805 
806 
808 
809 void KVSimDirGUI::SelectDataSet(const char* name)
810 {
811  KVDataSet* ds = gDataSetManager->GetDataSet(name);
812  if (ds) {
813  fDataset = name;
814  fSystem = "";
815  fRun = "";
816  ds->cd();
817  // use ROOT geometry if available
818  if (ds->GetDataSetEnv("KVMultiDetArray.ROOTGeometry", kTRUE)) {
819  GeoType(kGTROOT);
820  }
821  else {
823  }
824  KVSeqCollection* systems = 0;
825  if (gExpDB) systems = gExpDB->GetSystems();
826  fCBsystem->RemoveAll();
827  fCBsystem->AddEntry("Choose system...", 0);
828  if (systems) {
829  TIter next(systems);
830  KVDBSystem* sys;
831  int i = 1;
832  while ((sys = (KVDBSystem*)next())) {
833  fCBsystem->AddEntry(sys->GetName(), i++);
834  }
835  }
836  fCBsystem->Layout();
837  fCBsystem->Select(0, kFALSE);
838  fCBrun->RemoveAll();
839  fCBrun->AddEntry("Choose run...", 0);
840  fCBrun->Layout();
841  fCBrun->Select(0, kFALSE);
842  }
843 }
844 
845 
846 
848 
849 void KVSimDirGUI::SelectSystem(const char* sysname)
850 {
851  KVDBSystem* sys = gExpDB->GetSystem(sysname);
852  if (sys) {
853  fSystem = sysname;
854  fRun = "";
855  auto runs = sys->GetRuns();
856  KVDBRun* dbr;
857  TIter next(runs);
858  int i = 1;
859  fCBrun->RemoveAll();
860  fCBrun->AddEntry("Choose run...", 0);
861  while ((dbr = (KVDBRun*)next())) {
862  fCBrun->AddEntry(Form("%4d", dbr->GetNumber()), i++);
863  }
864  fCBrun->Layout();
865  fCBrun->Select(0, kFALSE);
866  //fTESystem->SetText(sysname);
867  }
868 }
869 
870 
871 
874 
875 void KVSimDirGUI::UpdateSystemText(const char* s)
876 {
877  // called every time the text changes
879 }
880 
881 
882 
884 
885 void KVSimDirGUI::SelectRun(const char* run)
886 {
887  fRun = run;
888  fRun.Remove(TString::kBoth, ' ');
889  if (!fRun.IsDigit()) fRun = "";
890 }
891 
892 
893 
896 
898 {
899  // Called when "Process" button is pressed to launch the analysis
900 
901  if (fAnalysisTabs->GetCurrent() == 0) RunAnalysis("tree");
902  else if (fAnalysisTabs->GetCurrent() == 1) {
903  if (fDataset == "") { // Make sure a dataset has been chosen
904  new TGMsgBox(gClient->GetRoot(), MainFrame, "KVSimDirGUI::Run", "First choose the dataset which describes the geometry!", kMBIconExclamation);
905  return;
906  }
907  RunAnalysis("filter");
908  }
909 }
910 
911 
912 // void KVSimDirGUI::ChangeOutputDirectory()
913 // {
914 // static TString dir(".");
915 // TGFileInfo fi;
916 // fi.fIniDir = StrDup(dir);
917 // new KVFileDialog(gClient->GetDefaultRoot(), MainFrame, kKVFDDirectory, &fi);
918 // if (fi.fFilename) {
919 // fTEOutputDir->SetText(fi.fIniDir);
920 // }
921 // dir = fi.fIniDir;
922 // }
923 
924 
926 
928 {
929  unique_ptr<TList> selected_sim_runs(fLVsimData->GetSelectedObjects());
930  unique_ptr<TList> selected_filt_runs(fLVfiltData->GetSelectedObjects());
931  TList* runs_to_analyse(nullptr);
932  TList* aux_runs_to_analyse(nullptr);
933  TString analysis_task;
934  if (type == "tree") { // analysis of simulated or filtered events
935  if (!selected_sim_runs->GetEntries() && !selected_filt_runs->GetEntries()) {
936  new TGMsgBox(gClient->GetRoot(), MainFrame, "KVSimDirGUI::RunAnalysis", "Choose one or more simulated or filtered data files!", kMBIconExclamation);
937  return;
938  }
939  // if (selected_sim_runs->GetEntries() && selected_filt_runs->GetEntries()) {
940  // new TGMsgBox(gClient->GetRoot(), MainFrame, "KVSimDirGUI::RunAnalysis", "Choose EITHER simulated or filtered data files!", kMBIconExclamation);
941  // return;
942  // }
943  if (fAnalClassHeader == "" || fAnalClassImp == "") {
944  new TGMsgBox(gClient->GetRoot(), MainFrame, "KVSimDirGUI::RunAnalysis", "Choose a valid analysis class!", kMBIconExclamation);
945  return;
946  }
947  if (selected_sim_runs->GetEntries()) {
948  if (selected_filt_runs->GetEntries()) {
949  // if both simulated & filtered events are selected, we assume the user wants to analyse filtered
950  // data while having access to the original non-filtered data as an auxiliary/"friend" tree
951  runs_to_analyse = selected_filt_runs.get();
952  analysis_task = "analysis filtered";
953  aux_runs_to_analyse = selected_sim_runs.get();
954  }
955  else {
956  runs_to_analyse = selected_sim_runs.get();
957  analysis_task = "analysis simulated";
958  }
959  }
960  else {
961  runs_to_analyse = selected_filt_runs.get();
962  analysis_task = "analysis filtered";
963  }
964  }
965  else {
966  // filtering
967  if (selected_filt_runs->GetEntries()) {
968  new TGMsgBox(gClient->GetRoot(), MainFrame, "KVSimDirGUI::RunFilter", "Only simulated events can be filtered!", kMBIconExclamation);
969  return;
970  }
971  if (!selected_sim_runs->GetEntries()) {
972  new TGMsgBox(gClient->GetRoot(), MainFrame, "KVSimDirGUI::RunFilter", "Choose a simulated data file to filter!", kMBIconExclamation);
973  return;
974  }
975  runs_to_analyse = selected_sim_runs.get();
976  analysis_task = "filter simulated";
977  }
978  KVDataAnalysisTask* anTask = gDataSetManager->GetAnalysisTaskAny(analysis_task);
979  gDataAnalyser = KVDataAnalyser::GetAnalyser(anTask->GetDataAnalyser());
980  gDataAnalyser->SetAnalysisTask(anTask);
981  gDataAnalyser->SetFileList(runs_to_analyse);
982  if (aux_runs_to_analyse) gDataAnalyser->SetAuxFileList(aux_runs_to_analyse);
983  if (anTask->WithUserClass()) {
984  gDataAnalyser->SetUserClass(fAnalClassName);
985  if (!gDataAnalyser->IsUserClassValid()) {
986  new TGMsgBox(gClient->GetRoot(), MainFrame, "KVSimDirGUI::RunAnalysis", "Compilation failed. Correct mistakes and try again!", kMBIconExclamation);
987  }
988  }
989  else if (strcmp(anTask->GetUserBaseClass(), ""))
990  gDataAnalyser->SetUserClass(anTask->GetUserBaseClass(), kFALSE);//task with default "user" class
991  Bool_t all_events = fCBAllEvents->IsDown();
992  if (!all_events)
994  else
995  gDataAnalyser->SetNbEventToRead(0);
996  fCancelJob = kFALSE;
997  if (type == "filter") {
998  // set extra infos in kvsimdiranalyser for auto jobname
999  if (fCustomKinematics) {
1000  // if an ad hoc system is used for the kinematics, we have to use it instead of fSystem,
1001  // but only after first checking if it is legit
1003  // check valid ad hoc system given by user
1004  if (cd.IsZombie()) {
1005  Error("SetFilterOptions", "Please check the format of the ad hoc system name you gave");
1006  WarningBox("Bad System", "Please check the format of the ad hoc system name you gave", kFALSE);
1007  fCancelJob = kTRUE;
1008  }
1009  else {
1010  cd.CalculateKinematics();
1011  cd.Print();
1013  }
1014  }
1015 
1016  KVSimDirAnalyser* simda = dynamic_cast<KVSimDirAnalyser*>(gDataAnalyser);
1017  simda->SetDataSetForFilter(fDataset);
1018  simda->SetSystemForFilter(fSystem);
1019  }
1020  Bool_t cancel_batch_job = kFALSE;
1021  if (fWithPROOF) {
1022  gBatchSystem->Clear();
1023  KVNameValueList batchParams;
1024  gBatchSystem->GetBatchSystemParameterList(batchParams);
1025  new KVBatchSystemParametersGUI(MainFrame, &batchParams, gDataAnalyser, &cancel_batch_job);
1026  if (!cancel_batch_job) {
1027  gBatchSystem->SetBatchSystemParameters(batchParams);
1028  gDataAnalyser->SetBatchSystem(gBatchSystem);
1029  }
1030  }
1031  if (!cancel_batch_job && !fCancelJob) {
1032  if (type == "filter") SetFilterOptions(); // this may yet set fCancelJob=true...
1033  if (!fCancelJob) gDataAnalyser->Run();
1034  }
1035  selected_filt_runs.reset(nullptr);
1036  selected_sim_runs.reset(nullptr);
1037  RefreshSimDir();
1038 }
1039 
1040 
1041 
1043 
1045 {
1046  TString geometry;
1047  if (fGeoType == kGTROOT) geometry = "ROOT";
1048  else geometry = "KV";
1049  TString kinema;
1050  if (fKine == kKCM) kinema = "cm";
1051  else if (fKine == kKProj) kinema = "proj";
1052  else kinema = "lab";
1053  TString filter;
1054  switch (fFilterType) {
1055  case kFTGeo:
1056  filter = "Geo";
1057  break;
1058  case kFTSeuils:
1059  filter = "GeoThresh";
1060  break;
1061  case kFTFull:
1062  filter = "Full";
1063  }
1064 
1065  TString options;
1066  options = Form("Dataset=%s,", fDataset.Data());
1067  if (fSystem != "") options += Form("System=%s,", fSystem.Data());
1068  else if (kinema != "lab") {
1069  // a kinematical frame transform is required, but no system is given!
1070  new TGMsgBox(gClient->GetRoot(), MainFrame,
1071  "KVSimDirGUI::SetFilterOptions",
1072  Form("Cannot transform kinematics from %s to lab without a defined reaction (system)!", kinema.Data()),
1074  fCancelJob = true;
1075  return;
1076  }
1077  options += Form("Geometry=%s,", geometry.Data());
1078  options += Form("Filter=%s,", filter.Data());
1079  options += Form("Kinematics=%s", kinema.Data());
1080  if (fRun != "") {
1081  TString r;
1082  r.Form(",Run=%s", fRun.Data());
1083  options += r;
1084  }
1085  else if (filter == "Full" && (fCustomKinematics || fSystem == "")) {
1086  // "Full" filter requires run number to work: either given explicitly or taken from first run of database system (not ad hoc)
1087  new TGMsgBox(gClient->GetRoot(), MainFrame,
1088  "KVSimDirGUI::SetFilterOptions",
1089  Form("To use 'FULL' (run-dependent) filter requires either a run number or a system from the dataset!"),
1091  fCancelJob = true;
1092  return;
1093  }
1094  if (!fRandomPhi) options += ",PhiRot=no";
1095  if (fGemDecay) {
1096  options += ",Gemini=yes";
1097  options += Form(",GemDecayPerEvent=%d", (Int_t)gemini_decays->GetNumber());
1098 
1099  if (fGemAddRotEner) options += Form(",GemAddRotEner=yes");
1100  }
1101 
1102  gDataAnalyser->SetUserClassOptions(options);
1103 
1104  std::cout << options << std::endl;
1105 }
1106 
1107 
1108 
1111 
1113 {
1114  // Import simulation data from currently selected directory
1115 
1116  const char* filetypes[] = {
1117  "All files", "*.*",
1118  0, 0
1119  };
1120  TGFileInfo fi;
1122  fi.fFileTypes = filetypes;
1123  fi.SetMultipleSelection(true);
1124 
1125  new KVFileDialog(gClient->GetDefaultRoot(), MainFrame, kKVFDOpen, &fi);
1126 
1127  bool one_file = (!fi.fMultipleSelection && fi.fFilename);
1128  bool many_files = (fi.fMultipleSelection && fi.fFileNamesList);//may only be one
1129  if (one_file || many_files) {
1130  // set up list of KVSimReader plugins
1131  KVString plugins = KVBase::GetListOfPlugins("KVSimReader");
1132  KVString choices;
1133  plugins.Begin(" ");
1134  while (!plugins.End()) {
1135  // get URI corresponding to plugin
1136  KVString uri = KVBase::GetPluginURI("KVSimReader", plugins.Next());
1137  if (choices.Length()) choices += " ";
1138  choices += uri;
1139  }
1140  // get model from user
1141  TString model;
1142  Bool_t ok;
1143  new KVDropDownDialog(MainFrame, "Choose the simulation model and type of events", choices, 0, &model, &ok);
1144  if (ok) {
1145 
1146  if (one_file) {
1147  unique_ptr<KVSimReader> SR(KVSimReader::MakeSimReader(model));
1148  SR->SetOutputDirectory(fSelectedSimDir->GetDirectory());
1149  SR->ConvertAndSaveEventsInFile(fi.fFilename);
1150  }
1151  else {
1152  if (fi.fFileNamesList->GetEntries() == 1) {
1153  unique_ptr<KVSimReader> SR(KVSimReader::MakeSimReader(model));
1154  SR->SetOutputDirectory(fSelectedSimDir->GetDirectory());
1155  SR->ConvertAndSaveEventsInFile(fi.fFileNamesList->First()->GetName());
1156  }
1157  else {
1158  TIter it(fi.fFileNamesList);
1159  TObject* o;
1160  int i = 1;
1161  while ((o = it())) {
1162  unique_ptr<KVSimReader> SR(KVSimReader::MakeSimReader(model));
1163  SR->SetMultiFiles();
1164  SR->SetFileIndex(i++);
1165  SR->SetOutputDirectory(fSelectedSimDir->GetDirectory());
1166  SR->ConvertAndSaveEventsInFile(o->GetName());
1167  }
1168  }
1169  }
1170 
1171  RefreshSimDir();
1172  }
1173  }
1174  else if (fi.fMultipleSelection && fi.fFileNamesList) {
1175  fi.fFileNamesList->ls();
1176  }
1177 }
1178 
1179 
1180 
1183 
1185 {
1186  // Get name of new class
1187  TString classname;
1188  Bool_t ok;
1189  new KVInputDialog(MainFrame, "Enter name of new analysis class", &classname, &ok, "Enter name of new analysis class");
1190  // check new classname is not name of existing class
1191  KVString impfile, decfile;
1192  if (KVBase::FindClassSourceFiles(classname, impfile, decfile)) {
1193  ok = ok && WarningBox("Replacing existing class",
1194  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)",
1195  classname.Data(), decfile.Data(), impfile.Data()),
1196  kTRUE);
1197  }
1198  if (ok) {
1199  KVSimDirFilterAnalyser::Make(classname);
1200  }
1201 }
1202 
1203 
1204 
1207 
1209 {
1210  // Get name of new class
1211  TString classname;
1212  Bool_t ok;
1213  new KVInputDialog(MainFrame, "Enter name of new analysis class", &classname, &ok, "Enter name of new analysis class");
1214  // check new classname is not name of existing class
1215  KVString impfile, decfile;
1216  if (KVBase::FindClassSourceFiles(classname, impfile, decfile)) {
1217  ok = ok && WarningBox("Replacing existing class",
1218  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)",
1219  classname.Data(), decfile.Data(), impfile.Data()),
1220  kTRUE);
1221  }
1222  if (ok) {
1223  KVSimDirAnalyser::Make(classname);
1224  }
1225 }
1226 
1227 
1228 
1234 
1235 Bool_t KVSimDirGUI::WarningBox(const char* title, const char* msg, Bool_t confirm)
1236 {
1237  // Warning box in case of problems
1238  // if confirm=kTRUE we ask for a yes/no answer from the user:
1239  // if 'yes' is pressed, we return kTRUE, if 'no', kFALSE.
1240  // by default, only a 'dismiss' button is shown, and this method always returns kTRUE.
1241 
1242  Bool_t reply = kTRUE;
1243  if (!confirm)
1244  new TGMsgBox(gClient->GetRoot(), MainFrame, title, msg, kMBIconExclamation);
1245  else {
1246  Int_t ret_code = 0;
1247  new TGMsgBox(gClient->GetRoot(), MainFrame, title, msg, kMBIconExclamation, kMBYes | kMBNo, &ret_code);
1248  reply = (ret_code & kMBYes);
1249  }
1250  return reply;
1251 }
1252 
1253 
1254 #ifdef WITH_RSQLITE
1255 
1258 
1260 {
1261  // Rebuild all KVSimDir/KVSimFile objects from information in sqlite DB
1262 
1263  fConfigDB.select_data("Datasets");
1264  KVNameValueList tables;
1265  while (fConfigDB.get_next_result()) {
1266  fListOfDirs.Add(new KVSimDir(fConfigDB["Datasets"]["Name"].get_data<TString>(),
1267  fConfigDB["Datasets"]["Directory"].get_data<TString>()));
1268  tables.SetValue(fConfigDB["Datasets"]["Name"].get_data<TString>(),
1269  fConfigDB["Datasets"]["Table"].get_data<TString>());
1270  }
1271  for (int i = 0; i < tables.GetNpar(); ++i) {
1273  fConfigDB.select_data(tables.GetValue<TString>(i));
1274  KVSQLite::table& dstable = fConfigDB[tables.GetValue<TString>(i)];
1275  while (fConfigDB.get_next_result()) {
1276  if (dstable["Filtered"].get_data<int>()) {
1277  // filtered/reconstructed data
1278  KVSimFile* f = new KVSimFile(
1279  sd,
1280  dstable["FileName"].get_data<TString>(), dstable["TreeInfo"].get_data<TString>(),
1281  dstable["Events"].get_data<int>(), dstable["TreeName"].get_data<TString>(),
1282  dstable["BranchName"].get_data<TString>(), dstable["DataSet"].get_data<TString>(),
1283  dstable["System"].get_data<TString>(), dstable["Run"].get_data<int>(),
1284  dstable["GeoType"].get_data<TString>(), dstable["OrigFile"].get_data<TString>(),
1285  dstable["FiltType"].get_data<TString>()
1286  );
1287  f->SetGemini(dstable["Gemini"].get_data<bool>());
1288  if (f->IsGemini()) f->SetGemDecayPerEvent(dstable["GemDecayPerEvent"].get_data<int>());
1289  sd->AddFiltData(f);
1290  }
1291  else {
1292  // simulation data
1293  KVSimFile* f = new KVSimFile(
1294  sd,
1295  dstable["FileName"].get_data<TString>(), dstable["TreeInfo"].get_data<TString>(),
1296  dstable["Events"].get_data<int>(), dstable["TreeName"].get_data<TString>(),
1297  dstable["BranchName"].get_data<TString>());
1298  sd->AddSimData(f);
1299  }
1300  }
1301  }
1302 }
1303 
1304 #endif
1305 
int Int_t
kVerticalFrame
kHorizontalFrame
kMainFrame
ROOT::R::TRInterface & r
#define f(i)
bool Bool_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
kEnvUser
kButtonDown
kButtonUp
#define gClient
kMWMFuncAll
kMWMDecorAll
kMWMInputModeless
kLHintsRight
kLHintsExpandY
kLHintsLeft
kLHintsCenterY
kLHintsBottom
kLHintsTop
kLHintsExpandX
kMBNo
kMBYes
kMBIconExclamation
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
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 Atom_t Atom_t Time_t type
char name[80]
#define quest
char * Form(const char *fmt,...)
char * StrDup(const char *str)
R__EXTERN TSystem * gSystem
Relativistic binary kinematics calculator.
Definition: KV2Body.h:166
void Print(Option_t *opt="") const
Definition: KV2Body.cpp:813
void CalculateKinematics()
Definition: KV2Body.cpp:677
Base class for KaliVeda framework.
Definition: KVBase.h:142
static Bool_t FindClassSourceFiles(const Char_t *class_name, KVString &imp_file, KVString &dec_file, const Char_t *dir_name=".")
Definition: KVBase.cpp:1102
static const Char_t * GetListOfPlugins(const Char_t *base)
Definition: KVBase.cpp:1260
static const Char_t * GetPluginURI(const Char_t *base, const Char_t *plugin)
Definition: KVBase.cpp:1177
virtual void Copy(TObject &) const
Make a copy of this object.
Definition: KVBase.cpp:394
Handles list of all available batch systems for processing non-interactive data analysis tasks.
KVBatchSystem * GetDefaultBatchSystem() const
Utility GUI used for setting batch system parameters.
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 &)
virtual void Clear(Option_t *opt="")
virtual Int_t GetNumber() const
Definition: KVDBRecord.h:73
Description of an experimental run in database ,,.
Definition: KVDBRun.h:36
Database class used to store information on different colliding systems studied during an experiment....
Definition: KVDBSystem.h:52
KVUnownedList * GetRuns() const
Returns a sorted list of all the runs associated with this system.
Definition: KVDBSystem.h:117
virtual void Run()
Check all task variables, then run analyser.
virtual void SetAuxFileList(TList *)
void SetBatchSystem(KVBatchSystem *bs)
void SetUserClassOptions(const Char_t *o="")
void SetUserClass(const Char_t *kvs, Bool_t check=kTRUE)
void SetAnalysisTask(KVDataAnalysisTask *at)
virtual void SetFileList(TList *)
static KVDataAnalyser * GetAnalyser(const Char_t *plugin)
Bool_t IsUserClassValid() const
void SetNbEventToRead(Long64_t nb=0)
Define and manage data analysis tasks.
virtual Bool_t WithUserClass() const
virtual const Char_t * GetDataAnalyser() const
virtual const Char_t * GetUserBaseClass() const
Manage all datasets contained in a given data repository.
virtual Bool_t Init(KVDataRepository *=0)
virtual Int_t GetNtotal() const
KVDataAnalysisTask * GetAnalysisTaskAny(const Char_t *keywords) 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:35
const Char_t * GetDataSetEnv(const Char_t *type, const Char_t *defval="") const
Definition: KVDataSet.cpp:767
void cd() const
Definition: KVDataSet.cpp:745
Ask user to choose between several options in a drop-down list.
virtual KVDBSystem * GetSystem(const Char_t *system) const
Definition: KVExpDB.h:85
virtual KVSeqCollection * GetSystems() const
Definition: KVExpDB.h:89
Modified version of TGFileDialog file selection dialog.
Definition: KVFileDialog.h:49
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:146
virtual void ActivateSortButtons()
Definition: KVListView.cpp:72
virtual void SetDataColumns(Int_t ncolumns)
Definition: KVListView.cpp:91
virtual void Display(const TCollection *l)
Definition: KVListView.h:173
TList * GetSelectedObjects() const
Definition: KVListView.h:245
virtual void RemoveAll()
Definition: KVListView.h:190
void AllowContextMenu(Bool_t on=kTRUE)
Definition: KVListView.h:283
virtual void SetDataColumn(Int_t index, const Char_t *name, const Char_t *method="", Int_t mode=kTextCenterX)
Definition: KVListView.cpp:106
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
KVNamedParameter * GetParameter(Int_t idx) const
return the parameter object with index idx
void SetValue(const Char_t *name, value_type value)
Int_t GetNpar() const
return the number of stored parameters
value_type GetValue(const Char_t *name) const
const Char_t * GetString() const
int get_number_of_tables() const
Definition: SQLiteDB.h:442
int count(const TString &table, const TString &column="*", const TString &selection="", bool distinct=false) const
Definition: SQLiteDB.cpp:739
void delete_data(const TString &table, const TString &selection="")
Definition: SQLiteDB.cpp:834
void insert_data_row()
Definition: SQLiteDB.cpp:393
void end_data_insertion()
Definition: SQLiteDB.cpp:433
bool select_data(const TString &tables, const TString &columns="*", const TString &selection="", bool distinct=false, const TString &anything_else="") const
Definition: SQLiteDB.cpp:493
KVNameValueList get_name_value_list(const TString &table, const TString &name_column, const TString &value_column, const TString &selection="", const TString &anything_else="")
Definition: SQLiteDB.cpp:675
bool get_next_result() const
Definition: SQLiteDB.cpp:595
void add_table(const table &)
Definition: SQLiteDB.cpp:219
bool prepare_data_insertion(const TString &)
Definition: SQLiteDB.cpp:269
void clear_table(const TString &name)
Delete all data from table.
Definition: SQLiteDB.cpp:723
const column & add_primary_key(const TString &name)
Definition: SQLiteDB.cpp:1152
column & add_column(const KVSQLite::column &c)
Definition: SQLiteDB.cpp:1115
KaliVeda extensions to ROOT collection classes.
virtual void Add(TObject *obj)
virtual TObject * Remove(TObject *obj)
Remove object from list.
virtual TObject * FindObject(const char *name) const
Class piloting analyses of simulated data.
void SetDataSetForFilter(const TString &f)
void SetSystemForFilter(const TString &f)
static void Make(const Char_t *kvsname="MySimulatedAnalysis")
Generate a new simulated analysis selector class.
static void Make(const Char_t *kvsname="MyFilteredAnalysis")
Generate a new filtered analysis selector class.
GUI for analysing and filtering simulated data.
Definition: KVSimDirGUI.h:152
TGPictureButton * BremDir
Definition: KVSimDirGUI.h:162
void SelectDataSet(const char *)
void ReconstructSimDirsFromDB()
Rebuild all KVSimDir/KVSimFile objects from information in sqlite DB.
void NewFilteredAnalysisClass()
Get name of new class.
TGCheckButton * gemini_add_rot_energy
Definition: KVSimDirGUI.h:199
Bool_t fGemAddRotEner
Definition: KVSimDirGUI.h:200
TGCompositeFrame * fAnalTab
analysis tab
Definition: KVSimDirGUI.h:175
KVSQLite::database fConfigDB
Definition: KVSimDirGUI.h:223
void RemSimDir()
TGComboBox * fCBrun
Definition: KVSimDirGUI.h:188
TGComboBox * fCBdataset
Definition: KVSimDirGUI.h:186
TGTextEntry * fTESystem
Definition: KVSimDirGUI.h:178
void EmptyTreeList()
void RefreshSimDir()
void SelectAnalysisClass()
KVString fRun
Definition: KVSimDirGUI.h:191
TGCompositeFrame * fFiltTab
filter tab
Definition: KVSimDirGUI.h:176
Bool_t fGemDecay
Definition: KVSimDirGUI.h:197
void UpdateSystemText(const char *)
called every time the text changes
void SetFilterOptions()
void AddSimDir()
TGCheckButton * fCBAllEvents
Definition: KVSimDirGUI.h:183
virtual ~KVSimDirGUI()
Destructor.
TGCheckButton * custom_kinematics_check
Definition: KVSimDirGUI.h:192
void NewSimulatedAnalysisClass()
Get name of new class.
KVList fListOfDirs
Definition: KVSimDirGUI.h:155
TGMainFrame * MainFrame
Definition: KVSimDirGUI.h:158
TGCheckButton * gemini_decay
Definition: KVSimDirGUI.h:196
TGViewPort * fDirListViewPort
Definition: KVSimDirGUI.h:166
TGNumberEntry * fNENumberEvents
Definition: KVSimDirGUI.h:184
KVString fAnalClassName
Definition: KVSimDirGUI.h:179
void SelectSystem(const char *)
void FillTreeList()
Int_t fFilterType
Definition: KVSimDirGUI.h:215
TGComboBox * fCBsystem
Definition: KVSimDirGUI.h:187
KVSimDir * fSelectedSimDir
Definition: KVSimDirGUI.h:156
void Copy(TObject &) const
TGTab * fAnalysisTabs
Definition: KVSimDirGUI.h:174
KVString fReactionKinematics
Definition: KVSimDirGUI.h:190
KVString fSystem
Definition: KVSimDirGUI.h:190
TGListTree * fDirListTree
Definition: KVSimDirGUI.h:167
TGCanvas * fDirListCanvas
Definition: KVSimDirGUI.h:165
const TGPicture * pclose
used for list tree items
Definition: KVSimDirGUI.h:169
const TGPicture * popen
used for list tree items
Definition: KVSimDirGUI.h:168
KVString fAnalClassHeader
Definition: KVSimDirGUI.h:180
Bool_t fCustomKinematics
Definition: KVSimDirGUI.h:193
KVListView * fLVfiltData
Definition: KVSimDirGUI.h:172
void Run()
void ChangeOutputDirectory();
void FillDataSetTableWithInfos(TString ds_table_name, KVSimDir *sd)
Definition: KVSimDirGUI.cpp:67
TGPictureButton * proof_analysis
TGTextEntry* fTEOutputDir;.
Definition: KVSimDirGUI.h:219
KVString fAnalClassImp
Definition: KVSimDirGUI.h:181
TGNumberEntry * gemini_decays
Definition: KVSimDirGUI.h:198
TGCheckButton * phi_rotation_check
Definition: KVSimDirGUI.h:194
KVString fAnalClassDir
Definition: KVSimDirGUI.h:182
void EnableEventNumberEntry(Bool_t)
Int_t fGeoType
Definition: KVSimDirGUI.h:216
void RunAnalysis(const TString &type)
Bool_t WarningBox(const char *title, const char *msg, Bool_t confirm)
TGPictureButton * BaddDir
Definition: KVSimDirGUI.h:160
Bool_t fWithPROOF
=kTRUE when running with PROOF-lite
Definition: KVSimDirGUI.h:225
void GeoType(Int_t i)
Definition: KVSimDirGUI.h:264
Bool_t fCancelJob
if job parameters are not valid
Definition: KVSimDirGUI.h:226
Bool_t fRandomPhi
Definition: KVSimDirGUI.h:195
KVListView * fLVsimData
Definition: KVSimDirGUI.h:171
TGPictureButton * BimpSim
Definition: KVSimDirGUI.h:161
TGPictureButton * BrefreshDir
Definition: KVSimDirGUI.h:163
TGTextEntry * fTEAnalysisClassFileName
Definition: KVSimDirGUI.h:177
void SelectSimDir(TGListTreeItem *, Int_t)
TString AddTableForDataSet(KVSimDir *sd, int ds_table_number)
Add a new dataset table for the given KVSimDir object.
Definition: KVSimDirGUI.cpp:35
void ImportSimulation()
Import simulation data from currently selected directory.
KVString fDataset
Definition: KVSimDirGUI.h:189
void SelectRun(const char *)
Handle directory containing simulated and/or filtered simulated data ,.
Definition: KVSimDir.h:44
virtual const KVList * GetFiltDataList() const
Definition: KVSimDir.h:73
void AddSimData(KVSimFile *)
Definition: KVSimDir.cpp:264
virtual void AnalyseDirectory()
Definition: KVSimDir.cpp:126
virtual const KVList * GetSimDataList() const
Definition: KVSimDir.h:69
void AddFiltData(KVSimFile *)
Definition: KVSimDir.cpp:273
virtual const Char_t * GetDirectory() const
Definition: KVSimDir.h:61
Handle file containing simulated and/or filtered simulated data ,.
Definition: KVSimFile.h:19
const Char_t * GetSystem() const
Definition: KVSimFile.h:81
const Char_t * GetBranchName() const
Definition: KVSimFile.h:118
const Char_t * GetOriginalFile() const
Definition: KVSimFile.h:123
Int_t GetRun() const
Definition: KVSimFile.h:96
const Char_t * GetFilterType() const
Definition: KVSimFile.h:91
Bool_t IsGemini() const
Definition: KVSimFile.h:49
const Char_t * GetGeometry() const
Definition: KVSimFile.h:106
const Char_t * GetDataSet() const
Definition: KVSimFile.h:76
Long64_t GetEvents() const
Definition: KVSimFile.h:71
const Char_t * GetTreeName() const
Definition: KVSimFile.h:113
Int_t GetGemDecayPerEvent() const
Definition: KVSimFile.h:61
static KVSimReader * MakeSimReader(const char *model_uri)
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
void ls(Option_t *option="") const override
virtual Int_t GetEntries() 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)
virtual void SetToolTipText(const char *text, Long_t delayms=400)
virtual void AllowStayDown(Bool_t a)
virtual void SetEnabled(Bool_t e=kTRUE)
virtual void SetContainer(TGFrame *f)
TGViewPort * GetViewPort() const
void MapSubwindows() override
virtual void SetDisabledAndSelected(Bool_t)
Bool_t IsDown() const override
void SetState(EButtonState state, Bool_t emit=kFALSE) override
void Layout() override
void RemoveAll() override
virtual void Select(Int_t id, Bool_t emit=kTRUE)
virtual void AddEntry(const char *s, Int_t id)
TGDimension GetDefaultSize() const override
virtual void SetLayoutManager(TGLayoutManager *l)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
UInt_t GetDefaultWidth() const override
void MapSubwindows() override
void ChangeOptions(UInt_t options) override
TList * fFileNamesList
char * fFilename
void SetMultipleSelection(Bool_t option)
const char ** fFileTypes
char * fIniDir
Bool_t fMultipleSelection
virtual UInt_t GetDefaultHeight() const
virtual void Resize(TGDimension size)
void MapWindow() override
virtual void Layout()=0
virtual const char * GetText() const=0
virtual void SetPictures(const TGPicture *, const TGPicture *)
Int_t DeleteItem(TGListTreeItem *item)
TGListTreeItem * GetFirstItem() const
void AddItem(const char *string)
void CloseItem(TGListTreeItem *item)
void SetWindowName(const char *name=nullptr) override
void SetMWMHints(UInt_t value, UInt_t funcs, UInt_t input)
TGNumberEntryField * GetNumberEntry() const
virtual void SetState(Bool_t enable=kTRUE)
virtual Double_t GetNumber() const
void SetState(EButtonState state, Bool_t emit=kFALSE) override
virtual TGCompositeFrame * AddTab(const char *text)
Int_t GetCurrent() const
TGLayoutManager * GetLayoutManager() const override
void SetEnabled(Bool_t flag=kTRUE)
virtual void SetToolTipText(const char *text, Long_t delayms=500)
virtual void SetText(const char *text, Bool_t emit=kTRUE)
virtual void SetName(const char *name)
TObject * First() const override
const char * GetName() const override
const char * GetTitle() const override
static TClass * Class()
virtual const char * GetName() const
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual void Error(const char *method, const char *msgfmt,...) const
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Ssiz_t Length() const
const char * Data() const
Bool_t IsDigit() const
TString & Remove(EStripType s, char c)
TString & ReplaceAll(const char *s1, const char *s2)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual const char * BaseName(const char *pathname)
virtual void SetBuildDir(const char *build_dir, Bool_t isflat=kFALSE)
virtual const char * TempDirectory() const
long long Long64_t
ClassImp(TPyArg)