Back to home page

EIC code displayed by LXR

 
 

    


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