-
Notifications
You must be signed in to change notification settings - Fork 122
/
PlotAsymmetryByLogValue.h
176 lines (156 loc) · 6.33 KB
/
PlotAsymmetryByLogValue.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#ifndef MANTID_ALGORITHM_PLOTASYMMETRYBULOGVALUE_H_
#define MANTID_ALGORITHM_PLOTASYMMETRYBULOGVALUE_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/Algorithm.h"
#include "MantidDataObjects/Workspace2D.h"
namespace Mantid {
//----------------------------------------------------------------------
// Forward declarations
//----------------------------------------------------------------------
namespace API {
class MatrixWorkspace;
}
namespace Algorithms {
/**Takes a muon workspace as input and sums all the spectra into two spectra
which represent
the two detector groupings. The resultant spectra are used to calculate
(F-aB) / (F+aB) the results of which
are stored in the output workspace.
Required Properties:
<UL>
<LI> InputWorkspace - The name of the Workspace2D to take as input </LI>
<LI> OutputWorkspace - The name of the workspace in which to store the result
</LI>
<LI> ForwardSpectra - The detector number of the first group </LI>
<LI> BackwardSpectra - The detector number of the second group </LI>
<LI> Alpha - ?? </LI>
</UL>
@author
@date 11/07/2008
Copyright © 2008 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport PlotAsymmetryByLogValue : public API::Algorithm {
public:
/// Default constructor
PlotAsymmetryByLogValue();
/// Destructor
~PlotAsymmetryByLogValue() override{};
/// Algorithm's name for identification overriding a virtual method
const std::string name() const override { return "PlotAsymmetryByLogValue"; }
/// Summary of algorithms purpose
const std::string summary() const override {
return "Calculates asymmetry for a series of log values";
}
/// Algorithm's version for identification overriding a virtual method
int version() const override { return 1; }
/// Algorithm's category for identification overriding a virtual method
const std::string category() const override { return "Muon"; }
private:
// Overridden Algorithm methods
void init() override;
void exec() override;
// Load run, apply dead time corrections and detector grouping
API::Workspace_sptr doLoad(size_t runNumber);
// Analyse loaded run
void doAnalysis(API::Workspace_sptr loadedWs, size_t index);
// Parse run names
void parseRunNames(std::string &firstFN, std::string &lastFN,
std::string &fnBase, std::string &fnExt, int &fnZeros);
// Load dead-time corrections from specified file
API::Workspace_sptr loadCorrectionsFromFile(const std::string &deadTimeFile);
// Apply dead-time corrections
void applyDeadtimeCorr(API::Workspace_sptr &loadedWs,
API::Workspace_sptr deadTimes);
/// Create custom detector grouping
API::Workspace_sptr createCustomGrouping(const std::vector<int> &fwd,
const std::vector<int> &bwd);
/// Group detectors
void groupDetectors(API::Workspace_sptr &loadedWs,
API::Workspace_sptr grouping);
/// Calculate the integral asymmetry for a workspace (single period)
void calcIntAsymmetry(API::MatrixWorkspace_sptr ws, double &Y, double &E);
/// Calculate the integral asymmetry for a workspace (red & green)
void calcIntAsymmetry(API::MatrixWorkspace_sptr ws_red,
API::MatrixWorkspace_sptr ws_green, double &Y,
double &E);
/// Group detectors
void groupDetectors(API::MatrixWorkspace_sptr &ws,
const std::vector<int> &spectraList);
/// Get log value
double getLogValue(API::MatrixWorkspace &ws);
/// Populate output workspace with results
void populateOutputWorkspace(API::MatrixWorkspace_sptr &outWS, int nplots);
/// Populate the hidden ws storing current results
void saveResultsToADS(API::MatrixWorkspace_sptr &outWS, int nplots);
/// Check input properties
void checkProperties(size_t &is, size_t &ie);
/// Properties needed to load a run
/// Stores base name shared by all runs
std::string m_filenameBase;
/// Stores extension shared by all runs
std::string m_filenameExt;
/// Sotres number of zeros in run name
int m_filenameZeros;
/// Store type of dead time corrections
std::string m_dtcType;
/// File to read corrections from
std::string m_dtcFile;
/// Store forward spectra
std::vector<int> m_forward_list;
/// Store backward spectra
std::vector<int> m_backward_list;
/// Properties needed to analyse a run
/// Type of calculation: integral or differential
bool m_int;
/// Red period
int m_red;
/// Green period
int m_green;
/// Minimum time for the analysis
double m_minTime;
/// Maximum time for the analysis
double m_maxTime;
/// Properties needed to get the log value
// LogValue name
std::string m_logName;
/// LogValue function
std::string m_logFunc;
/// Mantid maps to store intermediate results
// Map to store log value
std::map<size_t, double> m_logValue;
// Red values
std::map<size_t, double> m_redY;
std::map<size_t, double> m_redE;
// Green values
std::map<size_t, double> m_greenY;
std::map<size_t, double> m_greenE;
// Sum values (Red + Green)
std::map<size_t, double> m_sumY;
std::map<size_t, double> m_sumE;
// Diff values (Red - Green)
std::map<size_t, double> m_diffY;
std::map<size_t, double> m_diffE;
// String containing all the properties
std::string m_allProperties;
// Name of the hidden ws
std::string m_currResName;
};
} // namespace Algorithm
} // namespace Mantid
#endif /*MANTID_ALGORITHM_PLOTASYMMETRYBULOGVALUE_H_*/