OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
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, Switzerland
10// 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 "Algorithms/Vektor.h"
26
27#include <fstream>
28#include <list>
29#include <string>
30#include <vector>
31
33
34public:
35 using container_t = std::vector<double>;
36
37public:
38 PeakFinder() = delete;
39
40 PeakFinder(const std::string& elem, double min, double max, double binwidth, bool singlemode);
41
46 void addParticle(const Vector_t& R);
47
51 void evaluate(const int& turn);
52
53 void save();
54
55private:
56 // compute global histogram, involves some inter-node communication
57 void createHistogram_m();
58
59 /***************
60 * Output file *
61 ***************/
63 void open_m();
65 void append_m();
67 void close_m();
69 void saveASCII_m();
70
71 void computeCentroid_m();
72
73private:
77
79 std::string fileName_m;
80
82 std::string hist_m;
83
85 std::ofstream os_m;
86
88 std::ofstream hos_m;
89
91 std::string outputName_m;
92
93 // Histogram details
95 unsigned int nBins_m;
97 double binWidth_m;
99 double min_m, max_m;
100
104 std::list<double> peaks_m;
108};
109
110#endif
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
std::vector< double > container_t
Definition PeakFinder.h:35
void open_m()
Open output file.
std::list< double > peaks_m
Definition PeakFinder.h:104
std::ofstream hos_m
used to write out the histrogram
Definition PeakFinder.h:88
PeakFinder()=delete
std::ofstream os_m
used to write out the data
Definition PeakFinder.h:85
double binWidth_m
Bin width in mm.
Definition PeakFinder.h:97
double peakRadius_m
Definition PeakFinder.h:102
container_t globHist_m
global histogram values
Definition PeakFinder.h:76
bool singlemode_m
Definition PeakFinder.h:105
void save()
container_t radius_m
Definition PeakFinder.h:74
bool finished_m
Definition PeakFinder.h:107
void createHistogram_m()
void computeCentroid_m()
double min_m
histogram size
Definition PeakFinder.h:99
unsigned int nBins_m
Number of bins.
Definition PeakFinder.h:95
std::string outputName_m
Element/probe name, for name output file.
Definition PeakFinder.h:91
void append_m()
Open output file in append mode.
std::string hist_m
histogram filename with extension (.hist)
Definition PeakFinder.h:82
std::string fileName_m
filename with extension (.peaks)
Definition PeakFinder.h:79
int registered_m
Definition PeakFinder.h:103
void evaluate(const int &turn)
void saveASCII_m()
Write to output file.
void addParticle(const Vector_t &R)
double max_m
Definition PeakFinder.h:99
void close_m()
Close output file.