Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:29:51

0001 // Author: Enrico Guiraud, CERN 10/2021
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2021, 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_RVARIATIONBASE
0012 #define ROOT_RVARIATIONBASE
0013 
0014 #include <ROOT/RDF/RColumnRegister.hxx>
0015 #include <ROOT/RDF/Utils.hxx> // ColumnNames_t
0016 #include <ROOT/RVec.hxx>
0017 
0018 #include <array>
0019 #include <deque>
0020 #include <memory>
0021 #include <string>
0022 #include <vector>
0023 
0024 class TTreeReader;
0025 
0026 namespace ROOT {
0027 namespace RDF {
0028 class RDataSource;
0029 }
0030 namespace Detail {
0031 namespace RDF {
0032 class RLoopManager;
0033 }
0034 } // namespace Detail
0035 namespace Internal {
0036 namespace RDF {
0037 
0038 /// This type includes all parts of RVariation that do not depend on the callable signature.
0039 class RVariationBase {
0040 protected:
0041    std::vector<std::string> fColNames;       ///< The names of the varied columns.
0042    std::vector<std::string> fVariationNames; ///< The names of the systematic variation.
0043    std::string fType;                        ///< The type of the custom column as a text string.
0044    std::vector<Long64_t> fLastCheckedEntry;
0045    RColumnRegister fColumnRegister;
0046    RLoopManager *fLoopManager;
0047    ColumnNames_t fInputColumns;
0048    /// The nth flag signals whether the nth input column is a custom column or not.
0049    ROOT::RVecB fIsDefine;
0050 
0051 public:
0052    RVariationBase(const std::vector<std::string> &colNames, std::string_view variationName,
0053                   const std::vector<std::string> &variationTags, std::string_view type,
0054                   const RColumnRegister &colRegister, RLoopManager &lm, const ColumnNames_t &inputColNames);
0055 
0056    RVariationBase(const RVariationBase &) = delete;
0057    RVariationBase(RVariationBase &&) = default;
0058    RVariationBase &operator=(const RVariationBase &) = delete;
0059    RVariationBase &operator=(RVariationBase &&) = default;
0060    virtual ~RVariationBase();
0061 
0062    virtual void InitSlot(TTreeReader *r, unsigned int slot) = 0;
0063 
0064    /// Return the (type-erased) address of the value of one variation of one column (can be safely cast back to a T*).
0065    virtual void *GetValuePtr(unsigned int slot, const std::string &column, const std::string &variation) = 0;
0066    virtual const std::type_info &GetTypeId() const = 0;
0067    const std::vector<std::string> &GetColumnNames() const;
0068    const std::vector<std::string> &GetVariationNames() const;
0069    std::string GetTypeName() const;
0070    /// Update the value at the address returned by GetValuePtr with the content corresponding to the given entry
0071    virtual void Update(unsigned int slot, Long64_t entry) = 0;
0072    /// Clean-up operations to be performed at the end of a task.
0073    virtual void FinalizeSlot(unsigned int slot) = 0;
0074 };
0075 
0076 } // namespace RDF
0077 } // namespace Internal
0078 } // namespace ROOT
0079 
0080 #endif // ROOT_RVARIATIONBASE