GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TCalibrator.h
Go to the documentation of this file.
1#ifndef TCALIBRATORS_H
2#define TCALIBRATORS_H
3
4#include <map>
5#include <array>
6
7#include "TNamed.h"
8#include "TGraphErrors.h"
9
10class TH1;
11
12class TChannel;
13class TNucleus;
14
15class TCalibrator : public TNamed {
16public:
18 TCalibrator(const TCalibrator&) = default;
19 TCalibrator(TCalibrator&&) noexcept = default;
20 TCalibrator& operator=(const TCalibrator&) = default;
21 TCalibrator& operator=(TCalibrator&&) noexcept = default;
22 ~TCalibrator();
23
24 void Copy(TObject& obj) const override;
25 void Print(Option_t* opt = "") const override;
26 void Clear(Option_t* opt = "") override;
27 void Draw(Option_t* opt = "") override;
28 UInt_t Size() const { return fPeaks.size(); }
29
30 int GetFitOrder() const { return fFitOrder; }
31 void SetFitOrder(int order) { fFitOrder = order; }
32
33 TGraph& MakeCalibrationGraph(double min_figure_of_merit = 0.001);
34 TGraphErrors& MakeEffGraph(double seconds = 3600., double bq = 100000., Option_t* opt = "draw");
35 std::vector<double> Calibrate(double min_figure_of_merit = 0.001);
36
37 int AddData(TH1* data, const std::string& source, double sigma = 2.0, double threshold = 0.05, double error = 0.001);
38
39 int AddData(TH1* data, TNucleus* source, double sigma = 2.0, double threshold = 0.05, double error = 0.001);
40
41 void UpdateTChannel(TChannel* channel);
42
43 void Fit(int order = 1);
44 double GetParameter(int i = 0) const;
45 double GetEffParameter(int i = 0) const;
46
47 struct Peak {
48 double centroid{0.};
49 double energy{0.};
50 double area{0.};
51 double intensity{0.};
52 std::string nucleus;
53 };
54
55 void AddPeak(double cent, double eng, std::string nuc, double a = 0.0, double inten = 0.0);
56 Peak GetPeak(UInt_t i) const { return fPeaks.at(i); }
57
58 TGraph* FitGraph() { return &fFitGraph; }
59 TGraph* EffGraph() { return &fEffGraph; }
60 TF1* LinFit() { return fLinFit; }
61 TF1* EffFit() { return fEffFit; }
62
63 std::string PrintEfficency(const char* filename = "");
64
65#ifndef __CINT__
66// struct SingleFit {
67// double max_error;
68// std::string nucleus;
69// std::map<double,double> data2source;
70// TGraph graph;
71//};
72#endif
73
74private:
75#ifndef __CINT__
76 // std::map<std::string,SingleFit> all_fits;
77 static std::map<double, double> Match(std::vector<double>, std::vector<double>);
78#endif
79 std::vector<Peak> fPeaks;
80
81 TGraph fFitGraph;
82 TGraphErrors fEffGraph;
83 TF1* fLinFit{nullptr};
84 TF1* fEffFit{nullptr};
85
86 int fFitOrder{0};
87
88 std::array<double, 4> fEffPar{0.};
89
90 static void ResetMap(std::map<double, double>& inmap);
91 static void PrintMap(std::map<double, double>& inmap);
92 static bool CheckMap(const std::map<double, double>& inmap);
93
94 /// \cond CLASSIMP
95 ClassDefOverride(TCalibrator, 1) // NOLINT(readability-else-after-return)
96 /// \endcond
97};
98
99#endif
static void PrintMap(std::map< double, double > &inmap)
TGraphErrors & MakeEffGraph(double seconds=3600., double bq=100000., Option_t *opt="draw")
void SetFitOrder(int order)
Definition TCalibrator.h:31
TCalibrator(TCalibrator &&) noexcept=default
int AddData(TH1 *data, const std::string &source, double sigma=2.0, double threshold=0.05, double error=0.001)
std::vector< double > Calibrate(double min_figure_of_merit=0.001)
int GetFitOrder() const
Definition TCalibrator.h:30
TGraph fFitGraph
Definition TCalibrator.h:81
void Fit(int order=1)
static std::map< double, double > Match(std::vector< double >, std::vector< double >)
TCalibrator(const TCalibrator &)=default
TF1 * fEffFit
Definition TCalibrator.h:84
TF1 * EffFit()
Definition TCalibrator.h:61
double GetParameter(int i=0) const
void Draw(Option_t *opt="") override
void Copy(TObject &obj) const override
std::array< double, 4 > fEffPar
Definition TCalibrator.h:88
static bool CheckMap(const std::map< double, double > &inmap)
void AddPeak(double cent, double eng, std::string nuc, double a=0.0, double inten=0.0)
double GetEffParameter(int i=0) const
TGraphErrors fEffGraph
Definition TCalibrator.h:82
TGraph * FitGraph()
Definition TCalibrator.h:58
TF1 * LinFit()
Definition TCalibrator.h:60
Peak GetPeak(UInt_t i) const
Definition TCalibrator.h:56
UInt_t Size() const
Definition TCalibrator.h:28
TF1 * fLinFit
Definition TCalibrator.h:83
void UpdateTChannel(TChannel *channel)
void Print(Option_t *opt="") const override
std::string PrintEfficency(const char *filename="")
TGraph * EffGraph()
Definition TCalibrator.h:59
static void ResetMap(std::map< double, double > &inmap)
std::vector< Peak > fPeaks
Definition TCalibrator.h:79
TGraph & MakeCalibrationGraph(double min_figure_of_merit=0.001)
void Clear(Option_t *opt="") override
std::string nucleus
Definition TCalibrator.h:52