61 double default_ctr_x_pix = 0.0;
62 double default_ctr_y_pix = 0.0;
63 double default_ctr_x = 0.0;
64 double default_ctr_y = 0.0;
71 center_x = default_ctr_x_pix;
72 center_y = default_ctr_y_pix;
73 g_log.
information() <<
"Setting beam center to [" << Poco::NumberFormatter::format(center_x, 1) <<
", "
74 << Poco::NumberFormatter::format(center_y, 1) <<
"]\n";
78 double beam_ctr_x = 0.0;
79 double beam_ctr_y = 0.0;
84 mvAlg->setProperty(
"ComponentName",
"detector1");
85 mvAlg->setProperty(
"X", default_ctr_x - beam_ctr_x);
86 mvAlg->setProperty(
"Y", default_ctr_y - beam_ctr_y);
87 mvAlg->setProperty(
"RelativePosition",
true);
88 mvAlg->executeAsChildAlg();
89 g_log.
information() <<
"Moving beam center to " << center_x <<
" " << center_y <<
'\n';
100 const std::string reductionManagerName =
getProperty(
"ReductionProperties");
101 std::shared_ptr<PropertyManager> reductionManager;
102 if (PropertyManagerDataService::Instance().doesExist(reductionManagerName)) {
103 reductionManager = PropertyManagerDataService::Instance().retrieve(reductionManagerName);
105 reductionManager = std::make_shared<PropertyManager>();
106 PropertyManagerDataService::Instance().addOrReplace(reductionManagerName, reductionManager);
114 if (!reductionManager->existsProperty(
"LoadAlgorithm")) {
115 auto algProp = std::make_unique<AlgorithmProperty>(
"LoadAlgorithm");
117 reductionManager->declareProperty(std::move(algProp));
123 std::string output_message;
124 const double wavelength_input =
getProperty(
"Wavelength");
125 const double wavelength_spread_input =
getProperty(
"WavelengthSpread");
130 loadAlg->setProperty(
"Filename", fileName);
131 loadAlg->setPropertyValue(
"OutputWorkspace",
getPropertyValue(
"OutputWorkspace"));
132 if (!
isEmpty(wavelength_input)) {
133 loadAlg->setProperty(
"Wavelength", wavelength_input);
134 loadAlg->setProperty(
"WavelengthSpread", wavelength_spread_input);
137 loadAlg->executeAsChildAlg();
147 g_log.
warning() <<
"Unable to load file as a SPICE file. Trying to load as "
150 loadAlg->setProperty(
"Filename", fileName);
151 loadAlg->executeAsChildAlg();
152 Workspace_sptr dataWS_tmp = loadAlg->getProperty(
"OutputWorkspace");
154 dataWS->mutableRun().addProperty(
"is_sensitivity", 1,
"",
true);
155 setProperty<MatrixWorkspace_sptr>(
"OutputWorkspace", dataWS);
156 g_log.
notice() <<
"Successfully loaded " << fileName <<
" and setting sensitivity flag to True\n";
159 Workspace_sptr dataWS_tmp = loadAlg->getProperty(
"OutputWorkspace");
160 AnalysisDataService::Instance().addOrReplace(
getPropertyValue(
"OutputWorkspace"), dataWS_tmp);
161 g_log.
debug() <<
"Calling LoadSpice2D Done. OutputWorkspace name = " << dataWS_tmp->getName() <<
'\n';
169 const double sample_det_dist =
getProperty(
"SampleDetectorDistance");
170 if (!
isEmpty(sample_det_dist)) {
171 g_log.
debug() <<
"Getting the SampleDetectorDistance = " << sample_det_dist
172 <<
" from the Algorithm input property.\n";
173 sdd = sample_det_dist;
175 const std::string sddName =
"total-sample-detector-distance";
179 throw std::runtime_error(
"Could not cast (interpret) the property " + sddName +
180 " as a floating point numeric value.");
185 const double sample_det_offset =
getProperty(
"SampleDetectorDistanceOffset");
186 if (!
isEmpty(sample_det_offset)) {
187 sdd += sample_det_offset;
190 dataWS->mutableRun().addProperty(
"sample_detector_distance", sdd,
"mm",
true);
191 g_log.
debug() <<
"FINAL: Using Total Sample Detector Distance = " << sdd <<
"\n";
193 progress.report(
"MoveInstrumentComponent...");
198 mvAlg->setProperty(
"ComponentName",
"detector1");
199 mvAlg->setProperty(
"Z", sdd / 1000.0);
200 mvAlg->setProperty(
"RelativePosition",
false);
201 mvAlg->executeAsChildAlg();
203 output_message +=
" Detector position: " + Poco::NumberFormatter::format(sdd / 1000.0, 3) +
" m\n";
206 double src_to_sample = 0.0;
210 dataWS->mutableRun().addProperty(
"source-sample-distance", src_to_sample,
"mm",
true);
212 " Computed SSD from number of guides: " + Poco::NumberFormatter::format(src_to_sample / 1000.0, 3) +
" \n";
217 output_message +=
" Could not compute SSD from number of guides, taking: " +
218 Poco::NumberFormatter::format(src_to_sample / 1000.0, 3) +
" \n";
221 const std::string sampleADName =
"sample-aperture-diameter";
225 throw std::runtime_error(
"Could not cast (interpret) the property " + sampleADName +
226 " as a floating point numeric value.");
228 double sample_apert = *dp;
230 const std::string sourceADName =
"source-aperture-diameter";
231 prop = dataWS->run().getProperty(sourceADName);
234 throw std::runtime_error(
"Could not cast (interpret) the property " + sourceADName +
235 " as a floating point numeric value.");
237 double source_apert = *dp;
239 const double beam_diameter = sdd / src_to_sample * (source_apert + sample_apert) + sample_apert;
240 dataWS->mutableRun().addProperty(
"beam-diameter", beam_diameter,
"mm",
true);
242 progress.report(
"Move to center beam...");
248 const bool noBeamCenter =
getProperty(
"NoBeamCenter");
253 if (reductionManager->existsProperty(
"LatestBeamCenterX") &&
254 reductionManager->existsProperty(
"LatestBeamCenterY")) {
255 center_x = reductionManager->getProperty(
"LatestBeamCenterX");
256 center_y = reductionManager->getProperty(
"LatestBeamCenterY");
267 if (!reductionManager->existsProperty(
"LatestBeamCenterX"))
270 reductionManager->setProperty(
"LatestBeamCenterX", center_x);
271 if (!reductionManager->existsProperty(
"LatestBeamCenterY"))
274 reductionManager->setProperty(
"LatestBeamCenterY", center_y);
276 dataWS->mutableRun().addProperty(
"beam_center_x", center_x,
"pixel",
true);
277 dataWS->mutableRun().addProperty(
"beam_center_y", center_y,
"pixel",
true);
278 output_message +=
" Beam center: " + Poco::NumberFormatter::format(center_x, 1) +
", " +
279 Poco::NumberFormatter::format(center_y, 1) +
"\n";
283 dataWS->mutableRun().addProperty(
"beam_center_x", center_x,
"pixel",
true);
284 dataWS->mutableRun().addProperty(
"beam_center_y", center_y,
"pixel",
true);
285 output_message +=
" Default beam center: " + Poco::NumberFormatter::format(center_x, 1) +
", " +
286 Poco::NumberFormatter::format(center_y, 1) +
"\n";
289 setProperty<MatrixWorkspace_sptr>(
"OutputWorkspace", std::dynamic_pointer_cast<MatrixWorkspace>(dataWS));