CbmRoot
Loading...
Searching...
No Matches
LandauTable.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Felix Weiglhofer [committer] */
5
7
8#include <fstream>
9#include <sstream>
10
11using namespace cbm::algo;
12
14{
15 sts::LandauTable table;
16
17 if (!fs::exists(path)) {
18 std::stringstream msg;
19 msg << "sts::LandauTable: file " << path.string() << " does not exist";
20 throw std::runtime_error(msg.str());
21 }
22
23 std::vector<f32> charge;
24 std::vector<f32> prob;
25 std::ifstream file(path.string());
26
27 while (!file.eof()) {
28
29 f32 q, p;
30 file >> q >> p;
31 charge.push_back(q);
32 prob.push_back(p);
33
34 L_(trace) << "Reading Landau table " << path << " q=" << q << " p=" << p;
35 }
36
37 // TODO: check if charge is monotonically increasing, also more than 2 entries
38
39 table.stepSize = charge[1] - charge[0];
40 table.values = std::move(prob);
41
42 return table;
43}
#define L_(level)
float f32
Definition Definitions.h:24
static LandauTable FromFile(fs::path path)
std::vector< f32 > values
Definition LandauTable.h:19