-
Notifications
You must be signed in to change notification settings - Fork 122
/
GetAllEi.h
106 lines (94 loc) · 5.01 KB
/
GetAllEi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2008 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAlgorithms/DllConfig.h"
#include "MantidKernel/cow_ptr.h"
//#include "MantidAPI/IAlgorithm.h"
namespace Mantid {
namespace Geometry {
class IComponent;
}
namespace Kernel {
class Unit;
}
namespace Algorithms {
/** Estimate all incident energies, used by chopper instrument.
*/
class MANTID_ALGORITHMS_DLL GetAllEi : public API::Algorithm {
public:
GetAllEi();
/// Algorithms name for identification. @see Algorithm::name
const std::string name() const override { return "GetAllEi"; };
/// Algorithm's summary for use in the GUI and help. @see Algorithm::summary
const std::string summary() const override {
return "Analyze the chopper logs and the signal registered by the monitors "
"to identify energies used as incident energies in an inelastic "
"experiment.";
}
/// Algorithm's version for identification. @see Algorithm::version
int version() const override { return 1; };
const std::vector<std::string> seeAlso() const override { return {"GetEi"}; }
/// Algorithm's category for identification. @see Algorithm::category
const std::string category() const override { return "Inelastic\\Ei"; };
/// Cross-check properties with each other @see IAlgorithm::validateInputs
std::map<std::string, std::string> validateInputs() override;
private:
// Implement abstract Algorithm methods
void init() override;
void exec() override;
Kernel::Property *getPLogForProperty(const API::MatrixWorkspace_sptr &inputWS, const std::string &propertyName);
void setFilterLog(const API::MatrixWorkspace_sptr &inputWS);
// former lambda function exposed as not evry compiler support this yet
bool peakGuess(const API::MatrixWorkspace_sptr &inputWS, size_t index, double Ei,
const std::vector<size_t> &monsRangeMin, const std::vector<size_t> &monsRangeMax, double &peakPos,
double &peakHeight, double &peakTwoSigma);
protected: // for testing, private otherwise.
// prepare working workspace with appropriate monitor spectra for fitting
API::MatrixWorkspace_sptr
// prepare matrix workspace to analyze monitor signal
buildWorkspaceToFit(const API::MatrixWorkspace_sptr &inputWS, size_t &wsIndex0);
/**Return average time series log value for the appropriately filtered log*/
double getAvrgLogValue(const API::MatrixWorkspace_sptr &inputWS, const std::string &propertyName,
std::vector<Kernel::SplittingInterval> &splitter);
/**process logs and retrieve chopper speed and chopper delay*/
void findChopSpeedAndDelay(const API::MatrixWorkspace_sptr &inputWS, double &chop_speed, double &chop_delay);
void findGuessOpeningTimes(const std::pair<double, double> &TOF_range, double ChopDelay, double Period,
std::vector<double> &guess_opening_times);
/**Get energy of monitor peak if one is present*/
bool findMonitorPeak(const API::MatrixWorkspace_sptr &inputWS, double Ei, const std::vector<size_t> &monsRangeMin,
const std::vector<size_t> &monsRangeMax, double &position, double &height, double &twoSigma);
/**Find indexes of each expected peak intervals */
void findBinRanges(const HistogramData::HistogramX &eBins, const HistogramData::HistogramY &signal,
const std::vector<double> &guess_energy, double eResolution, std::vector<size_t> &irangeMin,
std::vector<size_t> &irangeMax, std::vector<bool> &guessValid);
size_t calcDerivativeAndCountZeros(const std::vector<double> &bins, const std::vector<double> &signal,
std::vector<double> &deriv, std::vector<double> &zeros);
/**Auxiliary method to print guess chopper energies in debug mode*/
void printDebugModeInfo(const std::vector<double> &guess_opening, const std::pair<double, double> &TOF_range,
std::shared_ptr<Kernel::Unit> &destUnit);
/// if true, take derivate of the filter log to identify interval when
/// instrument is running.
bool m_FilterWithDerivative;
/// maximal relative peak width to consider acceptable. Defined by minimal
/// instrument resolution
/// and does not exceed 0.08
double m_min_Eresolution;
// set as half max LET resolution at 20mev at 5e-4
double m_max_Eresolution;
double m_peakEnergyRatio2reject;
// the value of constant phase shift on the chopper used to calculate
// tof at chopper from recorded delay.
double m_phase;
// internal pointer to access to chopper
std::shared_ptr<const Geometry::IComponent> m_chopper;
// internal pointer to access log, used for filtering
Kernel::TimeSeriesProperty<double> *m_pFilterLog;
};
} // namespace Algorithms
} // namespace Mantid