Skip to content

Commit 38d12e7

Browse files
peterfpetersonrosswhitfieldpre-commit-ci[bot]
authored
AlignAndFocusPowderSlim prototype (#38279)
* Template code from class_maker * Make method public so it can be reused * Remove unused variable * First version with everything hard-coded * Add methods to DetectorInfo to make the iterator more useful * Add support for having focus parameters * Simple parallel event processing * Multithread finding min/max and add timers * Move to std::optional like the rest of mantid * Add Fitler By Time * Fix limits * Add loading cal file and change output to be d-spacing * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Set units * Add binning params * Simplify workspace creation * Use mask from calibration file * Filter banks to process before starting the main processing loop * Refactor code in preparation of having a loading task * Refactor code to multithread reading from disk * Undo changes to LoadBankFromDiskTask * Add event filtering and loading logs * Read 1GB of events from disk at a time to improve perfomance on larger files * Change name following nexus refactor * Split binning parameters into separate properties * Add focus positions and set them on the instrument * Change the units of the output workspace to TOF and fix all the math * Add test with default values for everything * Add test with values appropriate for the data * Expose how many banks to read in a single thread and add progress bar * Move chunking parameters to be input options * Add release notes * Change return since it is always a known value * Make clear this is for vulcan plus small multithreading improvements * Ignore commit from using black on the repository * Ban 1GB VULCAN file from system test to keep things moving * Fix issues spotted by clang * Add user docs. Most of them are limitations * Lots of small changes based on review observations * Bring back make_unique for cppcheck --------- Co-authored-by: Ross Whitfield <whitfieldre1@ornl.gov> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 33a6dd7 commit 38d12e7

File tree

15 files changed

+1097
-9
lines changed

15 files changed

+1097
-9
lines changed

.git-blame-ignore-revs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
# git blame --ignore-revs-file .git-blame-ignore-revs
1212

1313
dccacdbddbc28f43a4ab9d1b63caf2fda71b1688
14+
80a5951cd11c70f24836b934d832ef7c265daa84
1415
9485437150f800515afbf15ab6ef05108714a0eb
1516
a90b115e443e27eb187aba3cd794eee591079401

Framework/DataHandling/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
set(SRC_FILES
2+
src/AlignAndFocusPowderSlim.cpp
23
src/ApplyDiffCal.cpp
34
src/BankPulseTimes.cpp
45
src/CheckMantidVersion.cpp
@@ -211,6 +212,7 @@ set(SRC_FILES
211212
)
212213

213214
set(INC_FILES
215+
inc/MantidDataHandling/AlignAndFocusPowderSlim.h
214216
inc/MantidDataHandling/ApplyDiffCal.h
215217
inc/MantidDataHandling/BankPulseTimes.h
216218
inc/MantidDataHandling/BitStream.h
@@ -427,6 +429,7 @@ set(INC_FILES
427429
)
428430

429431
set(TEST_FILES
432+
AlignAndFocusPowderSlimTest.h
430433
ApplyDiffCalTest.h
431434
BankPulseTimesTest.h
432435
CheckMantidVersionTest.h
@@ -449,8 +452,8 @@ set(TEST_FILES
449452
ExtractPolarizationEfficienciesTest.h
450453
FindDetectorsInShapeTest.h
451454
FindDetectorsParTest.h
452-
GenerateGroupingPowderTest.h
453455
GenerateGroupingPowder2Test.h
456+
GenerateGroupingPowderTest.h
454457
GroupDetectors2Test.h
455458
GroupDetectorsTest.h
456459
ISISDataArchiveTest.h
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Mantid Repository : https://github.com/mantidproject/mantid
2+
//
3+
// Copyright &copy; 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+
#pragma once
8+
9+
#include "MantidAPI/Algorithm.h"
10+
#include "MantidAPI/MatrixWorkspace_fwd.h"
11+
#include "MantidDataHandling/DllConfig.h"
12+
#include "MantidGeometry/IDTypes.h"
13+
14+
namespace NeXus {
15+
class File;
16+
}
17+
18+
namespace Mantid {
19+
namespace DataHandling {
20+
21+
/** AlignAndFocusPowderSlim : TODO: DESCRIPTION
22+
*/
23+
class MANTID_DATAHANDLING_DLL AlignAndFocusPowderSlim : public API::Algorithm {
24+
public:
25+
const std::string name() const override;
26+
int version() const override;
27+
const std::string category() const override;
28+
const std::string summary() const override;
29+
const std::vector<std::string> seeAlso() const override;
30+
31+
class MANTID_DATAHANDLING_DLL BankCalibration {
32+
public:
33+
BankCalibration(const detid_t idmin, const detid_t idmax, const std::map<detid_t, double> &calibration_map);
34+
const double &value(const detid_t detid) const;
35+
const detid_t &idmin() const;
36+
detid_t idmax() const;
37+
38+
private:
39+
std::vector<double> m_calibration;
40+
detid_t m_detid_offset;
41+
};
42+
43+
private:
44+
void init() override;
45+
std::map<std::string, std::string> validateInputs() override;
46+
void exec() override;
47+
48+
API::MatrixWorkspace_sptr createOutputWorkspace(const size_t numHist, const bool linearBins, const double x_delta);
49+
API::MatrixWorkspace_sptr editInstrumentGeometry(API::MatrixWorkspace_sptr &wksp, const double l1,
50+
const std::vector<double> &polars,
51+
const std::vector<specnum_t> &specids,
52+
const std::vector<double> &l2s,
53+
const std::vector<double> &azimuthals);
54+
void initCalibrationConstants(API::MatrixWorkspace_sptr &wksp, const std::vector<double> &difc_focus);
55+
void loadCalFile(const API::Workspace_sptr &inputWS, const std::string &filename,
56+
const std::vector<double> &difc_focus);
57+
58+
std::map<detid_t, double> m_calibration; // detid: 1/difc
59+
std::set<detid_t> m_masked;
60+
bool is_time_filtered{false};
61+
size_t pulse_start_index{0};
62+
size_t pulse_stop_index{std::numeric_limits<size_t>::max()};
63+
/// Index to load start at in the file
64+
std::vector<int64_t> loadStart;
65+
/// How much to load in the file
66+
std::vector<int64_t> loadSize;
67+
};
68+
69+
} // namespace DataHandling
70+
} // namespace Mantid

0 commit comments

Comments
 (0)