OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
OpalFilter.h
Go to the documentation of this file.
1//
2// Class OpalFilter
3// The class for the Filter Object.
4// A FILTER definition is used to define a filter which can be applied
5// to a 1D histogram in order to get rid of noise.
6//
7// Copyright (c) 2008 - 2022, Christof Metzger-Kraus
8// All rights reserved
9//
10// This file is part of OPAL.
11//
12// OPAL is free software: you can redistribute it and/or modify
13// it under the terms of the GNU General Public License as published by
14// the Free Software Foundation, either version 3 of the License, or
15// (at your option) any later version.
16//
17// You should have received a copy of the GNU General Public License
18// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
19//
20#ifndef OPAL_FILTER_HH
21#define OPAL_FILTER_HH
22
24#include "Filters/Filter.h"
25
26#include <memory>
27#include <vector>
28
29class OpalFilter : public Definition {
30public:
32 OpalFilter();
33
34 virtual ~OpalFilter();
35
37 // Can replace only by another OpalFilter
38 virtual bool canReplaceBy(Object* object);
39
41 virtual OpalFilter* clone(const std::string& name);
42
44 virtual void execute();
45
47 static OpalFilter* find(const std::string& name);
48
50 virtual void update();
51
52 void print(std::ostream& os) const;
53
54 void initOpalFilter();
55
56 inline void apply(std::vector<double>& histogram);
57 inline void calc_derivative(std::vector<double>& histogram, const double& hz);
58
60
61private:
62 enum class FilterType : unsigned short {
67 };
68
69 // Not implemented.
71 void operator=(const OpalFilter&);
72
73 // Clone constructor.
74 OpalFilter(const std::string& name, OpalFilter* parent);
75};
76
77void OpalFilter::apply(std::vector<double>& histogram) {
78 if (filter_m) filter_m->apply(histogram);
79}
80
81void OpalFilter::calc_derivative(std::vector<double>& histogram, const double& hz) {
82 if (filter_m) filter_m->calc_derivative(histogram, hz);
83}
84
85inline std::ostream& operator<<(std::ostream& os, const OpalFilter& b) {
86 b.print(os);
87 return os;
88}
89
90#endif // OPAL_FILTER_HH
std::ostream & operator<<(std::ostream &os, const OpalFilter &b)
Definition OpalFilter.h:85
The base class for all OPAL definitions.
Definition Definition.h:29
Definition Filter.h:8
virtual void calc_derivative(std::vector< double > &histogram, const double &h)=0
virtual void apply(std::vector< double > &histogram)=0
The base class for all OPAL objects.
Definition Object.h:45
void calc_derivative(std::vector< double > &histogram, const double &hz)
Definition OpalFilter.h:81
void initOpalFilter()
OpalFilter(const OpalFilter &)
virtual void execute()
Check the OpalFilter data.
virtual ~OpalFilter()
static OpalFilter * find(const std::string &name)
Find named FILTER.
Filter * filter_m
Definition OpalFilter.h:59
virtual bool canReplaceBy(Object *object)
Test if replacement is allowed.
virtual OpalFilter * clone(const std::string &name)
Make clone.
void apply(std::vector< double > &histogram)
Definition OpalFilter.h:77
void operator=(const OpalFilter &)
virtual void update()
Update the OpalFilter data.
OpalFilter()
Exemplar constructor.
void print(std::ostream &os) const
Print the object.