Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 09:14:19

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_RDFNODEBASE
0012 #define ROOT_RDFNODEBASE
0013 
0014 #include "RtypesCore.h"
0015 #include "TError.h" // R__ASSERT
0016 
0017 #include <memory>
0018 #include <string>
0019 #include <vector>
0020 #include <unordered_map>
0021 
0022 namespace ROOT {
0023 namespace RDF {
0024 class RCutFlowReport;
0025 }
0026 
0027 namespace Internal {
0028 namespace RDF {
0029 namespace GraphDrawing {
0030 class GraphNode;
0031 }
0032 }
0033 }
0034 
0035 namespace Detail {
0036 namespace RDF {
0037 
0038 class RLoopManager;
0039 
0040 /// Base class for non-leaf nodes of the computational graph.
0041 /// It only exposes the bare minimum interface required to work as a generic part of the computation graph.
0042 /// RDataFrames and results of transformations can be cast to this type via ROOT::RDF::RNode (or ROOT.RDF.AsRNode in PyROOT).
0043 class RNodeBase {
0044 protected:
0045    RLoopManager *fLoopManager;
0046    unsigned int fNChildren{0};      ///< Number of nodes of the functional graph hanging from this object
0047    unsigned int fNStopsReceived{0}; ///< Number of times that a children node signaled to stop processing entries.
0048    std::vector<std::string> fVariations; ///< List of systematic variations that affect this node.
0049 
0050 public:
0051    RNodeBase(const std::vector<std::string> &variations = {}, RLoopManager *lm = nullptr)
0052       : fLoopManager(lm), fVariations(variations)
0053    {
0054    }
0055 
0056    // Rule of five
0057    RNodeBase(const RNodeBase &) = delete;
0058    RNodeBase &operator=(const RNodeBase &) = delete;
0059    RNodeBase(RNodeBase &&) = delete;
0060    RNodeBase &operator=(RNodeBase &&) = delete;
0061    virtual ~RNodeBase() = default;
0062 
0063    virtual bool CheckFilters(unsigned int, Long64_t) = 0;
0064    virtual void Report(ROOT::RDF::RCutFlowReport &) const = 0;
0065    virtual void PartialReport(ROOT::RDF::RCutFlowReport &) const = 0;
0066    virtual void IncrChildrenCount() = 0;
0067    virtual void StopProcessing() = 0;
0068    virtual void AddFilterName(std::vector<std::string> &filters) = 0;
0069    // Helper function for SaveGraph
0070    virtual std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode>
0071    GetGraph(std::unordered_map<void *, std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode>> &visitedMap) = 0;
0072 
0073    virtual void ResetChildrenCount()
0074    {
0075       fNChildren = 0;
0076       fNStopsReceived = 0;
0077    }
0078 
0079    virtual RLoopManager *GetLoopManagerUnchecked() { return fLoopManager; }
0080 
0081    const std::vector<std::string> &GetVariations() const { return fVariations; }
0082 
0083    /// Return a clone of this node that acts as a Filter working with values in the variationName "universe".
0084    virtual std::shared_ptr<RNodeBase> GetVariedFilter(const std::string & /*variationName*/)
0085    {
0086       R__ASSERT(false &&
0087                 "GetVariedFilter was called on a node type that does not implement it. This should never happen.");
0088       return nullptr;
0089    }
0090 };
0091 } // ns RDF
0092 } // ns Detail
0093 } // ns ROOT
0094 
0095 #endif