ndmspc v1.2.0-0.1.rc7
Loading...
Searching...
No Matches
NGnTree.h
1#ifndef Ndmspc_NGnTree_H
2#define Ndmspc_NGnTree_H
3#include <TObject.h>
4#include <THnSparse.h>
5#include <TH1.h>
6#include <TH2.h>
7#include <TH3.h>
8#include <TObject.h>
9#include <vector>
10#include "NBinning.h"
11#include "NParameters.h"
12#include "NStorageTree.h"
13// #include "NBinningPoint.h"
14
15namespace Ndmspc {
16
27using NHnSparseProcessFuncPtr = void (*)(Ndmspc::NBinningPoint *, TList *, TList *, int);
28
40using NGnProcessFuncPtr = void (*)(Ndmspc::NBinningPoint *, TList *, TList *, int);
41
52using NGnBeginFuncPtr = void (*)(Ndmspc::NBinningPoint *, int);
53
62using NGnEndFuncPtr = void (*)(Ndmspc::NBinningPoint *, int);
63
74class NGnNavigator;
75class NGnTree : public TObject {
76 public:
80 NGnTree();
81
88 NGnTree(std::vector<TAxis *> axes, std::string filename = "", std::string treename = "ngnt");
89
96 NGnTree(TObjArray * axes, std::string filename = "", std::string treename = "ngnt");
97
104 NGnTree(NGnTree * ngnt, std::string filename = "", std::string treename = "ngnt");
105
111 NGnTree(NBinning * binning, NStorageTree * treeStorage);
112
121 NGnTree(THnSparse * hns, std::string parameterAxis, const std::string & outFileName = "/tmp/ngnt_imported.root",
122 json cfg = json::object());
123
127 virtual ~NGnTree();
128
133 virtual void Print(Option_t * option = "") const override;
134
143 virtual void Draw(Option_t * option = "") override;
144
154 void Play(int timeout = 0, std::string binning = "", std::vector<int> outputPointIds = {0},
155 std::vector<std::vector<int>> ranges = {}, Option_t * option = "");
156
161 NBinning * GetBinning() const { return fBinning; }
162
167 void SetBinning(NBinning * binning) { fBinning = binning; }
168
174
179 std::map<std::string, TList *> GetOutputs() const { return fOutputs; }
180
186 TList * GetOutput(std::string name = "");
187
192 void SetOutputs(std::map<std::string, TList *> outputs) { fOutputs = outputs; }
193
198 NGnTree * GetInput() const { return fInput; }
199
204 void SetInput(NGnTree * input) { fInput = input; }
205
211
216 void SetNavigator(NGnNavigator * navigator);
217
223 bool IsPureCopy() const { return fIsPureCopy; }
224
230 void SetIsPureCopy(bool val) { fIsPureCopy = val; }
231
236 Long64_t GetEntries() const { return fTreeStorage ? fTreeStorage->GetEntries() : 0; }
237
244 Int_t GetEntry(Long64_t entry, bool checkBinningDef = true);
245
253 Int_t GetEntry(std::vector<std::vector<int>> range, bool checkBinningDef = true);
254
260 bool Close(bool write = false);
261
269 bool Process(NGnProcessFuncPtr func, const json & cfg = json::object(), std::string binningName = "",
270 NGnBeginFuncPtr beginFunc = nullptr, NGnEndFuncPtr endFunc = nullptr);
271
280 bool Process(NGnProcessFuncPtr func, const std::vector<std::string> & defNames, const json & cfg = json::object(),
281 NBinning * binningIn = nullptr, NGnBeginFuncPtr beginFunc = nullptr, NGnEndFuncPtr endFunc = nullptr);
282
292 void SetWorkerMacro(const std::string & macroList) { fWorkerMacroList = macroList; }
293
300 TList * Projection(const json & cfg, std::string binningName = "");
310 NGnNavigator * Reshape(std::string binningName, std::vector<std::vector<int>> levels, int level = 0,
311 std::map<int, std::vector<int>> ranges = {}, std::map<int, std::vector<int>> rangesBase = {});
322 NGnNavigator * GetResourceStatisticsNavigator(std::string binningName, std::vector<std::vector<int>> levels,
323 int level = 0, std::map<int, std::vector<int>> ranges = {},
324 std::map<int, std::vector<int>> rangesBase = {});
330
339 bool InitParameters(const std::vector<std::string> & paramNames);
340
348 static NGnTree * Open(const std::string & filename, const std::string & branches = "",
349 const std::string & treename = "ngnt");
350
358 static NGnTree * Open(TTree * tree, const std::string & branches = "", TFile * file = nullptr);
359
372 static NGnTree * Import(const std::string & findPath, const std::string & fileName,
373 const std::vector<std::string> & headers,
374 const std::string & outFileName = "/tmp/ngnt_imported.root",bool close=true);
375
383 static std::string BuildObjectPath(const json & cfg, const json & objCfg, const NBinningPoint * point);
384
385 protected:
386 NBinning * fBinning{nullptr};
388 std::map<std::string, TList *> fOutputs;
389 NGnTree * fInput{nullptr};
392 bool fOwnsBinning{true};
394 bool fIsPureCopy{false};
395 std::string fWorkerMacroList;
396
398 ClassDefOverride(NGnTree, 1);
400};
401} // namespace Ndmspc
402#endif
Represents a single point in multi-dimensional binning.
NBinning object for managing multi-dimensional binning and axis definitions.
Definition NBinning.h:45
Navigator object for managing hierarchical data structures and projections.
NDMSPC tree object for managing multi-dimensional data storage and processing.
Definition NGnTree.h:75
NStorageTree * GetStorageTree() const
Get pointer to storage tree object.
Definition NGnTree.h:173
NGnNavigator * GetResourceStatisticsNavigator(std::string binningName, std::vector< std::vector< int > > levels, int level=0, std::map< int, std::vector< int > > ranges={}, std::map< int, std::vector< int > > rangesBase={})
Returns a navigator for resource statistics based on binning and levels.
Definition NGnTree.cxx:1657
virtual void Draw(Option_t *option="") override
Draws the tree object.
Definition NGnTree.cxx:492
void SetIsPureCopy(bool val)
Sets the pure copy status of the tree.
Definition NGnTree.h:230
bool Close(bool write=false)
Close the tree, optionally writing data.
Definition NGnTree.cxx:1347
bool fOwnsTreeStorage
True when fTreeStorage is owned by this instance.
Definition NGnTree.h:393
void SetBinning(NBinning *binning)
Set binning object pointer.
Definition NGnTree.h:167
bool IsPureCopy() const
Checks if the tree is a pure copy.
Definition NGnTree.h:223
virtual ~NGnTree()
Destructor.
Definition NGnTree.cxx:453
NGnNavigator * GetNavigator() const
Returns the navigator associated with this tree.
Definition NGnTree.h:210
Int_t GetEntry(Long64_t entry, bool checkBinningDef=true)
Get entry by index.
Definition NGnTree.cxx:1361
virtual void Print(Option_t *option="") const override
Print tree information.
Definition NGnTree.cxx:468
void SetInput(NGnTree *input)
Set input NGnTree pointer.
Definition NGnTree.h:204
NGnTree()
Default constructor.
Definition NGnTree.cxx:157
static NGnTree * Import(const std::string &findPath, const std::string &fileName, const std::vector< std::string > &headers, const std::string &outFileName="/tmp/ngnt_imported.root", bool close=true)
Imports an NGnTree from a specified file.
Definition NGnTree.cxx:1714
NBinning * fBinning
Binning object.
Definition NGnTree.h:386
TList * GetOutput(std::string name="")
Get output list by name.
Definition NGnTree.cxx:1227
std::map< std::string, TList * > GetOutputs() const
Get outputs map.
Definition NGnTree.h:179
NGnTree * fInput
Input NGnTree for processing.
Definition NGnTree.h:389
bool fOwnsBinning
True when fBinning is owned by this instance.
Definition NGnTree.h:392
NGnNavigator * Reshape(std::string binningName, std::vector< std::vector< int > > levels, int level=0, std::map< int, std::vector< int > > ranges={}, std::map< int, std::vector< int > > rangesBase={})
Reshape navigator using binning name and levels.
Definition NGnTree.cxx:1644
NParameters * GetParameters() const
Returns the parameters associated with this tree.
Definition NGnTree.h:329
std::string fWorkerMacroList
Comma-separated macro paths sent to TCP workers.
Definition NGnTree.h:395
void SetOutputs(std::map< std::string, TList * > outputs)
Set outputs map.
Definition NGnTree.h:192
void SetWorkerMacro(const std::string &macroList)
Set the macro(s) that TCP workers should load when bootstrapping.
Definition NGnTree.h:292
bool InitParameters(const std::vector< std::string > &paramNames)
Initializes the parameters for the tree using the provided parameter names.
Definition NGnTree.cxx:1693
void Play(int timeout=0, std::string binning="", std::vector< int > outputPointIds={0}, std::vector< std::vector< int > > ranges={}, Option_t *option="")
Play tree data with optional binning and output point IDs.
Definition NGnTree.cxx:1385
std::map< std::string, TList * > fOutputs
Outputs.
Definition NGnTree.h:388
NGnNavigator * fNavigator
! Navigator object
Definition NGnTree.h:390
Long64_t GetEntries() const
Get number of entries in storage tree.
Definition NGnTree.h:236
NParameters * fParameters
Parameters object.
Definition NGnTree.h:391
TList * Projection(const json &cfg, std::string binningName="")
Project tree data using configuration and binning name.
Definition NGnTree.cxx:1542
NStorageTree * fTreeStorage
Tree storage.
Definition NGnTree.h:387
NGnTree * GetInput() const
Get pointer to input NGnTree.
Definition NGnTree.h:198
static std::string BuildObjectPath(const json &cfg, const json &objCfg, const NBinningPoint *point)
Helper: build object path string from configuration and a binning point.
Definition NGnTree.cxx:43
void SetNavigator(NGnNavigator *navigator)
Sets the navigator for this tree.
Definition NGnTree.cxx:1333
NBinning * GetBinning() const
Get pointer to binning object.
Definition NGnTree.h:161
static NGnTree * Open(const std::string &filename, const std::string &branches="", const std::string &treename="ngnt")
Open NGnTree from file.
Definition NGnTree.cxx:1243
bool Process(NGnProcessFuncPtr func, const json &cfg=json::object(), std::string binningName="", NGnBeginFuncPtr beginFunc=nullptr, NGnEndFuncPtr endFunc=nullptr)
Process tree data using a function pointer and configuration.
Definition NGnTree.cxx:501
bool fIsPureCopy
Flag indicating pure copy mode.
Definition NGnTree.h:394
NParameters object.
Definition NParameters.h:13
NDMSPC storage tree object for managing ROOT TTree-based data storage.
Global callback function for libwebsockets client events.
void(*)(Ndmspc::NBinningPoint *, TList *, TList *, int) NGnProcessFuncPtr
Function pointer type for processing binning points and lists.
Definition NGnTree.h:40
void(*)(Ndmspc::NBinningPoint *, TList *, TList *, int) NHnSparseProcessFuncPtr
Function pointer type for processing sparse nodes in the tree.
Definition NGnTree.h:27
void(*)(Ndmspc::NBinningPoint *, int) NGnEndFuncPtr
Function pointer type for termination functions used in NGnTree.
Definition NGnTree.h:62
void(*)(Ndmspc::NBinningPoint *, int) NGnBeginFuncPtr
Function pointer type for the beginning of a tree operation.
Definition NGnTree.h:52