CbmRoot
Loading...
Searching...
No Matches
CaToolsDebugger.h
Go to the documentation of this file.
1/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergey Gorbunov[committer] */
4
9
10#ifndef CaToolsDebugger_h
11#define CaToolsDebugger_h 1
12
13#include <iostream>
14#include <vector>
15
16class TFile;
17class TNtuple;
18
20{
23 class Debugger {
24 public:
25 // *****************************************
26 // ** Constructors and destructor **
27 // *****************************************
28
29
31 Debugger(const char* fileName = "CAdebug.root");
32
34 ~Debugger();
35
37 Debugger(const Debugger& other) = delete;
38
40 Debugger(Debugger&& other) = delete;
41
43 Debugger& operator=(const Debugger& other) = delete;
44
46 Debugger& operator=(Debugger&& other) = delete;
47
49 static Debugger& Instance();
50
52 void Write();
53
55 void AddNtuple(const char* name, const char* varlist);
56
58 void FillNtuple(const char* name, float v[]);
59
61 template<typename... Targs>
62 void FillNtuple(const char* name, Targs... args)
63 {
64 constexpr std::size_t n = sizeof...(Targs);
65 if (n <= 0) return;
66 float v[n];
67 FillFloatArray(v, args...);
68 FillNtuple(name, v);
69 }
70
72 int GetNtupleIndex(const char* name);
73
74 private:
75 template<typename T, typename... Targs>
76 void FillFloatArray(float* v, T val, Targs... args)
77 {
78 v[0] = (float) val;
79 if (sizeof...(args) > 0) {
80 FillFloatArray(v + 1, args...);
81 }
82 }
83
84 template<typename T>
85 void FillFloatArray(float* v, T last)
86 {
87 v[0] = (float) last;
88 }
89
90 private:
91 std::string fFileName{"CAdebug.root"};
92 bool fIsWritten{0};
93 TFile* fFile{nullptr};
94 std::vector<TNtuple*> fNtuples;
95 };
96} // namespace cbm::ca::tools
97
98#endif // CaToolsDebugger_h
fscal v[fmask::Size]
Definition KfSimdPseudo.h:4
static Debugger & Instance()
Instance.
std::vector< TNtuple * > fNtuples
Debugger & operator=(const Debugger &other)=delete
Copy assignment operator.
void AddNtuple(const char *name, const char *varlist)
Set new ntuple.
Debugger(const char *fileName="CAdebug.root")
Default constructor.
Debugger(const Debugger &other)=delete
Copy constructor.
void Write()
Write ntuples to the file.
int GetNtupleIndex(const char *name)
Get ntuple index.
void FillNtuple(const char *name, float v[])
Add an entry to ntuple.
void FillFloatArray(float *v, T last)
void FillFloatArray(float *v, T val, Targs... args)
void FillNtuple(const char *name, Targs... args)
Add an entry to ntuple.
Debugger(Debugger &&other)=delete
Move constructor.
Debugger & operator=(Debugger &&other)=delete
Move assignment operator.