Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
6b71c9fb
Commit
6b71c9fb
authored
Feb 22, 2018
by
Lynch, Vickie
Browse files
Refs #21752 clang-format
parent
5d9c9a3e
Changes
10
Hide whitespace changes
Inline
Side-by-side
Framework/Crystal/src/LoadIsawPeaks.cpp
View file @
6b71c9fb
...
...
@@ -76,8 +76,7 @@ int LoadIsawPeaks::confidence(Kernel::FileDescriptor &descriptor) const {
getWord
(
in
,
false
);
readToEndOfLine
(
in
,
true
);
confidence
=
95
;
}
catch
(
std
::
exception
&
)
{
}
catch
(
std
::
exception
&
)
{
}
return
confidence
;
...
...
@@ -87,11 +86,11 @@ int LoadIsawPeaks::confidence(Kernel::FileDescriptor &descriptor) const {
/** Initialize the algorithm's properties.
*/
void
LoadIsawPeaks
::
init
()
{
const
std
::
vector
<
std
::
string
>
exts
{
".peaks"
,
".integrate"
};
const
std
::
vector
<
std
::
string
>
exts
{
".peaks"
,
".integrate"
};
declareProperty
(
Kernel
::
make_unique
<
FileProperty
>
(
"Filename"
,
""
,
FileProperty
::
Load
,
exts
),
"Path to an ISAW-style .peaks filename."
);
declareProperty
(
make_unique
<
WorkspaceProperty
<
Workspace
>
>
(
declareProperty
(
make_unique
<
WorkspaceProperty
<
Workspace
>>
(
"OutputWorkspace"
,
""
,
Direction
::
Output
),
"Name of the output workspace."
);
}
...
...
@@ -237,8 +236,7 @@ std::string LoadIsawPeaks::readHeader(PeaksWorkspace_sptr outWS,
if
(
!
alg
->
execute
())
throw
std
::
runtime_error
(
"MaskDetectors Child Algorithm has not executed successfully"
);
}
catch
(...)
{
}
catch
(...)
{
g_log
.
error
(
"Can't execute MaskBTP algorithm"
);
}
}
...
...
@@ -513,8 +511,7 @@ void LoadIsawPeaks::appendFile(PeaksWorkspace_sptr outWS,
peak
.
setWavelength
(
wl
.
singleFromTOF
(
tof
));
// Add the peak to workspace
outWS
->
addPeak
(
peak
);
}
catch
(
std
::
runtime_error
&
e
)
{
}
catch
(
std
::
runtime_error
&
e
)
{
g_log
.
error
()
<<
"Error reading peak SEQN "
<<
seqNum
<<
" : "
<<
e
.
what
()
<<
'\n'
;
throw
std
::
runtime_error
(
"Corrupted input file. "
);
...
...
Framework/Crystal/src/PeakStatisticsTools.cpp
View file @
6b71c9fb
...
...
@@ -128,8 +128,8 @@ UniqueReflectionCollection::UniqueReflectionCollection(
/// Assigns the supplied peaks to the proper UniqueReflection. Peaks for which
/// the reflection family can not be found are ignored.
void
UniqueReflectionCollection
::
addObservations
(
const
std
::
vector
<
Peak
>
&
peaks
)
{
void
UniqueReflectionCollection
::
addObservations
(
const
std
::
vector
<
Peak
>
&
peaks
)
{
for
(
auto
const
&
peak
:
peaks
)
{
V3D
hkl
=
peak
.
getHKL
();
hkl
.
round
();
...
...
@@ -257,8 +257,8 @@ void PeaksStatistics::calculatePeaksStatistics(
double
sumOfDeviationsFromMean
=
std
::
accumulate
(
intensities
.
begin
(),
intensities
.
end
(),
0.0
,
[
meanIntensity
](
double
sum
,
double
intensity
)
{
return
sum
+
fabs
(
intensity
-
meanIntensity
);
});
return
sum
+
fabs
(
intensity
-
meanIntensity
);
});
// Accumulate into total sum for numerator of RMerge
rMergeNumerator
+=
sumOfDeviationsFromMean
;
...
...
@@ -311,9 +311,9 @@ void PeaksStatistics::calculatePeaksStatistics(
/// Returns the sum of all I/sigma-ratios defined by the two vectors using
/// std::inner_product.
double
PeaksStatistics
::
getIOverSigmaSum
(
const
std
::
vector
<
double
>
&
sigmas
,
const
std
::
vector
<
double
>
&
intensities
)
const
{
double
PeaksStatistics
::
getIOverSigmaSum
(
const
std
::
vector
<
double
>
&
sigmas
,
const
std
::
vector
<
double
>
&
intensities
)
const
{
return
std
::
inner_product
(
intensities
.
begin
(),
intensities
.
end
(),
sigmas
.
begin
(),
0.0
,
std
::
plus
<
double
>
(),
std
::
divides
<
double
>
());
...
...
Framework/Crystal/src/SaveHKL.cpp
View file @
6b71c9fb
...
...
@@ -33,11 +33,11 @@ DECLARE_ALGORITHM(SaveHKL)
/** Initialize the algorithm's properties.
*/
void
SaveHKL
::
init
()
{
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>
>
(
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>>
(
"InputWorkspace"
,
""
,
Direction
::
Input
),
"An input PeaksWorkspace."
);
auto
mustBePositive
=
boost
::
make_shared
<
BoundedValidator
<
double
>
>
();
auto
mustBePositive
=
boost
::
make_shared
<
BoundedValidator
<
double
>>
();
mustBePositive
->
setLower
(
0.0
);
declareProperty
(
"ScalePeaks"
,
1.0
,
mustBePositive
,
"Multiply FSQ and sig(FSQ) by scaleFactor"
);
...
...
@@ -69,7 +69,7 @@ void SaveHKL::init() {
make_unique
<
FileProperty
>
(
"Filename"
,
""
,
FileProperty
::
Save
,
".hkl"
),
"Path to an hkl file to save."
);
std
::
vector
<
std
::
string
>
histoTypes
{
"Bank"
,
"RunNumber"
,
""
};
std
::
vector
<
std
::
string
>
histoTypes
{
"Bank"
,
"RunNumber"
,
""
};
declareProperty
(
"SortBy"
,
histoTypes
[
2
],
boost
::
make_shared
<
StringListValidator
>
(
histoTypes
),
"Sort the histograms by bank, run number or both (default)."
);
...
...
@@ -78,7 +78,7 @@ void SaveHKL::init() {
declareProperty
(
"WidthBorder"
,
EMPTY_INT
(),
"Width of border of detectors"
);
declareProperty
(
"MinIntensity"
,
EMPTY_DBL
(),
mustBePositive
,
"The minimum Intensity"
);
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>
>
(
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>>
(
"OutputWorkspace"
,
"SaveHKLOutput"
,
Direction
::
Output
),
"Output PeaksWorkspace"
);
declareProperty
(
...
...
@@ -88,7 +88,7 @@ void SaveHKL::init() {
"DirectionCosines"
,
false
,
"Extra columns (22 total) in file if true for direction cosines.
\n
"
"If false, original 14 columns (default)."
);
const
std
::
vector
<
std
::
string
>
exts
{
".mat"
,
".ub"
,
".txt"
};
const
std
::
vector
<
std
::
string
>
exts
{
".mat"
,
".ub"
,
".txt"
};
declareProperty
(
Kernel
::
make_unique
<
FileProperty
>
(
"UBFilename"
,
""
,
FileProperty
::
OptionalLoad
,
exts
),
"Path to an ISAW-style UB matrix text file only needed for "
...
...
@@ -185,7 +185,7 @@ void SaveHKL::exec() {
std
::
string
bankPart
=
"?"
;
// We must sort the peaks first by run, then bank #, and save the list of
// workspace indices of it
typedef
std
::
map
<
int
,
std
::
vector
<
size_t
>
>
bankMap_t
;
typedef
std
::
map
<
int
,
std
::
vector
<
size_t
>>
bankMap_t
;
typedef
std
::
map
<
int
,
bankMap_t
>
runMap_t
;
std
::
set
<
int
>
uniqueBanks
;
std
::
set
<
int
>
uniqueRuns
;
...
...
@@ -221,8 +221,8 @@ void SaveHKL::exec() {
}
bool
correctPeaks
=
getProperty
(
"ApplyAnvredCorrections"
);
std
::
vector
<
std
::
vector
<
double
>
>
spectra
;
std
::
vector
<
std
::
vector
<
double
>
>
time
;
std
::
vector
<
std
::
vector
<
double
>>
spectra
;
std
::
vector
<
std
::
vector
<
double
>>
time
;
int
iSpec
=
0
;
m_smu
=
getProperty
(
"LinearScatteringCoef"
);
// in 1/cm
m_amu
=
getProperty
(
"LinearAbsorptionCoef"
);
// in 1/cm
...
...
@@ -688,8 +688,8 @@ double SaveHKL::absor_sphere(double &twoth, double &wl, double &tbar) {
}
double
SaveHKL
::
spectrumCalc
(
double
TOF
,
int
iSpec
,
std
::
vector
<
std
::
vector
<
double
>
>
time
,
std
::
vector
<
std
::
vector
<
double
>
>
spectra
,
std
::
vector
<
std
::
vector
<
double
>>
time
,
std
::
vector
<
std
::
vector
<
double
>>
spectra
,
size_t
id
)
{
double
spect
=
0
;
if
(
iSpec
==
1
)
{
...
...
@@ -717,9 +717,9 @@ double SaveHKL::spectrumCalc(double TOF, int iSpec,
for
(
i
=
1
;
i
<
spectra
[
id
].
size
();
++
i
)
if
(
TOF
<
time
[
id
][
i
])
break
;
spect
=
spectra
[
id
][
i
-
1
]
+
(
TOF
-
time
[
id
][
i
-
1
])
/
(
time
[
id
][
i
]
-
time
[
id
][
i
-
1
])
*
(
spectra
[
id
][
i
]
-
spectra
[
id
][
i
-
1
]);
spect
=
spectra
[
id
][
i
-
1
]
+
(
TOF
-
time
[
id
][
i
-
1
])
/
(
time
[
id
][
i
]
-
time
[
id
][
i
-
1
])
*
(
spectra
[
id
][
i
]
-
spectra
[
id
][
i
-
1
]);
}
return
spect
;
...
...
Framework/Crystal/src/SaveIsawPeaks.cpp
View file @
6b71c9fb
...
...
@@ -27,7 +27,7 @@ DECLARE_ALGORITHM(SaveIsawPeaks)
/** Initialize the algorithm's properties.
*/
void
SaveIsawPeaks
::
init
()
{
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>
>
(
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>>
(
"InputWorkspace"
,
""
,
Direction
::
Input
,
boost
::
make_shared
<
InstrumentValidator
>
()),
"An input PeaksWorkspace with an instrument."
);
...
...
@@ -35,13 +35,13 @@ void SaveIsawPeaks::init() {
declareProperty
(
"AppendFile"
,
false
,
"Append to file if true.
\n
"
"If false, new file (default)."
);
const
std
::
vector
<
std
::
string
>
exts
{
".peaks"
,
".integrate"
};
const
std
::
vector
<
std
::
string
>
exts
{
".peaks"
,
".integrate"
};
declareProperty
(
Kernel
::
make_unique
<
FileProperty
>
(
"Filename"
,
""
,
FileProperty
::
Save
,
exts
),
"Path to an ISAW-style peaks or integrate file to save."
);
declareProperty
(
make_unique
<
WorkspaceProperty
<
Workspace2D
>
>
(
make_unique
<
WorkspaceProperty
<
Workspace2D
>>
(
"ProfileWorkspace"
,
""
,
Direction
::
Input
,
PropertyMode
::
Optional
),
"An optional Workspace2D of profiles from integrating cylinder."
);
}
...
...
@@ -62,9 +62,9 @@ void SaveIsawPeaks::exec() {
// We must sort the peaks first by run, then bank #, and save the list of
// workspace indices of it
typedef
std
::
map
<
int
,
std
::
vector
<
size_t
>
>
bankMap_t
;
typedef
std
::
map
<
int
,
std
::
vector
<
size_t
>>
bankMap_t
;
typedef
std
::
map
<
int
,
bankMap_t
>
runMap_t
;
std
::
set
<
int
,
std
::
less
<
int
>
>
uniqueBanks
;
std
::
set
<
int
,
std
::
less
<
int
>>
uniqueBanks
;
if
(
!
inst
)
throw
std
::
runtime_error
(
"No instrument in the Workspace. Cannot save DetCal file."
);
...
...
Framework/Crystal/src/SortHKL.cpp
View file @
6b71c9fb
...
...
@@ -38,7 +38,7 @@ SortHKL::SortHKL() {
SortHKL
::~
SortHKL
()
=
default
;
void
SortHKL
::
init
()
{
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>
>
(
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>>
(
"InputWorkspace"
,
""
,
Direction
::
Input
),
"An input PeaksWorkspace with an instrument."
);
...
...
@@ -60,31 +60,31 @@ void SortHKL::init() {
boost
::
make_shared
<
StringListValidator
>
(
centeringOptions
),
"Appropriate lattice centering for the peaks."
);
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>
>
(
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>>
(
"OutputWorkspace"
,
""
,
Direction
::
Output
),
"Output PeaksWorkspace"
);
declareProperty
(
"OutputChi2"
,
0.0
,
"Chi-square is available as output"
,
Direction
::
Output
);
declareProperty
(
make_unique
<
WorkspaceProperty
<
ITableWorkspace
>
>
(
declareProperty
(
make_unique
<
WorkspaceProperty
<
ITableWorkspace
>>
(
"StatisticsTable"
,
"StatisticsTable"
,
Direction
::
Output
),
"An output table workspace for the statistics of the peaks."
);
declareProperty
(
make_unique
<
PropertyWithValue
<
std
::
string
>
>
(
declareProperty
(
make_unique
<
PropertyWithValue
<
std
::
string
>>
(
"RowName"
,
"Overall"
,
Direction
::
Input
),
"name of row"
);
declareProperty
(
"Append"
,
false
,
"Append to output table workspace if true.
\n
"
"If false, new output table workspace (default)."
);
std
::
vector
<
std
::
string
>
equivTypes
{
"Mean"
,
"Median"
};
std
::
vector
<
std
::
string
>
equivTypes
{
"Mean"
,
"Median"
};
declareProperty
(
"EquivalentIntensities"
,
equivTypes
[
0
],
boost
::
make_shared
<
StringListValidator
>
(
equivTypes
),
"Replace intensities by mean(default), "
"or median."
);
declareProperty
(
Kernel
::
make_unique
<
PropertyWithValue
<
double
>
>
(
declareProperty
(
Kernel
::
make_unique
<
PropertyWithValue
<
double
>>
(
"SigmaCritical"
,
3.0
,
Direction
::
Input
),
"Removes peaks whose intensity deviates more than "
"SigmaCritical from the mean (or median)."
);
declareProperty
(
make_unique
<
WorkspaceProperty
<
MatrixWorkspace
>
>
(
make_unique
<
WorkspaceProperty
<
MatrixWorkspace
>>
(
"EquivalentsWorkspace"
,
"EquivalentIntensities"
,
Direction
::
Output
),
"Output Equivalent Intensities"
);
}
...
...
@@ -230,9 +230,10 @@ SortHKL::getNonZeroPeaks(const std::vector<Peak> &inputPeaks) const {
std
::
remove_copy_if
(
inputPeaks
.
begin
(),
inputPeaks
.
end
(),
std
::
back_inserter
(
peaks
),
[](
const
Peak
&
peak
)
{
return
peak
.
getIntensity
()
<=
0.0
||
peak
.
getSigmaIntensity
()
<=
0.0
||
peak
.
getHKL
()
==
V3D
(
0
,
0
,
0
);
});
return
peak
.
getIntensity
()
<=
0.0
||
peak
.
getSigmaIntensity
()
<=
0.0
||
peak
.
getHKL
()
==
V3D
(
0
,
0
,
0
);
});
return
peaks
;
}
...
...
@@ -331,9 +332,9 @@ SortHKL::getStatisticsTable(const std::string &name) const {
/// Inserts statistics the supplied PeaksStatistics-objects into the supplied
/// TableWorkspace.
void
SortHKL
::
insertStatisticsIntoTable
(
const
ITableWorkspace_sptr
&
table
,
const
PeaksStatistics
&
statistics
)
const
{
void
SortHKL
::
insertStatisticsIntoTable
(
const
ITableWorkspace_sptr
&
table
,
const
PeaksStatistics
&
statistics
)
const
{
if
(
!
table
)
{
throw
std
::
runtime_error
(
"Can't store statistics into Null-table."
);
}
...
...
@@ -367,9 +368,8 @@ PeaksWorkspace_sptr SortHKL::getOutputPeaksWorkspace(
/// Sorts the peaks in the workspace by H, K and L.
void
SortHKL
::
sortOutputPeaksByHKL
(
IPeaksWorkspace_sptr
outputPeaksWorkspace
)
{
// Sort by HKL
std
::
vector
<
std
::
pair
<
std
::
string
,
bool
>
>
criteria
{
{
"H"
,
true
},
{
"K"
,
true
},
{
"L"
,
true
}
};
std
::
vector
<
std
::
pair
<
std
::
string
,
bool
>>
criteria
{
{
"H"
,
true
},
{
"K"
,
true
},
{
"L"
,
true
}};
outputPeaksWorkspace
->
sort
(
criteria
);
}
...
...
Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp
View file @
6b71c9fb
...
...
@@ -33,7 +33,7 @@ StatisticsOfPeaksWorkspace::StatisticsOfPeaksWorkspace() {
/** Initialize the algorithm's properties.
*/
void
StatisticsOfPeaksWorkspace
::
init
()
{
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>
>
(
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>>
(
"InputWorkspace"
,
""
,
Direction
::
Input
),
"An input PeaksWorkspace with an instrument."
);
std
::
vector
<
std
::
string
>
propOptions
;
...
...
@@ -54,29 +54,29 @@ void StatisticsOfPeaksWorkspace::init() {
boost
::
make_shared
<
StringListValidator
>
(
centeringOptions
),
"Appropriate lattice centering for the peaks."
);
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>
>
(
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>>
(
"OutputWorkspace"
,
""
,
Direction
::
Output
),
"Output PeaksWorkspace"
);
declareProperty
(
make_unique
<
WorkspaceProperty
<
ITableWorkspace
>
>
(
declareProperty
(
make_unique
<
WorkspaceProperty
<
ITableWorkspace
>>
(
"StatisticsTable"
,
"StatisticsTable"
,
Direction
::
Output
),
"An output table workspace for the statistics of the peaks."
);
std
::
vector
<
std
::
string
>
sortTypes
{
"ResolutionShell"
,
"Bank"
,
"RunNumber"
,
"Overall"
};
std
::
vector
<
std
::
string
>
sortTypes
{
"ResolutionShell"
,
"Bank"
,
"RunNumber"
,
"Overall"
};
declareProperty
(
"SortBy"
,
sortTypes
[
0
],
boost
::
make_shared
<
StringListValidator
>
(
sortTypes
),
"Sort the peaks by resolution shell in d-Spacing(default), "
"bank, run number, or only overall statistics."
);
std
::
vector
<
std
::
string
>
equivTypes
{
"Mean"
,
"Median"
};
std
::
vector
<
std
::
string
>
equivTypes
{
"Mean"
,
"Median"
};
declareProperty
(
"EquivalentIntensities"
,
equivTypes
[
0
],
boost
::
make_shared
<
StringListValidator
>
(
equivTypes
),
"Replace intensities by mean(default), "
"or median."
);
declareProperty
(
Kernel
::
make_unique
<
PropertyWithValue
<
double
>
>
(
declareProperty
(
Kernel
::
make_unique
<
PropertyWithValue
<
double
>>
(
"SigmaCritical"
,
3.0
,
Direction
::
Input
),
"Removes peaks whose intensity deviates more than "
"SigmaCritical from the mean (or median)."
);
declareProperty
(
make_unique
<
WorkspaceProperty
<
MatrixWorkspace
>
>
(
make_unique
<
WorkspaceProperty
<
MatrixWorkspace
>>
(
"EquivalentsWorkspace"
,
"EquivalentIntensities"
,
Direction
::
Output
),
"Output Equivalent Intensities"
);
}
...
...
@@ -93,7 +93,7 @@ void StatisticsOfPeaksWorkspace::exec() {
tempWS
->
copyExperimentInfoFrom
(
ws
.
get
());
// We must sort the peaks
std
::
vector
<
std
::
pair
<
std
::
string
,
bool
>
>
criteria
;
std
::
vector
<
std
::
pair
<
std
::
string
,
bool
>>
criteria
;
if
(
sortType
.
compare
(
0
,
2
,
"Re"
)
==
0
)
criteria
.
push_back
(
std
::
pair
<
std
::
string
,
bool
>
(
"DSpacing"
,
false
));
else
if
(
sortType
.
compare
(
0
,
2
,
"Ru"
)
==
0
)
...
...
Framework/DataObjects/inc/MantidDataObjects/Peak.h
View file @
6b71c9fb
...
...
@@ -111,12 +111,12 @@ public:
Mantid
::
Kernel
::
V3D
getDetectorPosition
()
const
override
;
Mantid
::
Kernel
::
V3D
getDetectorPositionNoCheck
()
const
override
;
void
setQSampleFrame
(
const
Mantid
::
Kernel
::
V3D
&
QSampleFrame
,
boost
::
optional
<
double
>
detectorDistance
=
boost
::
none
)
override
;
void
setQLabFrame
(
const
Mantid
::
Kernel
::
V3D
&
QLabFrame
,
boost
::
optional
<
double
>
detectorDistance
=
boost
::
none
)
override
;
void
setQSampleFrame
(
const
Mantid
::
Kernel
::
V3D
&
QSampleFrame
,
boost
::
optional
<
double
>
detectorDistance
=
boost
::
none
)
override
;
void
setQLabFrame
(
const
Mantid
::
Kernel
::
V3D
&
QLabFrame
,
boost
::
optional
<
double
>
detectorDistance
=
boost
::
none
)
override
;
void
setWavelength
(
double
wavelength
)
override
;
double
getWavelength
()
const
override
;
...
...
Framework/Kernel/inc/MantidKernel/Statistics.h
View file @
6b71c9fb
...
...
@@ -94,7 +94,8 @@ Statistics getStatistics(const std::vector<TYPE> &data,
template
<
typename
TYPE
>
std
::
vector
<
double
>
getZscore
(
const
std
::
vector
<
TYPE
>
&
data
);
template
<
typename
TYPE
>
std
::
vector
<
double
>
getWeightedZscore
(
const
std
::
vector
<
TYPE
>
&
data
,
const
std
::
vector
<
TYPE
>
&
weights
);
std
::
vector
<
double
>
getWeightedZscore
(
const
std
::
vector
<
TYPE
>
&
data
,
const
std
::
vector
<
TYPE
>
&
weights
);
/// Return the modified Z score values for a dataset
template
<
typename
TYPE
>
std
::
vector
<
double
>
getModifiedZscore
(
const
std
::
vector
<
TYPE
>
&
data
,
...
...
Framework/Kernel/src/Statistics.cpp
View file @
6b71c9fb
...
...
@@ -68,7 +68,7 @@ double getMedian(const vector<TYPE> &data, const size_t num_data,
// return the average
return
(
left
+
right
)
/
2.
;
}
else
// Odd number
// Odd number
{
if
(
sorted
)
{
// If sorted and odd, just return the centre value
...
...
@@ -111,7 +111,8 @@ std::vector<double> getZscore(const vector<TYPE> &data) {
* put it in a single function.
*/
template
<
typename
TYPE
>
std
::
vector
<
double
>
getWeightedZscore
(
const
vector
<
TYPE
>
&
data
,
const
vector
<
TYPE
>
&
weights
)
{
std
::
vector
<
double
>
getWeightedZscore
(
const
vector
<
TYPE
>
&
data
,
const
vector
<
TYPE
>
&
weights
)
{
if
(
data
.
size
()
<
3
)
{
std
::
vector
<
double
>
Zscore
(
data
.
size
(),
0.
);
return
Zscore
;
...
...
@@ -129,9 +130,10 @@ std::vector<double> getWeightedZscore(const vector<TYPE> &data, const vector<TYP
sumWeights
+=
static_cast
<
double
>
(
weights
[
it
]);
sumWeightedData
+=
static_cast
<
double
>
(
weights
[
it
]
*
data
[
it
]);
}
double
weightedMean
=
sumWeightedData
/
sumWeights
;
double
weightedMean
=
sumWeightedData
/
sumWeights
;
for
(
size_t
it
=
0
;
it
!=
data
.
size
();
++
it
)
{
weightedVariance
+=
std
::
pow
(
data
[
it
]
-
weightedMean
,
2
)
*
std
::
pow
(
weights
[
it
]
/
sumWeights
,
2
);
weightedVariance
+=
std
::
pow
(
data
[
it
]
-
weightedMean
,
2
)
*
std
::
pow
(
weights
[
it
]
/
sumWeights
,
2
);
}
for
(
auto
it
=
data
.
cbegin
();
it
!=
data
.
cend
();
++
it
)
{
Zscore
.
push_back
(
fabs
((
*
it
-
weightedMean
)
/
std
::
sqrt
(
weightedVariance
)));
...
...
@@ -190,7 +192,7 @@ Statistics getStatistics(const vector<TYPE> &data, const unsigned int flags) {
(
flags
&
StatOptions
::
CorrectedStdDev
));
if
(
stddev
)
{
using
namespace
boost
::
accumulators
;
accumulator_set
<
double
,
stats
<
tag
::
min
,
tag
::
max
,
tag
::
variance
>
>
acc
;
accumulator_set
<
double
,
stats
<
tag
::
min
,
tag
::
max
,
tag
::
variance
>>
acc
;
for
(
auto
&
value
:
data
)
{
acc
(
static_cast
<
double
>
(
value
));
}
...
...
@@ -207,7 +209,7 @@ Statistics getStatistics(const vector<TYPE> &data, const unsigned int flags) {
}
else
if
(
flags
&
StatOptions
::
Mean
)
{
using
namespace
boost
::
accumulators
;
accumulator_set
<
double
,
stats
<
tag
::
mean
>
>
acc
;
accumulator_set
<
double
,
stats
<
tag
::
mean
>>
acc
;
for
(
auto
&
value
:
data
)
{
acc
(
static_cast
<
double
>
(
value
));
}
...
...
@@ -438,8 +440,8 @@ std::vector<double> getMomentsAboutMean(const std::vector<TYPE> &x,
getStatistics<TYPE>(const vector<TYPE> &, const unsigned int); \
template MANTID_KERNEL_DLL std::vector<double> getZscore<TYPE>( \
const vector<TYPE> &); \
template MANTID_KERNEL_DLL std::vector<double> getWeightedZscore<TYPE>(
\
const vector<TYPE> &, const vector<TYPE> &);
\
template MANTID_KERNEL_DLL std::vector<double> getWeightedZscore<TYPE>( \
const vector<TYPE> &, const vector<TYPE> &); \
template MANTID_KERNEL_DLL std::vector<double> getModifiedZscore<TYPE>( \
const vector<TYPE> &, const bool); \
template MANTID_KERNEL_DLL std::vector<double> getMomentsAboutOrigin<TYPE>( \
...
...
Framework/MDAlgorithms/src/FindPeaksMD.cpp
View file @
6b71c9fb
...
...
@@ -120,24 +120,24 @@ FindPeaksMD::FindPeaksMD()
/** Initialize the algorithm's properties.
*/
void
FindPeaksMD
::
init
()
{
declareProperty
(
make_unique
<
WorkspaceProperty
<
IMDWorkspace
>
>
(
declareProperty
(
make_unique
<
WorkspaceProperty
<
IMDWorkspace
>>
(
"InputWorkspace"
,
""
,
Direction
::
Input
),
"An input MDEventWorkspace or MDHistoWorkspace with at least "
"3 dimensions."
);
declareProperty
(
make_unique
<
PropertyWithValue
<
double
>
>
(
"PeakDistanceThreshold"
,
0.1
,
Direction
::
Input
),
make_unique
<
PropertyWithValue
<
double
>>
(
"PeakDistanceThreshold"
,
0.1
,
Direction
::
Input
),
"Threshold distance for rejecting peaks that are found to be too close "
"from each other.
\n
"
"This should be some multiple of the radius of a peak. Default: 0.1."
);
declareProperty
(
make_unique
<
PropertyWithValue
<
int64_t
>
>
(
"MaxPeaks"
,
500
,
Direction
::
Input
),
declareProperty
(
make_unique
<
PropertyWithValue
<
int64_t
>>
(
"MaxPeaks"
,
500
,
Direction
::
Input
),
"Maximum number of peaks to find. Default: 500."
);
std
::
vector
<
std
::
string
>
strategy
=
{
volumeNormalization
,
numberOfEventsNormalization
};
std
::
vector
<
std
::
string
>
strategy
=
{
volumeNormalization
,
numberOfEventsNormalization
};
declareProperty
(
"PeakFindingStrategy"
,
volumeNormalization
,
boost
::
make_shared
<
StringListValidator
>
(
strategy
),
...
...
@@ -156,7 +156,7 @@ void FindPeaksMD::init() {
"be larger than 1. Note that this approach does not work for event-based "
"raw data.
\n
"
);
declareProperty
(
make_unique
<
PropertyWithValue
<
double
>
>
(
declareProperty
(
make_unique
<
PropertyWithValue
<
double
>>
(
"DensityThresholdFactor"
,
10.0
,
Direction
::
Input
),
"The overall signal density of the workspace will be "
"multiplied by this factor
\n
"
...
...
@@ -170,7 +170,7 @@ void FindPeaksMD::init() {
Mantid
::
Kernel
::
ePropertyCriterion
::
IS_EQUAL_TO
,
volumeNormalization
));
declareProperty
(
make_unique
<
PropertyWithValue
<
double
>
>
(
declareProperty
(
make_unique
<
PropertyWithValue
<
double
>>
(
"SignalThresholdFactor"
,
1.5
,
Direction
::
Input
),
"The overal signal value (not density!) normalized by the "
"number of events is compared to the specified signal "
...
...
@@ -193,7 +193,7 @@ void FindPeaksMD::init() {
"only) for a constant wavelength. This only works for Q "
"sample workspaces."
);
auto
nonNegativeDbl
=
boost
::
make_shared
<
BoundedValidator
<
double
>
>
();
auto
nonNegativeDbl
=
boost
::
make_shared
<
BoundedValidator
<
double
>>
();
nonNegativeDbl
->
setLower
(
0
);
declareProperty
(
"Wavelength"
,
DBL_MAX
,
nonNegativeDbl
,
"Wavelength to use when calculating goniometer angle"
);
...
...
@@ -203,7 +203,7 @@ void FindPeaksMD::init() {
"CalculateGoniometerForCW"
,
Mantid
::
Kernel
::
ePropertyCriterion
::
IS_NOT_DEFAULT
));
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>
>
(
declareProperty
(
make_unique
<
WorkspaceProperty
<
PeaksWorkspace
>>
(
"OutputWorkspace"
,
""
,
Direction
::
Output
),
"An output PeaksWorkspace with the peaks' found positions."
);
...
...
@@ -212,7 +212,7 @@ void FindPeaksMD::init() {
"if it exists.
\n
"
"If unchecked, the output workspace is replaced (Default)."
);
auto
nonNegativeInt
=
boost
::
make_shared
<
BoundedValidator
<
int
>
>
();
auto
nonNegativeInt
=
boost
::
make_shared
<
BoundedValidator
<
int
>>
();
nonNegativeInt
->
setLower
(
0
);
declareProperty
(
"EdgePixels"
,
0
,
nonNegativeInt
,
"Remove peaks that are at pixels this close to edge. "
);
...
...
@@ -246,8 +246,7 @@ void FindPeaksMD::readExperimentInfo(const ExperimentInfo_sptr &ei,
Mantid
::
Kernel
::
Matrix
<
double
>
(
3
,
3
,
true
);
// Default IDENTITY matrix
try
{
m_goniometer
=
ei
->
mutableRun
().
getGoniometerMatrix
();
}
catch
(
std
::
exception
&
e
)
{
}
catch
(
std
::
exception
&
e
)
{
g_log
.
warning
()
<<
"Error finding goniometer matrix. It will not be set in "
"the peaks found.
\n
"
;
g_log
.
warning
()
<<
e
.
what
()
<<
'\n'
;
...
...
@@ -271,8 +270,7 @@ void FindPeaksMD::addPeak(const V3D &Q, const double binCount,
}
if
(
p
->
getDetectorID
()
!=
-
1
)
peakWS
->
addPeak
(
*
p
);
}
catch
(
std
::
exception
&
e
)
{
}
catch
(
std
::
exception
&
e
)
{
g_log
.
notice
()
<<
"Error creating peak at "
<<
Q
<<
" because of '"
<<
e
.
what
()
<<
"'. Peak will be skipped.
\n
"
;
}
...
...
@@ -306,9 +304,9 @@ FindPeaksMD::createPeak(const Mantid::Kernel::V3D &Q, const double binCount,
// Solve to find rotation matrix, assuming only rotation around y-axis
// A * X = B
Matrix
<
double
>
A
({
Q
[
0
],
Q
[
2
],
Q
[
2
],
-
Q
[
0
]
},
2
,
2
);
Matrix
<
double
>
A
({
Q
[
0
],
Q
[
2
],
Q
[
2
],
-
Q
[
0
]},
2
,
2
);
A
.
Invert
();
std
::
vector
<
double
>
B
{
Q_lab
[
0
],
Q_lab
[
2
]
};
std
::
vector
<
double
>
B
{
Q_lab
[
0
],
Q_lab
[
2
]};
std
::
vector
<
double
>
X
=
A
*
B
;
double
rot
=
atan2
(
X
[
1
],
X
[
0
]);
g_log
.
information
()
<<
"Found goniometer rotation to be "
...
...
@@ -332,8 +330,7 @@ FindPeaksMD::createPeak(const Mantid::Kernel::V3D &Q, const double binCount,
try
{
// Look for a detector
p
->
findDetector
(
tracer
);
}
catch
(...)
{
/* Ignore errors in ray-tracer */
}
catch
(...)
{
/* Ignore errors in ray-tracer */
}
p
->
setBinCount
(
binCount
);
...
...
@@ -503,8 +500,8 @@ void FindPeaksMD::findPeaks(typename MDEventWorkspace<MDE, nd>::sptr ws) {
if
(
nexp
>
1
)
{
MDBox
<
MDE
,
nd
>
*
mdbox
=
dynamic_cast
<
MDBox
<
MDE
,
nd
>
*>
(
box
);
typename
std
::
vector
<
MDE
>
&
events
=
mdbox
->
getEvents
();
if
(
std
::
none_of
(
events
.
cbegin
(),
events
.
cend
(),
[
&
iexp
,
&
nexp
](
MDE
event
)
{
if
(
std
::
none_of
(
events
.
cbegin
(),
events
.
cend
(),
[
&
iexp
,
&
nexp
](
MDE
event
)
{
return
event
.
getRunIndex
()
==
iexp
||
event
.
getRunIndex
()
>=
nexp
;
}))
continue
;
...
...
@@ -548,8 +545,7 @@ void FindPeaksMD::findPeaks(typename MDEventWorkspace<MDE, nd>::sptr ws) {
g_log
.
information
()
<<
"Add new peak with Q-center = "
<<
Q
[
0
]
<<
", "
<<
Q
[
1
]
<<
", "
<<
Q
[
2
]
<<
"
\n
"
;
}
}
catch
(
std
::
exception
&
e
)
{
}
catch
(
std
::
exception
&
e
)
{
g_log
.
notice
()
<<
"Error creating peak at "
<<
Q
<<
" because of '"
<<
e
.
what
()
<<
"'. Peak will be skipped.
\n
"
;
}
...
...
@@ -568,8 +564,8 @@ void FindPeaksMD::findPeaks(typename MDEventWorkspace<MDE, nd>::sptr ws) {
*
* @param ws :: MDHistoWorkspace
*/
void
FindPeaksMD
::
findPeaksHisto
(
Mantid
::
DataObjects
::
MDHistoWorkspace_sptr
ws
)
{
void
FindPeaksMD
::
findPeaksHisto
(
Mantid
::
DataObjects
::
MDHistoWorkspace_sptr
ws
)
{
size_t
nd
=
ws
->
getNumDims
();
if
(
nd
<
3
)
throw
std
::
invalid_argument
(
"Workspace must have at least 3 dimensions."
);
...
...
@@ -744,7 +740,7 @@ void FindPeaksMD::exec() {
}
// Do a sort by bank name and then descending bin count (intensity)
std
::
vector
<
std
::
pair
<
std
::
string
,
bool
>
>
criteria
;
std
::
vector
<
std
::
pair
<
std
::
string
,
bool
>>
criteria
;
criteria
.
push_back
(
std
::
pair
<
std
::
string
,
bool
>
(
"RunNumber"
,
true
));
criteria
.
push_back
(
std
::
pair
<
std
::
string
,
bool
>
(
"BankName"
,
true
));
criteria
.
push_back
(
std
::
pair
<
std
::
string
,
bool
>
(
"bincount"
,
false
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment