本文整理汇总了C++中EventWorkspace_const_sptr::YUnitLabel方法的典型用法代码示例。如果您正苦于以下问题:C++ EventWorkspace_const_sptr::YUnitLabel方法的具体用法?C++ EventWorkspace_const_sptr::YUnitLabel怎么用?C++ EventWorkspace_const_sptr::YUnitLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventWorkspace_const_sptr
的用法示例。
在下文中一共展示了EventWorkspace_const_sptr::YUnitLabel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exec
//.........这里部分代码省略.........
// copy over the data as well.
outputEventWS->copyDataFrom((*inputEventWS));
}
if (common_limits) {
// get the delta from the first since they are all the same
MantidVecPtr xValues;
double delta =
this->determineBinning(xValues.access(), xmins[0], xmaxs[0]);
g_log.debug() << "delta = " << delta << "\n";
outputEventWS->setAllX(xValues);
} else {
// initialize progress reporting.
Progress prog(this, 0.0, 1.0, numSpectra);
// do the rebinning
PARALLEL_FOR2(inputEventWS, outputWS)
for (int wkspIndex = 0; wkspIndex < numSpectra; ++wkspIndex) {
PARALLEL_START_INTERUPT_REGION
MantidVec xValues;
double delta = this->determineBinning(xValues, xmins[wkspIndex],
xmaxs[wkspIndex]);
g_log.debug() << "delta[wkspindex=" << wkspIndex << "] = " << delta
<< " xmin=" << xmins[wkspIndex]
<< " xmax=" << xmaxs[wkspIndex] << "\n";
outputEventWS->getSpectrum(wkspIndex)->setX(xValues);
prog.report(name()); // Report progress
PARALLEL_END_INTERUPT_REGION
}
PARALLEL_CHECK_INTERUPT_REGION
}
this->setProperty(
"OutputWorkspace",
boost::dynamic_pointer_cast<MatrixWorkspace>(outputEventWS));
} // end if (m_preserveEvents)
else // event workspace -> matrix workspace
{
//--------- Different output, OR you're inplace but not preserving Events
//--- create a Workspace2D -------
g_log.information() << "Creating a Workspace2D from the EventWorkspace "
<< inputEventWS->getName() << ".\n";
// Create a Workspace2D
// This creates a new Workspace2D through a torturous route using the
// WorkspaceFactory.
// The Workspace2D is created with an EMPTY CONSTRUCTOR
outputWS = WorkspaceFactory::Instance().create("Workspace2D", numSpectra,
m_numBins, m_numBins - 1);
WorkspaceFactory::Instance().initializeFromParent(inputWS, outputWS,
true);
// Initialize progress reporting.
Progress prog(this, 0.0, 1.0, numSpectra);
// Go through all the histograms and set the data
PARALLEL_FOR2(inputEventWS, outputWS)
for (int wkspIndex = 0; wkspIndex < numSpectra; ++wkspIndex) {
PARALLEL_START_INTERUPT_REGION
// Set the X axis for each output histogram
MantidVec xValues;
double delta =
this->determineBinning(xValues, xmins[wkspIndex], xmaxs[wkspIndex]);
g_log.debug() << "delta[wkspindex=" << wkspIndex << "] = " << delta
<< "\n";
outputWS->setX(wkspIndex, xValues);
// Get a const event list reference. inputEventWS->dataY() doesn't work.
const EventList &el = inputEventWS->getEventList(wkspIndex);
MantidVec y_data, e_data;
// The EventList takes care of histogramming.
el.generateHistogram(xValues, y_data, e_data);
// Copy the data over.
outputWS->dataY(wkspIndex).assign(y_data.begin(), y_data.end());
outputWS->dataE(wkspIndex).assign(e_data.begin(), e_data.end());
// Report progress
prog.report(name());
PARALLEL_END_INTERUPT_REGION
}
PARALLEL_CHECK_INTERUPT_REGION
// Copy all the axes
for (int i = 1; i < inputWS->axes(); i++) {
outputWS->replaceAxis(i, inputWS->getAxis(i)->clone(outputWS.get()));
outputWS->getAxis(i)->unit() = inputWS->getAxis(i)->unit();
}
// Copy the units over too.
for (int i = 0; i < outputWS->axes(); ++i)
outputWS->getAxis(i)->unit() = inputWS->getAxis(i)->unit();
outputWS->setYUnit(inputEventWS->YUnit());
outputWS->setYUnitLabel(inputEventWS->YUnitLabel());
// Assign it to the output workspace property
setProperty("OutputWorkspace", outputWS);
}
return;
} else // (inputeventWS != NULL)
示例2: exec
//.........这里部分代码省略.........
// Now, determine if the input workspace is actually an EventWorkspace
EventWorkspace_const_sptr eventInputWS =
boost::dynamic_pointer_cast<const EventWorkspace>(inputWS);
if (eventInputWS != NULL) {
//------- EventWorkspace as input -------------------------------------
EventWorkspace_sptr eventOutputWS =
boost::dynamic_pointer_cast<EventWorkspace>(outputWS);
if (inPlace && PreserveEvents) {
// -------------Rebin in-place, preserving events
// ----------------------------------------------
// This only sets the X axis. Actual rebinning will be done upon data
// access.
eventOutputWS->setAllX(XValues_new);
this->setProperty(
"OutputWorkspace",
boost::dynamic_pointer_cast<MatrixWorkspace>(eventOutputWS));
} else if (!inPlace && PreserveEvents) {
// -------- NOT in-place, but you want to keep events for some reason.
// ----------------------
// Must copy the event workspace to a new EventWorkspace (and bin that).
// Make a brand new EventWorkspace
eventOutputWS = boost::dynamic_pointer_cast<EventWorkspace>(
API::WorkspaceFactory::Instance().create(
"EventWorkspace", inputWS->getNumberHistograms(), 2, 1));
// Copy geometry over.
API::WorkspaceFactory::Instance().initializeFromParent(
inputWS, eventOutputWS, false);
// You need to copy over the data as well.
eventOutputWS->copyDataFrom((*eventInputWS));
// This only sets the X axis. Actual rebinning will be done upon data
// access.
eventOutputWS->setAllX(XValues_new);
// Cast to the matrixOutputWS and save it
this->setProperty(
"OutputWorkspace",
boost::dynamic_pointer_cast<MatrixWorkspace>(eventOutputWS));
} else {
//--------- Different output, OR you're inplace but not preserving Events
//--- create a Workspace2D -------
g_log.information() << "Creating a Workspace2D from the EventWorkspace "
<< eventInputWS->getName() << ".\n";
// Create a Workspace2D
// This creates a new Workspace2D through a torturous route using the
// WorkspaceFactory.
// The Workspace2D is created with an EMPTY CONSTRUCTOR
outputWS = WorkspaceFactory::Instance().create("Workspace2D", histnumber,
ntcnew, ntcnew - 1);
WorkspaceFactory::Instance().initializeFromParent(inputWS, outputWS,
true);
// Initialize progress reporting.
Progress prog(this, 0.0, 1.0, histnumber);
// Go through all the histograms and set the data
PARALLEL_FOR3(inputWS, eventInputWS, outputWS)
for (int i = 0; i < histnumber; ++i) {
PARALLEL_START_INTERUPT_REGION
// Set the X axis for each output histogram
outputWS->setX(i, XValues_new);
// Get a const event list reference. eventInputWS->dataY() doesn't work.
const EventList &el = eventInputWS->getEventList(i);
MantidVec y_data, e_data;
// The EventList takes care of histogramming.
el.generateHistogram(*XValues_new, y_data, e_data);
// Copy the data over.
outputWS->dataY(i).assign(y_data.begin(), y_data.end());
outputWS->dataE(i).assign(e_data.begin(), e_data.end());
// Report progress
prog.report(name());
PARALLEL_END_INTERUPT_REGION
}
PARALLEL_CHECK_INTERUPT_REGION
// Copy all the axes
for (int i = 1; i < inputWS->axes(); i++) {
outputWS->replaceAxis(i, inputWS->getAxis(i)->clone(outputWS.get()));
outputWS->getAxis(i)->unit() = inputWS->getAxis(i)->unit();
}
// Copy the units over too.
for (int i = 0; i < outputWS->axes(); ++i)
outputWS->getAxis(i)->unit() = inputWS->getAxis(i)->unit();
outputWS->setYUnit(eventInputWS->YUnit());
outputWS->setYUnitLabel(eventInputWS->YUnitLabel());
// Assign it to the output workspace property
setProperty("OutputWorkspace", outputWS);
}
} // END ---- EventWorkspace
示例3: exec
//.........这里部分代码省略.........
// start doing actual work
EventWorkspace_const_sptr inputEventWS =
boost::dynamic_pointer_cast<const EventWorkspace>(inputWS);
if (inputEventWS != nullptr) {
if (m_preserveEvents) {
if (inPlace) {
g_log.debug() << "Rebinning event workspace in place\n";
} else {
g_log.debug() << "Rebinning event workspace out of place\n";
outputWS = inputWS->clone();
}
auto outputEventWS =
boost::dynamic_pointer_cast<EventWorkspace>(outputWS);
if (common_limits) {
// get the delta from the first since they are all the same
BinEdges xValues(0);
const double delta = this->determineBinning(xValues.mutableRawData(),
xmins[0], xmaxs[0]);
g_log.debug() << "delta = " << delta << "\n";
outputEventWS->setAllX(xValues);
} else {
// initialize progress reporting.
Progress prog(this, 0.0, 1.0, numSpectra);
// do the rebinning
PARALLEL_FOR_IF(Kernel::threadSafe(*inputEventWS, *outputWS))
for (int wkspIndex = 0; wkspIndex < numSpectra; ++wkspIndex) {
PARALLEL_START_INTERUPT_REGION
BinEdges xValues(0);
const double delta = this->determineBinning(
xValues.mutableRawData(), xmins[wkspIndex], xmaxs[wkspIndex]);
g_log.debug() << "delta[wkspindex=" << wkspIndex << "] = " << delta
<< " xmin=" << xmins[wkspIndex]
<< " xmax=" << xmaxs[wkspIndex] << "\n";
outputEventWS->setHistogram(wkspIndex, xValues);
prog.report(name()); // Report progress
PARALLEL_END_INTERUPT_REGION
}
PARALLEL_CHECK_INTERUPT_REGION
}
} // end if (m_preserveEvents)
else // event workspace -> matrix workspace
{
//--------- Different output, OR you're inplace but not preserving Events
g_log.information() << "Creating a Workspace2D from the EventWorkspace "
<< inputEventWS->getName() << ".\n";
outputWS = create<DataObjects::Workspace2D>(
*inputWS, numSpectra, HistogramData::BinEdges(m_numBins + 1));
// Initialize progress reporting.
Progress prog(this, 0.0, 1.0, numSpectra);
// Go through all the histograms and set the data
PARALLEL_FOR_IF(Kernel::threadSafe(*inputEventWS, *outputWS))
for (int wkspIndex = 0; wkspIndex < numSpectra; ++wkspIndex) {
PARALLEL_START_INTERUPT_REGION
// Set the X axis for each output histogram
MantidVec xValues;
const double delta =
this->determineBinning(xValues, xmins[wkspIndex], xmaxs[wkspIndex]);
g_log.debug() << "delta[wkspindex=" << wkspIndex << "] = " << delta
<< "\n";
outputWS->setBinEdges(wkspIndex, xValues);
// Get a const event list reference. inputEventWS->dataY() doesn't work.
const EventList &el = inputEventWS->getSpectrum(wkspIndex);
MantidVec y_data, e_data;
// The EventList takes care of histogramming.
el.generateHistogram(xValues, y_data, e_data);
// Copy the data over.
outputWS->mutableY(wkspIndex) = std::move(y_data);
outputWS->mutableE(wkspIndex) = std::move(e_data);
// Report progress
prog.report(name());
PARALLEL_END_INTERUPT_REGION
}
PARALLEL_CHECK_INTERUPT_REGION
// Copy all the axes
for (int i = 1; i < inputWS->axes(); i++) {
outputWS->replaceAxis(i, inputWS->getAxis(i)->clone(outputWS.get()));
outputWS->getAxis(i)->unit() = inputWS->getAxis(i)->unit();
}
// Copy the units over too.
for (int i = 0; i < outputWS->axes(); ++i) {
outputWS->getAxis(i)->unit() = inputWS->getAxis(i)->unit();
}
outputWS->setYUnit(inputEventWS->YUnit());
outputWS->setYUnitLabel(inputEventWS->YUnitLabel());
}
// Assign it to the output workspace property
setProperty("OutputWorkspace", outputWS);
return;
} else // (inputeventWS != NULL)