本文整理汇总了C++中kernel::V3D::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ V3D::toString方法的具体用法?C++ V3D::toString怎么用?C++ V3D::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kernel::V3D
的用法示例。
在下文中一共展示了V3D::toString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertSpiceMatrixToMomentumMDEvents
/** Convert a SPICE 2D Det MatrixWorkspace to MDEvents and append to an
* MDEventWorkspace
* It is optional to use a virtual instrument or copy from input data workspace
* @brief ConvertCWSDExpToMomentum::convertSpiceMatrixToMomentumMDEvents
* @param dataws :: data matrix workspace
* @param usevirtual :: boolean flag to use virtual instrument
* @param startdetid :: starting detid for detectors from this workspace mapping
* to virtual instrument in MDEventWorkspace
* @param runnumber :: run number for all MDEvents created from this matrix
* workspace
*/
void ConvertCWSDExpToMomentum::convertSpiceMatrixToMomentumMDEvents(
MatrixWorkspace_sptr dataws, bool usevirtual, const detid_t &startdetid,
const int runnumber) {
// Create transformation matrix from which the transformation is
Kernel::DblMatrix rotationMatrix;
setupTransferMatrix(dataws, rotationMatrix);
g_log.information() << "Before insert new event, output workspace has "
<< m_outputWS->getNEvents() << "Events.\n";
// Creates a new instance of the MDEventInserte to output workspace
MDEventWorkspace<MDEvent<3>, 3>::sptr mdws_mdevt_3 =
boost::dynamic_pointer_cast<MDEventWorkspace<MDEvent<3>, 3>>(m_outputWS);
MDEventInserter<MDEventWorkspace<MDEvent<3>, 3>::sptr> inserter(mdws_mdevt_3);
// Calcualte k_i: it is assumed that all k_i are same for one Pt.
// number, i.e., one 2D XML file
Kernel::V3D sourcePos = dataws->getInstrument()->getSource()->getPos();
Kernel::V3D samplePos = dataws->getInstrument()->getSample()->getPos();
if (dataws->readX(0).size() != 2)
throw std::runtime_error(
"Input matrix workspace has wrong dimension in X-axis.");
double momentum = 0.5 * (dataws->readX(0)[0] + dataws->readX(0)[1]);
Kernel::V3D ki = (samplePos - sourcePos) * (momentum / sourcePos.norm());
g_log.debug() << "Source at " << sourcePos.toString()
<< ", Norm = " << sourcePos.norm()
<< ", momentum = " << momentum << "\n"
<< "k_i = " << ki.toString() << "\n";
// Go though each spectrum to conver to MDEvent
size_t numspec = dataws->getNumberHistograms();
double maxsignal = 0;
size_t nummdevents = 0;
for (size_t iws = 0; iws < numspec; ++iws) {
// Get detector positions and signal
double signal = dataws->readY(iws)[0];
// Skip event with 0 signal
if (signal < 0.001)
continue;
double error = dataws->readE(iws)[0];
Kernel::V3D detpos = dataws->getDetector(iws)->getPos();
std::vector<Mantid::coord_t> q_sample(3);
// Calculate Q-sample and new detector ID in virtual instrument.
Kernel::V3D qlab = convertToQSample(samplePos, ki, detpos, momentum,
q_sample, rotationMatrix);
detid_t native_detid = dataws->getDetector(iws)->getID();
detid_t detid = native_detid + startdetid;
// Insert
inserter.insertMDEvent(
static_cast<float>(signal), static_cast<float>(error * error),
static_cast<uint16_t>(runnumber), detid, q_sample.data());
updateQRange(q_sample);
g_log.debug() << "Q-lab = " << qlab.toString() << "\n";
g_log.debug() << "Insert DetID " << detid << ", signal = " << signal
<< ", with q_sample = " << q_sample[0] << ", " << q_sample[1]
<< ", " << q_sample[2] << "\n";
// Update some statistical inforamtion
if (signal > maxsignal)
maxsignal = signal;
++nummdevents;
}
g_log.information() << "Imported Matrixworkspace: Max. Signal = " << maxsignal
<< ", Add " << nummdevents << " MDEvents "
<< "\n";
// Add experiment info including instrument, goniometer and run number
ExperimentInfo_sptr expinfo = boost::make_shared<ExperimentInfo>();
if (usevirtual)
expinfo->setInstrument(m_virtualInstrument);
else {
Geometry::Instrument_const_sptr tmp_inst = dataws->getInstrument();
expinfo->setInstrument(tmp_inst);
}
expinfo->mutableRun().setGoniometer(dataws->run().getGoniometer(), false);
expinfo->mutableRun().addProperty("run_number", runnumber);
// Add all the other propertys from original data workspace
const std::vector<Kernel::Property *> vec_property =
dataws->run().getProperties();
for (auto property : vec_property) {
expinfo->mutableRun().addProperty(property->clone());
}
m_outputWS->addExperimentInfo(expinfo);
//.........这里部分代码省略.........