CFEL - ASG Software Suite  2.5.0
CASS
commonmode_calculator_base.cpp
Go to the documentation of this file.
1 // Copyright (C) 2011 Lutz Foucar
2 
3 /**
4  * @file commonmode_calculator_base.cpp contains base class for all common mode
5  * calculators.
6  *
7  * @author Lutz Foucar
8  */
9 
10 #include <stdexcept>
11 
13 
14 #include "commonmode_calculators.h"
15 #include "common_data.h"
16 #include "cass_settings.h"
17 
18 using namespace cass;
19 using namespace pixeldetector;
20 using namespace commonmode;
21 using namespace std;
22 using namespace std::tr1;
23 
24 namespace cass
25 {
26 namespace pixeldetector
27 {
28 namespace commonmode
29 {
30 /** Just returns a constant 0.
31  *
32  * this functor will just return 0 with any calculation with effectively will
33  * make sure that no common mode correction will be done:
34  *
35  * @author Lutz Foucar
36  */
37 class NoCalc : public CalculatorBase
38 {
39 public:
40  /** no operation performed
41  *
42  * @return 0.
43  * @param pixel unused
44  * @param idx unused
45  */
46  Detector::pixel_t operator ()(Detector::frame_t::const_iterator /*pixel*/, size_t /*idx*/)const {return 0;}
47 
48  /** need to load the settings of the base class loaded */
49  void loadSettings(CASSSettings& s) {load(s);}
50 };
51 }//end namespace commonmode
52 }//end namespace pixeldetector
53 }//end namespace cass
54 
56 {
57  shared_pointer ptr;
58  if (type == "none")
59  ptr = shared_pointer(new NoCalc());
60  else if (type == "mean")
61  ptr = shared_pointer(new MeanCalculator());
62  else if (type == "simpleMean")
64  else if (type == "median")
65  ptr = shared_pointer(new MedianCalculator());
66  else
67  throw invalid_argument("CalculatorBase::instance: Common Mode Calculator type '" + type +
68  "' is unknown.");
69  return ptr;
70 }
71 
73 {
74  string detectorname(DetectorName::fromSettings(s));
75  _commondata = CommonData::instance(detectorname);
76  s.beginGroup("CommonModeCorrection");
77  _nbrPixels = s.value("Width",128).toUInt();
78  _multiplier = s.value("Multiplier",4).toUInt();
79  s.endGroup();
80 }
std::tr1::shared_ptr< CalculatorBase > shared_pointer
typedef the shared pointer of this
contains base class for all common mode calculators.
Settings for CASS.
Definition: cass_settings.h:30
STL namespace.
Calculate the common mode by taking the median of pixel values.
Calculate the common mode by taking mean of pixel values.
float pixel_t
define a pixel of the pixel detector
void load(CASSSettings &s)
load all common settings
void loadSettings(CASSSettings &s)
need to load the settings of the base class loaded
static std::string fromSettings(const CASSSettings &s)
retrieve it from the casssettings
Definition: common_data.h:47
value(const QString &key, const QVariant &defaultValue=QVariant()
static shared_pointer instance(const std::string &type)
create an instance of the requested functor
contains the common data for one advanced pixeldetector
file contains specialized class that do the settings for cass
contains all available common mode calculators.
static shared_pointer instance(const instancesmap_t::key_type &detector)
static function creating instance of this.
Calculate the common mode by taking mean of pixel values.
base class for all common mode calculators
beginGroup(const QString &prefix)