OPAL (Object Oriented Parallel Accelerator Library)
2024.2
OPAL
ProbeHistReader.h
Go to the documentation of this file.
1
//
2
// Class ProbeHistReader
3
// Implements a parser and value extractor for hist files (*.hist).
4
// It is for example used together with the septum objective.
5
// A histogram file is generated by the OPAL probe element.
6
//
7
// Copyright (c) 2019, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
8
// All rights reserved
9
//
10
// Implemented as part of the PhD thesis
11
// "Precise Simulations of Multibunches in High Intensity Cyclotrons"
12
//
13
// This file is part of OPAL.
14
//
15
// OPAL is free software: you can redistribute it and/or modify
16
// it under the terms of the GNU General Public License as published by
17
// the Free Software Foundation, either version 3 of the License, or
18
// (at your option) any later version.
19
//
20
// You should have received a copy of the GNU General Public License
21
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
22
//
23
#ifndef __PROBE_HIST_READER_H__
24
#define __PROBE_HIST_READER_H__
25
26
#include <fstream>
27
#include <sstream>
28
#include <string>
29
#include <vector>
30
31
class
ProbeHistReader
{
32
33
public
:
34
typedef
std::vector<size_t>
container_t
;
35
36
ProbeHistReader
(std::string filename);
37
38
void
parseFile
();
39
44
size_t
minimum
(
double
lower,
double
upper);
45
46
private
:
47
void
parseHeader
(std::ifstream& ifs);
48
49
template
<
typename
T>
50
T
getValue
(
const
std::string& s);
51
53
std::string
filename_m
;
54
55
double
rmin_m
;
// start radius of probe in mm
56
double
binwidth_m
;
// size of each bin in mm
57
58
container_t
bincount_m
;
59
};
60
61
62
template
<
typename
T>
63
T
ProbeHistReader::getValue
(
const
std::string& s) {
64
std::istringstream ss(s);
65
T res;
66
ss >> res;
67
return
res;
68
}
69
70
#endif
ProbeHistReader::minimum
size_t minimum(double lower, double upper)
Definition
ProbeHistReader.cpp:65
ProbeHistReader::filename_m
std::string filename_m
Histogram file.
Definition
ProbeHistReader.h:53
ProbeHistReader::container_t
std::vector< size_t > container_t
Definition
ProbeHistReader.h:34
ProbeHistReader::ProbeHistReader
ProbeHistReader(std::string filename)
Definition
ProbeHistReader.cpp:29
ProbeHistReader::parseFile
void parseFile()
Definition
ProbeHistReader.cpp:37
ProbeHistReader::binwidth_m
double binwidth_m
Definition
ProbeHistReader.h:56
ProbeHistReader::getValue
T getValue(const std::string &s)
Definition
ProbeHistReader.h:63
ProbeHistReader::parseHeader
void parseHeader(std::ifstream &ifs)
Definition
ProbeHistReader.cpp:99
ProbeHistReader::rmin_m
double rmin_m
Definition
ProbeHistReader.h:55
ProbeHistReader::bincount_m
container_t bincount_m
Definition
ProbeHistReader.h:58