BmnRoot
Loading...
Searching...
No Matches
BmnFieldParser.h
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- BmnFieldParser header file -----
3// ----- Created 28/06/22 by M.Mamaev, S.Merts -----
4// -------------------------------------------------------------------------
5
6#ifndef BMN_FIELD_PARSER_H_
7#define BMN_FIELD_PARSER_H_
8
9// #include <string>
10// #include <vector>
11// #include <algorithm>
12// #include <stdexcept>
13// #include <limits>
14// #include <cassert>
15
16#include "BmnFieldPoint.h"
17#include "TString.h"
18#include <vector>
19#include <map>
20#include <iostream> // std::cout
21#include <sstream> // std::istringstream
22#include <fstream>
23
24using namespace std;
25
26class BmnFieldParser {
27public:
28 // The method reads the field points from the data
29 //vector<BmnFieldPoint> ParseData(TString file_name);
30 vector<BmnFieldPoint> ParseData(TString file_name, Bool_t shift = kTRUE);
31 map<pair<Int_t, Int_t>, BmnFieldPoint> ParseDataMap(TString file_name, Bool_t shift = kTRUE);
32
35
36
37
38 // The method sorts the large heap of field points into smaller ones so that
39 // each heap will be unique on this coordinate.
40 // { x1, x1, x1, x2, x2, x2, ... } ->
41 // {x1, x2, ... }
42 // {x1, x2, ... }
43 // {x1, x2, ... }
44 // template <typename T>
45 // static vector<vector<BmnFieldPoint>> SortPoints(const vector<BmnFieldPoint>& points, T coordinate) {
46 // vector<vector<BmnFieldPoint>> sorted_points;
47 // if (points.empty())
48 // throw runtime_error("Field Points are empty");
49 // auto copy_field_points = move(sorted_points);
50 // vector<vector<double>> sort_coordinates;
51 // sorted_points.emplace_back();
52 // sort_coordinates.emplace_back();
53
54 // for (auto& point : points) {
55 // auto x = coordinate(point);
56 // vector<int> number_of_inclusions;
57 // for (auto data : sorted_points) {
58 // auto n_ins = count_if(data.begin(), data.end(), [x, coordinate](BmnFieldPoint p) {
59 // return fabs(coordinate(p) - x) < numeric_limits<float>::min();
60 // });
61 // number_of_inclusions.push_back(n_ins);
62 // }
63 // bool is_filled = false;
64 // for (size_t i = 0; i < number_of_inclusions.size(); ++i) {
65 // if (number_of_inclusions.at(i) == 0) {
66 // sorted_points.at(i).push_back(point);
67 // is_filled = true;
68 // }
69 // }
70 // if (!is_filled) {
71 // sorted_points.emplace_back();
72 // sorted_points.back().push_back(point);
73 // }
74 // }
75 // for (auto& ds : sorted_points) {
76 // sort(ds.begin(), ds.end(), [coordinate](BmnFieldPoint a, BmnFieldPoint b) {
77 // return coordinate(a) < coordinate(b);
78 // });
79 // }
80 // return sorted_points;
81 // }
82
83
84};
85
86#endif // BMN_FIELD_PARSER_H_
vector< BmnFieldPoint > ParseData(TString file_name, Bool_t shift=kTRUE)
map< pair< Int_t, Int_t >, BmnFieldPoint > ParseDataMap(TString file_name, Bool_t shift=kTRUE)
STL namespace.