SourceXtractorPlusPlus
0.8
Please provide a description of the project.
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
SEImplementation
src
lib
Configuration
GroupingConfig.cpp
Go to the documentation of this file.
1
17
/*
18
* GroupingConfig.cpp
19
*
20
* Created on: Jul 3, 2018
21
* Author: mschefer
22
*/
23
24
#include <boost/algorithm/string.hpp>
25
26
#include "
ElementsKernel/Exception.h
"
27
#include "
Configuration/ConfigManager.h
"
28
29
#include "
SEImplementation/Configuration/GroupingConfig.h
"
30
31
using namespace
Euclid::Configuration;
32
namespace
po = boost::program_options;
33
34
namespace
SourceXtractor {
35
36
static
const
std::string
GROUPING_ALGORITHM
{
"grouping-algorithm"
};
37
static
const
std::string
GROUPING_MOFFAT_THRESHOLD
{
"grouping-moffat-threshold"
};
38
static
const
std::string
GROUPING_MOFFAT_MAX_DISTANCE
{
"grouping-moffat-max-distance"
};
39
40
static
const
std::string
GROUPING_ALGORITHM_NONE
{
"NONE"
};
41
static
const
std::string
GROUPING_ALGORITHM_OVERLAP
{
"OVERLAP"
};
42
static
const
std::string
GROUPING_ALGORITHM_SPLIT
{
"SPLIT"
};
43
static
const
std::string
GROUPING_ALGORITHM_MOFFAT
{
"MOFFAT"
};
44
45
GroupingConfig::GroupingConfig(
long
manager_id)
46
:
Configuration
(manager_id), m_selected_algorithm(
Algorithm
::SPLIT_SOURCES), m_moffat_threshold(0.02), m_moffat_max_distance(300) {
47
}
48
49
std::map<std::string, Configuration::OptionDescriptionList>
GroupingConfig::getProgramOptions
() {
50
return
{ {
"Grouping"
, {
51
{
GROUPING_ALGORITHM
.
c_str
(), po::value<std::string>()->default_value(
GROUPING_ALGORITHM_NONE
),
52
"Grouping algorithm to be used [none|overlap|split|moffat]."
},
53
{
GROUPING_MOFFAT_THRESHOLD
.
c_str
(), po::value<double>()->default_value(0.02),
54
"Threshold used for Moffat grouping."
},
55
{
GROUPING_MOFFAT_MAX_DISTANCE
.
c_str
(), po::value<double>()->default_value(300),
56
"Maximum distance (in pixels) to be considered for grouping"
},
57
}}};
58
}
59
60
void
GroupingConfig::initialize
(
const
UserValues& args) {
61
auto
algorithm_name = boost::to_upper_copy(args.at(
GROUPING_ALGORITHM
).as<
std::string
>());
62
if
(algorithm_name ==
GROUPING_ALGORITHM_NONE
) {
63
m_selected_algorithm
=
Algorithm::NO_GROUPING
;
64
}
else
if
(algorithm_name ==
GROUPING_ALGORITHM_OVERLAP
) {
65
m_selected_algorithm
=
Algorithm::OVERLAPPING
;
66
}
else
if
(algorithm_name ==
GROUPING_ALGORITHM_SPLIT
) {
67
m_selected_algorithm
=
Algorithm::SPLIT_SOURCES
;
68
}
else
if
(algorithm_name ==
GROUPING_ALGORITHM_MOFFAT
) {
69
m_selected_algorithm
=
Algorithm::MOFFAT
;
70
}
else
{
71
throw
Elements::Exception
() <<
"Unknown grouping algorithm : "
<< algorithm_name;
72
}
73
74
if
(args.find(
GROUPING_MOFFAT_THRESHOLD
) != args.end()) {
75
m_moffat_threshold
= args.find(
GROUPING_MOFFAT_THRESHOLD
)->second.as<
double
>();
76
}
77
if
(args.find(
GROUPING_MOFFAT_MAX_DISTANCE
) != args.end()) {
78
m_moffat_max_distance
= args.find(
GROUPING_MOFFAT_MAX_DISTANCE
)->second.as<
double
>();
79
}
80
}
81
82
}
// SourceXtractor namespace
83
84
85
SourceXtractor::GroupingConfig::Algorithm
Algorithm
Definition:
GroupingConfig.h:39
Euclid::Configuration::Configuration
SourceXtractor::GROUPING_ALGORITHM_SPLIT
static const std::string GROUPING_ALGORITHM_SPLIT
Definition:
GroupingConfig.cpp:42
std::map
STL class.
std::string
STL class.
SourceXtractor::GroupingConfig::Algorithm::SPLIT_SOURCES
GroupingConfig.h
SourceXtractor::GROUPING_MOFFAT_MAX_DISTANCE
static const std::string GROUPING_MOFFAT_MAX_DISTANCE
Definition:
GroupingConfig.cpp:38
SourceXtractor::GroupingConfig::m_moffat_threshold
double m_moffat_threshold
Definition:
GroupingConfig.h:71
SourceXtractor::GroupingConfig::Algorithm::NO_GROUPING
SourceXtractor::GROUPING_ALGORITHM
static const std::string GROUPING_ALGORITHM
Definition:
GroupingConfig.cpp:36
SourceXtractor::GROUPING_ALGORITHM_MOFFAT
static const std::string GROUPING_ALGORITHM_MOFFAT
Definition:
GroupingConfig.cpp:43
SourceXtractor::GroupingConfig::getProgramOptions
std::map< std::string, Configuration::OptionDescriptionList > getProgramOptions() override
Definition:
GroupingConfig.cpp:49
Elements::Exception
SourceXtractor::GROUPING_ALGORITHM_OVERLAP
static const std::string GROUPING_ALGORITHM_OVERLAP
Definition:
GroupingConfig.cpp:41
SourceXtractor::GROUPING_ALGORITHM_NONE
static const std::string GROUPING_ALGORITHM_NONE
Definition:
GroupingConfig.cpp:40
ConfigManager.h
std::string::c_str
T c_str(T...args)
SourceXtractor::GROUPING_MOFFAT_THRESHOLD
static const std::string GROUPING_MOFFAT_THRESHOLD
Definition:
GroupingConfig.cpp:37
SourceXtractor::GroupingConfig::Algorithm::OVERLAPPING
SourceXtractor::GroupingConfig::initialize
void initialize(const UserValues &args) override
Definition:
GroupingConfig.cpp:60
SourceXtractor::GroupingConfig::m_selected_algorithm
Algorithm m_selected_algorithm
Definition:
GroupingConfig.h:70
SourceXtractor::GroupingConfig::Algorithm::MOFFAT
Exception.h
SourceXtractor::GroupingConfig::m_moffat_max_distance
double m_moffat_max_distance
Definition:
GroupingConfig.h:72
Generated by
1.8.5