本文整理汇总了C++中Peak::setRunNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ Peak::setRunNumber方法的具体用法?C++ Peak::setRunNumber怎么用?C++ Peak::setRunNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Peak
的用法示例。
在下文中一共展示了Peak::setRunNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
示例2: findPeaks
//.........这里部分代码省略.........
// Distance between this box and a box we already put in.
coord_t distSquared = 0.0;
for (size_t d=0; d<nd; d++)
{
coord_t dist = otherCenter[d] - boxCenter[d];
distSquared += (dist * dist);
}
// Reject this box if it is too close to another previously found box.
if (distSquared < peakRadiusSquared)
{
badBox = true;
break;
}
}
// The box was not rejected for another reason.
if (!badBox)
{
if (numBoxesFound++ >= MaxPeaks)
{
g_log.notice() << "Number of peaks found exceeded the limit of " << MaxPeaks << ". Stopping peak finding." << std::endl;
break;
}
peakBoxes.push_back(box);
g_log.information() << "Found box at ";
for (size_t d=0; d<nd; d++)
g_log.information() << (d>0?",":"") << boxCenter[d];
g_log.information() << "; Density = " << density << std::endl;
// Report progres for each box found.
prog->report("Finding Peaks");
}
}
prog->resetNumSteps(numBoxesFound, 0.95, 1.0);
// Copy the instrument, sample, run to the peaks workspace.
peakWS->copyExperimentInfoFrom(ei.get());
// --- Convert the "boxes" to peaks ----
for (typename std::vector<boxPtr>::iterator it3=peakBoxes.begin(); it3 != peakBoxes.end(); it3++)
{
// The center of the box = Q in the lab frame
boxPtr box = *it3;
#ifndef MDBOX_TRACK_CENTROID
coord_t boxCenter[nd];
box->calculateCentroid(boxCenter);
#else
const coord_t * boxCenter = box->getCentroid();
#endif
V3D Q(boxCenter[0], boxCenter[1], boxCenter[2]);
// Create a peak and add it
// Empty starting peak.
Peak p;
try
{
if (dimType == QLAB)
{
// Build using the Q-lab-frame constructor
p = Peak(inst, Q);
// Save gonio matrix for later
p.setGoniometerMatrix(goniometer);
}
else if (dimType == QSAMPLE)
{
// Build using the Q-sample-frame constructor
p = Peak(inst, Q, goniometer);
}
}
catch (std::exception &e)
{
g_log.notice() << "Error creating peak at " << Q << " because of '" << e.what() << "'. Peak will be skipped." << std::endl;
continue;
}
try
{ // Look for a detector
p.findDetector();
}
catch (...)
{ /* Ignore errors in ray-tracer TODO: Handle for WISH data later */ }
// The "bin count" used will be the box density.
p.setBinCount( box->getSignalNormalized() * densityScalingFactor);
// Save the run number found before.
p.setRunNumber(runNumber);
peakWS->addPeak(p);
// Report progres for each box found.
prog->report("Adding Peaks");
} // for each box found
}