KaliVeda
Toolkit for HIC analysis
KVSimDataManager.cpp
1 #include "KVSimDataManager.h"
2 #include "TSystem.h"
3 #include "KVSimDir.h"
4 #include "KVSimFile.h"
5 #include "KVDataSetManager.h"
6 
8 
9 
10 
15 void KVSimDataManager::OpenDataBase(const TString& filepath)
16 {
17  // Open/create the SQLite database file with given path
18  //
19  // Creates default table(s) if not already done
20 
21  fDB.open(filepath);
22 
23  if (!fDB.has_table("datasets")) {
24  {
25  KVSQLite::table T("models");
26  T.add_column("id", "INTEGER");
27  T.add_column("name", "TEXT").NOT_NULL();
28  T.primary_key("id");
29  fDB.add_table(T);
30  }
31  {
32  KVSQLite::table T("datasets");
33  T.add_column("id", "INTEGER");
34  T.add_column("user", "TEXT").NOT_NULL();
35  T.add_column("description", "TEXT").NOT_NULL();
36  T.add_column("model_id", "INTEGER");
37  T.primary_key("id");
38  T.foreign_key("model_id", "models", "id");
39  fDB.add_table(T);
40  }
41  {
42  KVSQLite::table T("reactions");
43  T.add_column("id", "INTEGER");
44  T.add_column("nuc1", "TEXT").NOT_NULL(); // projectile if nuc1 & nuc2 defined, else compound nucleus
45  T.add_column("nuc2", "TEXT");
46  T.add_column("energy", "REAL"); // either beam energy in MeV for reactions, or excitation energy of CN in MeV
47  T.add_column("spin_hbar", "INTEGER"); // spin of CN, if fixed value used
48  T.add_column("impact_parameter", "REAL"); // fixed value of impact parameter, if used
49  T.add_column("ip_units", "TEXT"); // impact parameter units, if used: "fm" or "rel" (=> b/bmax)
50  T.primary_key("id");
51  fDB.add_table(T);
52  }
53  {
54  KVSQLite::table T("repositories");
55  T.add_column("id", "INTEGER");
56  T.primary_key("id");
57  T.add_column("root_dir", "TEXT").NOT_NULL();
58  T.add_column("type", "TEXT").NOT_NULL().DEFAULT("local");
59  T.add_column("Xrdsrv", "TEXT");
60  T.add_column("Xrdroot", "TEXT");
61  fDB.add_table(T);
62  }
63  {
64  KVSQLite::table T("unfiltered_files");
65  T.add_column("id", "INTEGER");
66  T.add_column("name", "TEXT").NOT_NULL();
67  T.add_column("path", "TEXT").NOT_NULL();
68  T.add_column("repository_id", "INTEGER"); // may contain id of a repository in table, or NULL
69  T.add_column("original_name", "TEXT"); // original name of file if it has been imported to the repository, or NULL
70  T.add_column("original_path", "TEXT"); // original full path to file if it has been imported to the repository, or NULL
71  T.add_column("events", "INTEGER");
72  T.add_column("type", "TEXT").NOT_NULL(); // = "primary" or "secondary" i.e. before or after secondary decay
73  T.add_column("dataset_id", "INTEGER");
74  T.add_column("reaction_id", "INTEGER");
75  T.primary_key("id");
76  T.foreign_key("dataset_id", "datasets", "id"); // link to dataset
77  T.foreign_key("reaction_id", "reactions", "id"); // link to reaction
78  fDB.add_table(T);
79  }
80  {
81  KVSQLite::table T("filters"); // table with all filtering parameters
82  T.add_column("id", "INTEGER");
83  T.add_column("kinematics", "INTEGER");
84  T.foreign_key("kinematics", "reactions", "id"); // definition of kinematics used, e.g. lab->CM transformation
85  T.add_column("geometry", "TEXT").NOT_NULL(); // experimental dataset used to define geometry of multidetector
86  T.add_column("run_number", "INTEGER"); // specific run number used to define experimental conditions, if used
87  T.add_column("filter_type", "TEXT").NOT_NULL(); // type of filter = "Geo" or "GeoThresh"
88  T.add_column("data_quality_audit", "TEXT"); // name of data quality audit defining identification performances, if used
89  T.add_column("random_phi", "TEXT"); // ="yes" if phi randomized for each event, NULL otherwise
90  T.add_column("gemini", "INTEGER"); // if KaliVeda Gemini++ used to perform secondary decay just before filter, number of decays per primary event, or NULL
91  T.add_column("gem_add_erot", "TEXT"); // if KaliVeda Gemini++ used, "yes" if rotational (Yrast) energy added to E*, or NULL
92  T.primary_key("id");
93  fDB.add_table(T);
94  }
95  {
96  KVSQLite::table T("filtered_files"); // filtered files
97  T.add_column("id", "INTEGER");
98  T.add_column("name", "TEXT").NOT_NULL();
99  T.add_column("path", "TEXT").NOT_NULL();
100  T.add_column("repository_id", "INTEGER"); // may contain id of a repository in table, or NULL
101  T.add_column("original_name", "TEXT"); // original name of file if it has been imported to the repository, or NULL
102  T.add_column("original_path", "TEXT"); // original full path to file if it has been imported to the repository, or NULL
103  T.add_column("events", "INTEGER");
104  T.add_column("unfiltered_file_id", "INTEGER"); // link to simulated file processed to produce this one
105  T.add_column("dataset_id", "INTEGER");
106  T.add_column("reaction_id", "INTEGER");
107  T.add_column("filter_id", "INTEGER");
108  T.primary_key("id");
109  T.foreign_key("unfiltered_file_id", "unfiltered_files", "id");
110  T.foreign_key("dataset_id", "datasets", "id"); // link to dataset
111  T.foreign_key("reaction_id", "reactions", "id"); // link to reaction
112  T.foreign_key("filter_id", "filters", "id"); // link to filter parameters
113  fDB.add_table(T);
114  }
115  }
116 }
117 
118 
119 
131 
133  bool random_phi, std::optional<int> run_number, std::optional<TString> data_quality_audit, std::optional<int> gem_decay_per_event,
134  std::optional<bool> gem_add_rot_energy)
135 {
136  // Add a set of filtering conditions to the database and return the corresponding index
137  //
138  // \param[in] kinematics index of reaction used to define lab->CM transform
139  // \param[in] geometry name of experimental dataset used to define multidetector array geometry
140  // \param[in] filter_type can be "Geo" or "GeoThresh" (or "Full" for old filtered simulations before KaliVeda v1.15)
141  // \param[in] random_phi [default=true] whether each event underwent a random azimuthal rotation before filtering
142  // \param[in] run_number [optional] specific run number of dataset used to define experimental conditions
143  // \param[in] data_quality_audit [optional] name of audit used to define identification performances
144  // \param[in] gem_decay_per_event [optional] if Gemini++ used to perform secondary decay just before filtering, number of decays per primary event
145  // \param[in] gem_add_rot_energy [optional] if Gemini++ used, was rotational (Yrast) energy added to E* before decay?
146 
147  KVNameValueList params;
148  params.SetValue("kinematics", kinematics);
149  params.SetValue("geometry", geometry);
150  params.SetValue("filter_type", filter_type);
151  if (random_phi) params.SetValue("random_phi", "yes");
152  else params.SetValue("random_phi", "no");
153  if (run_number) params.SetValue("run_number", run_number.value());
154  if (data_quality_audit) params.SetValue("data_quality_audit", data_quality_audit.value());
155  if (gem_decay_per_event) {
156  params.SetValue("gemini", gem_decay_per_event.value());
157  params.SetValue("gem_add_erot", (gem_add_rot_energy ? (gem_add_rot_energy.value() ? "yes" : "no") : "no"));
158  }
159  // check not already in table
160  auto id = find_index_in_table("filters", params);
161  if (id)
162  return id.value();
163 
164  enter_data_row("filters", params);
165  return find_index_in_table("filters", params).value();
166 }
167 
168 
169 
172 
173 void KVSimDataManager::initialize_repository(repository_id id, const TString& root_dir, const TString& access, std::optional<TString> xrdsrv, std::optional<TString> xrdroot)
174 {
175  // Initialize a new data repository with the given informations
176  fRepos[id].reset(new KVDataRepository("", root_dir, access));
177  if (xrdsrv) {
178  fRepos[id]->ReadWithXrootd(xrdsrv.value(), xrdroot.value());
179  }
180 }
181 
182 
183 
197 
198 std::pair<TString, TString> KVSimDataManager::import_file_to_repository(const TString& filepath, repository_id repo, dataset_id dset, reaction_id reac, std::optional<filter_id> filt_id)
199 {
200  // Copy the file into the data repository and return a pair of TString {path,filename} with the path and filename in the repository.
201  //
202  // The path will be of the form
203  //~~~
204  // [model]/[reaction]/[filename]
205  //~~~
206  // or
207  //~~~
208  // [model]/[reaction]/[filter]/[filename]
209  //~~~
210  // for filtered files
211 
212  // get model id from dataset
213  auto res = get_data_for_unique_index("datasets", dset);
214  auto model_id = res.GetIntValue("model_id");
215 
216  TString filt;
217  if (filt_id)
218  filt.Form("filter_%d", filt_id.value());
220  return std::make_pair<TString, TString>(get_data_repository(repo).GetRepositoryPath(GetModelName(model_id), GetReactionName(reac), filt), gSystem->BaseName(filepath));
221 }
222 
223 
224 
231 
233  std::optional<TString> xrdsrv, std::optional<TString> xrdroot)
234 {
235  // Initialize a (possibly new) data repository and return its id
236  //
237  // If the same repository is not already in the database, it is added
238  //
239  // If the repository is not in the list of currently active repositories, it is initialized and added to the list
240 
241  KVNameValueList params;
242  params.SetValue("type", access);
243  TString _root_dir = root_dir;
244  if (access == "local") {
245  // make sure root directory is an absolute path
246  auto rv = AbsoluteUnixPath(root_dir);
247  if (!rv) {
248  Error("AddDataRepository", "invalid root directory for local data repository: %s", root_dir.Data());
249  return 0;
250  }
251  _root_dir = rv.value();
252  }
253  params.SetValue("root_dir", _root_dir);
254  if (xrdsrv) params.SetValue("Xrdsrv", xrdsrv.value());
255  if (xrdroot) params.SetValue("Xrdroot", xrdroot.value());
256 
257  // check repository not already in repository
258  auto id = find_index_in_table("repositories", params);
259 
260  if (!id) {
261  enter_data_row("repositories", params);
262  id = find_index_in_table("repositories", params);
263  }
264 
265  // has repository been initialised ?
266  if (!fRepos[id.value()]) {
267  initialize_repository(id.value(), root_dir, access, xrdsrv, xrdroot);
268  }
269 
270  return id.value();
271 }
272 
273 
274 
286 
288  dataset_id dataset, reaction_id reaction)
289 {
290  // Add a file containing data from an unfiltered simulation
291  //
292  // \param[in] filepath full path to file
293  // \param[in] events number of events in file
294  // \param[in] P whether events are primary or secondary (before or after secondary decay)
295  // \param[in] dataset index of dataset file is part of
296  // \param[in] reaction index of reaction file corresponds to
297  //
298  // if ImportFilesToRepository() has been called with a valid data repository id, the file will be copied
299  // to the repository, and any future access to the file will be via the data repository
300 
301  KVNameValueList params;
302  params.SetValue("events", events);
304  params.SetValue("type", "primary");
305  else
306  params.SetValue("type", "secondary");
307  params.SetValue("dataset_id", dataset);
308  params.SetValue("reaction_id", reaction);
309 
310  add_file_to_collection("AddUnfilteredSimulation", "unfiltered_files", params, filepath, dataset, reaction);
311 }
312 
313 
314 
316 
317 void KVSimDataManager::add_file_to_collection(const TString& method_name, const TString& table_name, KVNameValueList& params,
318  const TString& filepath, dataset_id dataset, reaction_id reaction, std::optional<filter_id> filt_id)
319 {
321  // check file not already in database first
322  params.SetValue("repository_id", import_repo);
323  params.SetValue("original_name", gSystem->BaseName(filepath));
324  params.SetValue("original_path", gSystem->DirName(filepath));
325  auto id = find_index_in_table(table_name, params);
326  if (id) {
327  Error(method_name, "The file %s has already been added", filepath.Data());
328  return;
329  }
330  auto repo_path = import_file_to_repository(filepath, import_repo, dataset, reaction, filt_id);
331  params.SetValue("name", repo_path.second);
332  params.SetValue("path", repo_path.first);
333  }
334  else {
335  params.SetValue("name", gSystem->BaseName(filepath));
336  params.SetValue("path", gSystem->DirName(filepath));
337  // check file is not already in database
338  auto id = find_index_in_table(table_name, params);
339  if (id) {
340  Error(method_name, "The file %s has already been added", filepath.Data());
341  return;
342  }
343  }
344 
345  enter_data_row(table_name, params);
346 }
347 
348 
354 
356 {
357  // Add a filtered simulation to the collection
358 
359  // get kinematics used for transform lab<->CM.
360  // if the system name contains '@' it is an ad hoc kinematics
361  // if not, we have to look for it in the experimental dataset database
362  TString sys = f.GetSystem();
363  reaction_id kinematics = 0;
364  if (sys.Contains("@")) {
365  KV2Body k2b(sys);
366  auto kk = GetReactionId(k2b);
367  if (!kk) {
368  kinematics = AddReaction(k2b);
369  }
370  else
371  kinematics = kk.value();
372  }
373  else {
374  if (!gDataSetManager) {
375  auto dsm = new KVDataSetManager;
376  dsm->Init();
377  }
378  auto _sys = gDataSetManager->GetDataSet(f.GetDataSet())->GetDataBase("minimal")->GetSystem(sys);
379  auto kk = GetReactionId(*_sys->GetKinematics());
380  if (!kk) {
381  kinematics = AddReaction(*_sys->GetKinematics());
382  }
383  else
384  kinematics = kk.value();
385  }
386  auto filt_id = AddFilter(kinematics, f.GetDataSet(), f.GetFilterType(), f.IsRandomPhi(),
387  f.HasRun() ? f.GetRun() : std::optional<int> {},
388  f.HasDataQualityAudit() ? f.GetDataQualityAudit() : std::optional<TString> {},
389  f.IsGemini() ? f.GetGemDecayPerEvent() : std::optional<int> {});
390 
391  KVNameValueList params;
392  params.SetValue("events", (int)f.GetEvents()); // warning: GetEvents() returns Long64_t!
393  params.SetValue("dataset_id", dataset);
394  params.SetValue("reaction_id", reaction);
395  params.SetValue("filter_id", filt_id);
396  // find simulation file which was filtered
397  auto file_v = find_index_in_table("unfiltered_files", {{"name", f.GetOriginalFile()}});
398  if (!file_v) // has file been moved to repository since filtering took place ?
399  file_v = find_index_in_table("unfiltered_files", {{"original_name", f.GetOriginalFile()}});
400  params.SetValue("unfiltered_file_id", file_v.value());
401 
402  add_file_to_collection("AddFilteredSimulation", "filtered_files", params, f.GetFullPathToFile(), dataset, reaction, filt_id);
403 }
404 
405 
406 
409 
411 {
412  // Use KVSimDir to analyse files in directory, all supposed to correspond to the same reaction, and add them to the given dataset
413 
414  KVSimDir sim_dir("toto", dirpath);
415  sim_dir.AnalyseDirectory();
416 
417  // unfiltered files
418  for (auto _f : *sim_dir.GetSimDataList()) {
419  auto f = dynamic_cast<KVSimFile*>(_f);
420 
421  AddUnfilteredSimulation(f->GetFullPathToFile(), f->GetEvents(),
423  dataset, reaction);
424  }
425  // filtered files
426  for (auto _f : *sim_dir.GetFiltDataList()) {
427  auto f = dynamic_cast<KVSimFile*>(_f);
428  AddFilteredSimulation(*f, dataset, reaction);
429  }
430 }
431 
432 
433 
440 
442 {
443  // Call with the id of a previously initialised data repository (see AddDataRepository())
444  // for all following files added with AddFilesFromDirectory() to be imported (copied)
445  // into this data repository.
446  //
447  // Call with no argument (default repo_id = 0 => no repository) to stop importing.
448 
449  if (!repo) {
451  import_repo = 0;
452  return;
453  }
454  // check repository id is valid
455  try {
456  get_data_repository(repo);
458  import_repo = repo;
459  }
460  catch (const std::exception& e) {
461  Info("ImportFilesToRepository", "%s", e.what());
463  import_repo = 0;
464  }
465 }
466 
467 
468 
475 
477 {
478  // for given reaction index, return a string with a name like:
479  //~~~
480  // "reaction64Ni58Ni32AMeV"
481  // "decay64Ni170MeV"
482  //~~~
483 
484  auto res = get_data_for_unique_index("reactions", id);
485  if (res.HasParameter("nuc2")) {
486  KVNucleus proj(res.GetStringValue("nuc1"));
487  proj.SetE(res.GetDoubleValue("energy"));
488  TString reac;
489  reac.Form("reaction%s%s%.0fAMeV", res.GetStringValue("nuc1"), res.GetStringValue("nuc2"), proj.GetAMeV());
490  if (res.HasParameter("impact_parameter"))
491  reac.Append(Form("_b%.1f%s", res.GetDoubleValue("impact_parameter"), res.GetStringValue("ip_units")));
492  return reac;
493  }
494  TString CN;
495  CN.Form("decay%s%.0fMeV", res.GetStringValue("nuc1"), res.GetDoubleValue("energy"));
496  if (res.HasParameter("spin_hbar"))
497  CN.Append(Form("_%dhbar", res.GetIntValue("spin_hbar")));
498  return CN;
499 }
500 
501 
502 
506 
508 {
509  // for given model, return name as "AMD_1", "HIPSE_11", etc., where "_N" is the index which can be different
510  // for different parameter sets of the model
511 
512  auto res = get_data_for_unique_index("models", id);
513  return Form("%s_%d", res.GetStringValue("name"), id);
514 }
515 
516 
517 
519 
520 KVNameValueList KVSimDataManager::get_params_for_reaction(std::optional<double> opt, bool reaction, const KV2Body& R, const TString& ip_units) const
521 {
522  KVNameValueList params;
523  params.SetValue("nuc1", R.GetNucleus(1)->GetSymbol());
524  if (reaction) {
525  params.SetValue("nuc2", R.GetNucleus(2)->GetSymbol());
526  params.SetValue("energy", R.GetNucleus(1)->GetEnergy());
527  if (opt) {
528  params.SetValue("impact_parameter", opt.value());
529  params.SetValue("ip_units", ip_units);
530  }
531  }
532  else {
533  params.SetValue("energy", -(R.GetExcitEnergy()));
534  if (opt)
535  params.SetValue("spin_hbar", TMath::Nint(opt.value()));
536  }
537 
538  return params;
539 }
540 
541 
542 
550 
552 {
553  // Return reference to repository corresponding to an entry in the repositories table
554  //
555  // If not already initialized, the repository is initialized using the infos in the table
556  //
557  // If the repository can not be initialized because it is not in the database,
558  // throw a std::runtime_error()
559 
560  if (!fRepos[id]) {
561  auto make_repository = [&](const KVNameValueList & columns) {
562  std::optional<TString> xrdsrv;
563  if (columns.HasStringParameter("Xrdsrv"))
564  xrdsrv = columns["Xrdsrv"].GetTString();
565  std::optional<TString> xrdroot;
566  if (columns.HasStringParameter("Xrdroot"))
567  xrdroot = columns["Xrdroot"].GetTString();
568  initialize_repository(id, columns["root_dir"].GetString(), columns["type"].GetString(), xrdsrv, xrdroot);
569  return false;
570  };
571  fDB.get_name_value_list_for_each_row("repositories", make_repository, Form("id = %d", id));
572  }
573  if (!fRepos[id])
574  throw std::runtime_error(Form("no repository with id=%d in database; you should call AddDataRepository() first", id));
575  return *fRepos[id];
576 }
577 
578 
579 
590 
591 KVSimDataManager::reaction_id KVSimDataManager::AddReaction(const KV2Body& R, std::optional<double> opt, const TString& ip_units)
592 {
593  // Add new reaction to database
594  //
595  // \param[in] R two-body reaction or compound nucleus definition (KV2Body)
596  // \param[in] opt if given:
597  // + for reactions, fixed value of impact parameter
598  // + for CN decay, fixed spin of compound nucleus (integer value)
599  // \param[in] ip_units for impact parameter given in opt, either "fm" (default) or "rel" (=> b/bmax)
600  //
601  // \returns index of reaction in database
602 
603  auto reaction = (R.GetNucleus(2) != nullptr);
604 
605  KVNameValueList params = get_params_for_reaction(opt, reaction, R, ip_units);
606 
607  // check not already in database
608  auto id = find_index_in_table("reactions", params);
609  if (id)
610  return id.value();
611 
612  enter_data_row("reactions", params);
613 
614  return find_index_in_table("reactions", params).value();
615 }
616 
617 
618 
627 
628 std::optional<KVSimDataManager::reaction_id> KVSimDataManager::GetReactionId(const KV2Body& R, std::optional<double> opt, const TString& ip_units) const
629 {
630  // \param[in] R two-body reaction or compound nucleus definition (KV2Body)
631  // \param[in] opt if given:
632  // + for reactions, fixed value of impact parameter
633  // + for CN decay, fixed spin of compound nucleus (integer value)
634  // \param[in] ip_units for impact parameter given in opt, either "fm" (default) or "rel" (=> b/bmax)
635  //
636  // \returns index of reaction in database, if found
637 
638  auto reaction = (R.GetNucleus(2) != nullptr);
639  KVNameValueList params = get_params_for_reaction(opt, reaction, R, ip_units);
640  return find_index_in_table("reactions", params);
641 }
642 
643 
644 
654 
656 {
657  // Add model with given name and parameter values to database.
658  //
659  // \param[in] name (short) name of model
660  // \param[in] params arbitrary list of key-value pairs giving full description of model parameters
661  //
662  // \return index in models table
663  //
664  // \note that for the same model, different parameter values have different indices.
665 
666  fDB.add_missing_columns("models", params); // add any missing parameter columns to table
667  KVNameValueList params_copy(params);
668  params_copy.SetValue("name", name);
669 
670  enter_data_row("models", params_copy);
671 
672  return GetModelId(name, params).value();
673 }
674 
675 
676 
686 
687 std::optional<KVSimDataManager::model_id> KVSimDataManager::GetModelId(const TString& name, const KVNameValueList& params) const
688 {
689  // Look for model with given name and parameter values in database
690  //
691  // \param[in] name (short) name of model
692  // \param[in] params arbitrary list of key-value pairs giving full description of model parameters
693  //
694  // \return index in models table if found, std::nullopt if not
695  //
696  // \note that for the same model, different parameter values have different indices.
697 
698  fDB.add_missing_columns("models", params); // add any missing parameter columns to table
699  KVNameValueList params_copy(params);
700  params_copy.SetValue("name", name);
701 
702  return find_index_in_table("models", params_copy);
703 }
704 
705 
706 
714 
716 {
717  // Add a new dataset for given model with a short description
718  //
719  // \param[in] modid index of model with a given set of parameters in the database
720  // \param[in] short_description short description (1 phrase) of dataset
721  //
722  // \return index of dataset in table
723 
724  KVNameValueList params;
725  params.SetValue("model_id", modid);
726  params.SetValue("user", gSystem->GetUserInfo()->fUser);
727  params.SetValue("description", short_description);
728 
729  enter_data_row("datasets", params);
730 
731  return find_index_in_table("datasets", params).value();
732 }
733 
734 
735 
744 
745 KVSimDataManager::dataset_id KVSimDataManager::AddDataSet(const TString& short_description, const TString& model, const KVNameValueList& model_params)
746 {
747  // Add a new dataset for given model with a short description
748  //
749  // \param[in] short_description short description (1 phrase) of dataset
750  // \param[in] model (short) name of model
751  // \param[in] model_params arbitrary list of key-value pairs giving full description of model parameters used in dataset
752  //
753  // \return index of dataset in table
754 
755  auto modid = GetModelId(model, model_params);
756  if (!modid) {
757  modid = AddModel(model, model_params);
758  }
759  return AddDataSet(short_description, modid.value());
760 }
761 
762 
int Int_t
#define f(i)
#define e(i)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
Relativistic binary kinematics calculator.
Definition: KV2Body.h:168
void Error(const char *method, const char *msgfmt,...) const override
colourised errors (red) !
Definition: KVBase.cpp:1686
static std::optional< TString > AbsoluteUnixPath(const TString &)
Definition: KVBase.cpp:1729
Base class for managing repositories of data.
int CopyFileToRepository(const TString &filename, const TString &source, const Paths &... paths) const
Manage all datasets contained in a given data repository.
Bool_t Init(KVDataSetRepository *=0)
KVDataSet * GetDataSet(Int_t) const
Return pointer to DataSet using index in list of all datasets, index>=0.
KVExpDB * GetDataBase(const TString &opt="") const
Definition: KVDataSet.cpp:288
virtual KVDBSystem * GetSystem(const Char_t *system) const
Definition: KVExpDB.h:164
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
void SetValue(const Char_t *name, value_type value)
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:123
Double_t GetAMeV() const
Definition: KVNucleus.cpp:1378
void SetE(Double_t a)
Definition: KVParticle.h:597
void get_name_value_list_for_each_row(const TString &table, std::function< bool(const KVNameValueList &)> callback, const TString &selection="", const TString &anything_else="")
Definition: SQLiteDB.cpp:1078
void add_missing_columns(const TString &table, const KVNameValueList &l)
Definition: SQLiteDB.cpp:1338
Manage database of simulations ,.
std::optional< model_id > GetModelId(const TString &, const KVNameValueList &) const
std::map< int, std::unique_ptr< KVDataRepository > > fRepos
KVSQLite::database fDB
void initialize_repository(repository_id id, const TString &root_dir, const TString &access="local", std::optional< TString > xrdsrv=std::nullopt, std::optional< TString > xrdroot=std::nullopt)
Initialize a new data repository with the given informations.
model_id AddModel(const TString &, const KVNameValueList &)
std::optional< reaction_id > GetReactionId(const KV2Body &, std::optional< double >=std::nullopt, const TString &ip_units="fm") const
std::optional< int > find_index_in_table(const TString &table_name, const KVNameValueList &params) const
repository_id AddDataRepository(const TString &root_dir, const TString &access="local", std::optional< TString > xrdsrv=std::nullopt, std::optional< TString > xrdroot=std::nullopt)
KVNameValueList get_data_for_unique_index(const TString &table_name, int id) const
filter_id AddFilter(reaction_id kinematics, const TString &geometry, const TString &filter_type, bool random_phi, std::optional< int > run_number={}, std::optional< TString > data_quality_audit={}, std::optional< int > gem_decay_per_event={}, std::optional< bool > gem_add_rot_energy={})
std::pair< TString, TString > import_file_to_repository(const TString &filepath, repository_id repo, dataset_id dset, reaction_id reac, std::optional< filter_id > filt_id={})
const KVDataRepository & get_data_repository(repository_id id)
dataset_id AddDataSet(const TString &short_description, const TString &model, const KVNameValueList &model_params)
TString GetReactionName(reaction_id id) const
repository_id import_repo
Bool_t import_data_into_repository
void enter_data_row(const TString &table_name, const KVNameValueList &params)
void AddUnfilteredSimulation(const TString &filepath, Int_t events, primary_or_secondary P, dataset_id dataset, reaction_id reaction)
void AddFilteredSimulation(const KVSimFile &f, dataset_id dataset, reaction_id reaction)
KVNameValueList get_params_for_reaction(std::optional< double > opt, bool reaction, const KV2Body &R, const TString &ip_units) const
void add_file_to_collection(const TString &method_name, const TString &table_name, KVNameValueList &params, const TString &filepath, dataset_id dataset, reaction_id reaction, std::optional< filter_id > filt_id={})
void AddFilesFromDirectory(dataset_id dataset, reaction_id reaction, const TString &dirpath)
Use KVSimDir to analyse files in directory, all supposed to correspond to the same reaction,...
reaction_id AddReaction(const KV2Body &, std::optional< double >=std::nullopt, const TString &ip_units="fm")
void ImportFilesToRepository(repository_id=0)
TString GetModelName(model_id id) const
Handle directory containing simulated and/or filtered simulated data ,.
Definition: KVSimDir.h:46
const KVList * GetFiltDataList() const
Definition: KVSimDir.h:79
const KVList * GetSimDataList() const
Definition: KVSimDir.h:75
void AnalyseDirectory()
Definition: KVSimDir.cpp:167
Handle file containing simulated and/or filtered simulated data ,.
Definition: KVSimFile.h:20
virtual void Info(const char *method, const char *msgfmt,...) const
const char * Data() const
TString & Append(char c, Ssiz_t rep=1)
void Form(const char *fmt,...)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual const char * DirName(const char *pathname)
virtual UserGroup_t * GetUserInfo(const char *user=nullptr)
virtual const char * BaseName(const char *pathname)
double T(double x)
Int_t Nint(T x)
constexpr Double_t R()
TString fUser
ClassImp(TPyArg)