18using namespace Kernel;
24 "Name of the input workspace");
26 "Each histogram from the input workspace maps to a histogram in this\n"
27 "workspace with one value that indicates if there was a dead detector");
29 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
30 mustBePositive->setLower(0);
32 "The threshold against which to judge if a spectrum belongs to a dead\n"
38 "The value to assign to an integrated spectrum flagged as 'live'\n"
41 "The value to assign to an integrated spectrum flagged as 'dead'\n"
46 "No bin with a boundary at an x value less than this will be used\n"
47 "in the summation that decides if a detector is 'dead' (default: the\n"
48 "start of each histogram)");
50 "No bin with a boundary at an x value higher than this value will\n"
51 "be used in the summation that decides if a detector is 'dead'\n"
52 "(default: the end of each histogram)");
53 declareProperty(
"OutputFile",
"",
"A filename to which to write the list of dead detector UDETs");
63 double deadThreshold =
getProperty(
"DeadThreshold");
69 file <<
"Index Spectrum UDET(S)\n";
74 std::vector<detid_t> deadDets;
75 int countSpec = 0, countDets = 0;
79 const int64_t numSpec = integratedWorkspace->getNumberHistograms();
80 const auto numSpec_d =
static_cast<double>(numSpec);
81 int64_t iprogress_step = numSpec / 100;
82 if (iprogress_step == 0)
84 for (int64_t i = 0; i < int64_t(numSpec); ++i) {
86 double &
y = integratedWorkspace->mutableY(i)[0];
87 if (
y > deadThreshold) {
92 const auto &spec = integratedWorkspace->getSpectrum(i);
94 file << i <<
" " << spec.getSpectrumNo();
95 for (
const auto &
id : spec.getDetectorIDs()) {
100 deadDets.emplace_back(
id);
105 if (i % iprogress_step == 0) {
106 progress(
static_cast<double>(i) / numSpec_d);
111 g_log.
notice() <<
"Found a total of " << countDets <<
" 'dead' detectors within " << countSpec
112 <<
" 'dead' spectra.\n";
115 setProperty(
"OutputWorkspace", integratedWorkspace);
131 childAlg->setProperty<
double>(
"RangeLower",
getProperty(
"RangeLower"));
132 childAlg->setProperty<
double>(
"RangeUpper",
getProperty(
"RangeUpper"));
133 childAlg->executeAsChildAlg();
135 return childAlg->getProperty(
"OutputWorkspace");
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
void interruption_point()
This is called during long-running operations, and check if the algorithm has requested that it be ca...
A property class for workspaces.
API::MatrixWorkspace_sptr integrateWorkspace()
Run Integration as a Child Algorithm.
void exec() override
Executes the algorithm.
void init() override
Initialisation method.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void notice(const std::string &msg)
Logs at notice level.
void information(const std::string &msg)
Logs at information level.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ Input
An input workspace.
@ Output
An output workspace.