OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
PeakFinder.h
Go to the documentation of this file.
1//
2// Class PeakFinder
3// Find peaks of radial profile.
4// It computes a histogram based on the radial distribution of the particle
5// bunch. After that all peaks of the histogram are searched.
6// The radii are written in ASCII format to a file.
7// This class is used for the cyclotron probe element.
8//
9// Copyright (c) 2017 - 2021, Matthias Frey, Jochem Snuverink, Paul Scherrer Institut, Villigen PSI,
10// Switzerland All rights reserved
11//
12// This file is part of OPAL.
13//
14// OPAL is free software: you can redistribute it and/or modify
15// it under the terms of the GNU General Public License as published by
16// the Free Software Foundation, either version 3 of the License, or
17// (at your option) any later version.
18//
19// You should have received a copy of the GNU General Public License
20// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
21//
22#ifndef PEAKFINDER_H
23#define PEAKFINDER_H
24
25#include "OPALTypes.h"
26
27#include <fstream>
28#include <list>
29#include <string>
30#include <vector>
31
33public:
34 using container_t = std::vector<double>;
35
36public:
37 PeakFinder() = delete;
38
39 PeakFinder(std::string elem, double min, double max, double binwidth, bool singlemode);
40
45 void addParticle(const Vector_t<double, 3>& R);
46
50 void evaluate(const int& turn);
51
52 void save();
53
54private:
55 // compute global histogram, involves some inter-node communication
56 void createHistogram_m();
57
58 /***************
59 * Output file *
60 ***************/
62 void open_m();
64 void append_m();
66 void close_m();
68 void saveASCII_m();
69
70 void computeCentroid_m();
71
72private:
76
78 std::string fileName_m;
79
81 std::string hist_m;
82
84 std::ofstream os_m;
85
87 std::ofstream hos_m;
88
90 std::string outputName_m;
91
92 // Histogram details
94 unsigned int nBins_m;
96 double binWidth_m;
98 double min_m, max_m;
99
103 std::list<double> peaks_m;
107};
108
109#endif
ippl::Vector< T, Dim > Vector_t
void addParticle(const Vector_t< double, 3 > &R)
std::vector< double > container_t
Definition PeakFinder.h:34
void open_m()
Open output file.
std::list< double > peaks_m
Definition PeakFinder.h:103
std::ofstream hos_m
used to write out the histrogram
Definition PeakFinder.h:87
PeakFinder()=delete
std::ofstream os_m
used to write out the data
Definition PeakFinder.h:84
double binWidth_m
Bin width in mm.
Definition PeakFinder.h:96
double peakRadius_m
Definition PeakFinder.h:101
container_t globHist_m
global histogram values
Definition PeakFinder.h:75
bool singlemode_m
Definition PeakFinder.h:104
void save()
container_t radius_m
Definition PeakFinder.h:73
bool finished_m
Definition PeakFinder.h:106
void createHistogram_m()
void computeCentroid_m()
double min_m
histogram size
Definition PeakFinder.h:98
unsigned int nBins_m
Number of bins.
Definition PeakFinder.h:94
std::string outputName_m
Element/probe name, for name output file.
Definition PeakFinder.h:90
void append_m()
Open output file in append mode.
std::string hist_m
histogram filename with extension (.hist)
Definition PeakFinder.h:81
std::string fileName_m
filename with extension (.peaks)
Definition PeakFinder.h:78
int registered_m
Definition PeakFinder.h:102
void evaluate(const int &turn)
void saveASCII_m()
Write to output file.
double max_m
Definition PeakFinder.h:98
void close_m()
Close output file.