BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnFieldParser.cxx
Go to the documentation of this file.
1
2
// -------------------------------------------------------------------------
3
// ----- BmnFieldParser source file -----
4
// ----- Created 28/06/22 by M.Mamaev, S.Merts -----
5
// -------------------------------------------------------------------------
6
7
#include "
BmnFieldParser.h
"
8
9
vector<BmnFieldPoint>
BmnFieldParser::ParseData
(
TString
file_name,
Bool_t
doShift)
10
{
11
cout <<
"Reading file: "
<< file_name << endl;
12
Int_t
idxStart = file_name.
Index
(
"file_"
) + 5;
13
Int_t
idxEnd = file_name.
Index
(
"_CW."
);
14
TString
shift = file_name(idxStart, idxEnd - idxStart);
15
TString
fileIdx = shift(0, shift.
Index
(
"_"
));
16
Int_t
yShift = (doShift) ?
TString
(shift(shift.
Index
(
"_"
) + 1, shift.
Length
() - shift.
Index
(
"_"
) - 1)).
Atoi
() : 0;
17
cout <<
"File index: "
<< fileIdx <<
" Y shift = "
<< yShift << endl;
18
ifstream in_file(file_name);
19
if
(!in_file.is_open())
20
throw
runtime_error(
"Unable to read file "
+ file_name);
21
string
line;
22
size_t
line_number = 0;
23
vector<BmnFieldPoint> field_points;
24
while
(getline(in_file, line)) {
25
istringstream stream(line);
26
// Skipping the title of the table
27
if
(line_number == 0) {
28
line_number++;
29
continue
;
30
}
31
Double_t
enc_pos = 0;
32
Double_t
x = 0, y = 0, z = 0;
33
Double_t
mon = 0;
34
Double_t
bx = 0, by = 0, bz = 0;
35
stream >> enc_pos >> x >> y >> z >> mon >> bx >> by >> bz;
36
field_points.push_back(
BmnFieldPoint
(x, y + yShift, z, bx, by, bz));
37
line_number++;
38
}
39
cout << field_points.size() <<
" points are read"
<< endl;
40
return
field_points;
41
}
42
43
map<pair<Int_t, Int_t>,
BmnFieldPoint
>
BmnFieldParser::ParseDataMap
(
TString
file_name,
Bool_t
doShift)
44
{
45
cout <<
"Reading file: "
<< file_name << endl;
46
Int_t
idxStart = file_name.
Index
(
"file_"
) + 5;
47
Int_t
idxEnd = file_name.
Index
(
"_CW."
);
48
TString
shift = file_name(idxStart, idxEnd - idxStart);
49
TString
fileIdx = shift(0, shift.
Index
(
"_"
));
50
Int_t
yShift = (doShift) ?
TString
(shift(shift.
Index
(
"_"
) + 1, shift.
Length
() - shift.
Index
(
"_"
) - 1)).
Atoi
() : 0;
51
cout <<
"File index: "
<< fileIdx <<
" Y shift = "
<< yShift << endl;
52
ifstream in_file(file_name);
53
if
(!in_file.is_open())
54
throw
runtime_error(
"Unable to read file "
+ file_name);
55
string
line;
56
size_t
line_number = 0;
57
map<pair<Int_t, Int_t>,
BmnFieldPoint
> field_points;
58
while
(getline(in_file, line)) {
59
istringstream stream(line);
60
// Skipping the title of the table
61
if
(line_number == 0) {
62
line_number++;
63
continue
;
64
}
65
Double_t
enc_pos = 0;
66
Double_t
x = 0, y = 0, z = 0;
67
Double_t
mon = 0;
68
Double_t
bx = 0, by = 0, bz = 0;
69
stream >> enc_pos >> x >> y >> z >> mon >> bx >> by >> bz;
70
if
(
Int_t
(y + yShift) == 3075)
71
cout <<
Int_t
(x) <<
" "
<<
Int_t
(y + yShift) << endl;
72
field_points.insert(pair<pair<Int_t, Int_t>,
BmnFieldPoint
>(pair<Int_t, Int_t>(
Int_t
(x),
Int_t
(y + yShift)),
73
BmnFieldPoint
(x, y + yShift, z, bx, by, bz)));
74
line_number++;
75
}
76
cout << field_points.size() << endl;
77
cout << field_points.size() <<
" points are read"
<< endl;
78
return
field_points;
79
}
Bool_t
bool Bool_t
Int_t
int Int_t
Double_t
double Double_t
BmnFieldParser::ParseData
vector< BmnFieldPoint > ParseData(TString file_name, Bool_t shift=kTRUE)
Definition
BmnFieldParser.cxx:9
BmnFieldParser::ParseDataMap
map< pair< Int_t, Int_t >, BmnFieldPoint > ParseDataMap(TString file_name, Bool_t shift=kTRUE)
Definition
BmnFieldParser.cxx:43
BmnFieldPoint
Definition
BmnFieldPoint.h:16
TString
TString::Length
Ssiz_t Length() const
TString::Atoi
Int_t Atoi() const
TString::Index
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
BmnFieldParser.h
field
BmnFieldParser.cxx
Generated on
for BmnRoot by
1.17.0