23#ifndef REST_TRestDataSet
24#define REST_TRestDataSet
26#include <TTimeStamp.h>
28#include <ROOT/RDataFrame.hxx>
31#include "TRestMetadata.h"
112 Bool_t fExternal =
false;
128 if (!fExternal &&
fTree ==
nullptr)
129 RESTWarning <<
"DataFrame has not been yet initialized" <<
RESTendl;
133 void EnableMultiThreading(Bool_t enable =
true) {
fMT = enable; }
137 if (
fTree ==
nullptr && fExternal) {
138 RESTInfo <<
"The tree is not accessible. Only GetDataFrame can be used in an externally "
141 RESTInfo <<
"You may write a tree using GetDataFrame()->Snapshot(\"MyTree\", \"output.root\");"
146 if (
fTree ==
nullptr) {
147 RESTError <<
"Tree has not been yet initialized" <<
RESTendl;
148 RESTError <<
"You should invoke TRestDataSet::GenerateDataSet() or " <<
RESTendl;
149 RESTError <<
"TRestDataSet::Import( fname ) before trying to access the tree" <<
RESTendl;
168 inline auto GetStartTime()
const {
return fStartTime; }
169 inline auto GetEndTime()
const {
return fEndTime; }
170 inline auto GetFilePattern()
const {
return fFilePattern; }
179 inline auto GetQuantity()
const {
return fQuantity; }
181 inline auto GetCut()
const {
return fCut; }
184 inline void SetObservablesList(
const std::vector<std::string>& obsList) {
fObservablesList = obsList; }
185 inline void SetFilePattern(
const std::string& pattern) {
fFilePattern = pattern; }
186 inline void SetQuantity(
const std::map<std::string, RelevantQuantity>& quantity) {
fQuantity = quantity; }
188 void SetTotalTimeInSeconds(Double_t seconds) {
fTotalDuration = seconds; }
189 void SetDataFrame(
const ROOT::RDF::RNode& dS) {
196 void Import(
const std::string& fileName);
197 void Import(std::vector<std::string> fileNames);
198 void Export(
const std::string& filename, std::vector<std::string> excludeColumns = {});
201 ROOT::RDF::RNode
DefineColumn(
const std::string& columnName,
const std::string& formula);
209 TRestDataSet(
const char* cfgFileName,
const std::string& name =
"");
A class to help on cuts definitions. To be used with TRestAnalysisTree.
It allows to group a number of runs that satisfy given metadata conditions.
std::vector< std::string > fFilterContains
If not empty it will check if the metadata member contains the string.
virtual std::vector< std::string > FileSelection()
Function to determine the filenames that satisfy the dataset conditions.
std::vector< Double_t > fFilterLowerThan
If the corresponding element is not empty it will check if the metadata member is lower.
void PrintMetadata() override
Prints on screen the information about the metadata members of TRestDataSet.
TChain * fTree
A pointer to the generated tree.
std::vector< std::string > fProcessObservablesList
It contains a list of the process where all observables should be added.
void Import(const std::string &fileName)
This function imports metadata from a root file it import metadata info from the previous dataSet whi...
std::map< std::string, RelevantQuantity > fQuantity
The properties of a relevant quantity that we want to store together with the dataset.
ROOT::RDF::RNode fDataSet
The resulting RDF::RNode object after initialization.
std::vector< std::pair< std::string, std::string > > fColumnNameExpressions
A list of new columns together with its corresponding expressions added to the dataset.
ROOT::RDF::RNode DefineColumn(const std::string &columnName, const std::string &formula)
This function will add a new column to the RDataFrame using the same scheme as the usual RDF::Define ...
Double_t fEndTime
TimeStamp for the end time of the last file.
size_t GetNumberOfBranches()
Number of variables (or observables)
TRestDataSet()
Default constructor.
ROOT::RDF::RNode GetDataFrame() const
Gives access to the RDataFrame.
Double_t GetTotalTimeInSeconds() const
It returns the accumulated run time in seconds.
ROOT::RDF::RNode MakeCut(const TRestCut *cut)
This function applies a TRestCut to the dataframe and returns a dataframe with the applied cuts....
void GenerateDataSet()
This function generates the data frame with the filelist and column names (or observables) that have ...
Bool_t fMT
A flag to enable Multithreading during dataframe generation.
TRestCut * fCut
Parameter cuts over the selected dataset.
void Export(const std::string &filename, std::vector< std::string > excludeColumns={})
It will generate an output file with the dataset compilation. Only the selected branches and the file...
std::string fFilterStartTime
All the selected runs will have a starting date after fStartTime.
Bool_t Merge(const TRestDataSet &dS)
This function merge different TRestDataSet metadata in current dataSet.
std::vector< std::string > fFilterMetadata
A list of metadata members where filters will be applied.
std::vector< std::string > fFileSelection
A list populated by the FileSelection method using the conditions of the dataset.
std::vector< std::string > GetFileSelection()
It returns a list of the files that have been finally selected.
std::string fFilterEndTime
All the selected runs will have an ending date before fEndTime.
Double_t fStartTime
TimeStamp for the start time of the first file.
std::vector< std::string > fObservablesList
It contains a list of the observables that will be added to the final tree or exported file.
TTree * GetTree() const
Gives access to the tree.
Bool_t fMergedDataset
It keeps track if the generated dataset is a pure dataset or a merged one.
void Initialize() override
This function initialize different parameters from the TRestDataSet.
std::vector< std::string > fImportedFiles
The list of dataset files imported.
Double_t fTotalDuration
The total integrated run time of selected files.
std::string fFilePattern
A glob file pattern that must be satisfied by all files.
size_t GetNumberOfColumns()
Number of variables (or observables)
std::vector< Double_t > fFilterGreaterThan
If the corresponding element is not empty it will check if the metadata member is greater.
std::vector< Double_t > fFilterEqualsTo
If the corresponding element is not empty it will check if the metadata member is equal.
void InitFromConfigFile() override
Initialization of specific TRestDataSet members through an RML file.
TRestDataSet & operator=(TRestDataSet &dS)
Operator to copy TRestDataSet metadata.
~TRestDataSet()
Default destructor.
time_t StringToTimeStamp(std::string time)
A method to convert a date/time formatted string to a timestamp.
std::string metadata
The associated metadata member used to register the relevant quantity.
std::string description
A user given description that can be used to define the relevant quantity.
std::string strategy
It determines how to produce the relevant quantity (accumulate/unique/last/max/min)
std::string value
The quantity value.