Mantid
Loading...
Searching...
No Matches
AlignAndFocusPowderSlim.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2024 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7
10#include "MantidAPI/Axis.h"
13#include "MantidAPI/Run.h"
14#include "MantidAPI/Sample.h"
40#include "MantidKernel/Timer.h"
41#include "MantidKernel/Unit.h"
42#include "MantidKernel/V3D.h"
44#include "MantidNexus/H5Util.h"
45
46#include <H5Cpp.h>
47#include <numbers>
48#include <ranges>
49#include <regex>
50#include <vector>
51
73
74namespace { // anonymous namespace
75
76const std::string LOG_CHARGE_NAME("proton_charge");
77
78const std::vector<std::string> binningModeNames{"Logarithmic", "Linear"};
79enum class BinningMode { LOGARITHMIC, LINEAR, enum_count };
81
82const std::vector<std::string> unitNames{"dSpacing", "TOF", "MomentumTransfer"};
83enum class BinUnit { DSPACE, TOF, Q, enum_count };
85
86const size_t NUM_HIST{6}; // TODO make this determined from groupin
87
88const std::string ENTRY_TOP_LEVEL("entry");
89
90// TODO refactor this to use the actual grouping
91double getFocussedPostion(const detid_t detid, const std::vector<double> &difc_focus,
92 std::map<detid_t, size_t> &detIDToSpecNum) {
93 if (detIDToSpecNum.contains(detid)) {
94 return difc_focus[detIDToSpecNum[detid]];
95 } else {
96 return IGNORE_PIXEL;
97 }
98}
99
100std::vector<double> calculate_difc_focused(const double l1, const std::vector<double> &l2s,
101 const std::vector<double> &polars) {
102 constexpr double deg2rad = std::numbers::pi_v<double> / 180.;
103
104 std::vector<double> difc;
105
106 std::transform(l2s.cbegin(), l2s.cend(), polars.cbegin(), std::back_inserter(difc),
107 [l1, deg2rad](const auto &l2, const auto &polar) {
108 return 1. / Kernel::Units::tofToDSpacingFactor(l1, l2, deg2rad * polar, 0.);
109 });
110
111 return difc;
112}
113
114} // namespace
115
116// Register the algorithm into the AlgorithmFactory
117DECLARE_ALGORITHM(AlignAndFocusPowderSlim)
118
119//----------------------------------------------------------------------------------------------
120
121
122const std::string AlignAndFocusPowderSlim::name() const { return "AlignAndFocusPowderSlim"; }
123
125int AlignAndFocusPowderSlim::version() const { return 1; }
126
128const std::string AlignAndFocusPowderSlim::category() const { return "Workflow\\Diffraction"; }
129
131const std::string AlignAndFocusPowderSlim::summary() const {
132 return "VULCAN ONLY Algorithm to focus powder diffraction data into a number of histograms according to a grouping "
133 "scheme defined in a CalFile.";
134}
135
136const std::vector<std::string> AlignAndFocusPowderSlim::seeAlso() const { return {"AlignAndFocusPowderFromFiles"}; }
137
138//----------------------------------------------------------------------------------------------
142 const std::vector<std::string> exts{".nxs.h5", ".nxs", "_event.nxs"};
143 // docs copied/modified from LoadEventNexus
144 declareProperty(std::make_unique<FileProperty>(PropertyNames::FILENAME, "", FileProperty::Load, exts),
145 "The name of the Event NeXus file to read, including its full or relative path. "
146 "The file name is typically of the form INST_####_event.nxs.");
149 "To only include events after the provided start time, in seconds (relative to the start of the run).");
150
153 "To only include events before the provided stop time, in seconds (relative to the start of the run).");
156 "Input workspace specifying \"splitters\", i.e. time intervals and targets for event filtering. "
157 "Currently only a single output workspace is supported.");
159 "Flag indicating whether in SplitterWorkspace the times are absolute or "
160 "relative. If true, they are relative to the run start time.");
163 "For development testing. Changes how the splitters are processed. If true then use ProcessBankSplitTask "
164 "otherwise loop over ProcessBankTask.");
166 "Find time-of-flight when neutron was at the sample position. This is only necessary for fast logs "
167 "(i.e. more frequent than proton on target pulse).");
170 "If true, events will be splitting using full time values (tof+pulsetime) rather than just pulsetime.");
171 auto mustBePositive = std::make_shared<BoundedValidator<int>>();
172 mustBePositive->setLower(0);
174 "Filter bad pulses in the same way that :ref:`algm-FilterBadPulses` does.");
175 auto range = std::make_shared<BoundedValidator<double>>();
176 range->setBounds(0., 100.);
178 "The percentage of the average to use as the lower bound when filtering bad pulses.");
181 "A GroupingWorkspace giving the grouping info. If not provided then the grouping from the "
182 "calibration file will be used if provided, else a default grouping of one group per bank.");
183 const std::vector<std::string> cal_exts{".h5", ".hd5", ".hdf", ".cal"};
184 declareProperty(std::make_unique<FileProperty>(PropertyNames::CAL_FILE, "", FileProperty::OptionalLoad, cal_exts),
185 "The .cal file containing the position correction factors. Either this or OffsetsWorkspace needs to "
186 "be specified.");
187 auto mustBePosArr = std::make_shared<Kernel::ArrayBoundedValidator<double>>();
188 mustBePosArr->setLower(0.0);
189 declareProperty(std::make_unique<ArrayProperty<double>>(PropertyNames::X_MIN, std::vector<double>{0.1}, mustBePosArr),
190 "Minimum x-value for the output binning");
191 declareProperty(std::make_unique<ArrayProperty<double>>(PropertyNames::X_DELTA, std::vector<double>{0.0016}),
192 "Bin size for output data");
193 declareProperty(std::make_unique<ArrayProperty<double>>(PropertyNames::X_MAX, std::vector<double>{2.0}, mustBePosArr),
194 "Minimum x-value for the output binning");
196 "The units of the input X min, max and delta values. Output will always be TOF");
198 "Specify binning behavior ('Logarithmic')");
200 "If specified, only these logs will be loaded from the file");
202 "If specified, these logs will not be loaded from the file");
205 "An output workspace.");
206
207 // parameters for chunking options - consider removing these later
208 const std::string CHUNKING_PARAM_GROUP("Chunking-temporary");
209 auto positiveIntValidator = std::make_shared<Mantid::Kernel::BoundedValidator<int>>();
210 positiveIntValidator->setLower(1);
212 std::make_unique<PropertyWithValue<int>>(PropertyNames::READ_SIZE_FROM_DISK, 2000 * 50000, positiveIntValidator),
213 "Number of elements of time-of-flight or detector-id to read at a time. This is a maximum");
216 std::make_unique<PropertyWithValue<int>>(PropertyNames::EVENTS_PER_THREAD, 1000000, positiveIntValidator),
217 "Number of events to read in a single thread. Higher means less threads are created.");
219
220 // load single spectrum
222 std::make_unique<PropertyWithValue<int>>(PropertyNames::OUTPUT_SPEC_NUM, EMPTY_INT(), positiveIntValidator),
223 "The bank for which to read data; if specified, others will be blank");
224
225 // parameters for focus position
226 // for L1, mandatory and must be positive
227 auto mandatoryDblValidator = std::make_shared<MandatoryValidator<double>>();
228 auto positiveDblValidator = std::make_shared<Mantid::Kernel::BoundedValidator<double>>();
229 positiveDblValidator->setLower(0);
230 auto l1Validator = std::make_shared<CompositeValidator>();
231 l1Validator->add(mandatoryDblValidator);
232 l1Validator->add(positiveDblValidator);
233 // for L2, 2theta, phi, mandatory arrays with positive valyes
234 auto mandatoryDblArrayValidator = std::make_shared<MandatoryValidator<std::vector<double>>>();
235 auto positionArrayValidator = std::make_shared<CompositeValidator>();
236 positionArrayValidator->add(mandatoryDblArrayValidator);
237 positionArrayValidator->add(mustBePosArr);
238 declareProperty(std::make_unique<PropertyWithValue<double>>(PropertyNames::L1, EMPTY_DBL(), l1Validator),
239 "The primary distance :math:`\\ell_1` from beam to sample");
241 std::make_unique<ArrayProperty<double>>(PropertyNames::L2, std::vector<double>{}, positionArrayValidator),
242 "The secondary distances :math:`\\ell_2` from sample to focus group");
244 std::make_unique<ArrayProperty<double>>(PropertyNames::POLARS, std::vector<double>{}, positionArrayValidator),
245 "The effective polar angle (:math:`2\\theta`) of each focus group");
247 std::make_unique<ArrayProperty<double>>(PropertyNames::AZIMUTHALS, std::vector<double>{}, mustBePosArr),
248 "The effective azimuthal angle :math:`\\phi` for each focus group");
249}
250
251std::map<std::string, std::string> AlignAndFocusPowderSlim::validateInputs() {
252 std::map<std::string, std::string> errors;
253
254 // make sure that data is read in larger chunks than the events processed in a single thread
255 const int disk_chunk = getProperty(PropertyNames::READ_SIZE_FROM_DISK);
256 const int grainsize_events = getProperty(PropertyNames::EVENTS_PER_THREAD);
257 if (disk_chunk < grainsize_events) {
258 const std::string msg(PropertyNames::READ_SIZE_FROM_DISK + " must be larger than " +
262 }
263
264 // only specify allow or block list for logs
266 errors[PropertyNames::ALLOW_LOGS] = "Cannot specify both allow and block lists";
267 errors[PropertyNames::BLOCK_LOGS] = "Cannot specify both allow and block lists";
268 }
269
270 // the focus group position parameters must have same lengths
271 std::vector<double> l2s = getProperty(PropertyNames::L2);
272 const auto num_l2s = l2s.size();
273 std::vector<double> twoTheta = getProperty(PropertyNames::POLARS);
274 if (num_l2s != twoTheta.size()) {
275 errors[PropertyNames::L2] = strmakef("L2S has inconsistent length %zu", num_l2s);
276 errors[PropertyNames::POLARS] = strmakef("Polar has inconsistent length %zu", twoTheta.size());
277 }
278 // phi is optional, but if set must also have same size
279 std::vector<double> phi = getProperty(PropertyNames::AZIMUTHALS);
280 if (!phi.empty()) {
281 if (num_l2s != phi.size()) {
282 errors[PropertyNames::L2] = strmakef("L2S has inconsistent length %zu", num_l2s);
283 errors[PropertyNames::AZIMUTHALS] = strmakef("Azimuthal has inconsistent length %zu", phi.size());
284 ;
285 }
286 }
287
288 // validate binning information is consistent with each other and number of focus groups
289 const std::vector<double> xmins = getProperty(PropertyNames::X_MIN);
290 const std::vector<double> xmaxs = getProperty(PropertyNames::X_MAX);
291 const std::vector<double> deltas = getProperty(PropertyNames::X_DELTA);
292
293 const auto numMin = xmins.size();
294 const auto numMax = xmaxs.size();
295 const auto numDelta = deltas.size();
296
297 if (std::any_of(deltas.cbegin(), deltas.cend(), [](double d) { return !std::isfinite(d) || d == 0; }))
298 errors[PropertyNames::X_DELTA] = "All must be nonzero";
299 else if (!(numDelta == 1 || numDelta == num_l2s))
300 errors[PropertyNames::X_DELTA] = "Must have 1 or consistent number of values";
301
302 if (!(numMin == 1 || numMin == num_l2s))
303 errors[PropertyNames::X_MIN] = "Must have 1 or consistent number of values";
304 if (!(numMax == 1 || numMax == num_l2s))
305 errors[PropertyNames::X_MAX] = "Must have 1 or consistent number of values";
306 return errors;
307}
308
309//----------------------------------------------------------------------------------------------
313
314 const std::string filename = getPropertyValue(PropertyNames::FILENAME);
315 { // TODO TEMPORARY - this algorithm is hard coded for VULCAN
316 // it needs to be made more generic
317 if (filename.find("VULCAN") == std::string::npos) {
318 throw std::runtime_error("File does not appear to be for VULCAN");
319 }
320 }
321 const Nexus::NexusDescriptor descriptor(filename);
322
323 // These give the limits in each file as to which events we actually load (when filtering by time).
324 loadStart.resize(1, 0);
325 loadSize.resize(1, 0);
326
327 size_t num_hist;
328 std::map<size_t, std::set<detid_t>> grouping;
330
331 // Create a temporary workspace to load the instrument. This is needed for LoadDiffCal but we cannot create the
332 // output workspace yet because we need grouping information from the cal file to know the correct number of
333 // spectra.
334 auto inst_ws = API::WorkspaceFactory::Instance().create("Workspace2D", 1, 2, 1);
335 LoadEventNexus::loadInstrument<MatrixWorkspace_sptr>(filename, inst_ws, ENTRY_TOP_LEVEL, this, &descriptor);
336
337 // load calibration file if provided
338 const std::string cal_filename = getPropertyValue(PropertyNames::CAL_FILE);
339 ITableWorkspace_sptr calibrationWS;
340 if (!cal_filename.empty()) {
341 calibrationWS = this->loadCalFile(inst_ws, cal_filename, groupingWS);
342 }
343
344 if (groupingWS) {
345 const auto groupIds = groupingWS->getGroupIDs(false);
346 num_hist = groupIds.size();
347 g_log.information() << "Using grouping workspace with " << num_hist << " groups\n";
348 for (size_t outputSpecNum = 0; outputSpecNum < groupIds.size(); ++outputSpecNum) {
349 const auto detids = groupingWS->getDetectorIDsOfGroup(groupIds[outputSpecNum]);
350 grouping[outputSpecNum] = std::set<detid_t>(detids.begin(), detids.end());
351 }
352 } else {
353 // if no grouping defined then everything goes to one spectrum
354 num_hist = 1;
355 }
356
357 this->progress(.0, "Create output workspace");
358 // create a histogram workspace with correct number of histograms and bins
359 MatrixWorkspace_sptr wksp = createOutputWorkspace(inst_ws->getInstrument(), num_hist);
360
361 // TODO parameters should be input information
362 const double l1 = getProperty(PropertyNames::L1);
363 const std::vector<double> l2s = getProperty(PropertyNames::L2);
364 const std::vector<double> polars = getProperty(PropertyNames::POLARS); // two-theta
365 // set angle from positive x-axis; will be zero unless specified
366 std::vector<double> setPhi(l2s.size(), 0.0);
369 }
370 const std::vector<double> azimuthals(setPhi);
371 const std::vector<specnum_t> specids;
372 const auto difc_focused = calculate_difc_focused(l1, l2s, polars);
373
374 // load run metadata
375 this->progress(.01, "Loading metadata");
376 // prog->doReport("Loading metadata"); TODO add progress bar stuff
377 try {
378 LoadEventNexus::loadEntryMetadata(filename, wksp, ENTRY_TOP_LEVEL, descriptor);
379 } catch (std::exception &e) {
380 g_log.warning() << "Error while loading meta data: " << e.what() << '\n';
381 }
382
383 // load logs
384 this->progress(.02, "Loading logs");
385 auto periodLog = std::make_unique<const TimeSeriesProperty<int>>("period_log"); // not used
386 const std::vector<std::string> &allow_logs = getProperty(PropertyNames::ALLOW_LOGS);
387 const std::vector<std::string> &block_logs = getProperty(PropertyNames::BLOCK_LOGS);
388 int nPeriods{1};
389 LoadEventNexus::runLoadNexusLogs<MatrixWorkspace_sptr>(filename, wksp, *this, false, nPeriods, periodLog, allow_logs,
390 block_logs);
391
392 const auto timeSplitter = this->timeSplitterFromSplitterWorkspace(wksp->run().startTime());
393 const auto filterROI = this->getFilterROI(wksp);
394 // determine the pulse indices from the time and splitter workspace
395 this->progress(.05, "Determining pulse indices");
396
397 // Now we want to go through all the bankN_event entries
398 const std::map<std::string, std::set<std::string>> &allEntries = descriptor.getAllEntries();
399 auto itClassEntries = allEntries.find("NXevent_data");
400
401 // load the events
402 H5::H5File h5file(filename, H5F_ACC_RDONLY, Nexus::H5Util::defaultFileAcc());
403 if (itClassEntries == allEntries.end()) {
404 h5file.close();
405 throw std::runtime_error("No NXevent_data entries found in file");
406 }
407
408 this->progress(.07, "Reading events");
409
410 // hard coded for VULCAN 6 banks
411 std::vector<std::string> bankEntryNames;
412 std::size_t num_banks_to_read;
413
414 int outputSpecNum = getProperty(PropertyNames::OUTPUT_SPEC_NUM);
415 if (outputSpecNum == EMPTY_INT()) {
416 for (size_t i = 1; i <= NUM_HIST; ++i) {
417 bankEntryNames.push_back("bank" + std::to_string(i) + "_events");
418 }
419 num_banks_to_read = NUM_HIST;
420 } else {
421 // fill this vector with blanks -- this is for the ProcessBankTask to correctly access it
422 for (size_t i = 1; i <= NUM_HIST; ++i) {
423 bankEntryNames.push_back("");
424 }
425 // the desired bank gets the correct entry name
426 bankEntryNames[outputSpecNum - 1] = "bank" + std::to_string(outputSpecNum) + "_events";
427 num_banks_to_read = 1;
428 }
429
430 // get detector ids for each bank
431 std::map<size_t, std::set<detid_t>> bank_detids;
432 for (size_t i = 1; i <= NUM_HIST; ++i) {
433 bank_detids[i - 1] = wksp->getInstrument()->getDetectorIDsInBank("bank" + std::to_string(i));
434 }
435
436 // create map of detid to output spectrum number to be used in focusing
437 if (!grouping.empty()) {
438 for (const auto &group : grouping) {
439 for (const auto &detid : group.second) {
440 detIDToSpecNum[detid] = group.first;
441 }
442 }
443 } else {
444 // no grouping provided so evenything goes in the 1 output spectrum
445 grouping[0] = std::set<detid_t>{};
446 for (const auto &[i, detids] : bank_detids) {
447 grouping[0].insert(detids.begin(), detids.end());
448 for (const auto &detid : detids) {
449 detIDToSpecNum[detid] = 0;
450 }
451 }
452 }
453
454 // create values for focusing time-of-flight
455 this->progress(.1, "Creating calibration constants");
456 if (calibrationWS) {
457 this->initCalibrationConstantsFromCalWS(difc_focused, calibrationWS);
458 } else {
459 this->initCalibrationConstants(wksp, difc_focused);
460 }
461
462 // calculate correction for tof of the neutron at the sample position
464 this->initScaleAtSample(wksp);
465 }
466
467 // set the instrument. Needs to happen after we get detector ids for each bank
468 this->progress(.15, "Set instrument geometry");
469 wksp = this->editInstrumentGeometry(wksp, l1, polars, specids, l2s, azimuthals);
470
471 // convert to TOF if not already
472 this->progress(.17, "Convert bins to TOF");
473 wksp = this->convertToTOF(wksp);
474
475 // create the bank calibration factory to share with all of the ProcessBank*Task objects
476 BankCalibrationFactory calibFactory(m_calibration, m_scale_at_sample, grouping, m_masked, bank_detids);
477
478 // threaded processing of the banks
479 const int DISK_CHUNK = getProperty(PropertyNames::READ_SIZE_FROM_DISK);
480 const int GRAINSIZE_EVENTS = getProperty(PropertyNames::EVENTS_PER_THREAD);
481 g_log.debug() << (DISK_CHUNK / GRAINSIZE_EVENTS) << " threads per chunk\n";
482
483 // get pulse times from frequency log on workspace. We use this in several places.
484 const auto frequency_log = dynamic_cast<const TimeSeriesProperty<double> *>(wksp->run().getProperty("frequency"));
485 if (!frequency_log) {
486 throw std::runtime_error("Frequency log not found in workspace run");
487 }
488 m_pulse_times = std::make_shared<std::vector<Mantid::Types::Core::DateAndTime>>(frequency_log->timesAsVector());
489
490 if (timeSplitter.empty()) {
491 // create the nexus loader for handling combined calls to hdf5
492
494 const auto pulse_indices = this->determinePulseIndices(filterROI);
495 auto loader = std::make_shared<NexusLoader>(is_time_filtered, pulse_indices);
496
497 auto progress = std::make_shared<API::Progress>(this, .17, .9, num_banks_to_read);
498 ProcessBankTask task(bankEntryNames, h5file, loader, processingData, calibFactory, static_cast<size_t>(DISK_CHUNK),
499 static_cast<size_t>(GRAINSIZE_EVENTS), progress);
500 // generate threads only if appropriate
501 if (num_banks_to_read > 1) {
502 tbb::parallel_for(tbb::blocked_range<size_t>(0, num_banks_to_read), task);
503 } else {
504 // a "range" of 1; note -1 to match 0-indexed array with 1-indexed bank labels
505 task(tbb::blocked_range<size_t>(outputSpecNum - 1, outputSpecNum));
506 }
507
508 // close the file so child algorithms can do their thing
509 h5file.close();
510
511 // copy data from processingData to wksp
512 storeSpectraProcessingData(processingData, wksp);
513
514 // update the run TimeROI and remove log data outside the time ROI
515 wksp->mutableRun().setTimeROI(filterROI);
516 wksp->mutableRun().removeDataOutsideTimeROI();
517
518 setProperty(PropertyNames::OUTPUT_WKSP, std::move(wksp));
519 } else {
520 std::string ws_basename = this->getPropertyValue(PropertyNames::OUTPUT_WKSP);
521 std::vector<std::string> wsNames;
522 std::vector<int> workspaceIndices;
523 std::vector<MatrixWorkspace_sptr> workspaces;
524 std::vector<SpectraProcessingData> processingDatas;
525 for (const int &splitter_target : timeSplitter.outputWorkspaceIndices()) {
526 std::string ws_name = ws_basename + "_" + timeSplitter.getWorkspaceIndexName(splitter_target);
527 wsNames.push_back(std::move(ws_name));
528 workspaceIndices.push_back(splitter_target);
529 workspaces.emplace_back(wksp->clone());
530 processingDatas.push_back(initializeSpectraProcessingData(workspaces.back()));
531 }
532
533 auto progress = std::make_shared<API::Progress>(this, .17, .9, num_banks_to_read * workspaceIndices.size());
535 g_log.information() << "Using ProcessBankSplitFullTimeTask for splitter processing\n";
536
537 // Get the combined time ROI for all targets so we only load necessary events.
538 // Need to offset the start time to account for tof's greater than pulsetime. 66.6ms is 4 pulses.
539 auto combined_time_roi = timeSplitter.combinedTimeROI(PULSETIME_OFFSET);
540 if (!filterROI.useAll()) {
541 combined_time_roi.update_intersection(filterROI);
542 }
543
544 // create the nexus loader for handling combined calls to hdf5
545 const auto pulse_indices = this->determinePulseIndices(combined_time_roi);
546 auto loader = std::make_shared<NexusLoader>(is_time_filtered, pulse_indices);
547
548 const auto &splitterMap = timeSplitter.getSplittersMap();
549
550 ProcessBankSplitFullTimeTask task(bankEntryNames, h5file, loader, workspaceIndices, processingDatas, calibFactory,
551 static_cast<size_t>(DISK_CHUNK), static_cast<size_t>(GRAINSIZE_EVENTS),
552 splitterMap, m_pulse_times, progress);
553
554 // generate threads only if appropriate
555 if (num_banks_to_read > 1) {
556 tbb::parallel_for(tbb::blocked_range<size_t>(0, num_banks_to_read), task);
557 } else {
558 // a "range" of 1; note -1 to match 0-indexed array with 1-indexed bank labels
559 task(tbb::blocked_range<size_t>(outputSpecNum - 1, outputSpecNum));
560 }
561
563 g_log.information() << "Using ProcessBankSplitTask for splitter processing\n";
564 // determine the pulse indices from the time and splitter workspace
565 const auto target_to_pulse_indices = this->determinePulseIndicesTargets(filterROI, timeSplitter);
566 // create the nexus loader for handling combined calls to hdf5
567 std::vector<PulseROI> pulse_indices; // intentionally empty to get around loader needing const reference
568 auto loader = std::make_shared<NexusLoader>(is_time_filtered, pulse_indices, target_to_pulse_indices);
569
570 ProcessBankSplitTask task(bankEntryNames, h5file, loader, workspaceIndices, processingDatas, calibFactory,
571 static_cast<size_t>(DISK_CHUNK), static_cast<size_t>(GRAINSIZE_EVENTS), progress);
572 // generate threads only if appropriate
573 if (num_banks_to_read > 1) {
574 tbb::parallel_for(tbb::blocked_range<size_t>(0, num_banks_to_read), task);
575 } else {
576 // a "range" of 1; note -1 to match 0-indexed array with 1-indexed bank labels
577 task(tbb::blocked_range<size_t>(outputSpecNum - 1, outputSpecNum));
578 }
579 } else {
580 g_log.information() << "Using ProcessBankTask for splitter processing\n";
581 // loop over the targets in the splitter workspace, each target gets its own output workspace
582 tbb::parallel_for(
583 tbb::blocked_range<size_t>(0, workspaceIndices.size()),
584 [&](const tbb::blocked_range<size_t> &target_indices) {
585 for (size_t target_index = target_indices.begin(); target_index != target_indices.end(); ++target_index) {
586 const int splitter_target = workspaceIndices[target_index];
587
588 auto splitter_roi = timeSplitter.getTimeROI(splitter_target);
589 // copy the roi so we can modify it just for this target
590 auto target_roi = filterROI;
591 if (target_roi.useAll())
592 target_roi = std::move(splitter_roi); // use the splitter ROI if no time filtering is specified
593 else if (!splitter_roi.useAll())
594 target_roi.update_intersection(splitter_roi); // otherwise intersect with the splitter ROI
595
596 // clone wksp for this target
597 MatrixWorkspace_sptr target_wksp = workspaces[target_index];
598
599 const auto pulse_indices = this->determinePulseIndices(target_roi);
600 auto loader = std::make_shared<NexusLoader>(is_time_filtered, pulse_indices);
601
602 ProcessBankTask task(bankEntryNames, h5file, loader, processingDatas[target_index], calibFactory,
603 static_cast<size_t>(DISK_CHUNK), static_cast<size_t>(GRAINSIZE_EVENTS), progress);
604 // generate threads only if appropriate
605 if (num_banks_to_read > 1) {
606 tbb::parallel_for(tbb::blocked_range<size_t>(0, num_banks_to_read), task);
607 } else {
608 // a "range" of 1; note -1 to match 0-indexed array with 1-indexed bank labels
609 task(tbb::blocked_range<size_t>(outputSpecNum - 1, outputSpecNum));
610 }
611 }
612 });
613 }
614
615 // close the file so child algorithms can do their thing
616 h5file.close();
617
618 // add the workspaces to the ADS
619 for (size_t idx = 0; idx < workspaceIndices.size(); ++idx) {
620 // copy data from processingData to wksp
621 storeSpectraProcessingData(processingDatas[idx], workspaces[idx]);
622
623 // create the target time ROI combining the splitter and filter ROIs
624 auto target_roi = timeSplitter.getTimeROI(workspaceIndices[idx]);
625 if (target_roi.useAll())
626 target_roi = filterROI; // use the splitter ROI if no time filtering is specified
627 else if (!filterROI.useAll())
628 target_roi.update_intersection(filterROI); // otherwise intersect with the splitter ROI
629
630 // update the run TimeROI and remove log data outside the time ROI
631 workspaces[idx]->mutableRun().setTimeROI(target_roi);
632 workspaces[idx]->mutableRun().removeDataOutsideTimeROI();
633 AnalysisDataService::Instance().addOrReplace(wsNames[idx], workspaces[idx]);
634 }
635
636 // group the workspaces
637 auto groupws = createChildAlgorithm("GroupWorkspaces", 0.95, 1.00, true);
638 groupws->setAlwaysStoreInADS(true);
639 groupws->setProperty("InputWorkspaces", wsNames);
640 groupws->setProperty("OutputWorkspace", ws_basename);
641 groupws->execute();
642
643 if (!groupws->isExecuted()) {
644 throw std::runtime_error("Failed to group output workspaces");
645 }
646
647 API::Workspace_sptr outputWorkspace = AnalysisDataService::Instance().retrieveWS<API::Workspace>(ws_basename);
648
649 setProperty(PropertyNames::OUTPUT_WKSP, outputWorkspace);
650 }
651}
652
653MatrixWorkspace_sptr AlignAndFocusPowderSlim::createOutputWorkspace(const Geometry::Instrument_const_sptr inst,
654 size_t num_hist) {
655 // set up the output workspace binning
656 const BINMODE binmode = getPropertyValue(PropertyNames::BINMODE);
657 const bool linearBins = bool(binmode == BinningMode::LINEAR);
658 const std::string binUnits = getPropertyValue(PropertyNames::BIN_UNITS);
659 std::vector<double> x_delta = getProperty(PropertyNames::X_DELTA);
660 std::vector<double> x_min = getProperty(PropertyNames::X_MIN);
661 std::vector<double> x_max = getProperty(PropertyNames::X_MAX);
662 const bool raggedBins = (x_delta.size() != 1 || x_min.size() != 1 || x_max.size() != 1);
663
664 constexpr bool resize_xnew{true};
665 constexpr bool full_bins_only{false};
666
667 // always use the first histogram x-values for initialization
668 HistogramData::BinEdges XValues(0);
669 if (linearBins) {
670 const std::vector<double> params{x_min[0], x_delta[0], x_max[0]};
672 Kernel::VectorHelper::createAxisFromRebinParams(params, XValues.mutableRawData(), resize_xnew, full_bins_only));
673 } else {
674 const std::vector<double> params{x_min[0], -1. * x_delta[0], x_max[0]};
676 Kernel::VectorHelper::createAxisFromRebinParams(params, XValues.mutableRawData(), resize_xnew, full_bins_only));
677 }
678 MatrixWorkspace_sptr wksp = Mantid::DataObjects::create<Workspace2D>(inst, num_hist, XValues);
679
680 if (raggedBins) {
681 // if ragged bins, we need to resize the x-values for each histogram after the first one
682 if (x_delta.size() == 1)
683 x_delta.resize(num_hist, x_delta[0]);
684 if (x_min.size() == 1)
685 x_min.resize(num_hist, x_min[0]);
686 if (x_max.size() == 1)
687 x_max.resize(num_hist, x_max[0]);
688
689 for (size_t i = 1; i < num_hist; ++i) {
690 HistogramData::BinEdges XValues_new(0);
691
692 if (linearBins) {
693 const std::vector<double> params{x_min[i], x_delta[i], x_max[i]};
694 Kernel::VectorHelper::createAxisFromRebinParams(params, XValues_new.mutableRawData(), resize_xnew,
695 full_bins_only);
696 } else {
697 const std::vector<double> params{x_min[i], -1. * x_delta[i], x_max[i]};
698 Kernel::VectorHelper::createAxisFromRebinParams(params, XValues_new.mutableRawData(), resize_xnew,
699 full_bins_only);
700 }
701 HistogramData::Histogram hist(XValues_new, HistogramData::Counts(XValues_new.size() - 1, 0.0));
702 wksp->setHistogram(i, hist);
703 }
704 }
705
706 wksp->getAxis(0)->setUnit(binUnits);
707 wksp->setYUnit("Counts");
708
709 return wksp;
710}
711
713AlignAndFocusPowderSlim::initializeSpectraProcessingData(const API::MatrixWorkspace_sptr &outputWS) {
714 SpectraProcessingData processingData;
715 const size_t numSpectra = outputWS->getNumberHistograms();
716 for (size_t i = 0; i < numSpectra; ++i) {
717 const auto &spectrum = outputWS->getSpectrum(i);
718 processingData.binedges.emplace_back(&spectrum.readX());
719 processingData.counts.emplace_back(spectrum.dataY().size());
720 }
721 return processingData;
722}
723
724void AlignAndFocusPowderSlim::storeSpectraProcessingData(const SpectraProcessingData &processingData,
725 const API::MatrixWorkspace_sptr &outputWS) {
726 const size_t numSpectra = outputWS->getNumberHistograms();
727 for (size_t i = 0; i < numSpectra; ++i) {
728 auto &spectrum = outputWS->getSpectrum(i);
729 auto &y_values = spectrum.dataY();
730 std::transform(
731 processingData.counts[i].cbegin(), processingData.counts[i].cend(), y_values.begin(),
732 [](const std::atomic_uint32_t &val) { return static_cast<double>(val.load(std::memory_order_relaxed)); });
733 auto &e_values = spectrum.dataE();
734 std::transform(processingData.counts[i].cbegin(), processingData.counts[i].cend(), e_values.begin(),
735 [](const std::atomic_uint32_t &val) {
736 return std::sqrt(static_cast<double>(val.load(std::memory_order_relaxed)));
737 });
738 }
739}
740
741void AlignAndFocusPowderSlim::initCalibrationConstants(API::MatrixWorkspace_sptr &wksp,
742 const std::vector<double> &difc_focus) {
743 const auto detInfo = wksp->detectorInfo();
744
745 for (auto iter = detInfo.cbegin(); iter != detInfo.cend(); ++iter) {
746 if (!iter->isMonitor()) {
747 const auto difc_focussed = getFocussedPostion(static_cast<detid_t>(iter->detid()), difc_focus, detIDToSpecNum);
748 if (difc_focussed == IGNORE_PIXEL)
749 m_calibration.emplace(static_cast<detid_t>(iter->detid()), IGNORE_PIXEL);
750 else
751 m_calibration.emplace(static_cast<detid_t>(iter->detid()),
752 difc_focussed / detInfo.difcUncalibrated(iter->index()));
753 }
754 }
755}
756
757void AlignAndFocusPowderSlim::initCalibrationConstantsFromCalWS(const std::vector<double> &difc_focus,
758 const ITableWorkspace_sptr calibrationWS) {
759 for (size_t row = 0; row < calibrationWS->rowCount(); ++row) {
760 const detid_t detid = calibrationWS->cell<int>(row, 0);
761 const double detc = calibrationWS->cell<double>(row, 1);
762 const auto difc_focussed = getFocussedPostion(detid, difc_focus, detIDToSpecNum);
763 if (difc_focussed == IGNORE_PIXEL)
764 m_calibration.emplace(detid, IGNORE_PIXEL);
765 else
766 m_calibration.emplace(detid, difc_focussed / detc);
767 }
768}
769
770const ITableWorkspace_sptr AlignAndFocusPowderSlim::loadCalFile(const Mantid::API::Workspace_sptr &inputWS,
771 const std::string &filename,
772 GroupingWorkspace_sptr &groupingWS) {
773 const bool load_grouping = !groupingWS;
774
775 auto alg = createChildAlgorithm("LoadDiffCal");
776 alg->setProperty("InputWorkspace", inputWS);
777 alg->setPropertyValue("Filename", filename);
778 alg->setProperty<bool>("MakeCalWorkspace", true);
779 alg->setProperty<bool>("MakeGroupingWorkspace", load_grouping);
780 alg->setProperty<bool>("MakeMaskWorkspace", true);
781 alg->setPropertyValue("WorkspaceName", "temp");
782 alg->executeAsChildAlg();
783
784 if (load_grouping) {
785 g_log.debug() << "Loading grouping workspace from calibration file\n";
786 groupingWS = alg->getProperty("OutputGroupingWorkspace");
787 }
788
789 const ITableWorkspace_sptr calibrationWS = alg->getProperty("OutputCalWorkspace");
790
791 const MaskWorkspace_sptr maskWS = alg->getProperty("OutputMaskWorkspace");
792 m_masked = maskWS->getMaskedDetectors();
793 g_log.debug() << "Masked detectors: " << m_masked.size() << '\n';
794
795 return calibrationWS;
796}
797
802void AlignAndFocusPowderSlim::initScaleAtSample(const API::MatrixWorkspace_sptr &wksp) {
803 // detector information for all of the L2
804 const auto detInfo = wksp->detectorInfo();
805 // cache a single L1 value
806 const double L1 = detInfo.l1();
807
808 if (this->getProperty(PropertyNames::CORRECTION_TO_SAMPLE)) {
809 // calculate scale factors for each detector
810 for (auto iter = detInfo.cbegin(); iter != detInfo.cend(); ++iter) {
811 if (!iter->isMonitor()) {
812 const double path_correction = L1 / (L1 + iter->l2()) * 1000.0;
813 m_scale_at_sample.emplace(static_cast<detid_t>(iter->detid()), path_correction);
814 }
815 }
816 } else {
817 // set all scale factors to 1.0
818 for (auto iter = detInfo.cbegin(); iter != detInfo.cend(); ++iter) {
819 if (!iter->isMonitor()) {
820 m_scale_at_sample.emplace(static_cast<detid_t>(iter->detid()), 1000.0);
821 }
822 }
823 }
824}
825
826API::MatrixWorkspace_sptr AlignAndFocusPowderSlim::editInstrumentGeometry(
827 API::MatrixWorkspace_sptr &wksp, const double l1, const std::vector<double> &polars,
828 const std::vector<specnum_t> &specids, const std::vector<double> &l2s, const std::vector<double> &azimuthals) {
829 API::IAlgorithm_sptr editAlg = createChildAlgorithm("EditInstrumentGeometry");
830 editAlg->setLoggingOffset(1);
831 editAlg->setProperty("Workspace", wksp);
832 if (l1 > 0.)
833 editAlg->setProperty("PrimaryFlightPath", l1);
834 if (!polars.empty())
835 editAlg->setProperty("Polar", polars);
836 if (!specids.empty())
837 editAlg->setProperty("SpectrumIDs", specids);
838 if (!l2s.empty())
839 editAlg->setProperty("L2", l2s);
840 if (!azimuthals.empty())
841 editAlg->setProperty("Azimuthal", azimuthals);
842 editAlg->executeAsChildAlg();
843
844 wksp = editAlg->getProperty("Workspace");
845
846 return wksp;
847}
848
849API::MatrixWorkspace_sptr AlignAndFocusPowderSlim::convertToTOF(API::MatrixWorkspace_sptr &wksp) {
850 if (wksp->getAxis(0)->unit()->unitID() == "TOF") {
851 // already in TOF, no need to convert
852 return wksp;
853 }
854
855 API::IAlgorithm_sptr convertUnits = createChildAlgorithm("ConvertUnits");
856 convertUnits->setProperty("InputWorkspace", wksp);
857 convertUnits->setPropertyValue("Target", "TOF");
858 convertUnits->executeAsChildAlg();
859 wksp = convertUnits->getProperty("OutputWorkspace");
860
861 return wksp;
862}
863
871Kernel::TimeROI AlignAndFocusPowderSlim::getFilterROI(const API::MatrixWorkspace_sptr &wksp) {
872 Kernel::TimeROI roi;
873 const auto startOfRun = wksp->run().startTime();
874
875 // filter by time
876 double filter_time_start_sec = getProperty(PropertyNames::FILTER_TIMESTART);
877 double filter_time_stop_sec = getProperty(PropertyNames::FILTER_TIMESTOP);
878 if (filter_time_start_sec != EMPTY_DBL() || filter_time_stop_sec != EMPTY_DBL()) {
879 this->progress(.15, "Creating time filtering");
880 g_log.information() << "Filtering pulses from " << filter_time_start_sec << " to " << filter_time_stop_sec << "s\n";
881
882 try {
883 roi.addROI(startOfRun + (filter_time_start_sec == EMPTY_DBL() ? 0.0 : filter_time_start_sec),
884 startOfRun + filter_time_stop_sec); // start and stop times in seconds
885 } catch (const std::runtime_error &e) {
886 throw std::invalid_argument("Invalid time range for filtering: " + std::string(e.what()));
887 }
888 }
889
890 // filter bad pulses
891 if (getProperty(PropertyNames::FILTER_BAD_PULSES)) {
892 this->progress(.16, "Filtering bad pulses");
893
894 // get limits from proton_charge
895 const auto [min_pcharge, max_pcharge, mean] =
896 wksp->run().getBadPulseRange(LOG_CHARGE_NAME, getProperty(PropertyNames::FILTER_BAD_PULSES_LOWER_CUTOFF));
897 g_log.information() << "Filtering bad pulses; pcharge outside of " << min_pcharge << " to " << max_pcharge << '\n';
898
899 const auto run_start = wksp->getFirstPulseTime();
900 const auto run_stop = wksp->getLastPulseTime();
901
902 const auto log = dynamic_cast<const TimeSeriesProperty<double> *>(wksp->run().getLogData(LOG_CHARGE_NAME));
903 if (log) {
904 // need to have centre=true for proton_charge
905 roi = log->makeFilterByValue(min_pcharge, max_pcharge, true, Mantid::Kernel::TimeInterval(run_start, run_stop),
906 0.0, true, &roi);
907 }
908 }
909 return roi;
910}
911
918std::vector<PulseROI> AlignAndFocusPowderSlim::determinePulseIndices(const TimeROI &filterROI) {
919
920 std::vector<PulseROI> pulse_indices;
921 if (filterROI.useAll()) {
922 pulse_indices.emplace_back(0, std::numeric_limits<size_t>::max());
923 } else {
924 is_time_filtered = true;
925 pulse_indices = filterROI.calculate_indices(*m_pulse_times);
926 if (pulse_indices.empty())
927 throw std::invalid_argument("No valid pulse time indices found for filtering");
928 }
929
930 return pulse_indices;
931}
932
941std::vector<std::pair<int, PulseROI>>
942AlignAndFocusPowderSlim::determinePulseIndicesTargets(const TimeROI &filterROI, const TimeSplitter &timeSplitter) {
943 std::vector<PulseROI> pulse_indices;
944 if (filterROI.useAll()) {
945 pulse_indices.emplace_back(0, std::numeric_limits<size_t>::max());
946 } else {
947 pulse_indices = filterROI.calculate_indices(*m_pulse_times);
948 if (pulse_indices.empty())
949 throw std::invalid_argument("No valid pulse time indices found for filtering");
950 }
951
952 const auto target_to_pulse_indices = timeSplitter.calculate_target_indices(*m_pulse_times);
953
954 // calculate intersection of target pulse indices and time filter pulse indices (removes pulses outside filterROI)
955 std::vector<std::pair<int, PulseROI>> intersected_target_pulse_indices;
956 auto pulse_it = pulse_indices.cbegin();
957 for (const auto &target_pair : target_to_pulse_indices) {
958 // move pulse_it to the first pulse that could overlap
959 while (pulse_it != pulse_indices.cend() && pulse_it->second <= target_pair.second.first) {
960 ++pulse_it;
961 }
962 // check for overlaps
963 auto check_it = pulse_it;
964 while (check_it != pulse_indices.cend() && check_it->first < target_pair.second.second) {
965 // there is an overlap
966 size_t start_index = std::max(check_it->first, target_pair.second.first);
967 size_t stop_index = std::min(check_it->second, target_pair.second.second);
968 if (start_index < stop_index) {
969 intersected_target_pulse_indices.emplace_back(target_pair.first, PulseROI(start_index, stop_index));
970 }
971 ++check_it;
972 }
973 }
974
975 return intersected_target_pulse_indices;
976}
977
979AlignAndFocusPowderSlim::timeSplitterFromSplitterWorkspace(const Types::Core::DateAndTime &filterStartTime) {
980 API::Workspace_sptr tempws = this->getProperty(PropertyNames::SPLITTER_WS);
981 DataObjects::SplittersWorkspace_sptr splittersWorkspace =
982 std::dynamic_pointer_cast<DataObjects::SplittersWorkspace>(tempws);
983 DataObjects::TableWorkspace_sptr splitterTableWorkspace =
984 std::dynamic_pointer_cast<DataObjects::TableWorkspace>(tempws);
985 API::MatrixWorkspace_sptr matrixSplitterWS = std::dynamic_pointer_cast<API::MatrixWorkspace>(tempws);
986
987 if (!splittersWorkspace && !splitterTableWorkspace && !matrixSplitterWS)
988 return {};
989
990 const bool isSplittersRelativeTime = this->getProperty(PropertyNames::SPLITTER_RELATIVE);
991
992 TimeSplitter time_splitter;
993 if (splittersWorkspace) {
994 time_splitter = TimeSplitter{splittersWorkspace};
995 } else if (splitterTableWorkspace) {
996 time_splitter =
997 TimeSplitter(splitterTableWorkspace, isSplittersRelativeTime ? filterStartTime : DateAndTime::GPS_EPOCH);
998 } else {
999 time_splitter = TimeSplitter(matrixSplitterWS, isSplittersRelativeTime ? filterStartTime : DateAndTime::GPS_EPOCH);
1000 }
1001
1002 return time_splitter;
1003}
1004
1005} // namespace Mantid::DataHandling::AlignAndFocusPowderSlim
std::string name
Definition Run.cpp:60
#define DECLARE_ALGORITHM(classname)
Definition Algorithm.h:538
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition System.h:48
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.
Kernel::Logger & g_log
Definition Algorithm.h:422
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
bool isDefault(const std::string &name) const
A specialized class for dealing with file properties.
@ OptionalLoad
to specify a file to read but the file doesn't have to exist
@ Load
allowed here which will be passed to the algorithm
A property class for workspaces.
Base Workspace Abstract Class.
Definition Workspace.h:29
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
API::MatrixWorkspace_sptr createOutputWorkspace(const Geometry::Instrument_const_sptr inst, size_t num_hist)
std::vector< std::pair< size_t, size_t > > determinePulseIndices(const Kernel::TimeROI &filterROI)
Determine the pulse indices for a given workspace and time ROI.
std::map< std::string, std::string > validateInputs() override
Perform validation of ALL the input properties of the algorithm.
SpectraProcessingData initializeSpectraProcessingData(const API::MatrixWorkspace_sptr &outputWS)
std::vector< int64_t > loadStart
Index to load start at in the file.
std::shared_ptr< std::vector< Types::Core::DateAndTime > > m_pulse_times
void storeSpectraProcessingData(const SpectraProcessingData &processingData, const API::MatrixWorkspace_sptr &outputWS)
DataObjects::TimeSplitter timeSplitterFromSplitterWorkspace(const Types::Core::DateAndTime &)
std::map< detid_t, double > m_scale_at_sample
Multiplicative 0<value<1 to move neutron TOF at sample.
void initScaleAtSample(const API::MatrixWorkspace_sptr &wksp)
For fast logs, calculate the sample position correction.
const std::string category() const override
Algorithm's category for identification.
std::vector< std::pair< int, std::pair< size_t, size_t > > > determinePulseIndicesTargets(const Kernel::TimeROI &filterROI, const DataObjects::TimeSplitter &timeSplitter)
Determine the pulse indices for a given workspace, time ROI, and time splitter.
API::MatrixWorkspace_sptr editInstrumentGeometry(API::MatrixWorkspace_sptr &wksp, const double l1, const std::vector< double > &polars, const std::vector< specnum_t > &specids, const std::vector< double > &l2s, const std::vector< double > &azimuthals)
int version() const override
Algorithm's version for identification.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
void initCalibrationConstantsFromCalWS(const std::vector< double > &difc_focus, const API::ITableWorkspace_sptr calibrationWS)
const API::ITableWorkspace_sptr loadCalFile(const API::Workspace_sptr &inputWS, const std::string &filename, DataObjects::GroupingWorkspace_sptr &groupingWS)
Kernel::TimeROI getFilterROI(const API::MatrixWorkspace_sptr &wksp)
Create a TimeROI based on the filtering properties set in the algorithm.
API::MatrixWorkspace_sptr convertToTOF(API::MatrixWorkspace_sptr &wksp)
void initCalibrationConstants(API::MatrixWorkspace_sptr &wksp, const std::vector< double > &difc_focus)
static void loadEntryMetadata(const std::string &nexusfilename, T WS, const std::string &entry_name, const Nexus::NexusDescriptor &descriptor)
Load the run number and other meta data from the given bank.
std::vector< std::pair< int, std::pair< size_t, size_t > > > calculate_target_indices(const std::vector< DateAndTime > &times) const
Given a list of times, calculate the corresponding indices in the TimeSplitter.
Concrete workspace implementation.
Definition Workspace2D.h:29
Kernel/ArrayBoundedValidator.h.
Support for a property that holds an array of values.
BoundedValidator is a validator that requires the values to be between upper or lower bounds,...
A concrete property based on user options of a finite list of strings.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void setPropertyGroup(const std::string &name, const std::string &group)
Set the group for a given property.
void debug(const std::string &msg)
Logs at debug level.
Definition Logger.cpp:145
void warning(const std::string &msg)
Logs at warning level.
Definition Logger.cpp:117
void information(const std::string &msg)
Logs at information level.
Definition Logger.cpp:136
Validator to check that a property is not left empty.
The concrete, templated class for properties.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
Represents a time interval.
Definition DateAndTime.h:25
TimeROI : Object that holds information about when the time measurement was active.
Definition TimeROI.h:18
std::vector< std::pair< size_t, size_t > > calculate_indices(const std::vector< Types::Core::DateAndTime > &times) const
Definition TimeROI.cpp:346
void addROI(const std::string &startTime, const std::string &stopTime)
Definition TimeROI.cpp:76
bool useAll() const
TimeROI selects all time to be used.
Definition TimeROI.cpp:693
A specialised Property class for holding a series of time-value pairs.
const std::map< std::string, std::set< std::string > > & getAllEntries() const noexcept
Returns a const reference of the internal map holding all entries in the Nexus HDF5 file.
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Mantid::Kernel::SingletonHolder< AnalysisDataServiceImpl > AnalysisDataService
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
const std::string GROUPING_WS("GroupingWorkspace")
const std::string FILTER_TIMESTART("FilterByTimeStart")
const std::string FILTER_BAD_PULSES_LOWER_CUTOFF("BadPulsesLowerCutoff")
const std::string OUTPUT_SPEC_NUM("OutputSpectrumNumber")
const std::string PROCESS_BANK_SPLIT_TASK("ProcessBankSplitTask")
const std::string CORRECTION_TO_SAMPLE("CorrectionToSample")
const std::string FILTER_TIMESTOP("FilterByTimeStop")
const std::string SPLITTER_WS("SplitterWorkspace")
const std::string EVENTS_PER_THREAD("EventsPerThread")
const std::string FILTER_BAD_PULSES("FilterBadPulses")
const std::string READ_SIZE_FROM_DISK("ReadSizeFromDisk")
std::shared_ptr< SplittersWorkspace > SplittersWorkspace_sptr
std::shared_ptr< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace
std::shared_ptr< GroupingWorkspace > GroupingWorkspace_sptr
shared pointer to the GroupingWorkspace class
std::shared_ptr< MaskWorkspace > MaskWorkspace_sptr
shared pointer to the MaskWorkspace class
constexpr double deg2rad
Defines units/enum for Crystal work.
Definition AngleUnits.h:20
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
MANTID_KERNEL_DLL std::string strmakef(char const *const fmt,...)
This is the constructor that std::string needed to have.
Definition Strings.cpp:1205
int MANTID_KERNEL_DLL createAxisFromRebinParams(const std::vector< double > &params, std::vector< double > &xnew, const bool resize_xnew=true, const bool full_bins_only=false, const double xMinHint=std::nan(""), const double xMaxHint=std::nan(""), const bool useReverseLogarithmic=false, const double power=-1)
Creates a new output X array given a 'standard' set of rebinning parameters.
MANTID_NEXUS_DLL H5::FileAccPropList defaultFileAcc()
Default file access is H5F_CLOSE_STRONG.
Definition H5Util.cpp:119
const std::string BINMODE("BinningMode")
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
Definition EmptyValues.h:24
int32_t detid_t
Typedef for a detector ID.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
Definition EmptyValues.h:42
STL namespace.
std::string to_string(const wide_integer< Bits, Signed > &n)
std::vector< std::vector< std::atomic_uint32_t > > counts
Describes the direction (within an algorithm) of a Property.
Definition Property.h:50
@ Input
An input workspace.
Definition Property.h:53
@ Output
An output workspace.
Definition Property.h:54