本文整理汇总了C++中EventWorkspace_sptr::getAxis方法的典型用法代码示例。如果您正苦于以下问题:C++ EventWorkspace_sptr::getAxis方法的具体用法?C++ EventWorkspace_sptr::getAxis怎么用?C++ EventWorkspace_sptr::getAxis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventWorkspace_sptr
的用法示例。
在下文中一共展示了EventWorkspace_sptr::getAxis方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: validateInputsForEventWorkspaces
/** Validate the input event workspaces
*
* @param inputWorkspaces The names of the input workspaces
* @throw invalid_argument if there is an incompatibility.
* @return true if all workspaces are event workspaces and valid. False if any
*are not found,
*/
bool MergeRuns::validateInputsForEventWorkspaces(
const std::vector<std::string> &inputWorkspaces) {
std::string xUnitID;
std::string YUnit;
bool dist(false);
m_inEventWS.clear();
// Going to check that name of instrument matches - think that's the best
// possible at the moment
// because if instrument is created from raw file it'll be a different
// object
std::string instrument;
for (size_t i = 0; i < inputWorkspaces.size(); ++i) {
// Fetch the next input workspace as an - throw an error if it's not there
EventWorkspace_sptr ws =
AnalysisDataService::Instance().retrieveWS<EventWorkspace>(
inputWorkspaces[i]);
if (!ws) { // Either it is not found, or it is not an EventWorkspace
return false;
}
m_inEventWS.push_back(ws);
// Check a few things are the same for all input workspaces
if (i == 0) {
xUnitID = ws->getAxis(0)->unit()->unitID();
YUnit = ws->YUnit();
dist = ws->isDistribution();
instrument = ws->getInstrument()->getName();
} else {
testCompatibility(ws, xUnitID, YUnit, dist, instrument);
}
} // for each input WS name
// We got here: all are event workspaces
return true;
}
示例2: exec
/** Execute the algorithm */
void LoadEventPreNexus::exec() {
// Check 'chunk' properties are valid, if set
const int chunks = getProperty("TotalChunks");
if (!isEmpty(chunks) && int(getProperty("ChunkNumber")) > chunks) {
throw std::out_of_range("ChunkNumber cannot be larger than TotalChunks");
}
prog = new Progress(this, 0.0, 1.0, 100);
// what spectra (pixel ID's) to load
this->spectra_list = this->getProperty(PID_PARAM);
// the event file is needed in case the pulseid fileanme is empty
string event_filename = this->getPropertyValue(EVENT_PARAM);
string pulseid_filename = this->getPropertyValue(PULSEID_PARAM);
bool throwError = true;
if (pulseid_filename.empty()) {
pulseid_filename = generatePulseidName(event_filename);
if (!pulseid_filename.empty()) {
if (Poco::File(pulseid_filename).exists()) {
this->g_log.information() << "Found pulseid file " << pulseid_filename
<< std::endl;
throwError = false;
} else {
pulseid_filename = "";
}
}
}
prog->report("Loading Pulse ID file");
this->readPulseidFile(pulseid_filename, throwError);
this->openEventFile(event_filename);
prog->report("Creating output workspace");
// prep the output workspace
EventWorkspace_sptr localWorkspace =
EventWorkspace_sptr(new EventWorkspace());
// Make sure to initialize.
// We can use dummy numbers for arguments, for event workspace it doesn't
// matter
localWorkspace->initialize(1, 1, 1);
// Set the units
localWorkspace->getAxis(0)->unit() = UnitFactory::Instance().create("TOF");
localWorkspace->setYUnit("Counts");
// TODO localWorkspace->setTitle(title);
// Add the run_start property
// Use the first pulse as the run_start time.
if (this->num_pulses > 0) {
// add the start of the run as a ISO8601 date/time string. The start = the
// first pulse.
// (this is used in LoadInstrument to find the right instrument file to
// use).
localWorkspace->mutableRun().addProperty(
"run_start", pulsetimes[0].toISO8601String(), true);
}
// determine the run number and add it to the run object
localWorkspace->mutableRun().addProperty("run_number",
getRunnumber(event_filename));
// Get the instrument!
prog->report("Loading Instrument");
this->runLoadInstrument(event_filename, localWorkspace);
// load the mapping file
prog->report("Loading Mapping File");
string mapping_filename = this->getPropertyValue(MAP_PARAM);
if (mapping_filename.empty()) {
mapping_filename = generateMappingfileName(localWorkspace);
if (!mapping_filename.empty())
this->g_log.information() << "Found mapping file \"" << mapping_filename
<< "\"" << std::endl;
}
this->loadPixelMap(mapping_filename);
// Process the events into pixels
this->procEvents(localWorkspace);
// Save output
this->setProperty<IEventWorkspace_sptr>(OUT_PARAM, localWorkspace);
// Cleanup
delete prog;
}
示例3: execEvent
/**
* Execute the align detectors algorithm for an event workspace.
*/
void AlignDetectors::execEvent()
{
//g_log.information("Processing event workspace");
// the calibration information is already read in at this point
// convert the input workspace into the event workspace we already know it is
const MatrixWorkspace_const_sptr matrixInputWS = this->getProperty("InputWorkspace");
EventWorkspace_const_sptr inputWS
= boost::dynamic_pointer_cast<const EventWorkspace>(matrixInputWS);
// generate the output workspace pointer
API::MatrixWorkspace_sptr matrixOutputWS = this->getProperty("OutputWorkspace");
EventWorkspace_sptr outputWS;
if (matrixOutputWS == matrixInputWS)
outputWS = boost::dynamic_pointer_cast<EventWorkspace>(matrixOutputWS);
else
{
//Make a brand new EventWorkspace
outputWS = boost::dynamic_pointer_cast<EventWorkspace>(
API::WorkspaceFactory::Instance().create("EventWorkspace", inputWS->getNumberHistograms(), 2, 1));
//Copy geometry over.
API::WorkspaceFactory::Instance().initializeFromParent(inputWS, outputWS, false);
//outputWS->mutableSpectraMap().clear();
//You need to copy over the data as well.
outputWS->copyDataFrom( (*inputWS) );
//Cast to the matrixOutputWS and save it
matrixOutputWS = boost::dynamic_pointer_cast<MatrixWorkspace>(outputWS);
this->setProperty("OutputWorkspace", matrixOutputWS);
}
// Set the final unit that our output workspace will have
outputWS->getAxis(0)->unit() = UnitFactory::Instance().create("dSpacing");
const int64_t numberOfSpectra = static_cast<int64_t>(inputWS->getNumberHistograms());
// Initialise the progress reporting object
Progress progress(this,0.0,1.0,numberOfSpectra);
PARALLEL_FOR_NO_WSP_CHECK()
for (int64_t i = 0; i < int64_t(numberOfSpectra); ++i)
{
PARALLEL_START_INTERUPT_REGION
// Compute the conversion factor
double factor = calcConversionFromMap(this->tofToDmap, inputWS->getSpectrum(size_t(i))->getDetectorIDs());
//Perform the multiplication on all events
outputWS->getEventList(i).convertTof(factor);
progress.report();
PARALLEL_END_INTERUPT_REGION
}
PARALLEL_CHECK_INTERUPT_REGION
if (outputWS->getTofMin() < 0.)
{
std::stringstream msg;
msg << "Something wrong with the calibration. Negative minimum d-spacing created. d_min = "
<< outputWS->getTofMin() << " d_max " << outputWS->getTofMax();
throw std::runtime_error(msg.str());
}
outputWS->clearMRU();
}