OPAL (Object Oriented Parallel Accelerator Library) 2022.1
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
32
33public:
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
46private:
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
59};
60
61
62template <typename T>
63T ProbeHistReader::getValue(const std::string& s) {
64 std::istringstream ss(s);
65 T res;
66 ss >> res;
67 return res;
68}
69
70#endif
size_t minimum(double lower, double upper)
std::string filename_m
Histogram file.
std::vector< size_t > container_t
ProbeHistReader(std::string filename)
T getValue(const std::string &s)
void parseHeader(std::ifstream &ifs)
container_t bincount_m