GamR  0.0.0
GammaROOT
Loading...
Searching...
No Matches
Transition.cc
Go to the documentation of this file.
1#include <fstream>
2
3#include "Transition.hh"
4
6 GamR::TK::Gate tempgate;
7 tempgate.SetGate();
8 this->fBackground.push_back(tempgate);
9}
10
11void GamR::Nucleus::Transition::AddBackground(double Low, double High) {
12 GamR::TK::Gate tempgate;
13 tempgate.SetGate(Low,High);
14 this->fBackground.push_back(tempgate);
15}
16
17GamR::Nucleus::TransitionMap::TransitionMap(const char *name, std::string asciimapfilename) : TNamed(name, name) {
18 this->ReadFile(asciimapfilename);
19}
20
21void GamR::Nucleus::TransitionMap::ReadFile(std::string asciimapfilename) {
22 std::ifstream asciimapfile (asciimapfilename.c_str());
23 std::string type;
24 std::string key;
25 double lowin;
26 double highin;
27 fMap.clear();
28 while (asciimapfile >> type >> key >> lowin >> highin) {
29 if (type=="[peak]") {
30 this->fMap[key].SetPeak(lowin,highin);
31 } else if (type=="[back]") {
32 this->fMap[key].AddBackground(lowin,highin);
33 }
34 }
35}
36
37void GamR::Nucleus::TransitionMap::WriteFile(std::string asciimapfilename) {
38 std::ofstream asciimapfile(asciimapfilename.c_str());
39
40 for (auto i = fMap.begin(); i != fMap.end(); ++i) {
41 asciimapfile << "[peak]" << " " << i->first << " "
42 << (i->second).GetGate()->GetLow() << " " << (i->second).GetGate()->GetHigh() << std::endl;
43 for (int ibackgate = 0; ibackgate<(i->second.GetGateBGs())->size(); ++ibackgate ) {
44 asciimapfile << "[back]" << " " << i->first << " "
45 << (*(i->second).GetGateBGs())[ibackgate].GetLow() << " " << (*(i->second).GetGateBGs())[ibackgate].GetHigh() << std::endl;
46
47 }
48 }
49
50 asciimapfile.close();
51}
52
53double GamR::Nucleus::Transition::Apply(TH1D *hist) const {
54 return this->GetGate()->GetIntegral(hist, *(this->GetGateBGs()));
55}
56double GamR::Nucleus::Transition::ApplyError(TH1D *hist) const {
57 return this->GetGate()->GetIntegralError(hist, *(this->GetGateBGs()));
58}
60 return this->GetGate()->GetCounts(hist, *(this->GetGateBGs()));
61}
63 return this->GetGate()->GetCountsError(hist, *(this->GetGateBGs()));
64}
double Apply(TH1D *hist) const
Definition Transition.cc:53
const GamR::TK::Gate * GetGate() const
Definition Transition.hh:39
double ApplyCountsError(TH1D *hist) const
Definition Transition.cc:62
std::vector< GamR::TK::Gate > fBackground
Definition Transition.hh:21
const std::vector< GamR::TK::Gate > * GetGateBGs() const
Definition Transition.hh:41
double ApplyError(TH1D *hist) const
Definition Transition.cc:56
double ApplyCounts(TH1D *hist) const
Definition Transition.cc:59
void WriteFile(std::string asciimapfilename)
Definition Transition.cc:37
void ReadFile(std::string asciimapfilename)
Definition Transition.cc:21
int SetGate()
Definition Gate.cc:76