OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
OpalFilter.h
Go to the documentation of this file.
1 #ifndef OPAL_FILTER_HH
2 #define OPAL_FILTER_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: OpalFilter.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: OpalFilter
13 //
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2008/10/14 09:33:44 $
17 // $Author: Christof Kraus $
18 //
19 // ------------------------------------------------------------------------
20 
21 #include <vector>
22 #include <memory>
24 #include "Filters/Filter.h"
25 
26 // Class OpalFilter
27 // ------------------------------------------------------------------------
29 // A FILTER definition is used to define a filter which can be applied
30 // to a 1D histogram in order to get rid of noise.
31 
32 class OpalFilter: public Definition {
33 
34 public:
35 
37  OpalFilter();
38 
39  virtual ~OpalFilter();
40 
42  // Can replace only by another OpalFilter
43  virtual bool canReplaceBy(Object *object);
44 
46  virtual OpalFilter *clone(const std::string &name);
47 
49  virtual void execute();
50 
52  static OpalFilter *find(const std::string &name);
53 
55  virtual void update();
56 
57  void print(std::ostream &os) const;
58 
59  void initOpalFilter();
60 
61  inline void apply(std::vector<double> &histogram);
62  inline void calc_derivative(std::vector<double> &histogram, const double &hz);
63 
65 private:
66 
67  // Not implemented.
69  void operator=(const OpalFilter &);
70 
71  // Clone constructor.
72  OpalFilter(const std::string &name, OpalFilter *parent);
73 
74 };
75 
76 void OpalFilter::apply(std::vector<double> &histogram) {
77  if(filter_m)
78  filter_m->apply(histogram);
79 }
80 
81 void OpalFilter::calc_derivative(std::vector<double> &histogram, const double &hz) {
82  if(filter_m)
83  filter_m->calc_derivative(histogram, hz);
84 }
85 
86 inline std::ostream &operator<<(std::ostream &os, const OpalFilter &b) {
87  b.print(os);
88  return os;
89 }
90 
91 #endif // OPAL_FILTER_HH
std::ostream & operator<<(std::ostream &os, const OpalFilter &b)
Definition: OpalFilter.h:86
const std::string name
The base class for all OPAL definitions.
Definition: Definition.h:30
The base class for all OPAL objects.
Definition: Object.h:48
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 FILTER definition.
Definition: OpalFilter.h:32
void calc_derivative(std::vector< double > &histogram, const double &hz)
Definition: OpalFilter.h:81
void initOpalFilter()
Definition: OpalFilter.cpp:142
OpalFilter(const OpalFilter &)
virtual void execute()
Check the OpalFilter data.
Definition: OpalFilter.cpp:121
virtual ~OpalFilter()
Definition: OpalFilter.cpp:104
static OpalFilter * find(const std::string &name)
Find named FILTER.
Definition: OpalFilter.cpp:126
Filter * filter_m
Definition: OpalFilter.h:64
virtual bool canReplaceBy(Object *object)
Test if replacement is allowed.
Definition: OpalFilter.cpp:110
virtual OpalFilter * clone(const std::string &name)
Make clone.
Definition: OpalFilter.cpp:116
void apply(std::vector< double > &histogram)
Definition: OpalFilter.h:76
void operator=(const OpalFilter &)
virtual void update()
Update the OpalFilter data.
Definition: OpalFilter.cpp:136
OpalFilter()
Exemplar constructor.
Definition: OpalFilter.cpp:57
void print(std::ostream &os) const
Print the object.
Definition: OpalFilter.cpp:187