Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/ROOT/RDF/RDatasetSpec.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Author: Vincenzo Eduardo Padulano CERN/UPV, Ivan Kabadzhov CERN  06/2022
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2022, Rene Brun and Fons Rademakers.               *
0005  * All rights reserved.                                                  *
0006  *                                                                       *
0007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0009  *************************************************************************/
0010 
0011 #ifndef ROOT_RDF_RDATASETSPEC
0012 #define ROOT_RDF_RDATASETSPEC
0013 
0014 #include <any>
0015 #include <limits>
0016 #include <string>
0017 #include <utility> // std::pair
0018 #include <vector>
0019 
0020 #include <ROOT/RDF/RSample.hxx>
0021 #include <RtypesCore.h> // Long64_t
0022 
0023 namespace ROOT::TreeUtils {
0024 struct RFriendInfo;
0025 }
0026 
0027 namespace ROOT {
0028 namespace Detail {
0029 namespace RDF {
0030 class RLoopManager;
0031 } // namespace RDF
0032 } // namespace Detail
0033 
0034 namespace RDF {
0035 namespace Experimental {
0036 class RDatasetSpec;
0037 class RSample;
0038 } // namespace Experimental
0039 } // namespace RDF
0040 
0041 namespace Internal {
0042 namespace RDF {
0043 std::vector<ROOT::RDF::Experimental::RSample> MoveOutSamples(ROOT::RDF::Experimental::RDatasetSpec &spec);
0044 }
0045 } // namespace Internal
0046 
0047 namespace RDF {
0048 namespace Experimental {
0049 
0050 // clang-format off
0051 /**
0052 \class ROOT::RDF::Experimental::RDatasetSpec
0053 \ingroup dataframe
0054 \brief The dataset specification for RDataFrame.
0055 
0056 This class allows users to create the dataset specification for RDataFrame 
0057 to which they add samples (using the RSample class object) with tree names and file names, 
0058 and, optionally, the metadata information (using the RMetaData class objects). 
0059 Adding global friend trees and/or setting the range of events to be processed
0060 are also available.
0061 
0062 Note, there exists yet another method to build RDataFrame from the dataset information using the JSON file format: \ref FromSpec(const std::string &jsonFile) "FromSpec()". 
0063 */
0064 
0065 class RDatasetSpec {
0066    // clang-format on 
0067    friend class ::ROOT::Detail::RDF::RLoopManager; // for MoveOutSamples
0068    friend std::vector<ROOT::RDF::Experimental::RSample> ROOT::Internal::RDF::MoveOutSamples(ROOT::RDF::Experimental::RDatasetSpec &); 
0069 
0070 
0071 public:
0072    struct REntryRange {
0073       Long64_t fBegin{0};
0074       Long64_t fEnd{std::numeric_limits<Long64_t>::max()};
0075       REntryRange();
0076       REntryRange(Long64_t endEntry);
0077       REntryRange(Long64_t startEntry, Long64_t endEntry);
0078    };
0079 
0080 private:
0081    std::vector<RSample> fSamples;             ///< List of samples
0082    std::any fFriendInfo;  ///< List of friends
0083    REntryRange fEntryRange; ///< Start (inclusive) and end (exclusive) entry for the dataset processing
0084    std::vector<RSample> MoveOutSamples();
0085    ROOT::TreeUtils::RFriendInfo &GetFriendInfo();
0086 
0087 public:
0088    RDatasetSpec() noexcept;
0089 
0090    const std::vector<std::string> GetSampleNames() const;
0091    const std::vector<std::string> GetTreeNames() const;
0092    const std::vector<std::string> GetFileNameGlobs() const;
0093    const std::vector<RMetaData> GetMetaData() const;
0094    const ROOT::TreeUtils::RFriendInfo &GetFriendInfo() const;
0095    Long64_t GetEntryRangeBegin() const;
0096    Long64_t GetEntryRangeEnd() const;
0097 
0098    RDatasetSpec &AddSample(RSample sample);
0099 
0100    RDatasetSpec &
0101    WithGlobalFriends(const std::string &treeName, const std::string &fileNameGlob, const std::string &alias = "");
0102 
0103    RDatasetSpec &WithGlobalFriends(const std::string &treeName, const std::vector<std::string> &fileNameGlobs,
0104                              const std::string &alias = "");
0105 
0106    RDatasetSpec &WithGlobalFriends(const std::vector<std::pair<std::string, std::string>> &treeAndFileNameGlobs,
0107                              const std::string &alias = "");
0108 
0109    RDatasetSpec &WithGlobalFriends(const std::vector<std::string> &treeNames,
0110                                    const std::vector<std::string> &fileNameGlobs, const std::string &alias = "");
0111  
0112    RDatasetSpec &WithGlobalRange(const RDatasetSpec::REntryRange &entryRange = {});
0113 };
0114 
0115 } // namespace Experimental
0116 } // namespace RDF
0117 } // namespace ROOT
0118 
0119 #endif // ROOT_RDF_RDATASETSPEC