ndmspc  v1.1.1-1
NBinningPoint.h
1 #ifndef Ndmspc_NBinningPoint_H
2 #define Ndmspc_NBinningPoint_H
3 #include <TObject.h>
4 #include <nlohmann/json.hpp>
5 #include "NParameters.h"
6 
7 using json = nlohmann::json;
8 
9 namespace Ndmspc {
10 
20 class NBinning;
21 class NStorageTree;
22 class NGnTree;
23 class NBinningPoint : public TObject {
24  public:
29  NBinningPoint(NBinning * b = nullptr);
30 
34  virtual ~NBinningPoint();
35 
40  virtual void Print(Option_t * option = "") const;
41 
45  virtual void Reset();
46 
51  Int_t GetNDimensionsContent() const { return fContentNDimensions; }
52 
57  Int_t * GetCoords() const { return fContentCoords; }
58 
63  Int_t GetNDimensions() const { return fNDimensions; }
64 
69  Int_t * GetStorageCoords() const { return fStorageCoords; }
70 
77  bool RecalculateStorageCoords(Long64_t entry = -1, bool useBinningDefCheck = false);
78 
85  bool SetPointContentFromLinearIndex(Long64_t linBin, bool checkBinningDef = false);
86 
93 
99  Long64_t Fill(bool ignoreFilledCheck = false);
100 
105  json & GetCfg() { return fCfg; }
106 
111  void SetCfg(json cfg) { fCfg = cfg; }
112 
117  std::map<int, std::vector<int>> GetBaseAxisRanges() const;
118 
126  std::string GetString(const std::string & prefix = "", bool all = false) const;
127 
132  std::vector<std::string> GetLabels() const { return fLabels; }
133 
138  Double_t * GetMins() const { return fMins; }
139 
144  Double_t * GetMaxs() const { return fMaxs; }
145 
151  Double_t GetBinMin(std::string axis) const;
152 
158  Double_t GetBinMax(std::string axis) const;
159 
166  Double_t GetBinCenter(std::string axis) const;
167 
173  std::string GetBinLabel(std::string axis) const;
174 
181  Int_t GetBin(std::string axis) const;
182 
187  NBinning * GetBinning() const { return fBinning; }
188 
193  void SetBinning(NBinning * b);
194 
200 
206 
211  NGnTree * GetInput() const { return fInput; }
212 
217  void SetInput(NGnTree * input) { fInput = input; }
218 
223  void SetEntryNumber(Long64_t entry) { fEntryNumber = entry; }
224 
229  Long64_t GetEntryNumber() const { return fEntryNumber; }
230 
238  void SetParameters(NParameters * params) { fParameters = params; }
239 
247  NParameters * GetParameters() const { return fParameters; }
248 
255  TObject * GetTempObject(const std::string & name) const;
256 
263  void SetTempObject(const std::string & name, TObject * obj) { fTempObjects[name] = obj; }
264 
269  json & GetTempCfg() { return fTempCfg; }
270 
271  private:
272  json fCfg{};
273  NGnTree * fInput{nullptr};
274  NBinning * fBinning{nullptr};
277  Int_t * fContentCoords{nullptr};
278  Int_t fNDimensions{1};
279  Int_t * fStorageCoords{nullptr};
280  Double_t * fMins{nullptr};
281  Double_t * fMaxs{nullptr};
282  Int_t * fBaseBinMin{nullptr};
283  Int_t * fBaseBinMax{nullptr};
284  std::vector<std::string> fLabels{};
285  Long64_t fEntryNumber{-1};
287  std::map<std::string, TObject *> fTempObjects;
288  json fTempCfg{};
289 
291  ClassDef(NBinningPoint, 1);
293 };
294 } // namespace Ndmspc
295 #endif
Represents a single point in multi-dimensional binning.
Definition: NBinningPoint.h:23
Double_t * GetMins() const
Get the array of minimum values for all axes.
json & GetTempCfg()
Get reference to temporary configuration JSON object.
NGnTree * fInput
Input NGnTree object.
NBinningPoint(NBinning *b=nullptr)
Constructor.
Double_t GetBinMax(std::string axis) const
Get the maximum value for a specific axis.
Long64_t Fill(bool ignoreFilledCheck=false)
Fill the binning point content.
Int_t fNDimensions
Number of dimensions.
std::map< int, std::vector< int > > GetBaseAxisRanges() const
Get base axis ranges for the point.
std::string GetString(const std::string &prefix="", bool all=false) const
Returns a string representation of the binning point.
Double_t * GetMaxs() const
Get the array of maximum values for all axes.
void SetEntryNumber(Long64_t entry)
Set entry number for the point.
void SetTreeStorage(NStorageTree *s)
Set storage tree object pointer.
std::string GetBinLabel(std::string axis) const
Get the label for a specific axis.
bool RecalculateStorageCoords(Long64_t entry=-1, bool useBinningDefCheck=false)
Recalculate storage coordinates for the point.
virtual ~NBinningPoint()
Destructor.
Long64_t GetEntryNumber() const
Get entry number for the point.
Int_t * fContentCoords
Coordinates of the point.
NParameters * GetParameters() const
Get the parameters associated with this binning point.
std::vector< std::string > fLabels
Labels for each axis.
Int_t * GetStorageCoords() const
Get pointer to storage coordinates array.
Definition: NBinningPoint.h:69
Double_t GetBinCenter(std::string axis) const
Returns the center value of the bin along the specified axis.
json fTempCfg
Temporary configuration object.
NBinning * fBinning
Binning object.
NParameters * fParameters
Parameter axis (if any)
Int_t * fBaseBinMin
Base bin minimum (for variable binning)
NStorageTree * GetTreeStorage() const
Get pointer to storage tree object.
void SetTempObject(const std::string &name, TObject *obj)
Set a temporary object with the given name.
void SetCfg(json cfg)
Set configuration JSON object.
NStorageTree * GetStorageTree() const
Returns a pointer to the associated storage tree.
Definition: NBinningPoint.h:92
virtual void Print(Option_t *option="") const
Print binning point information.
std::vector< std::string > GetLabels() const
Get labels for each axis.
Double_t * fMaxs
Maximum values for each axis.
bool SetPointContentFromLinearIndex(Long64_t linBin, bool checkBinningDef=false)
Set point content from linear index.
Int_t fContentNDimensions
Number of dimensions in content histogram.
Double_t * fMins
Minimum values for each axis.
void SetBinning(NBinning *b)
Set NBinning object pointer.
TObject * GetTempObject(const std::string &name) const
Retrieve a temporary object by name.
NStorageTree * fTreeStorage
Storage tree object.
NGnTree * GetInput() const
Get pointer to input NGnTree object.
NBinning * GetBinning() const
Get pointer to NBinning object.
Int_t GetBin(std::string axis) const
Returns the bin index for the specified axis.
std::map< std::string, TObject * > fTempObjects
! Outputs map
Int_t * GetCoords() const
Get pointer to content coordinates array.
Definition: NBinningPoint.h:57
void SetParameters(NParameters *params)
Set the parameters for this binning point.
Long64_t fEntryNumber
Entry in the storage tree.
Int_t * fBaseBinMax
Base bin maximum (for variable binning)
void SetInput(NGnTree *input)
Set input NGnTree object pointer.
json fCfg
Configuration object.
Int_t GetNDimensions() const
Get number of dimensions.
Definition: NBinningPoint.h:63
virtual void Reset()
Reset the binning point to initial state.
Int_t * fStorageCoords
Storage coordinates of the point.
json & GetCfg()
Get reference to configuration JSON object.
Int_t GetNDimensionsContent() const
Get number of dimensions in content histogram.
Definition: NBinningPoint.h:51
Double_t GetBinMin(std::string axis) const
Get the minimum value for a specific axis.
NBinning object for managing multi-dimensional binning and axis definitions.
Definition: NBinning.h:45
NDMSPC tree object for managing multi-dimensional data storage and processing.
Definition: NGnTree.h:76
NParameters object.
Definition: NParameters.h:13
NDMSPC storage tree object for managing ROOT TTree-based data storage.
Definition: NStorageTree.h:22