14 template <
typename arg_type>
17 template <
typename arg_type>
29 std::vector<T>
merge(
const std::vector<T> &
vec1,
const std::vector<T> &
vec2);
41 std::array<std::array<float, 2>, 2>
get_intercept(std::array<float, 2>
m1, std::array<float, 2>
q1, std::array<float, 2>
m2, std::array<float, 2>
q2) {
return get_intercept(
m1[0],
m1[1],
q1[0],
q1[1],
m2[0],
m2[1],
q2[0],
q2[1]); };
42 std::array<std::array<float, 2>, 2>
get_intercept_x(
float m,
float em,
float q,
float eq) {
return utility::get_intercept(
m,
em,
q,
eq, 0, 0, 0, 0); };
44 std::array<std::array<float, 2>, 2>
get_intercept_pol1_pol2(
float x0_1,
float ex0_1,
float x1_1,
float ex1_1,
float x0_2,
float ex0_2,
float x1_2,
float ex1_2,
float x2_2,
float ex2_2);
48template <
typename arg_type>
56template <
typename arg_type>
72 static_assert(std::is_arithmetic<T>::value,
"Type must be numeric");
87 std::vector<std::string>
folders;
88 for (
const auto &
entry : std::filesystem::directory_iterator(
dir_path))
89 if (
entry.is_directory())
101 std::map<std::string, std::array<T, 2>>
result;
159 if (!std::filesystem::exists(
filename))
161 throw std::runtime_error(
"[ERROR][readFileToMap] File does not exist: " +
filename);
167 throw std::runtime_error(
"[ERROR][readFileToMap] Could not open file " +
filename);
174 throw std::runtime_error(
"[ERROR][readFileToMap] File " +
filename +
" is empty or missing header row.");
180 std::cerr <<
"[ERROR][utility::readFileToMap] Filename too short to determine file type: " <<
filename << std::endl;
207 const std::regex
validPattern(R
"(^\s*[+-]?[0-9]+(\.[0-9]*)?([eE][+-]?[0-9]+)?\s*$)");
211 while (std::getline(file,
line))
217 while ((
end =
line.find(
',',
start)) != std::string::npos)
226 throw std::runtime_error(
"[ERROR][readFileToMap] Mismatched data and header columns in file " +
filename);
251 std::cout <<
"[WARNING] Skipping line for character incompatibility: " <<
line << std::endl;
260 if (!std::filesystem::exists(
filename))
262 throw std::runtime_error(
"[ERROR][readFileToMap] File does not exist: " +
filename);
268 throw std::runtime_error(
"[ERROR][readFileToMap] Could not open file " +
filename);
275 throw std::runtime_error(
"[ERROR][readFileToMap] File " +
filename +
" is empty or missing header row.");
292 const std::regex
validPattern(R
"(^\s*[+-]?[0-9]+(\.[0-9]*)?([eE][+-]?[0-9]+)?\s*$)");
296 while (std::getline(file,
line))
308 throw std::runtime_error(
"[ERROR][readFileToMap] Mismatched data and header columns.");
330 cout <<
"[WARNING] Skipping line for character incompatibility" <<
endl;
338 if (!std::filesystem::exists(
filename))
340 throw std::runtime_error(
"[ERROR][readFileToMap] File does not exist: " +
filename);
346 throw std::runtime_error(
"[ERROR][readFileToMap] Could not open file " +
filename);
353 throw std::runtime_error(
"[ERROR][readFileToMap] File " +
filename +
" is empty or missing header row.");
359 std::cerr <<
"[ERROR][utility::readFileToMap] Filename too short to determine file type: " <<
filename << std::endl;
381 std::cerr <<
"[WARNING][utility::readFileToMap] Unknown file type: " <<
filename <<
", treating as txt" << std::endl;
391 std::array<std::array<float, 2>, 2>
result;
401 std::array<std::array<float, 2>, 2>
result = {0};
468 std::array<std::array<float, 2>, 2>
result = {0};
TH2_Type * build_fine_tune_raw_histogram(std::vector< TString > kInputFileNames, TString kRunTag, TString kOutputFileName, bool kRecalculate)
Functions -------------------------------------------------------------------------------------------...
Definition fine_analysis.h:80
Definition general_utility.h:12
void readTxtToMap(const std::string &filename, std::map< std::string, std::vector< std::string > > &dataMap)
Definition general_utility.h:258
void swap_values(arg_type &first_element, arg_type &second_element)
Definition general_utility.h:49
arg_type sq_sum(arg_type value)
Definition general_utility.h:57
std::array< std::array< float, 2 >, 2 > get_intercept_pol1_pol1(float x0_1, float ex0_1, float x1_1, float ex1_1, float x0_2, float ex0_2, float x1_2, float ex1_2)
Definition general_utility.h:395
std::map< std::string, std::array< T, 2 > > average(std::vector< std::array< T, 2 > > list_of_measurements, bool skip_unfit_skim=false)
Definition general_utility.h:98
std::vector< std::string > get_folders(const std::string &dir_path)
Definition general_utility.h:85
std::array< std::array< float, 2 >, 2 > get_intercept_tf1(TF1 *first_target, TF2 *second_target, double first_guess, double starting_coarse, double req_precision)
Definition general_utility.h:465
std::array< std::array< float, 2 >, 2 > get_intercept_pol1_pol2(float x0_1, float ex0_1, float x1_1, float ex1_1, float x0_2, float ex0_2, float x1_2, float ex1_2, float x2_2, float ex2_2)
std::array< std::array< float, 2 >, 2 > get_intercept_y(float m, float em, float q, float eq)
Definition general_utility.h:43
std::array< std::array< float, 2 >, 2 > get_intercept(float x0_1, float ex0_1, float x1_1, float ex1_1, float x0_2, float ex0_2, float x1_2, float ex1_2)
Definition general_utility.h:385
T round_digits(T value, int digits)
Definition general_utility.h:69
std::vector< T > merge(const std::vector< T > &vec1, const std::vector< T > &vec2)
Definition general_utility.h:78
void readFileToMap(const std::string &filename, std::map< std::string, std::vector< std::string > > &dataMap)
Definition general_utility.h:336
void readCsvToMap(const std::string &filename, std::map< std::string, std::vector< std::string > > &dataMap)
Definition general_utility.h:157
std::array< std::array< float, 2 >, 2 > get_intercept_x(float m, float em, float q, float eq)
Definition general_utility.h:42