45 std::string output_message;
47 const std::string reductionManagerName =
getProperty(
"ReductionProperties");
48 std::shared_ptr<PropertyManager> reductionManager;
49 if (PropertyManagerDataService::Instance().doesExist(reductionManagerName)) {
50 reductionManager = PropertyManagerDataService::Instance().retrieve(reductionManagerName);
52 reductionManager = std::make_shared<PropertyManager>();
53 PropertyManagerDataService::Instance().addOrReplace(reductionManagerName, reductionManager);
57 const bool persistent =
getProperty(
"PersistentCorrection");
58 if (!reductionManager->existsProperty(
"DarkCurrentAlgorithm") && persistent) {
59 auto algProp = std::make_unique<AlgorithmProperty>(
"DarkCurrentAlgorithm");
61 reductionManager->declareProperty(std::move(algProp));
71 progress.report(
"Subtracting dark current");
74 Poco::Path path(fileName);
75 const std::string entryName =
"DarkCurrent" + path.getBaseName();
77 if (reductionManager->existsProperty(entryName)) {
78 darkWS = reductionManager->getProperty(entryName);
79 darkWSName = reductionManager->getPropertyValue(entryName);
80 output_message += darkWSName +
'\n';
83 if (darkWSName.empty()) {
84 darkWSName =
"__dark_current_" + path.getBaseName();
89 if (!reductionManager->existsProperty(
"LoadAlgorithm")) {
91 loadAlg->setProperty(
"Filename", fileName);
92 loadAlg->setProperty(
"ReductionProperties", reductionManagerName);
93 loadAlg->executeAsChildAlg();
95 IAlgorithm_sptr loadAlg0 = reductionManager->getProperty(
"LoadAlgorithm");
96 const std::string loadString = loadAlg0->toString();
98 loadAlg->setChild(
true);
99 loadAlg->setProperty(
"Filename", fileName);
100 loadAlg->setProperty(
"ReductionProperties", reductionManagerName);
101 loadAlg->setPropertyValue(
"OutputWorkspace", darkWSName);
104 darkWS = loadAlg->getProperty(
"OutputWorkspace");
105 output_message +=
"\n Loaded " + fileName +
"\n";
106 if (loadAlg->existsProperty(
"OutputMessage")) {
107 std::string msg = loadAlg->getPropertyValue(
"OutputMessage");
108 output_message +=
" |" + Poco::replace(msg,
"\n",
"\n |") +
"\n";
113 reductionManager->setPropertyValue(entryName, darkWSName);
114 reductionManager->setProperty(entryName, darkWS);
116 progress.report(3,
"Loaded dark current");
122 scaleAlg->setProperty(
"InputWorkspace", darkWS);
123 scaleAlg->setProperty(
"Factor", dataTimer / darkTimer);
124 scaleAlg->setProperty(
"Operation",
"Multiply");
125 scaleAlg->executeAsChildAlg();
129 for (
size_t i = 0; i < scaledDarkWS->dataY(0).size(); i++) {
136 minusAlg->setProperty(
"LHSWorkspace", inputWS);
137 minusAlg->setProperty(
"RHSWorkspace", scaledDarkWS);
139 minusAlg->setProperty(
"OutputWorkspace", outputWS);
140 minusAlg->executeAsChildAlg();
143 setProperty(
"OutputMessage",
"Dark current subtracted: " + output_message);
145 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.