SourceXtractorPlusPlus  0.10
Please provide a description of the project.
CoreThresholdPartitionConfig.cpp
Go to the documentation of this file.
1 
17 /*
18  * CoreThresholdPartitionConfig.cpp
19  *
20  * Created on: May 28, 2019
21  * Author: mkuemmel@usm.lmu.de
22  */
23 
25 
27 
31 
32 
33 namespace po = boost::program_options;
34 using namespace Euclid::Configuration;
35 
36 namespace SourceXtractor {
37 
38 static const std::string CORE_THRESHOLD {"core-threshold-value" };
39 static const std::string CORE_MINAREA {"core-minimum-area" };
40 static const std::string CORE_THRESH_USE {"partition-corethreshold" };
41 
42 CoreThresholdPartitionConfig::CoreThresholdPartitionConfig(long manager_id)
43  : Configuration(manager_id), m_core_threshold(0.), m_core_minarea(0) {
44  declareDependency<PartitionStepConfig>();
45 
46  ConfigManager::getInstance(manager_id).registerDependency<CoreThresholdPartitionConfig, MultiThresholdPartitionConfig>();
47 }
48 
50  return {{"Core threshold partitioning", {
51  {CORE_THRESHOLD.c_str(), po::value<double>()->default_value(0.0), "The core threshold level"},
52  {CORE_MINAREA.c_str(), po::value<int>()->default_value(0), "The minimum pixel area for partitioning"},
53  {CORE_THRESH_USE.c_str(), po::bool_switch(), "Activate core threshold partitioning"}
54  }}};
55 }
56 
58  m_core_threshold = args.find(CORE_THRESHOLD)->second.as<double>();
59  m_core_minarea = args.find(CORE_MINAREA)->second.as<int>();
60 
61  if (m_core_threshold < 0.) {
62  throw Elements::Exception() << "Invalid " << CORE_THRESHOLD << " value: " << m_core_threshold;
63  }
64  if (m_core_minarea < 0) {
65  throw Elements::Exception() << "Invalid " << CORE_MINAREA << " value: " << m_core_minarea;
66  }
67 
68  if (m_core_minarea > 0.0 && m_core_minarea > 0 && args.at(CORE_THRESH_USE).as<bool>()){
69 
70  double core_threshold = m_core_threshold;
71  int core_minarea = m_core_minarea;
72  getDependency<PartitionStepConfig>().addPartitionStepCreator([core_threshold, core_minarea](std::shared_ptr<SourceFactory>)
73  { return std::make_shared<CoreThresholdPartitionStep>(core_threshold, core_minarea); } );
74  }
75 }
76 
78  return m_core_threshold;
79 }
80 
82  return m_core_minarea;
83 }
84 
85 } // end SExtractor
SourceXtractor::CoreThresholdPartitionConfig::m_core_threshold
double m_core_threshold
Definition: CoreThresholdPartitionConfig.h:47
std::string
STL class.
std::shared_ptr< SourceFactory >
std::map::find
T find(T... args)
SourceXtractor::CoreThresholdPartitionConfig::initialize
void initialize(const UserValues &args) override
Definition: CoreThresholdPartitionConfig.cpp:57
SourceXtractor::CoreThresholdPartitionConfig::getCoreThreshold
const double & getCoreThreshold() const
Definition: CoreThresholdPartitionConfig.cpp:77
SourceXtractor::CORE_THRESHOLD
static const std::string CORE_THRESHOLD
Definition: CoreThresholdPartitionConfig.cpp:38
Euclid::Configuration
SourceXtractor::CoreThresholdPartitionConfig::getCoreMinArea
const int & getCoreMinArea() const
Definition: CoreThresholdPartitionConfig.cpp:81
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::MultiThresholdPartitionConfig
Definition: MultiThresholdPartitionConfig.h:32
std::map::at
T at(T... args)
std::string::c_str
T c_str(T... args)
SourceXtractor::CORE_THRESH_USE
static const std::string CORE_THRESH_USE
Definition: CoreThresholdPartitionConfig.cpp:40
SourceXtractor::CoreThresholdPartitionConfig::CoreThresholdPartitionConfig
CoreThresholdPartitionConfig(long manager_id)
Definition: CoreThresholdPartitionConfig.cpp:42
SourceXtractor::CoreThresholdPartitionConfig::m_core_minarea
int m_core_minarea
Definition: CoreThresholdPartitionConfig.h:48
MultiThresholdPartitionConfig.h
Elements::Exception
SourceXtractor::CoreThresholdPartitionConfig::getProgramOptions
std::map< std::string, OptionDescriptionList > getProgramOptions() override
Definition: CoreThresholdPartitionConfig.cpp:49
std::map
STL class.
PartitionStepConfig.h
SourceXtractor::CORE_MINAREA
static const std::string CORE_MINAREA
Definition: CoreThresholdPartitionConfig.cpp:39
CoreThresholdPartitionConfig.h
Euclid::Configuration::Configuration
CoreThresholdPartitionStep.h
ProgramOptionsHelper.h