本文整理汇总了C++中Algorithm_sptr::setProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ Algorithm_sptr::setProperty方法的具体用法?C++ Algorithm_sptr::setProperty怎么用?C++ Algorithm_sptr::setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Algorithm_sptr
的用法示例。
在下文中一共展示了Algorithm_sptr::setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/** Add workspace2 to workspace1 by adding spectrum.
*/
MatrixWorkspace_sptr
AlignAndFocusPowder::conjoinWorkspaces(API::MatrixWorkspace_sptr ws1,
API::MatrixWorkspace_sptr ws2,
size_t offset) {
// Get information from ws1: maximum spectrum number, and store original
// spectrum Nos
size_t nspec1 = ws1->getNumberHistograms();
specnum_t maxspecNo1 = 0;
std::vector<specnum_t> origspecNos;
for (size_t i = 0; i < nspec1; ++i) {
specnum_t tmpspecNo = ws1->getSpectrum(i).getSpectrumNo();
origspecNos.push_back(tmpspecNo);
if (tmpspecNo > maxspecNo1)
maxspecNo1 = tmpspecNo;
}
g_log.information() << "[DBx536] Max spectrum number of ws1 = " << maxspecNo1
<< ", Offset = " << offset << ".\n";
size_t nspec2 = ws2->getNumberHistograms();
// Conjoin 2 workspaces
Algorithm_sptr alg = this->createChildAlgorithm("AppendSpectra");
alg->initialize();
;
alg->setProperty("InputWorkspace1", ws1);
alg->setProperty("InputWorkspace2", ws2);
alg->setProperty("OutputWorkspace", ws1);
alg->setProperty("ValidateInputs", false);
alg->executeAsChildAlg();
API::MatrixWorkspace_sptr outws = alg->getProperty("OutputWorkspace");
// FIXED : Restore the original spectrum Nos to spectra from ws1
for (size_t i = 0; i < nspec1; ++i) {
specnum_t tmpspecNo = outws->getSpectrum(i).getSpectrumNo();
outws->getSpectrum(i).setSpectrumNo(origspecNos[i]);
g_log.information() << "[DBx540] Conjoined spectrum " << i
<< ": restore spectrum number to "
<< outws->getSpectrum(i).getSpectrumNo()
<< " from spectrum number = " << tmpspecNo << ".\n";
}
// Rename spectrum number
if (offset >= 1) {
for (size_t i = 0; i < nspec2; ++i) {
specnum_t newspecid = maxspecNo1 + static_cast<specnum_t>((i) + offset);
outws->getSpectrum(nspec1 + i).setSpectrumNo(newspecid);
// ISpectrum* spec = outws->getSpectrum(nspec1+i);
// if (spec)
// spec->setSpectrumNo(3);
}
}
return outws;
}
示例2: runLoadParameterFile
//-----------------------------------------------------------------------------------------------------------------------
/// Run the Child Algorithm LoadInstrument (or LoadInstrumentFromRaw)
void LoadInstrument::runLoadParameterFile() {
g_log.debug("Loading the parameter definition...");
// First search for XML parameter file in same folder as IDF file
const std::string::size_type dir_end = m_filename.find_last_of("\\/");
std::string directoryName =
m_filename.substr(0, dir_end + 1); // include final '/'.
std::string fullPathParamIDF = getFullPathParamIDF(directoryName);
if (fullPathParamIDF.empty()) {
// Not found, so search the other places were it may occur
Kernel::ConfigServiceImpl &configService =
Kernel::ConfigService::Instance();
std::vector<std::string> directoryNames =
configService.getInstrumentDirectories();
for (auto directoryName : directoryNames) {
// This will iterate around the directories from user ->etc ->install, and
// find the first beat file
fullPathParamIDF = getFullPathParamIDF(directoryName);
// stop when you find the first one
if (!fullPathParamIDF.empty())
break;
}
}
if (!fullPathParamIDF.empty()) {
g_log.debug() << "Parameter file: " << fullPathParamIDF << std::endl;
// Now execute the Child Algorithm. Catch and log any error, but don't stop.
try {
// To allow the use of ExperimentInfo instead of workspace, we call it
// manually
Algorithm_sptr loadParamAlg = createChildAlgorithm("LoadParameterFile");
loadParamAlg->setProperty("Filename", fullPathParamIDF);
loadParamAlg->setProperty("Workspace", m_workspace);
loadParamAlg->execute();
g_log.debug("Parameters loaded successfully.");
} catch (std::invalid_argument &e) {
g_log.information(
"LoadParameterFile: No parameter file found for this instrument");
g_log.information(e.what());
} catch (std::runtime_error &e) {
g_log.information(
"Unable to successfully run LoadParameterFile Child Algorithm");
g_log.information(e.what());
}
} else {
g_log.information("No parameter file found for this instrument");
}
}
示例3: getWorkspaceAboveX
/** Returns a cropped workspace with data equal to and above the specified x limit
*
* @param workspace :: MatrixWorkspace
* @param x :: Minimum allowed x-value in the data.
* @return MatrixWorkspace cropped to values with x >= specified limit.
*/
MatrixWorkspace_sptr PoldiTruncateData::getWorkspaceAboveX(MatrixWorkspace_sptr workspace, double x)
{
Algorithm_sptr crop = getCropAlgorithmForWorkspace(workspace);
crop->setProperty("Xmin", x);
return getOutputWorkspace(crop);
}
示例4: doSortEvents
/** Perform SortEvents on the output workspaces
* but only if they are EventWorkspaces.
*
* @param ws :: any Workspace. Does nothing if not EventWorkspace.
*/
void AlignAndFocusPowder::doSortEvents(Mantid::API::Workspace_sptr ws) {
EventWorkspace_sptr eventWS = boost::dynamic_pointer_cast<EventWorkspace>(ws);
if (!eventWS)
return;
Algorithm_sptr alg = this->createChildAlgorithm("SortEvents");
alg->setProperty("InputWorkspace", eventWS);
alg->setPropertyValue("SortBy", "X Value");
alg->executeAsChildAlg();
}
示例5: runCompareWorkspaces
/**
* Run new CompareWorkspaces algorithm as a child algorithm.
*
* Result string formatted the same way as before; "Success!" when workspaces
* match or a newline separated list of mismatch messages.
*
* @param group_compare Should output be formatted like group comparison?
* @return A string containing either successString() or mismatch messages
*/
std::string CheckWorkspacesMatch::runCompareWorkspaces(bool group_compare) {
// This algorithm produces a single result string
std::string result;
// Use new CompareWorkspaces algorithm to perform comparison
Algorithm_sptr compare = this->createChildAlgorithm("CompareWorkspaces");
compare->setRethrows(true);
compare->setLogging(false);
// Forward workspace properties
Workspace_sptr ws1 = getProperty("Workspace1");
Workspace_sptr ws2 = getProperty("Workspace2");
compare->setProperty("Workspace1", ws1);
compare->setProperty("Workspace2", ws2);
// Copy any other non-default properties
const std::vector<Property *> &allProps = this->getProperties();
auto propCount = allProps.size();
for (size_t i = 0; i < propCount; ++i) {
Property *prop = allProps[i];
const std::string &pname = prop->name();
if (!prop->isDefault() && pname != "Workspace1" && pname != "Workspace2" &&
pname != "Result")
compare->setPropertyValue(pname, prop->value());
}
// Execute comparison
compare->execute();
// Generate result string
if (!compare->getProperty("Result")) {
ITableWorkspace_sptr table = compare->getProperty("Messages");
auto rowcount = table->rowCount();
for (size_t i = 0; i < rowcount; ++i) {
result += table->cell<std::string>(i, 0);
// Emulate special case output format when comparing groups
if (group_compare &&
table->cell<std::string>(i, 0) !=
"Type mismatch. One workspace is a group, the other is not." &&
table->cell<std::string>(i, 0) != "GroupWorkspaces size mismatch.") {
result += ". Inputs=[" + table->cell<std::string>(i, 1) + "," +
table->cell<std::string>(i, 2) + "]";
}
if (i < (rowcount - 1))
result += "\n";
}
} else {
result = successString();
}
return result;
}
示例6: loadParameterFile
// Private function to load parameter file specified by a full path name into
// given workspace, returning success.
bool LoadIDFFromNexus::loadParameterFile(
const std::string &fullPathName,
const MatrixWorkspace_sptr localWorkspace) {
try {
// load and also populate instrument parameters from this 'fallback'
// parameter file
Algorithm_sptr loadParamAlg = createChildAlgorithm("LoadParameterFile");
loadParamAlg->setProperty("Filename", fullPathName);
loadParamAlg->setProperty("Workspace", localWorkspace);
loadParamAlg->execute();
g_log.notice() << "Instrument parameter file: " << fullPathName
<< " has been loaded.\n\n";
return true; // Success
} catch (std::runtime_error &) {
g_log.debug() << "Instrument parameter file: " << fullPathName
<< " not found or un-parsable.\n";
return false; // Failure
}
}
示例7: doSortEvents
/** Perform SortEvents on the output workspaces (accumulation or output)
* but only if they are EventWorkspaces. This will help the GUI
* cope with redrawing.
*
* @param ws :: any Workspace. Does nothing if not EventWorkspace.
*/
void LoadLiveData::doSortEvents(Mantid::API::Workspace_sptr ws) {
EventWorkspace_sptr eventWS = boost::dynamic_pointer_cast<EventWorkspace>(ws);
if (!eventWS)
return;
CPUTimer tim;
Algorithm_sptr alg = this->createChildAlgorithm("SortEvents");
alg->setProperty("InputWorkspace", eventWS);
alg->setPropertyValue("SortBy", "X Value");
alg->executeAsChildAlg();
g_log.debug() << tim << " to perform SortEvents on " << ws->name() << '\n';
}
示例8: runtime_error
/** Returns a MatrixWorkspace with all spectrum summed up.
*
* The summation is done with the SumSpectra-algorithm.
*
* @param workspace :: MatrixWorkspace
* @return MatrixWorkspace with one spectrum which contains all counts.
*/
MatrixWorkspace_sptr
PoldiTruncateData::getSummedSpectra(MatrixWorkspace_sptr workspace) {
Algorithm_sptr sumSpectra = createChildAlgorithm("SumSpectra");
if (!sumSpectra) {
throw std::runtime_error("Could not create SumSpectra algorithm.");
}
sumSpectra->setProperty("InputWorkspace", workspace);
return getOutputWorkspace(sumSpectra);
}
示例9: getCropAlgorithmForWorkspace
/** Creates a CropWorkspace-algorithm for the given workspace
*
* This method calls createChildAlgorithm() to create an instance of the
*CropWorkspace algorithm.
* If the creation is successful, the supplied workspace is set as
*InputParameter.
*
* @param workspace :: MatrixWorkspace
* @return Pointer to crop algorithm.
*/
Algorithm_sptr PoldiTruncateData::getCropAlgorithmForWorkspace(
MatrixWorkspace_sptr workspace) {
Algorithm_sptr crop = createChildAlgorithm("CropWorkspace");
if (!crop) {
throw std::runtime_error("Could not create CropWorkspace algorithm");
}
crop->setProperty("InputWorkspace", workspace);
return crop;
}
示例10: retrieveInstrumentParameters
void EstimatePDDetectorResolution::retrieveInstrumentParameters()
{
#if 0
// Call SolidAngle to get solid angles for all detectors
Algorithm_sptr calsolidangle = createChildAlgorithm("SolidAngle", -1, -1, true);
calsolidangle->initialize();
calsolidangle->setProperty("InputWorkspace", m_inputWS);
calsolidangle->execute();
if (!calsolidangle->isExecuted())
throw runtime_error("Unable to run solid angle. ");
m_solidangleWS = calsolidangle->getProperty("OutputWorkspace");
if (!m_solidangleWS)
throw runtime_error("Unable to get solid angle workspace from SolidAngle(). ");
size_t numspec = m_solidangleWS->getNumberHistograms();
for (size_t i = 0; i < numspec; ++i)
g_log.debug() << "[DB]: " << m_solidangleWS->readY(i)[0] << "\n";
#endif
// Calculate centre neutron velocity
Property* cwlproperty = m_inputWS->run().getProperty("LambdaRequest");
if (!cwlproperty)
throw runtime_error("Unable to locate property LambdaRequest as central wavelength. ");
TimeSeriesProperty<double>* cwltimeseries = dynamic_cast<TimeSeriesProperty<double>* >(cwlproperty);
if (!cwltimeseries)
throw runtime_error("LambdaReqeust is not a TimeSeriesProperty in double. ");
if (cwltimeseries->size() != 1)
throw runtime_error("LambdaRequest should contain 1 and only 1 entry. ");
double centrewavelength = cwltimeseries->nthValue(0);
string unit = cwltimeseries->units();
if (unit.compare("Angstrom") == 0)
centrewavelength *= 1.0E-10;
else
throw runtime_error("Unit is not recognized");
m_centreVelocity = PhysicalConstants::h/PhysicalConstants::NeutronMass/centrewavelength;
g_log.notice() << "Centre wavelength = " << centrewavelength << ", Centre neutron velocity = " << m_centreVelocity << "\n";
// Calcualte L1 sample to source
Instrument_const_sptr instrument = m_inputWS->getInstrument();
V3D samplepos = instrument->getSample()->getPos();
V3D sourcepos = instrument->getSource()->getPos();
m_L1 = samplepos.distance(sourcepos);
g_log.notice() << "L1 = " << m_L1 << "\n";
return;
}
示例11: invalid_argument
/** Get a pointer to an instrument in one of 3 ways: InputWorkspace,
* InstrumentName, InstrumentFilename
* @param alg :: algorithm from which to get the property values.
* */
Geometry::Instrument_const_sptr
LoadCalFile::getInstrument3Ways(Algorithm *alg) {
MatrixWorkspace_sptr inWS = alg->getProperty("InputWorkspace");
std::string InstrumentName = alg->getPropertyValue("InstrumentName");
std::string InstrumentFilename = alg->getPropertyValue("InstrumentFilename");
// Some validation
int numParams = 0;
if (inWS)
numParams++;
if (!InstrumentName.empty())
numParams++;
if (!InstrumentFilename.empty())
numParams++;
if (numParams > 1)
throw std::invalid_argument("You must specify exactly ONE way to get an "
"instrument (workspace, instrument name, or "
"IDF file). You specified more than one.");
if (numParams == 0)
throw std::invalid_argument("You must specify exactly ONE way to get an "
"instrument (workspace, instrument name, or "
"IDF file). You specified none.");
// ---------- Get the instrument one of 3 ways ---------------------------
Instrument_const_sptr inst;
if (inWS) {
inst = inWS->getInstrument();
} else {
Algorithm_sptr childAlg =
alg->createChildAlgorithm("LoadInstrument", 0.0, 0.2);
MatrixWorkspace_sptr tempWS = boost::make_shared<Workspace2D>();
childAlg->setProperty<MatrixWorkspace_sptr>("Workspace", tempWS);
childAlg->setPropertyValue("Filename", InstrumentFilename);
childAlg->setPropertyValue("InstrumentName", InstrumentName);
childAlg->setProperty("RewriteSpectraMap",
Mantid::Kernel::OptionalBool(false));
childAlg->executeAsChildAlg();
inst = tempWS->getInstrument();
}
return inst;
}
示例12: exec
/** Execute the algorithm.
*/
void CreateGroupingWorkspace::exec() {
MatrixWorkspace_sptr inWS = getProperty("InputWorkspace");
std::string InstrumentName = getPropertyValue("InstrumentName");
std::string InstrumentFilename = getPropertyValue("InstrumentFilename");
std::string OldCalFilename = getPropertyValue("OldCalFilename");
std::string GroupNames = getPropertyValue("GroupNames");
std::string grouping = getPropertyValue("GroupDetectorsBy");
int numGroups = getProperty("FixedGroupCount");
std::string componentName = getPropertyValue("ComponentName");
// Some validation
int numParams = 0;
if (inWS)
numParams++;
if (!InstrumentName.empty())
numParams++;
if (!InstrumentFilename.empty())
numParams++;
if (numParams > 1)
throw std::invalid_argument("You must specify exactly ONE way to get an "
"instrument (workspace, instrument name, or "
"IDF file). You specified more than one.");
if (numParams == 0)
throw std::invalid_argument("You must specify exactly ONE way to get an "
"instrument (workspace, instrument name, or "
"IDF file). You specified none.");
if (!OldCalFilename.empty() && !GroupNames.empty())
throw std::invalid_argument("You must specify either to use the "
"OldCalFilename parameter OR GroupNames but "
"not both!");
bool sortnames = false;
// ---------- Get the instrument one of 3 ways ---------------------------
Instrument_const_sptr inst;
if (inWS) {
inst = inWS->getInstrument();
} else {
Algorithm_sptr childAlg = createChildAlgorithm("LoadInstrument", 0.0, 0.2);
MatrixWorkspace_sptr tempWS = boost::make_shared<Workspace2D>();
childAlg->setProperty<MatrixWorkspace_sptr>("Workspace", tempWS);
childAlg->setPropertyValue("Filename", InstrumentFilename);
childAlg->setProperty("RewriteSpectraMap",
Mantid::Kernel::OptionalBool(true));
childAlg->setPropertyValue("InstrumentName", InstrumentName);
childAlg->executeAsChildAlg();
inst = tempWS->getInstrument();
}
if (GroupNames.empty() && OldCalFilename.empty()) {
if (grouping.compare("All") == 0) {
GroupNames = inst->getName();
} else if (inst->getName().compare("SNAP") == 0 &&
grouping.compare("Group") == 0) {
GroupNames = "East,West";
} else {
sortnames = true;
GroupNames = "";
int maxRecurseDepth = this->getProperty("MaxRecursionDepth");
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for schedule(dynamic, 1) )
for (int num = 0; num < 300; ++num) {
PARALLEL_START_INTERUPT_REGION
std::ostringstream mess;
mess << grouping << num;
IComponent_const_sptr comp =
inst->getComponentByName(mess.str(), maxRecurseDepth);
PARALLEL_CRITICAL(GroupNames)
if (comp)
GroupNames += mess.str() + ",";
PARALLEL_END_INTERUPT_REGION
}
PARALLEL_CHECK_INTERUPT_REGION
}
}
// --------------------------- Create the output --------------------------
auto outWS = boost::make_shared<GroupingWorkspace>(inst);
this->setProperty("OutputWorkspace", outWS);
// This will get the grouping
std::map<detid_t, int> detIDtoGroup;
Progress prog(this, 0.2, 1.0, outWS->getNumberHistograms());
// Make the grouping one of three ways:
if (!GroupNames.empty())
detIDtoGroup = makeGroupingByNames(GroupNames, inst, prog, sortnames);
else if (!OldCalFilename.empty())
detIDtoGroup = readGroupingFile(OldCalFilename, prog);
else if ((numGroups > 0) && !componentName.empty())
detIDtoGroup =
makeGroupingByNumGroups(componentName, numGroups, inst, prog);
g_log.information() << detIDtoGroup.size()
<< " entries in the detectorID-to-group map.\n";
//.........这里部分代码省略.........
示例13: processGroups
bool ReflectometryReductionOneAuto::processGroups() {
auto group = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(
getPropertyValue("InputWorkspace"));
const std::string outputIvsQ = this->getPropertyValue("OutputWorkspace");
const std::string outputIvsLam =
this->getPropertyValue("OutputWorkspaceWavelength");
// Create a copy of ourselves
Algorithm_sptr alg = this->createChildAlgorithm(
this->name(), -1, -1, this->isLogging(), this->version());
alg->setChild(false);
alg->setRethrows(true);
// Copy all the non-workspace properties over
std::vector<Property *> props = this->getProperties();
for (auto prop = props.begin(); prop != props.end(); ++prop) {
if (*prop) {
IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty *>(*prop);
if (!wsProp)
alg->setPropertyValue((*prop)->name(), (*prop)->value());
}
}
// Check if the transmission runs are groups or not
const std::string firstTrans = this->getPropertyValue("FirstTransmissionRun");
WorkspaceGroup_sptr firstTransG;
if (!firstTrans.empty()) {
auto firstTransWS =
AnalysisDataService::Instance().retrieveWS<Workspace>(firstTrans);
firstTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(firstTransWS);
if (!firstTransG)
alg->setProperty("FirstTransmissionRun", firstTrans);
else if (group->size() != firstTransG->size())
throw std::runtime_error("FirstTransmissionRun WorkspaceGroup must be "
"the same size as the InputWorkspace "
"WorkspaceGroup");
}
const std::string secondTrans =
this->getPropertyValue("SecondTransmissionRun");
WorkspaceGroup_sptr secondTransG;
if (!secondTrans.empty()) {
auto secondTransWS =
AnalysisDataService::Instance().retrieveWS<Workspace>(secondTrans);
secondTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(secondTransWS);
if (!secondTransG)
alg->setProperty("SecondTransmissionRun", secondTrans);
else if (group->size() != secondTransG->size())
throw std::runtime_error("SecondTransmissionRun WorkspaceGroup must be "
"the same size as the InputWorkspace "
"WorkspaceGroup");
}
std::vector<std::string> IvsQGroup, IvsLamGroup;
// Execute algorithm over each group member (or period, if this is
// multiperiod)
size_t numMembers = group->size();
for (size_t i = 0; i < numMembers; ++i) {
const std::string IvsQName =
outputIvsQ + "_" + boost::lexical_cast<std::string>(i + 1);
const std::string IvsLamName =
outputIvsLam + "_" + boost::lexical_cast<std::string>(i + 1);
alg->setProperty("InputWorkspace", group->getItem(i)->name());
alg->setProperty("OutputWorkspace", IvsQName);
alg->setProperty("OutputWorkspaceWavelength", IvsLamName);
// Handle transmission runs
if (firstTransG)
alg->setProperty("FirstTransmissionRun", firstTransG->getItem(i)->name());
if (secondTransG)
alg->setProperty("SecondTransmissionRun",
secondTransG->getItem(i)->name());
alg->execute();
IvsQGroup.push_back(IvsQName);
IvsLamGroup.push_back(IvsLamName);
// We use the first group member for our thetaout value
if (i == 0)
this->setPropertyValue("ThetaOut", alg->getPropertyValue("ThetaOut"));
}
// Group the IvsQ and IvsLam workspaces
Algorithm_sptr groupAlg = this->createChildAlgorithm("GroupWorkspaces");
groupAlg->setChild(false);
groupAlg->setRethrows(true);
groupAlg->setProperty("InputWorkspaces", IvsLamGroup);
groupAlg->setProperty("OutputWorkspace", outputIvsLam);
groupAlg->execute();
groupAlg->setProperty("InputWorkspaces", IvsQGroup);
groupAlg->setProperty("OutputWorkspace", outputIvsQ);
groupAlg->execute();
//.........这里部分代码省略.........
示例14: exec
/** Execute the algorithm.
*/
void LoadLiveData::exec() {
// The full, post-processed output workspace
m_outputWS = this->getProperty("OutputWorkspace");
// Validate inputs
if (this->hasPostProcessing()) {
if (this->getPropertyValue("AccumulationWorkspace").empty())
throw std::invalid_argument("Must specify the AccumulationWorkspace "
"parameter if using PostProcessing.");
// The accumulated but not post-processed output workspace
m_accumWS = this->getProperty("AccumulationWorkspace");
} else {
// No post-processing, so the accumulation and output are the same
m_accumWS = m_outputWS;
}
// Get or create the live listener
ILiveListener_sptr listener = this->getLiveListener();
// Do we need to reset the data?
bool dataReset = listener->dataReset();
// The listener returns a MatrixWorkspace containing the chunk of live data.
Workspace_sptr chunkWS;
bool dataNotYetGiven = true;
while (dataNotYetGiven) {
try {
chunkWS = listener->extractData();
dataNotYetGiven = false;
} catch (Exception::NotYet &ex) {
g_log.warning() << "The " << listener->name()
<< " is not ready to return data: " << ex.what() << "\n";
g_log.warning()
<< "Trying again in 10 seconds - cancel the algorithm to stop.\n";
const int tenSeconds = 40;
for (int i = 0; i < tenSeconds; ++i) {
Poco::Thread::sleep(10000 / tenSeconds); // 250 ms
this->interruption_point();
}
}
}
// TODO: Have the ILiveListener tell me exactly the time stamp
DateAndTime lastTimeStamp = DateAndTime::getCurrentTime();
this->setPropertyValue("LastTimeStamp", lastTimeStamp.toISO8601String());
// Now we process the chunk
Workspace_sptr processed = this->processChunk(chunkWS);
bool PreserveEvents = this->getProperty("PreserveEvents");
EventWorkspace_sptr processedEvent =
boost::dynamic_pointer_cast<EventWorkspace>(processed);
if (!PreserveEvents && processedEvent) {
// Convert the monitor workspace, if there is one and it's necessary
MatrixWorkspace_sptr monitorWS = processedEvent->monitorWorkspace();
auto monitorEventWS =
boost::dynamic_pointer_cast<EventWorkspace>(monitorWS);
if (monitorEventWS) {
auto monAlg = this->createChildAlgorithm("ConvertToMatrixWorkspace");
monAlg->setProperty("InputWorkspace", monitorEventWS);
monAlg->executeAsChildAlg();
if (!monAlg->isExecuted())
g_log.error(
"Failed to convert monitors from events to histogram form.");
monitorWS = monAlg->getProperty("OutputWorkspace");
}
// Now do the main workspace
Algorithm_sptr alg = this->createChildAlgorithm("ConvertToMatrixWorkspace");
alg->setProperty("InputWorkspace", processedEvent);
std::string outputName = "__anonymous_livedata_convert_" +
this->getPropertyValue("OutputWorkspace");
alg->setPropertyValue("OutputWorkspace", outputName);
alg->execute();
if (!alg->isExecuted())
throw std::runtime_error("Error when calling ConvertToMatrixWorkspace "
"(since PreserveEvents=False). See log.");
// Replace the "processed" workspace with the converted one.
MatrixWorkspace_sptr temp = alg->getProperty("OutputWorkspace");
if (monitorWS)
temp->setMonitorWorkspace(monitorWS); // Set back the monitor workspace
processed = temp;
}
// How do we accumulate the data?
std::string accum = this->getPropertyValue("AccumulationMethod");
// If the AccumulationWorkspace does not exist, we always replace the
// AccumulationWorkspace.
// Also, if the listener said we are resetting the data, then we clear out the
// old.
if (!m_accumWS || dataReset)
accum = "Replace";
g_log.notice() << "Performing the " << accum << " operation.\n";
// Perform the accumulation and set the AccumulationWorkspace workspace
//.........这里部分代码省略.........
示例15: getPropertyValue
/** Process groups. Groups are processed differently depending on transmission
* runs and polarization analysis. If transmission run is a matrix workspace, it
* will be applied to each of the members in the input workspace group. If
* transmission run is a workspace group, the behaviour is different depending
* on polarization analysis. If polarization analysis is off (i.e.
* 'PolarizationAnalysis' is set to 'None') each item in the transmission group
* is associated with the corresponding item in the input workspace group. If
* polarization analysis is on (i.e. 'PolarizationAnalysis' is 'PA' or 'PNR')
* items in the transmission group will be summed to produce a matrix workspace
* that will be applied to each of the items in the input workspace group. See
* documentation of this algorithm for more details.
*/
bool ReflectometryReductionOneAuto2::processGroups() {
// this algorithm effectively behaves as MultiPeriodGroupAlgorithm
m_usingBaseProcessGroups = true;
// Get our input workspace group
auto group = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(
getPropertyValue("InputWorkspace"));
// Get name of IvsQ workspace (native binning)
const std::string outputIvsQ = getPropertyValue("OutputWorkspace");
// Get name of IvsQ (native binning) workspace
const std::string outputIvsQBinned =
getPropertyValue("OutputWorkspaceBinned");
// Get name of IvsLam workspace
const std::string outputIvsLam =
getPropertyValue("OutputWorkspaceWavelength");
// Create a copy of ourselves
Algorithm_sptr alg =
createChildAlgorithm(name(), -1, -1, isLogging(), version());
alg->setChild(false);
alg->setRethrows(true);
// Copy all the non-workspace properties over
const std::vector<Property *> props = getProperties();
for (auto &prop : props) {
if (prop) {
IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty *>(prop);
if (!wsProp)
alg->setPropertyValue(prop->name(), prop->value());
}
}
const bool polarizationAnalysisOn =
getPropertyValue("PolarizationAnalysis") != "None";
// Check if the transmission runs are groups or not
const std::string firstTrans = getPropertyValue("FirstTransmissionRun");
WorkspaceGroup_sptr firstTransG;
MatrixWorkspace_sptr firstTransSum;
if (!firstTrans.empty()) {
auto firstTransWS =
AnalysisDataService::Instance().retrieveWS<Workspace>(firstTrans);
firstTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(firstTransWS);
if (!firstTransG) {
alg->setProperty("FirstTransmissionRun", firstTrans);
} else if (polarizationAnalysisOn) {
firstTransSum = sumTransmissionWorkspaces(firstTransG);
}
}
const std::string secondTrans = getPropertyValue("SecondTransmissionRun");
WorkspaceGroup_sptr secondTransG;
MatrixWorkspace_sptr secondTransSum;
if (!secondTrans.empty()) {
auto secondTransWS =
AnalysisDataService::Instance().retrieveWS<Workspace>(secondTrans);
secondTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(secondTransWS);
if (!secondTransG) {
alg->setProperty("SecondTransmissionRun", secondTrans);
} else if (polarizationAnalysisOn) {
secondTransSum = sumTransmissionWorkspaces(secondTransG);
}
}
std::vector<std::string> IvsQGroup, IvsQUnbinnedGroup, IvsLamGroup;
// Execute algorithm over each group member
for (size_t i = 0; i < group->size(); ++i) {
const std::string IvsQName = outputIvsQ + "_" + std::to_string(i + 1);
const std::string IvsQBinnedName =
outputIvsQBinned + "_" + std::to_string(i + 1);
const std::string IvsLamName = outputIvsLam + "_" + std::to_string(i + 1);
if (firstTransG) {
if (!polarizationAnalysisOn)
alg->setProperty("FirstTransmissionRun",
firstTransG->getItem(i)->getName());
else
alg->setProperty("FirstTransmissionRun", firstTransSum);
}
if (secondTransG) {
if (!polarizationAnalysisOn)
alg->setProperty("SecondTransmissionRun",
secondTransG->getItem(i)->getName());
else
alg->setProperty("SecondTransmissionRun", secondTransSum);
}
//.........这里部分代码省略.........