46 std::cout <<
"\t senergy scent scalc sarea snuc sintensity" << std::endl;
47 for(
const auto& it :
fPeaks) {
49 double pdiff = std::abs(caleng - it.energy) / it.energy;
50 std::cout << counter++ <<
":\t" << std::setw(7) << it.energy << std::setw(16) << it.centroid << std::setw(8) << caleng
51 <<
" [%%" << std::setw(3) << pdiff * 100. <<
"]" << std::setw(16) << it.area << std::setw(8) << it.nucleus << std::setw(16) << it.intensity << std::endl;
53 std::cout <<
"-------------------------------" << std::endl;
59 std::string file = filename;
61 toprint.append(
"line\teng\tcounts\tt1/2\tactivity\n");
62 toprint.append(
"--------------------------------------\n");
63 for(
const auto& it :
fPeaks) {
65 Form(
"%i\t%.02f\t%.02f\t%i\t%.02f\n", counter++, it.energy, it.area, 100, (it.intensity / 100) * 1e5));
67 toprint.append(
"--------------------------------------\n");
69 if(file.length() != 0u) {
71 ofile.open(file.c_str());
75 std::cout << toprint << std::endl;
85 if(option.Contains(
"Q")) {
87 option.ReplaceAll(
"Q",
"");
89 std::vector<double> energy;
90 std::vector<double> error_e;
91 std::vector<double> observed;
92 std::vector<double> error_o;
93 for(
const auto& it :
fPeaks) {
94 energy.push_back(it.energy);
95 error_e.push_back(0.0);
96 observed.push_back((it.area / seconds) / ((it.intensity / 100) * bq));
97 error_o.push_back(observed.back() * (sqrt(it.area) / it.area));
101 fEffGraph = TGraphErrors(
static_cast<Int_t
>(
fPeaks.size()), energy.data(), observed.data(), error_e.data(), error_o.data());
106 static int counter = 0;
110 if(option.Contains(
"draw", TString::kIgnoreCase)) {
111 TVirtualPad* current = gPad;
114 if(current !=
nullptr) {
118 for(
unsigned int i = 0; i < energy.size(); i++) {
119 std::cout <<
"[" << energy.at(i) <<
"] Observed = " << observed.at(i) <<
" | Calculated = " <<
fEffFit->Eval(energy.at(i)) <<
" | per diff = "
120 << (std::abs(observed.at(i) -
fEffFit->Eval(energy.at(i))) / observed.at(i)) * 100. << std::endl;
228 if((data ==
nullptr) || (source ==
nullptr)) {
229 std::cout <<
"data not added. data = " << data <<
" \t source = " << source << std::endl;
232 int actual_x_max = std::floor(data->GetXaxis()->GetXmax());
233 int actual_x_min = std::floor(data->GetXaxis()->GetXmax());
234 int displayed_x_max = std::floor(data->GetXaxis()->GetBinUpEdge(data->GetXaxis()->GetLast()));
235 int displayed_x_min = std::floor(data->GetXaxis()->GetBinLowEdge(data->GetXaxis()->GetFirst()));
238 if((actual_x_max == displayed_x_max) && (actual_x_min == displayed_x_min)) {
239 name = source->GetName();
241 name = Form(
"%s_%i_%i", source->GetName(), displayed_x_min, displayed_x_max);
245 std::vector<double> source_energy;
246 std::map<double, double> src_eng_int;
247 while(
auto* transition =
static_cast<TTransition*
>(iter.Next())) {
248 source_energy.push_back(transition->GetEnergy());
249 src_eng_int[transition->GetEnergy()] = transition->GetIntensity();
251 std::sort(source_energy.begin(), source_energy.end());
254 spectrum.Search(data, sigma,
"", threshold);
255 std::vector<double> data_channels;
256 std::map<double, double> peak_area;
257 for(
int x = 0; x < spectrum.GetNPeaks(); x++) {
258 double range = 8 * data->GetXaxis()->GetBinWidth(1);
260 PhotoPeakFit(data, spectrum.GetPositionX()[x] - range, spectrum.GetPositionX()[x] + range,
"no-print");
263 data->GetListOfFunctions()->Remove(fit);
267 std::map<double, double> datatosource =
Match(data_channels, source_energy);
269 for(
const auto& it : datatosource) {
270 AddPeak(it.first, it.second, source->GetName(), peak_area.at(it.first), src_eng_int[it.second]);
275 for(
const auto& it : datatosource) {
276 if(!std::isnan(it.second)) {
301 std::map<double, double> map;
302 std::sort(peaks.begin(), peaks.end());
303 std::sort(source.begin(), source.end());
308 std::vector<bool> filled(source.size());
309 std::fill(filled.begin(), filled.begin() + peaks.size(),
true);
311 TLinearFitter fitter(1,
"1 ++ x");
313 for(
size_t num_data_points = peaks.size(); num_data_points > 0; num_data_points--) {
314 double best_chi2 = DBL_MAX;
315 for(
auto peak_values :
combinations(peaks, num_data_points)) {
317 peak_values.push_back(0);
318 for(
auto source_values :
combinations(source, num_data_points)) {
319 source_values.push_back(0);
321 if(peaks.size() > 3) {
322 double max_err = 0.02;
323 double pratio = peak_values.front() / peak_values.at(peak_values.size() - 2);
324 double sratio = source_values.front() / source_values.at(source_values.size() - 2);
326 if(std::abs(pratio - sratio) > max_err) {
332 fitter.ClearPoints();
333 fitter.AssignData(
static_cast<Int_t
>(source_values.size()), 1, peak_values.data(), source_values.data());
336 if(fitter.GetChisquare() < best_chi2) {
338 for(
size_t i = 0; i < num_data_points; i++) {
339 map[peak_values[i]] = source_values[i];
341 best_chi2 = fitter.GetChisquare();
348 std::vector<double> peak_values;
349 std::vector<double> source_values;
350 for(
auto& item : map) {
351 peak_values.push_back(item.first);
352 source_values.push_back(item.second);
355 for(
size_t skipped_point = 0; skipped_point < source_values.size(); skipped_point++) {
356 std::swap(peak_values[skipped_point], peak_values.back());
357 std::swap(source_values[skipped_point], source_values.back());
359 fitter.ClearPoints();
360 fitter.AssignData(
static_cast<Int_t
>(source_values.size() - 1), 1, peak_values.data(), source_values.data());
363 if(std::abs(fitter.GetParameter(0)) > 10) {
368 std::swap(peak_values[skipped_point], peak_values.back());
369 std::swap(source_values[skipped_point], source_values.back());