Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:35

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    virtual ~RNodeBase() {}
0056    virtual bool CheckFilters(unsigned int, Long64_t) = 0;
0057    virtual void Report(ROOT::RDF::RCutFlowReport &) const = 0;
0058    virtual void PartialReport(ROOT::RDF::RCutFlowReport &) const = 0;
0059    virtual void IncrChildrenCount() = 0;
0060    virtual void StopProcessing() = 0;
0061    virtual void AddFilterName(std::vector<std::string> &filters) = 0;
0062    // Helper function for SaveGraph
0063    virtual std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode>
0064    GetGraph(std::unordered_map<void *, std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode>> &visitedMap) = 0;
0065 
0066    virtual void ResetChildrenCount()
0067    {
0068       fNChildren = 0;
0069       fNStopsReceived = 0;
0070    }
0071 
0072    virtual RLoopManager *GetLoopManagerUnchecked() { return fLoopManager; }
0073 
0074    const std::vector<std::string> &GetVariations() const { return fVariations; }
0075 
0076    /// Return a clone of this node that acts as a Filter working with values in the variationName "universe".
0077    virtual std::shared_ptr<RNodeBase> GetVariedFilter(const std::string & /*variationName*/)
0078    {
0079       R__ASSERT(false &&
0080                 "GetVariedFilter was called on a node type that does not implement it. This should never happen.");
0081       return nullptr;
0082    }
0083 };
0084 } // ns RDF
0085 } // ns Detail
0086 } // ns ROOT
0087 
0088 #endif