From 634fb2e1084ef73b5bd0dd517969aa02b13f907a Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Tue, 23 May 2023 11:05:24 +0200 Subject: [PATCH 01/14] TRestDataSet. Fixing output messages --- source/framework/core/inc/TRestDataSet.h | 2 +- source/framework/core/src/TRestDataSet.cxx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/framework/core/inc/TRestDataSet.h b/source/framework/core/inc/TRestDataSet.h index d78fd72ce..bcabc73f4 100644 --- a/source/framework/core/inc/TRestDataSet.h +++ b/source/framework/core/inc/TRestDataSet.h @@ -116,7 +116,7 @@ class TRestDataSet : public TRestMetadata { TTree* GetTree() const { if (fTree == nullptr) { RESTError << "Tree has not been yet initialized" << RESTendl; - RESTError << "You should invoke TRestDataSet::Initialize() before trying to access the tree" + RESTError << "You should invoke TRestDataSet::GenerateDataSet() before trying to access the tree" << RESTendl; } return fTree; diff --git a/source/framework/core/src/TRestDataSet.cxx b/source/framework/core/src/TRestDataSet.cxx index 9acd42e69..d2d8aff96 100644 --- a/source/framework/core/src/TRestDataSet.cxx +++ b/source/framework/core/src/TRestDataSet.cxx @@ -273,7 +273,8 @@ void TRestDataSet::Initialize() { SetSectionName(this->ClassName()); } /// void TRestDataSet::GenerateDataSet() { if (fTree != nullptr) { - RESTWarning << "Tree has already been loaded. Skipping TRestDataSet::Initialize ... " << RESTendl; + RESTWarning << "Tree has already been loaded. Skipping TRestDataSet::GenerateDataSet ... " + << RESTendl; return; } From a6400df8cb64235f355e30563b3bdfdbe38c2084 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Wed, 24 May 2023 14:27:12 +0200 Subject: [PATCH 02/14] TRestMetadata::GetDataMemberValues. Removing parenthesis that appear on TVector2,3 output string. --- source/framework/core/src/TRestMetadata.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/framework/core/src/TRestMetadata.cxx b/source/framework/core/src/TRestMetadata.cxx index 61a91ae7b..bd8eb1cc2 100644 --- a/source/framework/core/src/TRestMetadata.cxx +++ b/source/framework/core/src/TRestMetadata.cxx @@ -2327,6 +2327,8 @@ std::vector TRestMetadata::GetDataMemberValues(string memberName, Int_t result = Replace(result, "{", ""); result = Replace(result, "}", ""); + result = Replace(result, "(", ""); + result = Replace(result, ")", ""); std::vector results = REST_StringHelper::Split(result, ","); From f55e82f3f9fd17b159f5584cca5afe47120c9547 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Wed, 24 May 2023 15:42:03 +0200 Subject: [PATCH 03/14] Adding macro REST_GenerateDataSet. --- macros/REST_GenerateDataSet.C | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 macros/REST_GenerateDataSet.C diff --git a/macros/REST_GenerateDataSet.C b/macros/REST_GenerateDataSet.C new file mode 100644 index 000000000..35d3af82b --- /dev/null +++ b/macros/REST_GenerateDataSet.C @@ -0,0 +1,32 @@ +#include "TRestTask.h" +#include "TRestDataSet.h" + +#ifndef RestTask_GenerateDataSet +#define RestTask_GenerateDataSet + +//******************************************************************************************************* +//*** Description: This macro will launch the generation of datasets defined +//*** inside a particular RML file `datasets.rml` that contains the dataset +//*** definitions. The second argument will allow to specify the datasets +//*** to be generated from the existing ones inside `dataset.rml`. +//*** +//*** -------------- +//*** Usage: restManager GenerateDataSet datasets.rml set1,set2,set3 +//*** +//******************************************************************************************************* + +Int_t REST_GenerateDataSet( std::string inputRML, std::string datasets ) +{ + + std::vector sets = REST_StringHelper::Split( datasets, "," ); + + for( const auto &set: sets ) { + std::cout << "Set : " << set << std::endl; + TRestDataSet d( inputRML.c_str(), set.c_str() ); + d.GenerateDataSet(); + d.Export( "dataset_" + set + ".root" ); + } + return 0; + +} +#endif From 803bc2dc22763de84a2623124cdaf07e43aeeb76 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 24 May 2023 13:42:27 +0000 Subject: [PATCH 04/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- macros/REST_GenerateDataSet.C | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/macros/REST_GenerateDataSet.C b/macros/REST_GenerateDataSet.C index 35d3af82b..65852c8a7 100644 --- a/macros/REST_GenerateDataSet.C +++ b/macros/REST_GenerateDataSet.C @@ -1,5 +1,5 @@ -#include "TRestTask.h" #include "TRestDataSet.h" +#include "TRestTask.h" #ifndef RestTask_GenerateDataSet #define RestTask_GenerateDataSet @@ -15,18 +15,15 @@ //*** //******************************************************************************************************* -Int_t REST_GenerateDataSet( std::string inputRML, std::string datasets ) -{ - - std::vector sets = REST_StringHelper::Split( datasets, "," ); - - for( const auto &set: sets ) { - std::cout << "Set : " << set << std::endl; - TRestDataSet d( inputRML.c_str(), set.c_str() ); - d.GenerateDataSet(); - d.Export( "dataset_" + set + ".root" ); - } - return 0; +Int_t REST_GenerateDataSet(std::string inputRML, std::string datasets) { + std::vector sets = REST_StringHelper::Split(datasets, ","); + for (const auto& set : sets) { + std::cout << "Set : " << set << std::endl; + TRestDataSet d(inputRML.c_str(), set.c_str()); + d.GenerateDataSet(); + d.Export("dataset_" + set + ".root"); + } + return 0; } #endif From 7d6a909119b923375b9388a215ea6ae997d1c6a0 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Wed, 24 May 2023 16:12:58 +0200 Subject: [PATCH 05/14] TRestDataSet. Adding equalsTo metadata filter --- source/framework/core/inc/TRestDataSet.h | 6 +++++- source/framework/core/src/TRestDataSet.cxx | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/source/framework/core/inc/TRestDataSet.h b/source/framework/core/inc/TRestDataSet.h index bcabc73f4..9bcbbe0f4 100644 --- a/source/framework/core/inc/TRestDataSet.h +++ b/source/framework/core/inc/TRestDataSet.h @@ -65,7 +65,7 @@ class TRestDataSet : public TRestMetadata { /// A list of metadata members where filters will be applied std::vector fFilterMetadata; //< - /// If not empty it will check if the metadata member contains the value + /// If not empty it will check if the metadata member contains the string std::vector fFilterContains; //< /// If the corresponding element is not empty it will check if the metadata member is greater @@ -74,6 +74,9 @@ class TRestDataSet : public TRestMetadata { /// If the corresponding element is not empty it will check if the metadata member is lower std::vector fFilterLowerThan; //< + /// If the corresponding element is not empty it will check if the metadata member is equal + std::vector fFilterEqualsTo; //< + /// The properties of a relevant quantity that we want to store together with the dataset std::map fQuantity; //< @@ -145,6 +148,7 @@ class TRestDataSet : public TRestMetadata { inline auto GetFilterContains() const { return fFilterContains; } inline auto GetFilterGreaterThan() const { return fFilterGreaterThan; } inline auto GetFilterLowerThan() const { return fFilterLowerThan; } + inline auto GetFilterEqualsTo() const { return fFilterEqualsTo; } inline auto GetQuantity() const { return fQuantity; } inline auto GetCut() const { return fCut; } diff --git a/source/framework/core/src/TRestDataSet.cxx b/source/framework/core/src/TRestDataSet.cxx index d2d8aff96..97d00ceee 100644 --- a/source/framework/core/src/TRestDataSet.cxx +++ b/source/framework/core/src/TRestDataSet.cxx @@ -379,6 +379,9 @@ std::vector TRestDataSet::FileSelection() { if (fFilterLowerThan[n] != -1) if (StringToDouble(mdValue) >= fFilterLowerThan[n]) accept = false; + if (fFilterEqualsTo[n] != -1) + if (StringToDouble(mdValue) != fFilterEqualsTo[n]) accept = false; + n++; } @@ -512,6 +515,7 @@ void TRestDataSet::PrintMetadata() { if (!fFilterContains[n].empty()) RESTMetadata << " Contains: " << fFilterContains[n]; if (fFilterGreaterThan[n] != -1) RESTMetadata << " Greater than: " << fFilterGreaterThan[n]; if (fFilterLowerThan[n] != -1) RESTMetadata << " Lower than: " << fFilterLowerThan[n]; + if (fFilterEqualsTo[n] != -1) RESTMetadata << " Equals to: " << fFilterEqualsTo[n]; RESTMetadata << RESTendl; n++; @@ -560,10 +564,12 @@ void TRestDataSet::InitFromConfigFile() { if (contains == "Not defined") contains = ""; Double_t greaterThan = StringToDouble(GetFieldValue("greaterThan", filterDefinition)); Double_t lowerThan = StringToDouble(GetFieldValue("lowerThan", filterDefinition)); + Double_t equalsTo = StringToDouble(GetFieldValue("equalsTo", filterDefinition)); fFilterContains.push_back(contains); fFilterGreaterThan.push_back(greaterThan); fFilterLowerThan.push_back(lowerThan); + fFilterEqualsTo.push_back(equalsTo); filterDefinition = GetNextElement(filterDefinition); } @@ -689,6 +695,7 @@ void TRestDataSet::Export(const std::string& filename) { if (!fFilterContains[n].empty()) fprintf(f, " Contains: %s.", fFilterContains[n].c_str()); if (fFilterGreaterThan[n] != -1) fprintf(f, " Greater than: %6.3lf.", fFilterGreaterThan[n]); if (fFilterLowerThan[n] != -1) fprintf(f, " Lower than: %6.3lf.", fFilterLowerThan[n]); + if (fFilterEqualsTo[n] != -1) fprintf(f, " Equals to: %6.3lf.", fFilterLowerThan[n]); fprintf(f, "\n"); n++; } @@ -764,6 +771,7 @@ TRestDataSet& TRestDataSet::operator=(TRestDataSet& dS) { fFilterContains = dS.GetFilterContains(); fFilterGreaterThan = dS.GetFilterGreaterThan(); fFilterLowerThan = dS.GetFilterLowerThan(); + fFilterEqualsTo = dS.GetFilterEqualsTo(); fQuantity = dS.GetQuantity(); fTotalDuration = dS.GetTotalTimeInSeconds(); fCut = dS.GetCut(); From 6e1d435b58eee4cac541e7973b5aa09d36f0c19b Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Thu, 25 May 2023 12:10:47 +0200 Subject: [PATCH 06/14] REST_GenerateDataSet output file now starts by D uppercase --- macros/REST_GenerateDataSet.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macros/REST_GenerateDataSet.C b/macros/REST_GenerateDataSet.C index 65852c8a7..1d255c448 100644 --- a/macros/REST_GenerateDataSet.C +++ b/macros/REST_GenerateDataSet.C @@ -22,7 +22,7 @@ Int_t REST_GenerateDataSet(std::string inputRML, std::string datasets) { std::cout << "Set : " << set << std::endl; TRestDataSet d(inputRML.c_str(), set.c_str()); d.GenerateDataSet(); - d.Export("dataset_" + set + ".root"); + d.Export("Dataset_" + set + ".root"); } return 0; } From 1db66ba319f41aa55d775285b8539669a2d5ac86 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Thu, 25 May 2023 12:43:43 +0200 Subject: [PATCH 07/14] Making the macro name plural --- macros/{REST_GenerateDataSet.C => REST_GenerateDataSets.C} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename macros/{REST_GenerateDataSet.C => REST_GenerateDataSets.C} (93%) diff --git a/macros/REST_GenerateDataSet.C b/macros/REST_GenerateDataSets.C similarity index 93% rename from macros/REST_GenerateDataSet.C rename to macros/REST_GenerateDataSets.C index 1d255c448..7a5a2f62d 100644 --- a/macros/REST_GenerateDataSet.C +++ b/macros/REST_GenerateDataSets.C @@ -15,7 +15,7 @@ //*** //******************************************************************************************************* -Int_t REST_GenerateDataSet(std::string inputRML, std::string datasets) { +Int_t REST_GenerateDataSets(std::string inputRML, std::string datasets) { std::vector sets = REST_StringHelper::Split(datasets, ","); for (const auto& set : sets) { From 1ee3d3f6f45bc53c32248a4a858d2c4844ffc254 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Thu, 25 May 2023 12:44:13 +0200 Subject: [PATCH 08/14] Update REST_GenerateDataSets.C --- macros/REST_GenerateDataSets.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/macros/REST_GenerateDataSets.C b/macros/REST_GenerateDataSets.C index 7a5a2f62d..2903159cf 100644 --- a/macros/REST_GenerateDataSets.C +++ b/macros/REST_GenerateDataSets.C @@ -1,8 +1,8 @@ #include "TRestDataSet.h" #include "TRestTask.h" -#ifndef RestTask_GenerateDataSet -#define RestTask_GenerateDataSet +#ifndef RestTask_GenerateDataSets +#define RestTask_GenerateDataSets //******************************************************************************************************* //*** Description: This macro will launch the generation of datasets defined From c25c744b427ce4353e97d38c658094f1814d9f90 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Thu, 25 May 2023 12:47:12 +0200 Subject: [PATCH 09/14] REST_GenerateDataSets. Arguments passed by reference --- macros/REST_GenerateDataSets.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/macros/REST_GenerateDataSets.C b/macros/REST_GenerateDataSets.C index 2903159cf..d6c3f02bc 100644 --- a/macros/REST_GenerateDataSets.C +++ b/macros/REST_GenerateDataSets.C @@ -11,11 +11,11 @@ //*** to be generated from the existing ones inside `dataset.rml`. //*** //*** -------------- -//*** Usage: restManager GenerateDataSet datasets.rml set1,set2,set3 +//*** Usage: restManager GenerateDataSets datasets.rml set1,set2,set3 //*** //******************************************************************************************************* -Int_t REST_GenerateDataSets(std::string inputRML, std::string datasets) { +Int_t REST_GenerateDataSets(const std::string& inputRML, const std::string& datasets) { std::vector sets = REST_StringHelper::Split(datasets, ","); for (const auto& set : sets) { From f4dfe6f7b27dea4a8797d77967b8ce50394c521a Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Thu, 25 May 2023 21:34:12 +0200 Subject: [PATCH 10/14] TRestDataSet::Define method added --- source/framework/core/inc/TRestDataSet.h | 2 ++ source/framework/core/src/TRestDataSet.cxx | 23 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/source/framework/core/inc/TRestDataSet.h b/source/framework/core/inc/TRestDataSet.h index 9bcbbe0f4..ac6e74838 100644 --- a/source/framework/core/inc/TRestDataSet.h +++ b/source/framework/core/inc/TRestDataSet.h @@ -160,6 +160,8 @@ class TRestDataSet : public TRestMetadata { ROOT::RDF::RNode MakeCut(const TRestCut* cut); + ROOT::RDF::RNode Define(const std::string& columnName, const std::string& formula); + void PrintMetadata() override; void Initialize() override; diff --git a/source/framework/core/src/TRestDataSet.cxx b/source/framework/core/src/TRestDataSet.cxx index 97d00ceee..1e50c889c 100644 --- a/source/framework/core/src/TRestDataSet.cxx +++ b/source/framework/core/src/TRestDataSet.cxx @@ -470,6 +470,29 @@ ROOT::RDF::RNode TRestDataSet::MakeCut(const TRestCut* cut) { return df; } +/////////////////////////////////////////////// +/// \brief This function will add a new column to the RDataFrame using +/// the same scheme as the usual RDF::Define method, but it will on top of +/// that evaluate the values of any relevant quantities used. +/// +/// For example, the following code line would create a new column named +/// `test` replacing the relevant quantity `Nsim` and the previously +/// existing column `probability`. +/// \code +/// d.Define("test", "Nsim * probability"); +/// \endcode +/// +ROOT::RDF::RNode TRestDataSet::Define(const std::string& columnName, const std::string& formula) { + std::string evalFormula = formula; + for (auto const& [name, properties] : fQuantity) + evalFormula = + REST_StringHelper::Replace(evalFormula, name, DoubleToString(properties.value, "%12.10e")); + + fDataSet = fDataSet.Define(columnName, evalFormula); + + return fDataSet; +} + ///////////////////////////////////////////// /// \brief Prints on screen the information about the metadata members of TRestDataSet /// From 66bc4f1432ceecb692e11c84fdd9c189dc5b2a92 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Thu, 25 May 2023 21:39:25 +0200 Subject: [PATCH 11/14] TRestDataSet adding Define documentation --- source/framework/core/src/TRestDataSet.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/framework/core/src/TRestDataSet.cxx b/source/framework/core/src/TRestDataSet.cxx index 1e50c889c..b7739ab68 100644 --- a/source/framework/core/src/TRestDataSet.cxx +++ b/source/framework/core/src/TRestDataSet.cxx @@ -209,6 +209,18 @@ /// - **last**: It will simply register the value of the metadata member /// from the last file in the list of selected files. /// +/// ### Adding a new column based on relevant quantities +/// +/// Using the method TRestDataSet::Define method we can implement a +/// formula based on column names and relevant quantities. Then, the +/// relevant quantities will be sustituted by their dataset value. +/// +/// \code +/// dataset.GetColumnNames() +/// dataset.Define("newColumnName", "QuantityName * column1" ) +/// dataset.GetColumnNames() +/// dataset.GetDataFrame().Display({"column1", "newColumnName"})->Print(); +/// \endcode /// ///---------------------------------------------------------------------- /// From 04a70cd5db748d4023e6c6cf7036c5e6e24f6cff Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Thu, 25 May 2023 22:20:15 +0200 Subject: [PATCH 12/14] TRestDataSet. Adding the possibility to join different datasets --- source/framework/core/inc/TRestDataSet.h | 9 +++- source/framework/core/src/TRestDataSet.cxx | 55 +++++++++++++++++++++- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/source/framework/core/inc/TRestDataSet.h b/source/framework/core/inc/TRestDataSet.h index ac6e74838..790ef308f 100644 --- a/source/framework/core/inc/TRestDataSet.h +++ b/source/framework/core/inc/TRestDataSet.h @@ -95,11 +95,14 @@ class TRestDataSet : public TRestMetadata { /// TimeStamp for the end time of the last file Double_t fEndTime = REST_StringHelper::StringToTimeStamp(fFilterStartTime); + /// It keeps track if the generated dataset is a pure dataset or a merged one + Bool_t fMergedDataset = false; + /// The resulting RDF::RNode object after initialization ROOT::RDF::RNode fDataSet = ROOT::RDataFrame(0); //! /// A pointer to the generated tree - TTree* fTree = nullptr; //! + TChain* fTree = nullptr; //! void InitFromConfigFile() override; @@ -151,11 +154,13 @@ class TRestDataSet : public TRestMetadata { inline auto GetFilterEqualsTo() const { return fFilterEqualsTo; } inline auto GetQuantity() const { return fQuantity; } inline auto GetCut() const { return fCut; } + inline auto IsMergedDataSet() const { return fMergedDataset; } inline void SetFilePattern(const std::string& pattern) { fFilePattern = pattern; } TRestDataSet& operator=(TRestDataSet& dS); void Import(const std::string& fileName); + void Import(std::vector fileNames); void Export(const std::string& filename); ROOT::RDF::RNode MakeCut(const TRestCut* cut); @@ -171,6 +176,6 @@ class TRestDataSet : public TRestMetadata { TRestDataSet(const char* cfgFileName, const std::string& name = ""); ~TRestDataSet(); - ClassDefOverride(TRestDataSet, 2); + ClassDefOverride(TRestDataSet, 3); }; #endif diff --git a/source/framework/core/src/TRestDataSet.cxx b/source/framework/core/src/TRestDataSet.cxx index b7739ab68..be93f0a48 100644 --- a/source/framework/core/src/TRestDataSet.cxx +++ b/source/framework/core/src/TRestDataSet.cxx @@ -337,7 +337,7 @@ void TRestDataSet::GenerateDataSet() { fDataSet = ROOT::RDataFrame("AnalysisTree", fOutName); TFile* f = TFile::Open(fOutName.c_str()); - fTree = (TTree*)f->Get("AnalysisTree"); + fTree = (TChain*)f->Get("AnalysisTree"); RESTInfo << " - Dataset initialized!" << RESTendl; } @@ -847,5 +847,56 @@ void TRestDataSet::Import(const std::string& fileName) { RESTInfo << "Opening " << fileName << RESTendl; fDataSet = ROOT::RDataFrame("AnalysisTree", fileName); - fTree = (TTree*)file->Get("AnalysisTree"); + fTree = (TChain*)file->Get("AnalysisTree"); +} + +/////////////////////////////////////////////// +/// \brief This function initializes the chained tree and the RDataFrame using +/// as input several root files that should contain TRestDataSet metadata +/// information. The values of the first dataset will be considered to be stored +/// in this new instance. +/// +/// The metadata member `fMergedDataset` will be set to true to understand this +/// dataset is the combination of several datasets, and not a pure original one. +/// +void TRestDataSet::Import(std::vector fileNames) { + for (const auto& fN : fileNames) + if (TRestTools::GetFileNameExtension(fN) != "root") { + RESTError << "Datasets can only be imported from root files" << RESTendl; + return; + } + + if (fileNames.size() == 0) return; + + TFile* file = TFile::Open(fileNames[0].c_str(), "READ"); + if (file != nullptr) { + TIter nextkey(file->GetListOfKeys()); + TKey* key; + while ((key = (TKey*)nextkey())) { + std::string kName = key->GetClassName(); + if (REST_Reflection::GetClassQuick(kName.c_str()) != nullptr && + REST_Reflection::GetClassQuick(kName.c_str())->InheritsFrom("TRestDataSet")) { + TRestDataSet* dS = file->Get(key->GetName()); + if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Info) + dS->PrintMetadata(); + *this = *dS; + } + } + } else { + RESTError << "Cannot open " << fileNames[0] << RESTendl; + exit(1); + } + + RESTInfo << "Opening list of files. First file: " << fileNames[0] << RESTendl; + fDataSet = ROOT::RDataFrame("AnalysisTree", fileNames); + + if (fTree != nullptr) { + delete fTree; + fTree = nullptr; + } + fTree = new TChain("AnalysisTree"); + + for (const auto& fN : fileNames) fTree->Add((TString)fN); + + fMergedDataset = true; } From 7cdb0bd5b8f97aa88c5f4aac5d3d5bcd94b7edce Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Fri, 26 May 2023 08:26:03 +0200 Subject: [PATCH 13/14] TRestDataSet. Removing relevant quantities in a merged dataset --- source/framework/core/src/TRestDataSet.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/framework/core/src/TRestDataSet.cxx b/source/framework/core/src/TRestDataSet.cxx index be93f0a48..a619db703 100644 --- a/source/framework/core/src/TRestDataSet.cxx +++ b/source/framework/core/src/TRestDataSet.cxx @@ -899,4 +899,6 @@ void TRestDataSet::Import(std::vector fileNames) { for (const auto& fN : fileNames) fTree->Add((TString)fN); fMergedDataset = true; + + fQuantity.clear(); } From 397b6799e6adcd9821913c5adb2ba0f268e90114 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Fri, 26 May 2023 08:39:41 +0200 Subject: [PATCH 14/14] TRestDataSet. Adding a list with the files imported --- source/framework/core/inc/TRestDataSet.h | 9 ++++++--- source/framework/core/src/TRestDataSet.cxx | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/source/framework/core/inc/TRestDataSet.h b/source/framework/core/inc/TRestDataSet.h index 790ef308f..ac9570ce9 100644 --- a/source/framework/core/inc/TRestDataSet.h +++ b/source/framework/core/inc/TRestDataSet.h @@ -90,13 +90,16 @@ class TRestDataSet : public TRestMetadata { std::vector fFileSelection; //< /// TimeStamp for the start time of the first file - Double_t fStartTime = REST_StringHelper::StringToTimeStamp(fFilterEndTime); + Double_t fStartTime = REST_StringHelper::StringToTimeStamp(fFilterEndTime); //< /// TimeStamp for the end time of the last file - Double_t fEndTime = REST_StringHelper::StringToTimeStamp(fFilterStartTime); + Double_t fEndTime = REST_StringHelper::StringToTimeStamp(fFilterStartTime); //< /// It keeps track if the generated dataset is a pure dataset or a merged one - Bool_t fMergedDataset = false; + Bool_t fMergedDataset = false; //< + + /// The list of dataset files imported + std::vector fImportedFiles; //< /// The resulting RDF::RNode object after initialization ROOT::RDF::RNode fDataSet = ROOT::RDataFrame(0); //! diff --git a/source/framework/core/src/TRestDataSet.cxx b/source/framework/core/src/TRestDataSet.cxx index a619db703..babe06b69 100644 --- a/source/framework/core/src/TRestDataSet.cxx +++ b/source/framework/core/src/TRestDataSet.cxx @@ -575,6 +575,19 @@ void TRestDataSet::PrintMetadata() { } } + if (fMergedDataset) { + RESTMetadata << " " << RESTendl; + RESTMetadata << "This is a combined dataset." << RESTendl; + RESTMetadata << " -------------------- " << RESTendl; + RESTMetadata << " - Relevant quantities have been removed!" << RESTendl; + RESTMetadata << " - Dataset metadata properties correspond to the first file in the list." + << RESTendl; + RESTMetadata << " " << RESTendl; + RESTMetadata << "List of imported files: " << RESTendl; + RESTMetadata << " -------------------- " << RESTendl; + for (const auto& fn : fImportedFiles) RESTMetadata << " - " << fn << RESTendl; + } + RESTMetadata << "----" << RESTendl; } @@ -899,6 +912,7 @@ void TRestDataSet::Import(std::vector fileNames) { for (const auto& fN : fileNames) fTree->Add((TString)fN); fMergedDataset = true; + fImportedFiles = fileNames; fQuantity.clear(); }