本文整理汇总了C++中Peak::getTOF方法的典型用法代码示例。如果您正苦于以下问题:C++ Peak::getTOF方法的具体用法?C++ Peak::getTOF怎么用?C++ Peak::getTOF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Peak
的用法示例。
在下文中一共展示了Peak::getTOF方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveNexus
void PeaksWorkspace::saveNexus(::NeXus::File * file) const
{
//Number of Peaks
const size_t np(peaks.size());
// Column vectors for peaks table
std::vector<int> detectorID(np);
std::vector<double> H(np);
std::vector<double> K(np);
std::vector<double> L(np);
std::vector<double> intensity(np);
std::vector<double> sigmaIntensity(np);
std::vector<double> binCount(np);
std::vector<double> initialEnergy(np);
std::vector<double> finalEnergy(np);
std::vector<double> waveLength(np);
std::vector<double> scattering(np);
std::vector<double> dSpacing(np);
std::vector<double> TOF(np);
std::vector<int> runNumber(np);
std::vector<double> goniometerMatrix(9 * np);
// Populate column vectors from Peak Workspace
for (size_t i = 0; i < np; i++)
{
Peak p = peaks[i];
detectorID[i] = p.getDetectorID();
H[i] = p.getH();
K[i] = p.getK();
L[i] = p.getL();
intensity[i] = p.getIntensity();
sigmaIntensity[i] = p.getSigmaIntensity();
binCount[i] = p.getBinCount();
initialEnergy[i] = p.getInitialEnergy();
finalEnergy[i] = p.getFinalEnergy();
waveLength[i] = p.getWavelength();
scattering[i] = p.getScattering();
dSpacing[i] = p.getDSpacing();
TOF[i] = p.getTOF();
runNumber[i] = p.getRunNumber();
{
Matrix<double> gm = p.getGoniometerMatrix();
goniometerMatrix[9 * i] = gm[0][0];
goniometerMatrix[9 * i + 1] = gm[1][0];
goniometerMatrix[9 * i + 2] = gm[2][0];
goniometerMatrix[9 * i + 3] = gm[0][1];
goniometerMatrix[9 * i + 4] = gm[1][1];
goniometerMatrix[9 * i + 5] = gm[2][1];
goniometerMatrix[9 * i + 6] = gm[0][2];
goniometerMatrix[9 * i + 7] = gm[1][2];
goniometerMatrix[9 * i + 8] = gm[1][2];
}
// etc.
}
// Start Peaks Workspace in Nexus File
std::string specifyInteger = "An integer";
std::string specifyDouble = "A double";
file->makeGroup("peaks_workspace", "NXentry", true); // For when peaksWorkspace can be loaded
// Detectors column
file->writeData("column_1", detectorID);
file->openData("column_1");
file->putAttr("name", "Dectector ID");
file->putAttr("interpret_as", specifyInteger);
file->putAttr("units", "Not known");
file->closeData();
// H column
file->writeData("column_2", H);
file->openData("column_2");
file->putAttr("name", "H");
file->putAttr("interpret_as", specifyDouble);
file->putAttr("units", "Not known"); // Units may need changing when known
file->closeData();
// K column
file->writeData("column_3", K);
file->openData("column_3");
file->putAttr("name", "K");
file->putAttr("interpret_as", specifyDouble);
file->putAttr("units", "Not known"); // Units may need changing when known
file->closeData();
// L column
file->writeData("column_4", L);
file->openData("column_4");
file->putAttr("name", "L");
file->putAttr("interpret_as", specifyDouble);
file->putAttr("units", "Not known"); // Units may need changing when known
file->closeData();
// Intensity column
file->writeData("column_5", intensity);
file->openData("column_5");
file->putAttr("name", "Intensity");
file->putAttr("interpret_as", specifyDouble);
file->putAttr("units", "Not known"); // Units may need changing when known
file->closeData();
//.........这里部分代码省略.........
示例2: UBinv
void PeakHKLErrors::functionDeriv1D(Jacobian *out, const double *xValues,
const size_t nData) {
PeaksWorkspace_sptr Peaks =
AnalysisDataService::Instance().retrieveWS<PeaksWorkspace>(
PeakWorkspaceName);
boost::shared_ptr<Geometry::Instrument> instNew = getNewInstrument(Peaks);
const DblMatrix &UB = Peaks->sample().getOrientedLattice().getUB();
DblMatrix UBinv(UB);
UBinv.Invert();
UBinv /= 2 * M_PI;
double GonRotx = getParameter("GonRotx");
double GonRoty = getParameter("GonRoty");
double GonRotz = getParameter("GonRotz");
Matrix<double> InvGonRotxMat = RotationMatrixAboutRegAxis(GonRotx, 'x');
Matrix<double> InvGonRotyMat = RotationMatrixAboutRegAxis(GonRoty, 'y');
Matrix<double> InvGonRotzMat = RotationMatrixAboutRegAxis(GonRotz, 'z');
Matrix<double> GonRot = InvGonRotxMat * InvGonRotyMat * InvGonRotzMat;
InvGonRotxMat.Invert();
InvGonRotyMat.Invert();
InvGonRotzMat.Invert();
std::map<int, Kernel::Matrix<double>> RunNums2GonMatrix;
getRun2MatMap(Peaks, OptRuns, RunNums2GonMatrix);
g_log.debug()
<< "----------------------------Derivative------------------------\n";
V3D samplePosition = instNew->getSample()->getPos();
IPeak &ppeak = Peaks->getPeak(0);
double L0 = ppeak.getL1();
double velocity = (L0 + ppeak.getL2()) / ppeak.getTOF();
double K =
2 * M_PI / ppeak.getWavelength() / velocity; // 2pi/lambda = K* velocity
V3D beamDir = instNew->getBeamDirection();
size_t paramNums[] = {parameterIndex(std::string("SampleXOffset")),
parameterIndex(std::string("SampleYOffset")),
parameterIndex(std::string("SampleZOffset"))};
for (size_t i = 0; i < nData; i += 3) {
int peakNum = boost::math::iround(xValues[i]);
IPeak &peak_old = Peaks->getPeak(peakNum);
Peak peak = createNewPeak(peak_old, instNew, 0, peak_old.getL1());
int runNum = peak_old.getRunNumber();
std::string runNumStr = std::to_string(runNum);
for (int kk = 0; kk < static_cast<int>(nParams()); kk++) {
out->set(i, kk, 0.0);
out->set(i + 1, kk, 0.0);
out->set(i + 2, kk, 0.0);
}
double chi, phi, omega;
size_t chiParamNum, phiParamNum, omegaParamNum;
size_t N = OptRuns.find("/" + runNumStr);
if (N < OptRuns.size()) {
chi = getParameter("chi" + (runNumStr));
phi = getParameter("phi" + (runNumStr));
omega = getParameter("omega" + (runNumStr));
peak.setGoniometerMatrix(GonRot * RunNums2GonMatrix[runNum]);
chiParamNum = parameterIndex("chi" + (runNumStr));
phiParamNum = parameterIndex("phi" + (runNumStr));
omegaParamNum = parameterIndex("omega" + (runNumStr));
} else {
Geometry::Goniometer Gon(peak.getGoniometerMatrix());
std::vector<double> phichiOmega = Gon.getEulerAngles("YZY");
chi = phichiOmega[1];
phi = phichiOmega[2];
omega = phichiOmega[0];
// peak.setGoniometerMatrix( GonRot*Gon.getR());
chiParamNum = phiParamNum = omegaParamNum = nParams() + 10;
peak.setGoniometerMatrix(GonRot * peak.getGoniometerMatrix());
}
V3D sampOffsets(getParameter("SampleXOffset"),
getParameter("SampleYOffset"),
getParameter("SampleZOffset"));
peak.setSamplePos(peak.getSamplePos() + sampOffsets);
// NOTE:Use getQLabFrame except for below.
// For parameters the getGoniometerMatrix should remove GonRot, for derivs
// wrt GonRot*, wrt chi*,phi*,etc.
// Deriv wrt chi phi and omega
if (phiParamNum < nParams()) {
Matrix<double> chiMatrix = RotationMatrixAboutRegAxis(chi, 'z');
Matrix<double> phiMatrix = RotationMatrixAboutRegAxis(phi, 'y');
Matrix<double> omegaMatrix = RotationMatrixAboutRegAxis(omega, 'y');
Matrix<double> dchiMatrix = DerivRotationMatrixAboutRegAxis(chi, 'z');
Matrix<double> dphiMatrix = DerivRotationMatrixAboutRegAxis(phi, 'y');
Matrix<double> domegaMatrix = DerivRotationMatrixAboutRegAxis(omega, 'y');
//.........这里部分代码省略.........
示例3: appendFile
/** Append the peaks from a .peaks file into the workspace
* @param outWS :: the workspace in which to place the information
* @param filename :: path to the .peaks file
*/
void LoadIsawPeaks::appendFile( PeaksWorkspace_sptr outWS, std::string filename )
{
// Open the file
std::ifstream in( filename.c_str() );
// Read the header, load the instrument
double T0;
std::string s = readHeader( outWS, in , T0);
// set T0 in the run parameters
API::Run & m_run = outWS->mutableRun();
m_run.addProperty<double>("T0", T0, true);
if( !in.good() || s.length() < 1 )
throw std::runtime_error( "End of Peaks file before peaks" );
if( s.compare( std::string( "0" ) ) != 0 )
throw std::logic_error( "No header for Peak segments" );
readToEndOfLine( in , true );
s = getWord( in , false );
int run, bankNum;
double chi , phi , omega , monCount;
// Build the universal goniometer that will build the rotation matrix.
Mantid::Geometry::Goniometer uniGonio;
uniGonio.makeUniversalGoniometer();
// TODO: Can we find the number of peaks to get better progress reporting?
Progress prog(this, 0.0, 1.0, 100);
while( in.good() )
{
// Read the header if necessary
s = readPeakBlockHeader( s , in , run , bankNum , chi , phi ,
omega , monCount );
// Build the Rotation matrix using phi,chi,omega
uniGonio.setRotationAngle("phi", phi);
uniGonio.setRotationAngle("chi", chi);
uniGonio.setRotationAngle("omega", omega);
//Put goniometer into peaks workspace
outWS->mutableRun().setGoniometer(uniGonio, false);
std::ostringstream oss;
std::string bankString = "bank";
if (outWS->getInstrument()->getName() == "WISH") bankString = "WISHpanel0";
oss << bankString << bankNum;
std::string bankName = oss.str();
int seqNum = -1;
try
{
// Read the peak
Peak peak = readPeak(outWS, s, in, seqNum, bankName);
// Get the calculated goniometer matrix
Matrix<double> gonMat = uniGonio.getR();
peak.setGoniometerMatrix(gonMat);
peak.setRunNumber(run);
peak.setMonitorCount( monCount );
double tof = peak.getTOF();
Kernel::Units::Wavelength wl;
wl.initialize(peak.getL1(), peak.getL2(), peak.getScattering(), 0,
peak.getInitialEnergy(), 0.0);
peak.setWavelength(wl.singleFromTOF( tof));
// Add the peak to workspace
outWS->addPeak(peak);
}
catch (std::runtime_error & e)
{
g_log.warning() << "Error reading peak SEQN " << seqNum << " : " << e.what() << std::endl;
}
prog.report();
}
}
示例4: saveNexus
void PeaksWorkspace::saveNexus(::NeXus::File *file) const {
// Number of Peaks
const size_t np(peaks.size());
// Column vectors for peaks table
std::vector<int> detectorID(np);
std::vector<double> H(np);
std::vector<double> K(np);
std::vector<double> L(np);
std::vector<double> intensity(np);
std::vector<double> sigmaIntensity(np);
std::vector<double> binCount(np);
std::vector<double> initialEnergy(np);
std::vector<double> finalEnergy(np);
std::vector<double> waveLength(np);
std::vector<double> scattering(np);
std::vector<double> dSpacing(np);
std::vector<double> TOF(np);
std::vector<int> runNumber(np);
std::vector<double> goniometerMatrix(9 * np);
std::vector<std::string> shapes(np);
// Populate column vectors from Peak Workspace
size_t maxShapeJSONLength = 0;
for (size_t i = 0; i < np; i++) {
Peak p = peaks[i];
detectorID[i] = p.getDetectorID();
H[i] = p.getH();
K[i] = p.getK();
L[i] = p.getL();
intensity[i] = p.getIntensity();
sigmaIntensity[i] = p.getSigmaIntensity();
binCount[i] = p.getBinCount();
initialEnergy[i] = p.getInitialEnergy();
finalEnergy[i] = p.getFinalEnergy();
waveLength[i] = p.getWavelength();
scattering[i] = p.getScattering();
dSpacing[i] = p.getDSpacing();
TOF[i] = p.getTOF();
runNumber[i] = p.getRunNumber();
{
Matrix<double> gm = p.getGoniometerMatrix();
goniometerMatrix[9 * i] = gm[0][0];
goniometerMatrix[9 * i + 1] = gm[1][0];
goniometerMatrix[9 * i + 2] = gm[2][0];
goniometerMatrix[9 * i + 3] = gm[0][1];
goniometerMatrix[9 * i + 4] = gm[1][1];
goniometerMatrix[9 * i + 5] = gm[2][1];
goniometerMatrix[9 * i + 6] = gm[0][2];
goniometerMatrix[9 * i + 7] = gm[1][2];
goniometerMatrix[9 * i + 8] = gm[2][2];
}
const std::string shapeJSON = p.getPeakShape().toJSON();
shapes[i] = shapeJSON;
if (shapeJSON.size() > maxShapeJSONLength) {
maxShapeJSONLength = shapeJSON.size();
}
}
// Start Peaks Workspace in Nexus File
const std::string specifyInteger = "An integer";
const std::string specifyDouble = "A double";
const std::string specifyString = "A string";
file->makeGroup("peaks_workspace", "NXentry",
true); // For when peaksWorkspace can be loaded
// Coordinate system
file->writeData("coordinate_system", static_cast<uint32_t>(m_coordSystem));
// Write out the Qconvention
// ki-kf for Inelastic convention; kf-ki for Crystallography convention
std::string m_QConvention = this->getConvention();
file->putAttr("QConvention", m_QConvention);
// Detectors column
file->writeData("column_1", detectorID);
file->openData("column_1");
file->putAttr("name", "Detector ID");
file->putAttr("interpret_as", specifyInteger);
file->putAttr("units", "Not known");
file->closeData();
// H column
file->writeData("column_2", H);
file->openData("column_2");
file->putAttr("name", "H");
file->putAttr("interpret_as", specifyDouble);
file->putAttr("units", "Not known"); // Units may need changing when known
file->closeData();
// K column
file->writeData("column_3", K);
file->openData("column_3");
file->putAttr("name", "K");
file->putAttr("interpret_as", specifyDouble);
file->putAttr("units", "Not known"); // Units may need changing when known
file->closeData();
// L column
//.........这里部分代码省略.........