Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:53:06

0001 // Author: Enrico Guiraud, Danilo Piparo CERN  09/2018
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2018, 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_RDEFINEBASE
0012 #define ROOT_RDEFINEBASE
0013 
0014 #include "ROOT/RDF/GraphNode.hxx"
0015 #include "ROOT/RDF/RColumnRegister.hxx"
0016 #include "ROOT/RDF/RSampleInfo.hxx"
0017 #include "ROOT/RDF/Utils.hxx"
0018 #include "ROOT/RVec.hxx"
0019 
0020 #include <deque>
0021 #include <map>
0022 #include <memory>
0023 #include <string>
0024 #include <vector>
0025 
0026 class TTreeReader;
0027 
0028 namespace ROOT {
0029 namespace RDF {
0030 class RDataSource;
0031 }
0032 namespace Detail {
0033 namespace RDF {
0034 
0035 class RLoopManager;
0036 
0037 namespace RDFInternal = ROOT::Internal::RDF;
0038 
0039 class RDefineBase {
0040 protected:
0041    const std::string fName; ///< The name of the custom column
0042    const std::string fType; ///< The type of the custom column as a text string
0043    std::vector<Long64_t> fLastCheckedEntry;
0044    RDFInternal::RColumnRegister fColRegister;
0045    RLoopManager *fLoopManager; // non-owning pointer to the RLoopManager
0046    const ROOT::RDF::ColumnNames_t fColumnNames;
0047    /// The nth flag signals whether the nth input column is a custom column or not.
0048    ROOT::RVecB fIsDefine;
0049    std::vector<std::string> fVariationDeps; ///< List of systematic variations that affect the value of this define.
0050    std::string fVariation;                  ///< This indicates for what variation this define evaluates values.
0051 
0052 public:
0053    RDefineBase(std::string_view name, std::string_view type, const RDFInternal::RColumnRegister &colRegister,
0054                RLoopManager &lm, const ColumnNames_t &columnNames, const std::string &variationName = "nominal");
0055 
0056    RDefineBase &operator=(const RDefineBase &) = delete;
0057    RDefineBase &operator=(RDefineBase &&) = delete;
0058    virtual ~RDefineBase();
0059    virtual void InitSlot(TTreeReader *r, unsigned int slot) = 0;
0060    /// Return the (type-erased) address of the Define'd value for the given processing slot.
0061    virtual void *GetValuePtr(unsigned int slot) = 0;
0062    virtual const std::type_info &GetTypeId() const = 0;
0063    std::string GetName() const;
0064    std::string GetTypeName() const;
0065    /// Update the value at the address returned by GetValuePtr with the content corresponding to the given entry
0066    virtual void Update(unsigned int slot, Long64_t entry) = 0;
0067    /// Update function to be called once per sample, used if the derived type is a RDefinePerSample
0068    virtual void Update(unsigned int /*slot*/, const ROOT::RDF::RSampleInfo &/*id*/) {}
0069    /// Clean-up operations to be performed at the end of a task.
0070    virtual void FinalizeSlot(unsigned int slot) = 0;
0071 
0072    const std::vector<std::string> &GetVariations() const { return fVariationDeps; }
0073 
0074    /// Create clones of this Define that work with values in varied "universes".
0075    virtual void MakeVariations(const std::vector<std::string> &variations) = 0;
0076 
0077    /// Return a clone of this Define that works with values in the variationName "universe".
0078    virtual RDefineBase &GetVariedDefine(const std::string &variationName) = 0;
0079 };
0080 
0081 } // ns RDF
0082 } // ns Detail
0083 } // ns ROOT
0084 
0085 #endif // ROOT_RDEFINEBASE