GamR  0.0.0
GammaROOT
Loading...
Searching...
No Matches
Integral.cc
Go to the documentation of this file.
1#include <iostream>
2#include <string.h>
3
4/* ROOT */
5#include <TMarker.h>
6#include <TH1.h>
7#include <TMath.h>
8#include <TArrow.h>
9#include <TText.h>
10#include <TString.h>
11
12#include <utils/Utilities.hh>
13#include <nucleus/Transition.hh>
14#include "Integral.hh"
15
16namespace GamR{
17 namespace Spect{
18 std::pair<double, double> Integral(TH1 *hist, GamR::TK::Gate peak) {
19 double peakArea = peak.GetIntegral((TH1D*)hist);
20 double peakAreaError = peak.GetIntegralError((TH1D*)hist);
21 std::cout << " Peak Area Error" << std::endl;
22 printf("%21.4f %15.4f\n", peakArea, peakAreaError);
23 std::pair<double, double> area = std::pair<double, double>(peakArea, peakAreaError);
24 return area;
25 }
26
27 std::pair<double, double> Integral(TH1 *hist, double peakLow, double peakHigh) {
28 GamR::TK::Gate gate(peakLow, peakHigh);
29 return Integral(hist, gate);
30 }
31
32 std::pair<double, double> Integral(TCanvas *canvas /*= gPad->GetCanvas()*/) {
33 TH1D *hist = GamR::Utils::GetHist1D(canvas);
34 if (!hist) { return std::pair<int, int>(-1, -1); }
35 GamR::TK::Gate gate;
36 gate.SetGate(canvas, "x");
37 return Integral(hist, gate);
38 }
39
40 std::pair<double, double> IntegralBS(TH1 *hist, GamR::Nucleus::Transition transition) {
41 double peakArea = transition.Apply((TH1D*)hist);
42 double peakAreaError = transition.ApplyError((TH1D*)hist);
43 std::cout << " Peak Area Error" << std::endl;
44 printf("%21.4f %15.4f\n", peakArea, peakAreaError);
45 std::pair<double, double> area = std::pair<double, double>(peakArea, peakAreaError);
46 return area;
47 }
48
49 std::pair<double, double> IntegralBS(TH1 *hist, GamR::TK::Gate peak, GamR::TK::Gate background) {
50 GamR::Nucleus::Transition transition(0, peak.GetLow(), peak.GetHigh(), background.GetLow(), background.GetHigh());
51 return IntegralBS(hist, transition);
52 }
53
54 std::pair<double, double> IntegralBS(TH1 *hist, double peakLow, double peakHigh, double backLow, double backHigh) {
55 GamR::Nucleus::Transition transition(0, peakLow, peakHigh, backLow, backHigh);
56 return IntegralBS(hist, transition);
57 }
58
59 std::pair<double, double> IntegralBS(TCanvas *canvas/*=gPad->GetCanvas()*/)
60 {
61 TH1D *hist = GamR::Utils::GetHist1D(canvas);
62 if (!hist) { return std::pair<int, int>(-1, -1); }
64 transition.SetTransition();
65 return IntegralBS(hist, transition);
66 }
67
68
69 std::pair<double, double> Counts(TH1 *hist, GamR::TK::Gate peak, std::string opt) {
70 double peakArea = peak.GetCounts((TH1D*)hist);
71 double peakAreaError = peak.GetCountsError((TH1D*)hist);
72 TString opt_st(opt);
73 if (!opt_st.Contains("q")) {
74 std::cout << " Peak Area Error" << std::endl;
75 printf("%21.4f %15.4f\n", peakArea, peakAreaError);
76 }
77 std::pair<double, double> area = std::pair<double, double>(peakArea, peakAreaError);
78 return area;
79 }
80
81 std::pair<double, double> Counts(TH1 *hist, double peakLow, double peakHigh, std::string opt) {
82 GamR::TK::Gate gate(peakLow, peakHigh);
83 return Counts(hist, gate, opt);
84 }
85
86 std::pair<double, double> Counts(TCanvas *canvas /*= gPad->GetCanvas()*/) {
87 TH1D *hist = GamR::Utils::GetHist1D(canvas);
88 if (!hist) { return std::pair<int, int>(-1, -1); }
89 GamR::TK::Gate gate;
90 gate.SetGate(canvas, "x");
91 return Counts(hist, gate);
92 }
93
94 std::pair<double, double> CountsBS(TH1 *hist, GamR::Nucleus::Transition transition, std::string opt) {
95 double peakArea = transition.ApplyCounts((TH1D*)hist);
96 double peakAreaError = transition.ApplyCountsError((TH1D*)hist);
97 TString opt_st(opt);
98 if (!opt_st.Contains("q")) {
99 std::cout << " Peak Counts Error" << std::endl;
100 printf("%21.4f %15.4f\n", peakArea, peakAreaError);
101 }
102 std::pair<double, double> peak = std::pair<double, double>(peakArea, peakAreaError);
103 return peak;
104 }
105
106 std::pair<double, double> CountsBS(TH1 *hist, GamR::TK::Gate peak, GamR::TK::Gate background, std::string opt) {
107 GamR::Nucleus::Transition transition(0, peak.GetLow(), peak.GetHigh(), background.GetLow(), background.GetHigh());
108 return CountsBS(hist, transition, opt);
109 }
110
111 std::pair<double, double> CountsBS(TH1 *hist, GamR::TK::Gate peak, std::vector<GamR::TK::Gate> backgrounds, std::string opt) {
112 GamR::Nucleus::Transition transition(0, peak.GetLow(), peak.GetHigh(), backgrounds[0].GetLow(), backgrounds[0].GetHigh());
113 for (int i=1; i<backgrounds.size(); ++i) {
114 transition.AddBackground(backgrounds[i].GetLow(), backgrounds[i].GetHigh());
115 }
116 return CountsBS(hist, transition, opt);
117 }
118
119 std::pair<double, double> CountsBS(TH1 *hist, double peakLow, double peakHigh, double backLow, double backHigh, std::string opt) {
120 GamR::Nucleus::Transition transition(0, peakLow, peakHigh, backLow, backHigh);
121 return CountsBS(hist, transition, opt);
122 }
123
124 std::pair<double, double> CountsBS(TCanvas *canvas/*=gPad->GetCanvas()*/)
125 {
126 TH1D *hist = GamR::Utils::GetHist1D(canvas);
127 if (!hist) { return std::pair<int, int>(-1, -1); }
128 GamR::Nucleus::Transition transition;
129 transition.SetTransition();
130 return CountsBS(hist, transition);
131 }
132 }
133}
134
135
double Apply(TH1D *hist) const
Definition Transition.cc:53
double ApplyCountsError(TH1D *hist) const
Definition Transition.cc:62
double ApplyError(TH1D *hist) const
Definition Transition.cc:56
double ApplyCounts(TH1D *hist) const
Definition Transition.cc:59
double GetCountsError(TH1 *hist) const
Definition Gate.cc:596
double GetLow() const
Definition Gate.hh:70
double GetCounts(TH1 *hist) const
Definition Gate.cc:495
int SetGate()
Definition Gate.cc:76
double GetIntegralError(TH1 *hist) const
Definition Gate.cc:411
double GetIntegral(TH1 *hist) const
Definition Gate.cc:266
double GetHigh() const
Definition Gate.hh:71
std::pair< double, double > IntegralBS(TH1 *hist, GamR::Nucleus::Transition transition)
Definition Integral.cc:40
std::pair< double, double > CountsBS(TH1 *hist, GamR::Nucleus::Transition transition, std::string opt)
Definition Integral.cc:94
std::pair< double, double > Counts(TH1 *hist, GamR::TK::Gate peak, std::string opt)
Definition Integral.cc:69
std::pair< double, double > Integral(TH1 *hist, GamR::TK::Gate peak)
Definition Integral.cc:18
TH1D * GetHist1D(TVirtualPad *canvas)
Definition Utilities.cc:182
Definition Gain.cc:19