ndmspc 0.20250304.0
Loading...
Searching...
No Matches
PointRun.h
1#ifndef NdmspcCorePointRun_H
2#define NdmspcCorePointRun_H
3
4#include <TObject.h>
5#include <TMacro.h>
6#include <TFile.h>
7#include <TList.h>
8#include <TH1S.h>
9#include <THnSparse.h>
10#include <nlohmann/json.hpp>
11#include <vector>
12#include "Core.h"
13using json = nlohmann::json;
14
15namespace Ndmspc {
16
23
24class PointRun : public TObject {
25 public:
26 PointRun(std::string macro = "NdmspcPointRun.C");
27 virtual ~PointRun();
28
29 bool Run(std::string filename, std::string userConfig = "", std::string environment = "",
30 std::string userConfigRaw = "", std::string binnings = "", bool show = false, std::string outfilename = "");
31 bool GenerateJobs(std::string jobs, std::string filename, std::string userConfig = "", std::string environment = "",
32 std::string userConfigRaw = "", std::string jobDir = "/tmp/ndmspc-jobs", std::string binnings = "");
33
35 json & Cfg() { return gCfg; }
37 json * CfgPtr() { return &gCfg; }
39 TFile * GetInputFile() const { return fInputFile; }
41 TList * GetInputList() const { return fInputList; }
43 THnSparse * GetResultObject() const { return fResultObject; }
45 Int_t * GetCurrentPoint() { return fCurrentPoint; }
47 std::vector<std::string> GetCurrentPointLabels() { return fCurrentPointLabels; }
51 TList * GetOutputList() const { return fOutputList; }
53 void SetOutputList(TList * outList) { fOutputList = outList; }
55 void SetSkipCurrentBin(bool scb = true) { fIsSkipBin = scb; }
57 void SetProcessExit(bool pe = true) { fIsProcessExit = pe; }
59 static void SetEnvironment(std::string env) { fgEnvironment = env; }
60
61 static bool Generate(std::string name = "myAnalysis", std::string inFile = "myFile.root",
62 std::string inObjectName = "myNDHistogram");
64 static bool Merge(int from = 0, int to = 1, std::string name = "myAnalysis.json", std::string userConfig = "",
65 std::string environment = "", std::string userConfigRaw = "", std::string binning = "",
66 std::string cacheDir = "${PWD}/.ndmspc_merge_cache", std::string fileOpt = "?remote=1");
67
68 private:
69 TMacro * fMacro{nullptr};
70 int fVerbose{0};
71 int fBinCount{0};
72 TFile * fInputFile{nullptr};
73 TList * fInputList{nullptr};
74 THnSparse * fResultObject{nullptr};
75 TFile * fCurrentOutputFile{nullptr};
76 std::string fCurrentOutputFileName{};
77 TDirectory * fCurrentOutputRootDirectory{nullptr};
78 Int_t fCurrentPoint[32];
79 std::vector<std::string> fCurrentPointLabels{};
81 THnSparse * fCurrentProccessHistogram{nullptr};
82 TH1S * fMapAxesType{nullptr};
83 std::vector<TAxis *> fCurrentProcessHistogramAxes{};
84 std::vector<int> fCurrentProcessHistogramPoint{};
85 bool fIsSkipBin{false};
86 bool fIsProcessOk{false};
87 bool fIsProcessExit{false};
88 TList * fOutputList{nullptr};
89 static std::string fgEnvironment;
90
91 bool LoadConfig(std::string config, std::string userConfig = "", std::string environment = "",
92 std::string userConfigRaw = "", std::string binning = "", bool show = false,
93 std::string outfilename = "");
94 bool Init(std::string extraPath = "");
95 bool Finish();
96 TList * OpenInputs();
97 THnSparse * CreateResult();
98 bool ApplyCuts();
99
100 int ProcessSingleFile();
101 bool ProcessSinglePoint();
102 bool ProcessRecursive(int i);
103 bool ProcessRecursiveInner(Int_t i, std::vector<std::string> & n);
104 void OutputFileOpen();
105 void OutputFileClose();
107 bool GenerateRecursiveConfig(Int_t dim, std::vector<std::vector<int>> & ranges, json & cfg, std::string & outfilename,
108 int & count);
109
111 ClassDef(PointRun, 1);
113};
114} // namespace Ndmspc
115#endif /* PointRun_H */
PointRun object.
Definition PointRun.h:24
bool ProcessRecursiveInner(Int_t i, std::vector< std::string > &n)
Definition PointRun.cxx:662
std::string fCurrentOutputFileName
Current output filename.
Definition PointRun.h:76
void OutputFileOpen()
Definition PointRun.cxx:772
bool GenerateRecursiveConfig(Int_t dim, std::vector< std::vector< int > > &ranges, json &cfg, std::string &outfilename, int &count)
void SetProcessExit(bool pe=true)
Sets flag for ending process.
Definition PointRun.h:57
static void SetEnvironment(std::string env)
Sets environment.
Definition PointRun.h:59
THnSparse * GetResultObject() const
Returns retults hnsparse object.
Definition PointRun.h:43
TFile * fInputFile
Input file.
Definition PointRun.h:72
static std::string fgEnvironment
Environment.
Definition PointRun.h:89
int ProcessSingleFile()
Definition PointRun.cxx:934
THnSparse * fCurrentProccessHistogram
Current processed histogram.
Definition PointRun.h:81
bool Init(std::string extraPath="")
Definition PointRun.cxx:78
int fBinCount
Bin Count (TODO! rename to axis level maybe)
Definition PointRun.h:71
static bool Merge(int from=0, int to=1, std::string name="myAnalysis.json", std::string userConfig="", std::string environment="", std::string userConfigRaw="", std::string binning="", std::string cacheDir="${PWD}/.ndmspc_merge_cache", std::string fileOpt="?remote=1")
Merge.
int ProcessHistogramRun()
Definition PointRun.cxx:981
std::vector< std::string > GetCurrentPointLabels()
Returns current point labels.
Definition PointRun.h:47
bool LoadConfig(std::string config, std::string userConfig="", std::string environment="", std::string userConfigRaw="", std::string binning="", bool show=false, std::string outfilename="")
Definition PointRun.cxx:47
THnSparse * CreateResult()
Definition PointRun.cxx:249
TList * GetOutputList() const
Returns output list.
Definition PointRun.h:51
TList * OpenInputs()
Definition PointRun.cxx:159
PointRun(std::string macro="NdmspcPointRun.C")
Definition PointRun.cxx:29
TList * fOutputList
Output list.
Definition PointRun.h:88
TH1S * fMapAxesType
Map axis type histogram.
Definition PointRun.h:82
virtual ~PointRun()
Definition PointRun.cxx:40
bool Run(std::string filename, std::string userConfig="", std::string environment="", std::string userConfigRaw="", std::string binnings="", bool show=false, std::string outfilename="")
TList * fInputList
Input list.
Definition PointRun.h:73
std::vector< std::string > fCurrentPointLabels
Current labels.
Definition PointRun.h:79
THnSparse * fResultObject
Result object.
Definition PointRun.h:74
int fVerbose
Verbose level.
Definition PointRun.h:70
void SetSkipCurrentBin(bool scb=true)
Sets flag for skupping bin.
Definition PointRun.h:55
json fCurrentPointValue
Current point value.
Definition PointRun.h:80
void SetOutputList(TList *outList)
Sets output list.
Definition PointRun.h:53
bool fIsProcessOk
Flag that process is ok.
Definition PointRun.h:86
bool fIsSkipBin
Flag to skip bin.
Definition PointRun.h:85
TList * GetInputList() const
Returns list of input objects.
Definition PointRun.h:41
std::vector< TAxis * > fCurrentProcessHistogramAxes
Current process histogram axes.
Definition PointRun.h:83
bool fIsProcessExit
Flag to exit process.
Definition PointRun.h:87
TMacro * fMacro
Macro.
Definition PointRun.h:69
json * CfgPtr()
Returns global config pointer to object.
Definition PointRun.h:37
json GetCurrentPointValue()
Return current point value in json.
Definition PointRun.h:49
json & Cfg()
Returns global config object.
Definition PointRun.h:35
TFile * fCurrentOutputFile
Current output file.
Definition PointRun.h:75
static bool Generate(std::string name="myAnalysis", std::string inFile="myFile.root", std::string inObjectName="myNDHistogram")
TDirectory * fCurrentOutputRootDirectory
Current output root directory.
Definition PointRun.h:77
Int_t fCurrentPoint[32]
Current point.
Definition PointRun.h:78
bool ProcessSinglePoint()
Definition PointRun.cxx:547
bool GenerateJobs(std::string jobs, std::string filename, std::string userConfig="", std::string environment="", std::string userConfigRaw="", std::string jobDir="/tmp/ndmspc-jobs", std::string binnings="")
TFile * GetInputFile() const
Returns input file.
Definition PointRun.h:39
std::vector< int > fCurrentProcessHistogramPoint
Current process histoghram point.
Definition PointRun.h:84
void OutputFileClose()
Definition PointRun.cxx:887
Int_t * GetCurrentPoint()
Returns current point coordinates.
Definition PointRun.h:45
bool ProcessRecursive(int i)
Definition PointRun.cxx:594