19using API::FileProperty;
22using API::WorkspaceProperty;
23using Kernel::BoundedValidator;
24using Kernel::Direction;
25using Kernel::PropertyWithValue;
51 "See the GroupingPattern documentation of GroupDetectors.");
53 auto positive = std::make_shared<BoundedValidator<double>>();
54 positive->setLower(0.);
58 "An output workspace.");
61 std::vector<std::string>{
".map",
".xml"}),
62 "A file that consists of lists of spectra numbers to group. See the "
63 "help of GroupDetectors for the file format");
72 if (inputWorkspace != outputWorkspace) {
73 outputWorkspace = inputWorkspace->clone();
75 const auto map = outputWorkspace->getDetectorIDToWorkspaceIndexMap();
78 auto xAxisUnitID = inputWorkspace->getAxis(0)->unit()->unitID();
79 if (outputWorkspace->blocksize() != 1 && xAxisUnitID !=
"Empty") {
81 integrator->setProperty(
"InputWorkspace", inputWorkspace);
82 integrator->setPropertyValue(
"OutputWorkspace",
"unused");
83 integrator->executeAsChildAlg();
84 integrated = integrator->getProperty(
"OutputWorkspace");
88 for (
size_t index = 1;
index < integrated->getNumberHistograms(); ++
index) {
89 integrated->setSharedX(
index, integrated->sharedX(0));
92 const std::string groupingPattern =
getProperty(
"GroupingPattern");
94 if (!groupingPattern.empty()) {
96 grouper->setProperty(
"InputWorkspace", integrated);
97 grouper->setPropertyValue(
"OutputWorkspace",
"unused");
98 grouper->setPropertyValue(
"GroupingPattern", groupingPattern);
99 grouper->setPropertyValue(
"Behaviour",
"Sum");
100 grouper->setProperty(
"KeepUngroupedSpectra",
true);
101 grouper->executeAsChildAlg();
102 grouped = grouper->getProperty(
"OutputWorkspace");
104 const std::string filename =
getProperty(
"MapFile");
105 if (!filename.empty()) {
107 grouper->setProperty(
"InputWorkspace", integrated);
108 grouper->setPropertyValue(
"OutputWorkspace",
"unused");
109 grouper->setPropertyValue(
"MapFile", filename);
110 grouper->setPropertyValue(
"Behaviour",
"Sum");
111 grouper->setProperty(
"KeepUngroupedSpectra",
true);
112 grouper->executeAsChildAlg();
113 grouped = grouper->getProperty(
"OutputWorkspace");
118 for (
int index = 0; index < static_cast<int>(grouped->getNumberHistograms()); ++
index) {
121 auto correction = grouped->readY(
index);
122 for (
size_t bin = 0; bin < correction.size(); bin++) {
123 auto &
y = correction[bin];
124 if (
y >= 1.0 / tau) {
125 g_log.
warning() <<
"Saturation count rate reached for grouped detector at index " <<
index <<
", in bin " << bin
126 <<
". Correction will be infinity. Check your tau or input "
127 "workspace, make sure it is normalised by acquisition time.\n";
128 y = std::numeric_limits<double>::infinity();
131 std::for_each(correction.begin(), correction.end(), [&tau](
double &
y) { y = 1.0 / (1.0 - y * tau); });
133 const auto detIDs = grouped->getSpectrum(
index).getDetectorIDs();
134 for (
const auto id : detIDs) {
135 const size_t originalIndex = map.at(
id);
136 auto &spectrum = outputWorkspace->mutableY(originalIndex);
137 auto &errors = outputWorkspace->mutableE(originalIndex);
138 if (correction.size() == 1) {
139 spectrum *= correction[0];
140 errors *= correction[0];
142 spectrum *= correction;
143 errors *= correction;
#define DECLARE_ALGORITHM(classname)
std::map< DeltaEMode::Type, std::string > index
#define PARALLEL_START_INTERRUPT_REGION
Begins a block to skip processing is the algorithm has been interupted Note the end of the block if n...
#define PARALLEL_END_INTERRUPT_REGION
Ends a block to skip processing is the algorithm has been interupted Note the start of the block if n...
#define PARALLEL_FOR_IF(condition)
Empty definitions - to enable set your complier to enable openMP.
#define PARALLEL_CHECK_INTERRUPT_REGION
Adds a check after a Parallel region to see if it was interupted.
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
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.
@ OptionalLoad
to specify a file to read but the file doesn't have to exist
Helper class for reporting progress from algorithms.
A property class for workspaces.
DeadTimeCorrection : Performs dead time correction.
void exec() override
Execute the algorithm.
int version() const override
Algorithm's version for identification.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
void init() override
Initialize the algorithm's properties.
const std::string category() const override
Algorithm's category for identification.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void warning(const std::string &msg)
Logs at warning level.
The concrete, templated class for properties.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::enable_if< std::is_pointer< Arg >::value, bool >::type threadSafe(Arg workspace)
Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access.
std::string to_string(const wide_integer< Bits, Signed > &n)
@ Input
An input workspace.
@ Output
An output workspace.