Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 09:11:33

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 <limits>
0015 #include <string>
0016 #include <utility> // std::pair
0017 #include <vector>
0018 
0019 #include <ROOT/RDF/RSample.hxx>
0020 #include <ROOT/RFriendInfo.hxx>
0021 #include <RtypesCore.h> // Long64_t
0022 
0023 namespace ROOT {
0024 namespace Detail {
0025 namespace RDF {
0026 class RLoopManager;
0027 } // namespace RDF
0028 } // namespace Detail
0029 
0030 namespace RDF {
0031 namespace Experimental {
0032 class RDatasetSpec;
0033 class RSample;
0034 } // namespace Experimental
0035 } // namespace RDF
0036 
0037 namespace Internal {
0038 namespace RDF {
0039 std::vector<ROOT::RDF::Experimental::RSample> MoveOutSamples(ROOT::RDF::Experimental::RDatasetSpec &spec);
0040 }
0041 } // namespace Internal
0042 
0043 namespace RDF {
0044 namespace Experimental {
0045 
0046 // clang-format off
0047 /**
0048 \class ROOT::RDF::Experimental::RDatasetSpec
0049 \ingroup dataframe
0050 \brief The dataset specification for RDataFrame.
0051 
0052 This class allows users to create the dataset specification for RDataFrame 
0053 to which they add samples (using the RSample class object) with tree names and file names, 
0054 and, optionally, the metadata information (using the RMetaData class objects). 
0055 Adding global friend trees and/or setting the range of events to be processed
0056 are also available.
0057 
0058 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()". 
0059 */
0060 
0061 class RDatasetSpec {
0062    // clang-format on 
0063    friend class ::ROOT::Detail::RDF::RLoopManager; // for MoveOutSamples
0064    friend std::vector<ROOT::RDF::Experimental::RSample> ROOT::Internal::RDF::MoveOutSamples(ROOT::RDF::Experimental::RDatasetSpec &); 
0065 
0066 
0067 public:
0068    struct REntryRange {
0069       Long64_t fBegin{0};
0070       Long64_t fEnd{std::numeric_limits<Long64_t>::max()};
0071       REntryRange();
0072       REntryRange(Long64_t endEntry);
0073       REntryRange(Long64_t startEntry, Long64_t endEntry);
0074    };
0075 
0076 private:
0077    std::vector<RSample> fSamples;             ///< List of samples
0078    ROOT::TreeUtils::RFriendInfo fFriendInfo;  ///< List of friends
0079    REntryRange fEntryRange; ///< Start (inclusive) and end (exclusive) entry for the dataset processing
0080    std::vector<RSample> MoveOutSamples();
0081 
0082 public:
0083    RDatasetSpec() = default;
0084 
0085    const std::vector<std::string> GetSampleNames() const;
0086    const std::vector<std::string> GetTreeNames() const;
0087    const std::vector<std::string> GetFileNameGlobs() const;
0088    const std::vector<RMetaData> GetMetaData() const;
0089    const ROOT::TreeUtils::RFriendInfo &GetFriendInfo() const;
0090    Long64_t GetEntryRangeBegin() const;
0091    Long64_t GetEntryRangeEnd() const;
0092 
0093    RDatasetSpec &AddSample(RSample sample);
0094 
0095    RDatasetSpec &
0096    WithGlobalFriends(const std::string &treeName, const std::string &fileNameGlob, const std::string &alias = "");
0097 
0098    RDatasetSpec &WithGlobalFriends(const std::string &treeName, const std::vector<std::string> &fileNameGlobs,
0099                              const std::string &alias = "");
0100 
0101    RDatasetSpec &WithGlobalFriends(const std::vector<std::pair<std::string, std::string>> &treeAndFileNameGlobs,
0102                              const std::string &alias = "");
0103 
0104    RDatasetSpec &WithGlobalFriends(const std::vector<std::string> &treeNames,
0105                                    const std::vector<std::string> &fileNameGlobs, const std::string &alias = "");
0106  
0107    RDatasetSpec &WithGlobalRange(const RDatasetSpec::REntryRange &entryRange = {});
0108 };
0109 
0110 } // namespace Experimental
0111 } // namespace RDF
0112 } // namespace ROOT
0113 
0114 #endif // ROOT_RDF_RDATASETSPEC