46 std::string output_message;
48 const std::string reductionManagerName =
getProperty(
"ReductionProperties");
49 std::shared_ptr<PropertyManager> reductionManager;
50 if (PropertyManagerDataService::Instance().doesExist(reductionManagerName)) {
51 reductionManager = PropertyManagerDataService::Instance().retrieve(reductionManagerName);
53 reductionManager = std::make_shared<PropertyManager>();
54 PropertyManagerDataService::Instance().addOrReplace(reductionManagerName, reductionManager);
58 const bool persistent =
getProperty(
"PersistentCorrection");
59 if (!reductionManager->existsProperty(
"DarkCurrentAlgorithm") && persistent) {
60 auto algProp = std::make_unique<AlgorithmProperty>(
"DarkCurrentAlgorithm");
62 reductionManager->declareProperty(std::move(algProp));
72 progress.report(
"Subtracting dark current");
75 std::filesystem::path path(fileName);
76 const std::string entryName =
"DarkCurrent" + path.stem().string();
78 if (reductionManager->existsProperty(entryName)) {
79 darkWS = reductionManager->getProperty(entryName);
80 darkWSName = reductionManager->getPropertyValue(entryName);
81 output_message += darkWSName +
'\n';
84 if (darkWSName.empty()) {
85 darkWSName =
"__dark_current_" + path.stem().string();
90 if (!reductionManager->existsProperty(
"LoadAlgorithm")) {
92 loadAlg->setProperty(
"Filename", fileName);
93 loadAlg->setProperty(
"ReductionProperties", reductionManagerName);
94 loadAlg->executeAsChildAlg();
96 IAlgorithm_sptr loadAlg0 = reductionManager->getProperty(
"LoadAlgorithm");
97 const std::string loadString = loadAlg0->toString();
99 loadAlg->setChild(
true);
100 loadAlg->setProperty(
"Filename", fileName);
101 loadAlg->setProperty(
"ReductionProperties", reductionManagerName);
102 loadAlg->setPropertyValue(
"OutputWorkspace", darkWSName);
105 darkWS = loadAlg->getProperty(
"OutputWorkspace");
106 output_message +=
"\n Loaded " + fileName +
"\n";
107 if (loadAlg->existsProperty(
"OutputMessage")) {
108 std::string msg = loadAlg->getPropertyValue(
"OutputMessage");
109 output_message +=
" |" + Poco::replace(msg,
"\n",
"\n |") +
"\n";
114 reductionManager->setPropertyValue(entryName, darkWSName);
115 reductionManager->setProperty(entryName, darkWS);
117 progress.report(3,
"Loaded dark current");
123 scaleAlg->setProperty(
"InputWorkspace", darkWS);
124 scaleAlg->setProperty(
"Factor", dataTimer / darkTimer);
125 scaleAlg->setProperty(
"Operation",
"Multiply");
126 scaleAlg->executeAsChildAlg();
130 for (
size_t i = 0; i < scaledDarkWS->dataY(0).size(); i++) {
137 minusAlg->setProperty(
"LHSWorkspace", inputWS);
138 minusAlg->setProperty(
"RHSWorkspace", scaledDarkWS);
140 minusAlg->setProperty(
"OutputWorkspace", outputWS);
141 minusAlg->executeAsChildAlg();
144 setProperty(
"OutputMessage",
"Dark current subtracted: " + output_message);
146 progress.report(
"Subtracted dark current");
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.