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
beffd505
Commit
beffd505
authored
Jan 02, 2013
by
Nick Draper
Browse files
refs #6194 sub-alg to child alg name change
parent
3236df97
Changes
271
Hide whitespace changes
Inline
Side-by-side
Code/Mantid/Framework/API/inc/MantidAPI/Algorithm.h
View file @
beffd505
...
...
@@ -48,11 +48,11 @@ class AlgorithmHistory;
The base class provides utility methods for accessing
standard services (event data service etc.); for declaring
properties which may be configured by the job options
service; and for creating
sub a
lgorithms.
service; and for creating
Child A
lgorithms.
The only base class functionality which may be used in the
constructor of a concrete algorithm is the declaration of
member variables as properties. All other functionality,
i.e. the use of services and the creation of
sub-a
lgorithms,
i.e. the use of services and the creation of
Child A
lgorithms,
may be used only in initialise() and afterwards (see the
Gaudi user guide).
...
...
@@ -186,7 +186,7 @@ public:
/** @name IAlgorithm methods */
void
initialize
();
bool
execute
();
void
executeAs
Sub
Alg
();
void
executeAs
Child
Alg
();
virtual
std
::
map
<
std
::
string
,
std
::
string
>
validateInputs
();
virtual
bool
isInitialized
()
const
;
virtual
bool
isExecuted
()
const
;
...
...
@@ -257,7 +257,7 @@ public:
static
IAlgorithm_sptr
fromHistory
(
const
AlgorithmHistory
&
history
);
//@}
boost
::
shared_ptr
<
Algorithm
>
create
Sub
Algorithm
(
const
std
::
string
&
name
,
const
double
startProgress
=
-
1.
,
boost
::
shared_ptr
<
Algorithm
>
create
Child
Algorithm
(
const
std
::
string
&
name
,
const
double
startProgress
=
-
1.
,
const
double
endProgress
=
-
1.
,
const
bool
enableLogging
=
true
,
const
int
&
version
=
-
1
);
protected:
...
...
@@ -352,8 +352,8 @@ private:
bool
m_runningAsync
;
///< Algorithm is running asynchronously
bool
m_running
;
///< Algorithm is running
bool
m_rethrow
;
///< Algorithm should rethrow exceptions while executing
mutable
double
m_startChildProgress
;
///< Keeps value for algorithm's progress at start of an
sub-a
lgorithm
mutable
double
m_endChildProgress
;
///< Keeps value for algorithm's progress at
sub-a
lgorithm's finish
mutable
double
m_startChildProgress
;
///< Keeps value for algorithm's progress at start of an
Child A
lgorithm
mutable
double
m_endChildProgress
;
///< Keeps value for algorithm's progress at
Child A
lgorithm's finish
AlgorithmID
m_algorithmID
;
///< Algorithm ID for managed algorithms
std
::
string
m_OptionalMessage
;
///< An optional message string to be displayed in the GUI.
std
::
string
m_WikiSummary
;
///< A summary line for the wiki page.
...
...
Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h
View file @
beffd505
...
...
@@ -88,7 +88,7 @@ namespace Mantid
void
initialize
();
std
::
map
<
std
::
string
,
std
::
string
>
validateInputs
();
bool
execute
();
void
executeAs
Sub
Alg
()
{
throw
std
::
runtime_error
(
"Not implemented."
);
}
void
executeAs
Child
Alg
()
{
throw
std
::
runtime_error
(
"Not implemented."
);
}
Poco
::
ActiveResult
<
bool
>
executeAsync
();
bool
isInitialized
()
const
;
bool
isExecuted
()
const
;
...
...
Code/Mantid/Framework/API/inc/MantidAPI/IAlgorithm.h
View file @
beffd505
...
...
@@ -94,7 +94,7 @@ public:
/** Initialization method invoked by the framework. This method is responsible
* for any bookkeeping of initialization required by the framework itself.
* It will in turn invoke the init() method of the derived algorithm,
* and of any
sub-a
lgorithms which it creates.
* and of any
Child A
lgorithms which it creates.
*/
virtual
void
initialize
()
=
0
;
...
...
@@ -107,8 +107,8 @@ public:
/// Asynchronous execution of the algorithm.
virtual
Poco
::
ActiveResult
<
bool
>
executeAsync
()
=
0
;
/// Execute as a
sub-a
lgorithm, with try/catch
virtual
void
executeAs
Sub
Alg
()
=
0
;
/// Execute as a
Child A
lgorithm, with try/catch
virtual
void
executeAs
Child
Alg
()
=
0
;
/// Check whether the algorithm is initialized properly
virtual
bool
isInitialized
()
const
=
0
;
...
...
Code/Mantid/Framework/API/src/Algorithm.cpp
View file @
beffd505
...
...
@@ -226,8 +226,8 @@ namespace Mantid
/** Initialization method invoked by the framework. This method is responsible
* for any bookkeeping of initialization required by the framework itself.
* It will in turn invoke the init() method of the derived algorithm,
* and of any
sub-a
lgorithms which it creates.
* @throw runtime_error Thrown if algorithm or
sub-a
lgorithm cannot be initialised
* and of any
Child A
lgorithms which it creates.
* @throw runtime_error Thrown if algorithm or
Child A
lgorithm cannot be initialised
*
*/
void
Algorithm
::
initialize
()
...
...
@@ -416,10 +416,10 @@ namespace Mantid
/** The actions to be performed by the algorithm on a dataset. This method is
* invoked for top level algorithms by the application manager.
* This method invokes exec() method.
* For
sub-a
lgorithms either the execute() method or exec() method
* For
Child A
lgorithms either the execute() method or exec() method
* must be EXPLICITLY invoked by the parent algorithm.
*
* @throw runtime_error Thrown if algorithm or
sub-a
lgorithm cannot be executed
* @throw runtime_error Thrown if algorithm or
Child A
lgorithm cannot be executed
* @return true if executed successfully.
*/
bool
Algorithm
::
execute
()
...
...
@@ -634,11 +634,11 @@ namespace Mantid
}
//---------------------------------------------------------------------------------------------
/** Execute as a
sub-a
lgorithm.
/** Execute as a
Child A
lgorithm.
* This runs execute() but catches errors so as to log the name
* of the failed
sub-a
lgorithm, if it fails.
* of the failed
Child A
lgorithm, if it fails.
*/
void
Algorithm
::
executeAs
Sub
Alg
()
void
Algorithm
::
executeAs
Child
Alg
()
{
bool
executed
=
false
;
try
...
...
@@ -647,14 +647,14 @@ namespace Mantid
}
catch
(
std
::
runtime_error
&
)
{
g_log
.
error
()
<<
"Unable to successfully run
sub
Algorithm "
<<
this
->
name
()
<<
std
::
endl
;
g_log
.
error
()
<<
"Unable to successfully run
Child
Algorithm "
<<
this
->
name
()
<<
std
::
endl
;
throw
;
}
if
(
!
executed
)
{
g_log
.
error
()
<<
"Unable to successfully run
sub
Algorithm "
<<
this
->
name
()
<<
std
::
endl
;
throw
std
::
runtime_error
(
"Unable to successfully run
sub
Algorithm "
+
this
->
name
());
g_log
.
error
()
<<
"Unable to successfully run
Child
Algorithm "
<<
this
->
name
()
<<
std
::
endl
;
throw
std
::
runtime_error
(
"Unable to successfully run
Child
Algorithm "
+
this
->
name
());
}
}
...
...
@@ -684,19 +684,19 @@ namespace Mantid
}
//---------------------------------------------------------------------------------------------
/** Create a
sub a
lgorithm. A call to this method creates a child algorithm object.
/** Create a
Child A
lgorithm. A call to this method creates a child algorithm object.
* Using this mechanism instead of creating daughter
* algorithms directly via the new operator is prefered since then
* the framework can take care of all of the necessary book-keeping.
*
* @param name :: The concrete algorithm class of the
sub a
lgorithm
* @param name :: The concrete algorithm class of the
Child A
lgorithm
* @param startProgress :: The percentage progress value of the overall algorithm where this child algorithm starts
* @param endProgress :: The percentage progress value of the overall algorithm where this child algorithm ends
* @param enableLogging :: Set to false to disable logging from the child algorithm
* @param version :: The version of the child algorithm to create. By default gives the latest version.
* @return shared pointer to the newly created algorithm object
*/
Algorithm_sptr
Algorithm
::
create
Sub
Algorithm
(
const
std
::
string
&
name
,
const
double
startProgress
,
const
double
endProgress
,
Algorithm_sptr
Algorithm
::
create
Child
Algorithm
(
const
std
::
string
&
name
,
const
double
startProgress
,
const
double
endProgress
,
const
bool
enableLogging
,
const
int
&
version
)
{
Algorithm_sptr
alg
=
AlgorithmManager
::
Instance
().
createUnmanaged
(
name
,
version
);
...
...
@@ -704,14 +704,14 @@ namespace Mantid
alg
->
setChild
(
true
);
alg
->
setLogging
(
enableLogging
);
// Initialise the
sub-a
lgorithm
// Initialise the
Child A
lgorithm
try
{
alg
->
initialize
();
}
catch
(
std
::
runtime_error
&
exc
)
{
g_log
.
error
()
<<
"Unable to initialise
sub-a
lgorithm "
<<
name
<<
std
::
endl
;
g_log
.
error
()
<<
"Unable to initialise
Child A
lgorithm "
<<
name
<<
std
::
endl
;
g_log
.
error
()
<<
exc
.
what
()
<<
"
\n
"
;
}
...
...
@@ -734,7 +734,7 @@ namespace Mantid
// Before we return the shared pointer, use it to create a weak pointer and keep that in a vector.
// It will be used this to pass on cancellation requests
// It must be protected by a critical block so that
sub a
lgorithms can run in parallel safely.
// It must be protected by a critical block so that
Child A
lgorithms can run in parallel safely.
IAlgorithm_wptr
weakPtr
(
alg
);
PARALLEL_CRITICAL
(
Algorithm_StoreWeakPtr
)
{
...
...
@@ -1120,8 +1120,8 @@ namespace Mantid
// Go through each entry in the input group(s)
for
(
size_t
entry
=
0
;
entry
<
m_groupSize
;
entry
++
)
{
// use create
sub a
lgorithm that look like this one
Algorithm_sptr
alg_sptr
=
this
->
create
Sub
Algorithm
(
this
->
name
(),
-
1
,
-
1
,
this
->
isLogging
(),
this
->
version
());
// use create
Child A
lgorithm that look like this one
Algorithm_sptr
alg_sptr
=
this
->
create
Child
Algorithm
(
this
->
name
(),
-
1
,
-
1
,
this
->
isLogging
(),
this
->
version
());
// Don't make the new algorithm a child so that it's workspaces are stored correctly
alg_sptr
->
setChild
(
false
);
...
...
Code/Mantid/Framework/API/src/AlgorithmProxy.cpp
View file @
beffd505
...
...
@@ -69,10 +69,10 @@ namespace Mantid
/** The actions to be performed by the AlgorithmProxy on a dataset. This method is
* invoked for top level AlgorithmProxys by the application manager.
* This method invokes exec() method.
* For
sub-
AlgorithmProxys either the execute() method or exec() method
* For
Child
AlgorithmProxys either the execute() method or exec() method
* must be EXPLICITLY invoked by the parent AlgorithmProxy.
*
* @throw runtime_error Thrown if AlgorithmProxy or
sub-
AlgorithmProxy cannot be executed
* @throw runtime_error Thrown if AlgorithmProxy or
Child
AlgorithmProxy cannot be executed
*/
bool
AlgorithmProxy
::
execute
()
{
...
...
Code/Mantid/Framework/API/src/DataProcessorAlgorithm.cpp
View file @
beffd505
...
...
@@ -86,7 +86,7 @@ namespace API
std
::
string
threadOutput
=
partialWSName
;
#ifdef MPI_BUILD
Workspace_sptr
partialWS
=
AnalysisDataService
::
Instance
().
retrieve
(
partialWSName
);
IAlgorithm_sptr
gatherAlg
=
create
Sub
Algorithm
(
"GatherWorkspaces"
);
IAlgorithm_sptr
gatherAlg
=
create
Child
Algorithm
(
"GatherWorkspaces"
);
gatherAlg
->
setLogging
(
true
);
gatherAlg
->
setAlwaysStoreInADS
(
true
);
gatherAlg
->
setProperty
(
"InputWorkspace"
,
partialWS
);
...
...
@@ -118,7 +118,7 @@ namespace API
if
(
saveOutput
&&
outputFile
.
size
()
>
0
)
{
IAlgorithm_sptr
saveAlg
=
create
Sub
Algorithm
(
"SaveNexus"
);
IAlgorithm_sptr
saveAlg
=
create
Child
Algorithm
(
"SaveNexus"
);
saveAlg
->
setPropertyValue
(
"Filename"
,
outputFile
);
saveAlg
->
setPropertyValue
(
"InputWorkspace"
,
outputWSName
);
saveAlg
->
execute
();
...
...
@@ -175,7 +175,7 @@ namespace API
Poco
::
Path
p
(
foundFile
);
const
std
::
string
outputWSName
=
p
.
getBaseName
();
IAlgorithm_sptr
loadAlg
=
create
Sub
Algorithm
(
m_loadAlg
);
IAlgorithm_sptr
loadAlg
=
create
Child
Algorithm
(
m_loadAlg
);
loadAlg
->
setProperty
(
m_loadAlgFileProp
,
foundFile
);
if
(
!
loadQuiet
)
{
...
...
Code/Mantid/Framework/API/src/WorkspaceOpOverloads.cpp
View file @
beffd505
...
...
@@ -90,7 +90,7 @@ namespace OperatorOverloads
throw
std
::
runtime_error
(
message
);
}
throw
Kernel
::
Exception
::
NotFoundError
(
"Required output workspace property not found on
sub a
lgorithm"
,
"OutputWorkspace"
);
throw
Kernel
::
Exception
::
NotFoundError
(
"Required output workspace property not found on
Child A
lgorithm"
,
"OutputWorkspace"
);
//Horendous code inclusion to satisfy compilers that all code paths return a value
// in reality the above code should either throw or return successfully.
...
...
Code/Mantid/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnits.h
View file @
beffd505
...
...
@@ -88,7 +88,7 @@ private:
/// Convert the workspace units using TOF as an intermediate step in the conversion
void
convertViaTOF
(
Kernel
::
Unit_const_sptr
fromUnit
,
API
::
MatrixWorkspace_sptr
outputWS
);
// Calls Rebin as a
sub-a
lgorithm to align the bins of the output workspace
// Calls Rebin as a
Child A
lgorithm to align the bins of the output workspace
API
::
MatrixWorkspace_sptr
alignBins
(
const
API
::
MatrixWorkspace_sptr
workspace
);
const
std
::
vector
<
double
>
calculateRebinParams
(
const
API
::
MatrixWorkspace_const_sptr
workspace
)
const
;
...
...
Code/Mantid/Framework/Algorithms/inc/MantidAlgorithms/GetDetOffsetsMultiPeaks.h
View file @
beffd505
...
...
@@ -53,7 +53,7 @@ public:
virtual
int
version
()
const
{
return
1
;
}
/// Algorithm's category for identification overriding a virtual method
virtual
const
std
::
string
category
()
const
{
return
"Diffraction"
;
}
/// Call Gaussian as a
sub-a
lgorithm to fit the peak in a spectrum
/// Call Gaussian as a
Child A
lgorithm to fit the peak in a spectrum
void
fitSpectra
(
const
int64_t
s
,
API
::
MatrixWorkspace_sptr
inputW
,
const
std
::
vector
<
double
>
&
peakPositions
,
const
std
::
vector
<
double
>
&
fitWindows
,
size_t
&
nparams
,
double
&
minD
,
double
&
maxD
,
std
::
vector
<
double
>&
peakPosToFit
,
std
::
vector
<
double
>
&
peakPosFitted
,
std
::
vector
<
double
>
&
chisq
);
...
...
Code/Mantid/Framework/Algorithms/inc/MantidAlgorithms/GetDetectorOffsets.h
View file @
beffd505
...
...
@@ -56,7 +56,7 @@ private:
// Overridden Algorithm methods
void
init
();
void
exec
();
/// Call Gaussian as a
sub-a
lgorithm to fit the peak in a spectrum
/// Call Gaussian as a
Child A
lgorithm to fit the peak in a spectrum
double
fitSpectra
(
const
int64_t
s
);
/// Create a function string from the given parameters and the algorithm inputs
API
::
IFunction_sptr
createFunction
(
const
double
peakHeight
,
const
double
peakLoc
);
...
...
Code/Mantid/Framework/Algorithms/inc/MantidAlgorithms/ReadGroupsFromFile.h
View file @
beffd505
...
...
@@ -100,7 +100,7 @@ private:
void
readGroupingFile
(
const
std
::
string
&
filename
);
/// Read an XML Grouping File
void
readXMLGroupingFile
(
const
std
::
string
&
filename
);
///
Sub-a
lgorithm to Load the associated empty instrument
///
Child A
lgorithm to Load the associated empty instrument
/// @param instrument_xml_name :: The instrument xml name including extension(.xml or .XML) but no path
/// this is determine by the mantid instrument.directory
/// @return Shared pointer to the 2D workspace
...
...
Code/Mantid/Framework/Algorithms/inc/MantidAlgorithms/StripPeaks.h
View file @
beffd505
...
...
@@ -11,7 +11,7 @@ namespace Mantid
{
namespace
Algorithms
{
/** This algorithm calls FindPeaks as a
suba
lgorithm and then subtracts
/** This algorithm calls FindPeaks as a
ChildA
lgorithm and then subtracts
all the peaks found from the data, leaving just the 'background'.
*** IT IS ASSUMED THAT THE FITTING FUNCTION WAS A GAUSSIAN ***
...
...
@@ -24,8 +24,8 @@ namespace Algorithms
Optional Properties:
<UL>
<LI> fwhm - passed to the FindPeaks
suba
lgorithm</LI>
<LI> Tolerance - passed to the FindPeaks
suba
lgorithm</LI>
<LI> fwhm - passed to the FindPeaks
ChildA
lgorithm</LI>
<LI> Tolerance - passed to the FindPeaks
ChildA
lgorithm</LI>
<LI> WorkspaceIndex - The spectrum from which to remove peaks. Will search all spectra if absent.</LI>
</UL>
...
...
Code/Mantid/Framework/Algorithms/src/AlignDetectors.cpp
View file @
beffd505
...
...
@@ -198,14 +198,14 @@ void AlignDetectors::exec()
if
(
!
calFileName
.
empty
())
{
// Load the .cal file
IAlgorithm_sptr
alg
=
create
Sub
Algorithm
(
"LoadCalFile"
);
IAlgorithm_sptr
alg
=
create
Child
Algorithm
(
"LoadCalFile"
);
alg
->
setPropertyValue
(
"CalFilename"
,
calFileName
);
alg
->
setProperty
(
"InputWorkspace"
,
inputWS
);
alg
->
setProperty
<
bool
>
(
"MakeGroupingWorkspace"
,
false
);
alg
->
setProperty
<
bool
>
(
"MakeOffsetsWorkspace"
,
true
);
alg
->
setProperty
<
bool
>
(
"MakeMaskWorkspace"
,
false
);
alg
->
setPropertyValue
(
"WorkspaceName"
,
"temp"
);
alg
->
executeAs
Sub
Alg
();
alg
->
executeAs
Child
Alg
();
offsetsWS
=
alg
->
getProperty
(
"OutputOffsetsWorkspace"
);
}
...
...
Code/Mantid/Framework/Algorithms/src/AlphaCalc.cpp
View file @
beffd505
...
...
@@ -83,7 +83,7 @@ void AlphaCalc::exec()
// first step is to create two workspaces which groups all forward and
// backward spectra
API
::
IAlgorithm_sptr
groupForward
=
create
Sub
Algorithm
(
"GroupDetectors"
);
API
::
IAlgorithm_sptr
groupForward
=
create
Child
Algorithm
(
"GroupDetectors"
);
groupForward
->
setProperty
(
"InputWorkspace"
,
inputWS
);
groupForward
->
setProperty
(
"OutputWorkspace"
,
"tmp"
);
groupForward
->
setProperty
(
"SpectraList"
,
forwardSpectraList
);
...
...
@@ -91,7 +91,7 @@ void AlphaCalc::exec()
groupForward
->
execute
();
API
::
MatrixWorkspace_sptr
forwardWS
=
groupForward
->
getProperty
(
"OutputWorkspace"
);
API
::
IAlgorithm_sptr
groupBackward
=
create
Sub
Algorithm
(
"GroupDetectors"
);
API
::
IAlgorithm_sptr
groupBackward
=
create
Child
Algorithm
(
"GroupDetectors"
);
groupBackward
->
setProperty
(
"InputWorkspace"
,
inputWS
);
groupBackward
->
setProperty
(
"OutputWorkspace"
,
"tmp"
);
groupBackward
->
setProperty
(
"SpectraList"
,
backwardSpectraList
);
...
...
@@ -105,7 +105,7 @@ void AlphaCalc::exec()
double
firstGoodvalue
=
getProperty
(
"FirstGoodValue"
);
double
lastGoodvalue
=
getProperty
(
"LastGoodValue"
);
API
::
IAlgorithm_sptr
integr
=
create
Sub
Algorithm
(
"Integration"
);
API
::
IAlgorithm_sptr
integr
=
create
Child
Algorithm
(
"Integration"
);
integr
->
setProperty
(
"InputWorkspace"
,
forwardWS
);
integr
->
setPropertyValue
(
"OutputWorkspace"
,
"tmp"
);
if
(
firstGoodvalue
!=
EMPTY_DBL
())
...
...
@@ -128,7 +128,7 @@ void AlphaCalc::exec()
// calculate sum of backward counts
API
::
IAlgorithm_sptr
integrB
=
create
Sub
Algorithm
(
"Integration"
);
API
::
IAlgorithm_sptr
integrB
=
create
Child
Algorithm
(
"Integration"
);
integrB
->
setProperty
(
"InputWorkspace"
,
backwardWS
);
integrB
->
setPropertyValue
(
"OutputWorkspace"
,
"tmp"
);
if
(
firstGoodvalue
!=
EMPTY_DBL
())
...
...
Code/Mantid/Framework/Algorithms/src/ApplyDeadTimeCorr.cpp
View file @
beffd505
...
...
@@ -67,7 +67,7 @@ void ApplyDeadTimeCorr::exec()
numGoodFrames
=
boost
::
lexical_cast
<
double
>
(
run
.
getProperty
(
"goodfrm"
)
->
value
());
// Duplicate the input workspace. Only need to change Y values based on dead time corrections
IAlgorithm_sptr
duplicate
=
create
Sub
Algorithm
(
"CloneWorkspace"
);
IAlgorithm_sptr
duplicate
=
create
Child
Algorithm
(
"CloneWorkspace"
);
duplicate
->
initialize
();
duplicate
->
setProperty
<
Workspace_sptr
>
(
"InputWorkspace"
,
boost
::
dynamic_pointer_cast
<
Workspace
>
(
inputWs
));
duplicate
->
execute
();
...
...
Code/Mantid/Framework/Algorithms/src/ApplyDetailedBalance.cpp
View file @
beffd505
...
...
@@ -102,13 +102,13 @@ namespace Algorithms
double
oneOverT
=
PhysicalConstants
::
meVtoKelvin
/
Temp
;
// Run the exponential correction algorithm explicitly to enable progress reporting
IAlgorithm_sptr
expcor
=
create
Sub
Algorithm
(
"OneMinusExponentialCor"
,
0.0
,
1.0
);
IAlgorithm_sptr
expcor
=
create
Child
Algorithm
(
"OneMinusExponentialCor"
,
0.0
,
1.0
);
expcor
->
setProperty
<
MatrixWorkspace_sptr
>
(
"InputWorkspace"
,
inputWS
);
expcor
->
setProperty
<
MatrixWorkspace_sptr
>
(
"OutputWorkspace"
,
outputWS
);
expcor
->
setProperty
<
double
>
(
"C1"
,
M_PI
);
expcor
->
setProperty
<
double
>
(
"C"
,
oneOverT
);
expcor
->
setPropertyValue
(
"Operation"
,
"Multiply"
);
expcor
->
executeAs
Sub
Alg
();
expcor
->
executeAs
Child
Alg
();
// Get back the result
outputWS
=
expcor
->
getProperty
(
"OutputWorkspace"
);
...
...
Code/Mantid/Framework/Algorithms/src/BinaryOperateMasks.cpp
View file @
beffd505
...
...
@@ -77,7 +77,7 @@ namespace Algorithms
outputws
->
copyFrom
(
inputws1
);
}
// 3. Call
Sub
Algorithm
// 3. Call
Child
Algorithm
if
(
op
==
"NOT"
){
// Unary operation
...
...
Code/Mantid/Framework/Algorithms/src/BinaryOperation.cpp
View file @
beffd505
...
...
@@ -75,19 +75,19 @@ namespace Mantid
std
::
cout
<<
"Special DIVIDE of "
<<
this
->
getPropertyValue
(
inputPropName2
())
<<
" by "
<<
this
->
getPropertyValue
(
inputPropName1
())
<<
"
\n
"
;
// x / workspace = Power(workspace, -1) * x
// workspace ^ -1
IAlgorithm_sptr
pow
=
this
->
create
Sub
Algorithm
(
"Power"
,
0.0
,
0.5
,
true
);
IAlgorithm_sptr
pow
=
this
->
create
Child
Algorithm
(
"Power"
,
0.0
,
0.5
,
true
);
pow
->
setProperty
(
"InputWorkspace"
,
boost
::
const_pointer_cast
<
MatrixWorkspace
>
(
m_rhs
));
pow
->
setProperty
(
"Exponent"
,
-
1.0
);
pow
->
setPropertyValue
(
"OutputWorkspace"
,
this
->
getPropertyValue
(
"OutputWorkspace"
));
pow
->
executeAs
Sub
Alg
();
pow
->
executeAs
Child
Alg
();
out
=
pow
->
getProperty
(
"OutputWorkspace"
);
// Multiply by x
IAlgorithm_sptr
mult
=
this
->
create
Sub
Algorithm
(
"Multiply"
,
0.5
,
1.0
,
true
);
IAlgorithm_sptr
mult
=
this
->
create
Child
Algorithm
(
"Multiply"
,
0.5
,
1.0
,
true
);
mult
->
setProperty
(
inputPropName1
(),
out
);
//(workspace^-1)
mult
->
setProperty
(
inputPropName2
(),
boost
::
const_pointer_cast
<
MatrixWorkspace
>
(
m_lhs
));
// (1.0) or other number
mult
->
setProperty
(
outputPropName
(),
out
);
mult
->
executeAs
Sub
Alg
();
mult
->
executeAs
Child
Alg
();
out
=
mult
->
getProperty
(
"OutputWorkspace"
);
}
else
if
(
this
->
name
()
==
"Minus"
)
...
...
@@ -99,19 +99,19 @@ namespace Mantid
minusOne
->
dataE
(
0
)[
0
]
=
0.0
;
// workspace * -1
IAlgorithm_sptr
mult
=
this
->
create
Sub
Algorithm
(
"Multiply"
,
0.0
,
0.5
,
true
);
IAlgorithm_sptr
mult
=
this
->
create
Child
Algorithm
(
"Multiply"
,
0.0
,
0.5
,
true
);
mult
->
setProperty
(
inputPropName1
(),
boost
::
const_pointer_cast
<
MatrixWorkspace
>
(
m_rhs
));
mult
->
setProperty
(
inputPropName2
(),
minusOne
);
mult
->
setPropertyValue
(
"OutputWorkspace"
,
this
->
getPropertyValue
(
"OutputWorkspace"
));
mult
->
executeAs
Sub
Alg
();
mult
->
executeAs
Child
Alg
();
out
=
mult
->
getProperty
(
"OutputWorkspace"
);
// Multiply by x
IAlgorithm_sptr
plus
=
this
->
create
Sub
Algorithm
(
"Plus"
,
0.5
,
1.0
,
true
);
IAlgorithm_sptr
plus
=
this
->
create
Child
Algorithm
(
"Plus"
,
0.5
,
1.0
,
true
);
plus
->
setProperty
(
inputPropName1
(),
out
);
//(workspace^-1)
plus
->
setProperty
(
inputPropName2
(),
boost
::
const_pointer_cast
<
MatrixWorkspace
>
(
m_lhs
));
// (1.0) or other number
plus
->
setProperty
(
outputPropName
(),
out
);
plus
->
executeAs
Sub
Alg
();
plus
->
executeAs
Child
Alg
();
out
=
plus
->
getProperty
(
"OutputWorkspace"
);
}
...
...
Code/Mantid/Framework/Algorithms/src/CalMuonDeadTime.cpp
View file @
beffd505
...
...
@@ -99,12 +99,12 @@ void CalMuonDeadTime::exec()
std
::
string
wsName
=
"TempForMuonCalDeadTime"
;
API
::
IAlgorithm_sptr
cropWS
;
cropWS
=
create
Sub
Algorithm
(
"CropWorkspace"
,
-
1
,
-
1
);
cropWS
=
create
Child
Algorithm
(
"CropWorkspace"
,
-
1
,
-
1
);
cropWS
->
setProperty
(
"InputWorkspace"
,
inputWS
);
cropWS
->
setPropertyValue
(
"OutputWorkspace"
,
"croppedWS"
);
cropWS
->
setProperty
(
"XMin"
,
firstgooddata
);
cropWS
->
setProperty
(
"XMax"
,
lastgooddata
);
cropWS
->
executeAs
Sub
Alg
();
cropWS
->
executeAs
Child
Alg
();
// get cropped input workspace
...
...
@@ -119,10 +119,10 @@ void CalMuonDeadTime::exec()
// y-axis with measured counts * exp(t/t_mu)
API
::
IAlgorithm_sptr
convertToPW
;
convertToPW
=
create
Sub
Algorithm
(
"ConvertToPointData"
,
-
1
,
-
1
);
convertToPW
=
create
Child
Algorithm
(
"ConvertToPointData"
,
-
1
,
-
1
);
convertToPW
->
setProperty
(
"InputWorkspace"
,
wsCrop
);
convertToPW
->
setPropertyValue
(
"OutputWorkspace"
,
wsName
);
convertToPW
->
executeAs
Sub
Alg
();
convertToPW
->
executeAs
Child
Alg
();
// get pointworkspace
...
...
@@ -176,7 +176,7 @@ void CalMuonDeadTime::exec()
const
double
in_bg1
=
0.0
;
API
::
IAlgorithm_sptr
fit
;
fit
=
create
Sub
Algorithm
(
"Fit"
,
-
1
,
-
1
,
true
);
fit
=
create
Child
Algorithm
(
"Fit"
,
-
1
,
-
1
,
true
);
std
::
stringstream
ss
;
ss
<<
"name=LinearBackground,A0="
<<
in_bg0
<<
",A1="
<<
in_bg1
;
...
...
@@ -188,7 +188,7 @@ void CalMuonDeadTime::exec()
fit
->
setProperty
(
"WorkspaceIndex"
,
wsindex
);
fit
->
setPropertyValue
(
"Minimizer"
,
"Levenberg-MarquardtMD"
);
fit
->
executeAs
Sub
Alg
();
fit
->
executeAs
Child
Alg
();
std
::
string
fitStatus
=
fit
->
getProperty
(
"OutputStatus"
);
//std::vector<double> params = fit->getProperty("Parameters");
...
...
Code/Mantid/Framework/Algorithms/src/CalculateEfficiency.cpp
View file @
beffd505
...
...
@@ -78,9 +78,9 @@ void CalculateEfficiency::exec()
DataObjects
::
EventWorkspace_const_sptr
inputEventWS
=
boost
::
dynamic_pointer_cast
<
const
EventWorkspace
>
(
inputWS
);
// Sum up all the wavelength bins
IAlgorithm_sptr
childAlg
=
create
Sub
Algorithm
(
"Integration"
,
0.0
,
0.2
);
IAlgorithm_sptr
childAlg
=
create
Child
Algorithm
(
"Integration"
,
0.0
,
0.2
);
childAlg
->
setProperty
<
MatrixWorkspace_sptr
>
(
"InputWorkspace"
,
inputWS
);
childAlg
->
executeAs
Sub
Alg
();
childAlg
->
executeAs
Child
Alg
();
rebinnedWS
=
childAlg
->
getProperty
(
"OutputWorkspace"
);
outputWS
=
WorkspaceFactory
::
Instance
().
create
(
rebinnedWS
);
...
...
@@ -224,13 +224,13 @@ void CalculateEfficiency::normalizeDetectors(MatrixWorkspace_sptr rebinnedWS,
// Mask detectors that were found to be outside the acceptable efficiency band
try
{
IAlgorithm_sptr
mask
=
create
Sub
Algorithm
(
"MaskDetectors"
,
0.8
,
0.9
);
IAlgorithm_sptr
mask
=
create
Child
Algorithm
(
"MaskDetectors"
,
0.8
,
0.9
);
// First we mask detectors in the output workspace
mask
->
setProperty
<
MatrixWorkspace_sptr
>
(
"Workspace"
,
outputWS
);
mask
->
setProperty
<
std
::
vector
<
size_t
>
>
(
"WorkspaceIndexList"
,
dets_to_mask
);
mask
->
execute
();
mask
=
create
Sub
Algorithm
(
"MaskDetectors"
,
0.9
,
1.0
);
mask
=
create
Child
Algorithm
(
"MaskDetectors"
,
0.9
,
1.0
);
// Then we mask the same detectors in the input workspace
mask
->
setProperty
<
MatrixWorkspace_sptr
>
(
"Workspace"
,
rebinnedWS
);
mask
->
setProperty
<
std
::
vector
<
size_t
>
>
(
"WorkspaceIndexList"
,
dets_to_mask
);
...
...
@@ -238,12 +238,12 @@ void CalculateEfficiency::normalizeDetectors(MatrixWorkspace_sptr rebinnedWS,
}
catch
(
std
::
invalid_argument
&
err
)
{
std
::
stringstream
e
;
e
<<
"Invalid argument to MaskDetectors
sub-a
lgorithm: "
<<
err
.
what
();
e
<<
"Invalid argument to MaskDetectors
Child A
lgorithm: "
<<
err
.
what
();
g_log
.
error
(
e
.
str
());
}
catch
(
std
::
runtime_error
&
err
)
{
std
::
stringstream
e
;
e
<<
"Unable to successfully run MaskDetectors
sub-a
lgorithm: "
<<
err
.
what
();
e
<<
"Unable to successfully run MaskDetectors
Child A
lgorithm: "
<<
err
.
what
();
g_log
.
error
(
e
.
str
());
}
}
...
...
Prev
1
2
3
4
5
…
14
Next
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