-
Notifications
You must be signed in to change notification settings - Fork 122
/
PlotAsymmetryByLogValue.h
174 lines (161 loc) · 6.48 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
// 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
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/Algorithm.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidMuon/DllConfig.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 spectrum numbers of the forward group </LI>
<LI> BackwardSpectra - The spectrum numbers of the backward group </LI>
<LI> Alpha - balance parameter </LI>
</UL>
@author
@date 11/07/2008
*/
class MANTID_MUON_DLL PlotAsymmetryByLogValue : public API::Algorithm {
public:
/// Default constructor
PlotAsymmetryByLogValue();
/// 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; }
const std::vector<std::string> seeAlso() const override {
return {"AsymmetryCalc", "CalculateMuonAsymmetry", "PlotPeakByLogValue"};
}
/// Algorithm's category for identification overriding a virtual method
const std::string category() const override { return "Muon"; }
std::map<std::string, std::string> validateInputs() override;
int extractRunNumberFromRunName(std::string runName);
private:
// Overridden Algorithm methods
void init() override;
void exec() override;
// Load run, apply dead time corrections and detector grouping
API::Workspace_sptr doLoad(const std::string &fileName);
// Analyse loaded run
void doAnalysis(const 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(const API::MatrixWorkspace_sptr &ws, double &Y,
double &E);
/// Calculate the integral asymmetry for a workspace (red & green)
void calcIntAsymmetry(const API::MatrixWorkspace_sptr &ws_red,
const 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 &firstRunNumber, size_t &lastRunNumber);
/// Get path to the direcotry from a file name
std::string getDirectoryFromFileName(const std::string &fileName) const;
/// Uses FirstRun and LastRun to populate filenames vector
void populateFileNamesFromFirstLast(std::string firstRun,
std::string lastRun);
/// 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;
/// Stores 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;
/// Store workspaces
std::vector<std::string> m_fileNames;
/// The map holding extracted run numbers from filenames
std::map<std::string, int> m_rmap;
/// 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;
/// Cached start time for first run
int64_t m_firstStart_ns;
};
} // namespace Algorithms
} // namespace Mantid