Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Author: Enrico Guiraud, Danilo Piparo CERN  09/2018
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2020, 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_RACTIONBASE
0012 #define ROOT_RACTIONBASE
0013 
0014 #include "ROOT/RDF/RColumnRegister.hxx"
0015 #include "ROOT/RDF/RSampleInfo.hxx"
0016 #include "ROOT/RDF/Utils.hxx" // ColumnNames_t
0017 #include "RtypesCore.h"
0018 
0019 #include <memory>
0020 #include <string>
0021 
0022 namespace ROOT {
0023 
0024 namespace Detail {
0025 namespace RDF {
0026 class RLoopManager;
0027 class RDefineBase;
0028 class RMergeableValueBase;
0029 } // namespace RDF
0030 } // namespace Detail
0031 
0032 namespace Internal {
0033 namespace RDF {
0034 namespace GraphDrawing {
0035 class GraphNode;
0036 }
0037 
0038 using namespace ROOT::Detail::RDF;
0039 
0040 class RActionBase {
0041 protected:
0042    /// A raw pointer to the RLoopManager at the root of this functional graph.
0043    /// Never null: children nodes have shared ownership of parent nodes in the graph.
0044    RLoopManager *fLoopManager;
0045 
0046 private:
0047    const unsigned int fNSlots; ///< Number of thread slots used by this node.
0048    bool fHasRun = false;
0049    const ColumnNames_t fColumnNames;
0050    /// List of systematic variations that affect the result of this action ("nominal" excluded).
0051    std::vector<std::string> fVariations;
0052 
0053    RColumnRegister fColRegister;
0054 
0055 public:
0056    RActionBase(RLoopManager *lm, const ColumnNames_t &colNames, const RColumnRegister &colRegister,
0057                const std::vector<std::string> &prevVariations);
0058    RActionBase(const RActionBase &) = delete;
0059    RActionBase &operator=(const RActionBase &) = delete;
0060    virtual ~RActionBase();
0061 
0062    const ColumnNames_t &GetColumnNames() const { return fColumnNames; }
0063    RColumnRegister &GetColRegister() { return fColRegister; }
0064    RLoopManager *GetLoopManager() { return fLoopManager; }
0065    unsigned int GetNSlots() const { return fNSlots; }
0066    virtual void Run(unsigned int slot, Long64_t entry) = 0;
0067    virtual void Initialize() = 0;
0068    virtual void InitSlot(TTreeReader *r, unsigned int slot) = 0;
0069    virtual void TriggerChildrenCount() = 0;
0070    virtual void FinalizeSlot(unsigned int) = 0;
0071    virtual void Finalize() = 0;
0072    /// This method is invoked to update a partial result during the event loop, right before passing the result to a
0073    /// user-defined callback registered via RResultPtr::RegisterCallback
0074    virtual void *PartialUpdate(unsigned int slot) = 0;
0075 
0076    // overridden by RJittedAction
0077    virtual bool HasRun() const { return fHasRun; }
0078    virtual void SetHasRun() { fHasRun = true; }
0079 
0080    virtual std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode>
0081    GetGraph(std::unordered_map<void *, std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode>> &visitedMap) = 0;
0082 
0083    /**
0084       Retrieve a wrapper to the result of the action that knows how to merge
0085       with others of the same type.
0086    */
0087    virtual std::unique_ptr<RMergeableValueBase> GetMergeableValue() const = 0;
0088 
0089    virtual ROOT::RDF::SampleCallback_t GetSampleCallback() = 0;
0090 
0091    const std::vector<std::string> &GetVariations() const { return fVariations; }
0092 
0093    virtual std::unique_ptr<RActionBase> MakeVariedAction(std::vector<void *> &&results) = 0;
0094    virtual std::unique_ptr<RActionBase> CloneAction(void *newResult) = 0;
0095 };
0096 } // namespace RDF
0097 } // namespace Internal
0098 } // namespace ROOT
0099 
0100 #endif // ROOT_RACTIONBASE