本文整理汇总了C++中typenameMDEventWorkspace::getSpecialCoordinateSystem方法的典型用法代码示例。如果您正苦于以下问题:C++ typenameMDEventWorkspace::getSpecialCoordinateSystem方法的具体用法?C++ typenameMDEventWorkspace::getSpecialCoordinateSystem怎么用?C++ typenameMDEventWorkspace::getSpecialCoordinateSystem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typenameMDEventWorkspace
的用法示例。
在下文中一共展示了typenameMDEventWorkspace::getSpecialCoordinateSystem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: integrate
void CentroidPeaksMD::integrate(typename MDEventWorkspace<MDE, nd>::sptr ws) {
if (nd != 3)
throw std::invalid_argument("For now, we expect the input MDEventWorkspace "
"to have 3 dimensions only.");
/// Peak workspace to centroid
Mantid::DataObjects::PeaksWorkspace_sptr inPeakWS =
getProperty("PeaksWorkspace");
/// Output peaks workspace, create if needed
Mantid::DataObjects::PeaksWorkspace_sptr peakWS =
getProperty("OutputWorkspace");
if (peakWS != inPeakWS)
peakWS.reset(inPeakWS->clone().release());
std::string CoordinatesToUseStr = getPropertyValue("CoordinatesToUse");
int CoordinatesToUse = ws->getSpecialCoordinateSystem();
if (CoordinatesToUse == 1 && CoordinatesToUseStr != "Q (lab frame)")
g_log.warning() << "Warning: used Q (lab frame) coordinates for MD "
"workspace, not CoordinatesToUse from input "
<< std::endl;
else if (CoordinatesToUse == 2 && CoordinatesToUseStr != "Q (sample frame)")
g_log.warning() << "Warning: used Q (sample frame) coordinates for MD "
"workspace, not CoordinatesToUse from input "
<< std::endl;
else if (CoordinatesToUse == 3 && CoordinatesToUseStr != "HKL")
g_log.warning() << "Warning: used HKL coordinates for MD workspace, not "
"CoordinatesToUse from input " << std::endl;
/// Radius to use around peaks
double PeakRadius = getProperty("PeakRadius");
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for schedule(dynamic, 10) )
for (int i = 0; i < int(peakWS->getNumberPeaks()); ++i) {
// Get a direct ref to that peak.
IPeak &p = peakWS->getPeak(i);
double detectorDistance = p.getL2();
// Get the peak center as a position in the dimensions of the workspace
V3D pos;
if (CoordinatesToUse == 1) //"Q (lab frame)"
pos = p.getQLabFrame();
else if (CoordinatesToUse == 2) //"Q (sample frame)"
pos = p.getQSampleFrame();
else if (CoordinatesToUse == 3) //"HKL"
pos = p.getHKL();
// Build the sphere transformation
bool dimensionsUsed[nd];
coord_t center[nd];
for (size_t d = 0; d < nd; ++d) {
dimensionsUsed[d] = true; // Use all dimensions
center[d] = static_cast<coord_t>(pos[d]);
}
CoordTransformDistance sphere(nd, center, dimensionsUsed);
// Initialize the centroid to 0.0
signal_t signal = 0;
coord_t centroid[nd];
for (size_t d = 0; d < nd; d++)
centroid[d] = 0.0;
// Perform centroid
ws->getBox()->centroidSphere(
sphere, static_cast<coord_t>(PeakRadius * PeakRadius), centroid,
signal);
// Normalize by signal
if (signal != 0.0) {
for (size_t d = 0; d < nd; d++)
centroid[d] /= static_cast<coord_t>(signal);
V3D vecCentroid(centroid[0], centroid[1], centroid[2]);
// Save it back in the peak object, in the dimension specified.
if (CoordinatesToUse == 1) //"Q (lab frame)"
{
p.setQLabFrame(vecCentroid, detectorDistance);
p.findDetector();
} else if (CoordinatesToUse == 2) //"Q (sample frame)"
{
p.setQSampleFrame(vecCentroid, detectorDistance);
p.findDetector();
} else if (CoordinatesToUse == 3) //"HKL"
{
p.setHKL(vecCentroid);
}
g_log.information() << "Peak " << i << " at " << pos << ": signal "
<< signal << ", centroid " << vecCentroid << " in "
<< CoordinatesToUse << std::endl;
} else {
g_log.information() << "Peak " << i << " at " << pos
<< " had no signal, and could not be centroided."
<< std::endl;
}
}
// Save the output
//.........这里部分代码省略.........
示例2: slice
void SliceMD::slice(typename MDEventWorkspace<MDE, nd>::sptr ws) {
// Create the ouput workspace
typename MDEventWorkspace<OMDE, ond>::sptr outWS(
new MDEventWorkspace<OMDE, ond>());
for (size_t od = 0; od < m_binDimensions.size(); od++) {
outWS->addDimension(m_binDimensions[od]);
}
outWS->setCoordinateSystem(ws->getSpecialCoordinateSystem());
outWS->initialize();
// Copy settings from the original box controller
BoxController_sptr bc = ws->getBoxController();
// store wrute buffer size for the future
// uint64_t writeBufSize =
// bc->getFileIO()getDiskBuffer().getWriteBufferSize();
// and disable write buffer (if any) for input MD Events for this algorithm
// purposes;
// bc->setCacheParameters(1,0);
BoxController_sptr obc = outWS->getBoxController();
// Use the "number of bins" as the "split into" parameter
for (size_t od = 0; od < m_binDimensions.size(); od++)
obc->setSplitInto(od, m_binDimensions[od]->getNBins());
obc->setSplitThreshold(bc->getSplitThreshold());
bool bTakeDepthFromInputWorkspace =
getProperty("TakeMaxRecursionDepthFromInput");
int tempDepth = getProperty("MaxRecursionDepth");
size_t maxDepth =
bTakeDepthFromInputWorkspace ? bc->getMaxDepth() : size_t(tempDepth);
obc->setMaxDepth(maxDepth);
// size_t outputSize = writeBufSize;
// obc->setCacheParameters(sizeof(OMDE),outputSize);
obc->resetNumBoxes();
// Perform the first box splitting
outWS->splitBox();
size_t lastNumBoxes = obc->getTotalNumMDBoxes();
// --- File back end ? ----------------
std::string filename = getProperty("OutputFilename");
if (!filename.empty()) {
// First save to the NXS file
g_log.notice() << "Running SaveMD to create file back-end" << std::endl;
IAlgorithm_sptr alg = createChildAlgorithm("SaveMD");
alg->setPropertyValue("Filename", filename);
alg->setProperty("InputWorkspace", outWS);
alg->setProperty("MakeFileBacked", true);
alg->executeAsChildAlg();
if (!obc->isFileBacked())
throw std::runtime_error("SliceMD with file-backed output: Can not set "
"up file-backed output workspace ");
auto IOptr = obc->getFileIO();
size_t outBufSize = IOptr->getWriteBufferSize();
// the buffer size for resulting workspace; reasonable size is at least 10
// data chunk sizes (nice to verify)
if (outBufSize < 10 * IOptr->getDataChunk()) {
outBufSize = 10 * IOptr->getDataChunk();
IOptr->setWriteBufferSize(outBufSize);
}
}
// Function defining which events (in the input dimensions) to place in the
// output
MDImplicitFunction *function = this->getImplicitFunctionForChunk(NULL, NULL);
std::vector<API::IMDNode *> boxes;
// Leaf-only; no depth limit; with the implicit function passed to it.
ws->getBox()->getBoxes(boxes, 1000, true, function);
// Sort boxes by file position IF file backed. This reduces seeking time,
// hopefully.
bool fileBackedWS = bc->isFileBacked();
if (fileBackedWS)
API::IMDNode::sortObjByID(boxes);
Progress *prog = new Progress(this, 0.0, 1.0, boxes.size());
// The root of the output workspace
MDBoxBase<OMDE, ond> *outRootBox = outWS->getBox();
// if target workspace has events, we should count them as added
uint64_t totalAdded = outWS->getNEvents();
uint64_t numSinceSplit = 0;
// Go through every box for this chunk.
// PARALLEL_FOR_IF( !bc->isFileBacked() )
for (int i = 0; i < int(boxes.size()); i++) {
MDBox<MDE, nd> *box = dynamic_cast<MDBox<MDE, nd> *>(boxes[i]);
// Perform the binning in this separate method.
if (box) {
// An array to hold the rotated/transformed coordinates
coord_t outCenter[ond];
const std::vector<MDE> &events = box->getConstEvents();
typename std::vector<MDE>::const_iterator it = events.begin();
//.........这里部分代码省略.........