本文整理汇总了C++中EventWorkspace_const_sptr::getInstrument方法的典型用法代码示例。如果您正苦于以下问题:C++ EventWorkspace_const_sptr::getInstrument方法的具体用法?C++ EventWorkspace_const_sptr::getInstrument怎么用?C++ EventWorkspace_const_sptr::getInstrument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventWorkspace_const_sptr
的用法示例。
在下文中一共展示了EventWorkspace_const_sptr::getInstrument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTofOffset
//.........这里部分代码省略.........
3.9560346 * n_frame[i] * tof_frame_width / CHOPPER_LOCATION[i];
if (frame_wl_1 < c_wl_2[i] && frame_wl_2 > c_wl_1[i]) {
passed = true;
break;
}
if (frame_wl_2 < c_wl_1[i])
break; // over shot
} while (n_frame[i] - n_frame[i - 1] < 10);
if (!passed) {
n_frame[0] += 1;
break;
} else {
if (frame_wl_1 < c_wl_1[i])
frame_wl_1 = c_wl_1[i];
if (frame_wl_2 > c_wl_2[i])
frame_wl_2 = c_wl_2[i];
}
}
} while (!passed && n_frame[0] < 99);
if (frame_wl_2 > frame_wl_1) {
int n = 3;
if (c_wl_1[2] > c_wl_1[3])
n = 2;
frame_srcpulse_wl_1 =
c_wl_1[n] - 3.9560346 * c_wl_1[n] * PULSEWIDTH / CHOPPER_LOCATION[n];
for (int i = 0; i < 4; i++) {
chopper_wl_1[i] = c_wl_1[i];
chopper_wl_2[i] = c_wl_2[i];
if (frame_skipping) {
chopper_frameskip_wl_1[i] =
c_wl_1[i] +
3.9560346 * 2. * tof_frame_width / CHOPPER_LOCATION[i];
chopper_frameskip_wl_2[i] =
c_wl_2[i] +
3.9560346 * 2. * tof_frame_width / CHOPPER_LOCATION[i];
if (i == 0) {
frameskip_wl_1 = chopper_frameskip_wl_1[i];
frameskip_wl_2 = chopper_frameskip_wl_2[i];
} else {
if (frameskip_wl_1 < chopper_frameskip_wl_1[i])
frameskip_wl_1 = chopper_frameskip_wl_1[i];
if (frameskip_wl_2 > chopper_frameskip_wl_2[i])
frameskip_wl_2 = chopper_frameskip_wl_2[i];
}
}
}
} else
frame_srcpulse_wl_1 = 0.0;
}
// Get source and detector locations
// get the name of the mapping file as set in the parameter files
std::vector<std::string> temp =
inputWS->getInstrument()->getStringParameter("detector-name");
std::string det_name = "detector1";
if (temp.empty())
g_log.information() << "The instrument parameter file does not contain the "
"'detector-name' parameter: trying 'detector1'";
else
det_name = temp[0];
double source_z = inputWS->getInstrument()->getSource()->getPos().Z();
double detector_z =
inputWS->getInstrument()->getComponentByName(det_name)->getPos().Z();
double source_to_detector = (detector_z - source_z) * 1000.0;
frame_tof0 = frame_srcpulse_wl_1 / 3.9560346 * source_to_detector;
g_log.information() << "Frame width " << tmp_frame_width << '\n';
g_log.information() << "TOF offset = " << frame_tof0 << " microseconds\n";
g_log.information() << "Band defined by T1-T4 " << frame_wl_1 << " "
<< frame_wl_2;
if (frame_skipping)
g_log.information() << " + " << frameskip_wl_1 << " " << frameskip_wl_2
<< '\n';
else
g_log.information() << '\n';
g_log.information() << "Chopper Actual Phase Lambda1 Lambda2\n";
for (int i = 0; i < 4; i++)
g_log.information() << i << " " << chopper_actual_phase[i] << " "
<< chopper_wl_1[i] << " " << chopper_wl_2[i] << '\n';
double low_wl_discard = 3.9560346 * low_tof_cut / source_to_detector;
double high_wl_discard = 3.9560346 * high_tof_cut / source_to_detector;
setProperty("FrameSkipping", frame_skipping);
setProperty("TofOffset", frame_tof0);
setProperty("WavelengthMin", frame_wl_1 + low_wl_discard);
setProperty("WavelengthMax", frame_wl_2 - high_wl_discard);
if (frame_skipping) {
setProperty("WavelengthMinFrame2", frameskip_wl_1 + low_wl_discard);
setProperty("WavelengthMaxFrame2", frameskip_wl_2 - high_wl_discard);
}
return frame_tof0;
}
示例2: exec
/** Executes the algorithm
*
* @throw runtime_error Thrown if algorithm cannot execute
*/
void DiffractionEventCalibrateDetectors::exec()
{
// Try to retrieve optional properties
const int maxIterations = getProperty("MaxIterations");
const double peakOpt = getProperty("LocationOfPeakToOptimize");
// Get the input workspace
EventWorkspace_const_sptr inputW = getProperty("InputWorkspace");
// retrieve the properties
const std::string rb_params=getProperty("Params");
//Get some stuff from the input workspace
Instrument_const_sptr inst = inputW->getInstrument();
//Build a list of Rectangular Detectors
std::vector<boost::shared_ptr<RectangularDetector> > detList;
// --------- Loading only one bank ----------------------------------
std::string onebank = getProperty("BankName");
bool doOneBank = (onebank != "");
for (int i=0; i < inst->nelements(); i++)
{
boost::shared_ptr<RectangularDetector> det;
boost::shared_ptr<ICompAssembly> assem;
boost::shared_ptr<ICompAssembly> assem2;
det = boost::dynamic_pointer_cast<RectangularDetector>( (*inst)[i] );
if (det)
{
if (det->getName().compare(onebank) == 0) detList.push_back(det);
if (!doOneBank) detList.push_back(det);
}
else
{
//Also, look in the first sub-level for RectangularDetectors (e.g. PG3).
// We are not doing a full recursive search since that will be very long for lots of pixels.
assem = boost::dynamic_pointer_cast<ICompAssembly>( (*inst)[i] );
if (assem)
{
for (int j=0; j < assem->nelements(); j++)
{
det = boost::dynamic_pointer_cast<RectangularDetector>( (*assem)[j] );
if (det)
{
if (det->getName().compare(onebank) == 0) detList.push_back(det);
if (!doOneBank) detList.push_back(det);
}
else
{
//Also, look in the second sub-level for RectangularDetectors (e.g. PG3).
// We are not doing a full recursive search since that will be very long for lots of pixels.
assem2 = boost::dynamic_pointer_cast<ICompAssembly>( (*assem)[j] );
if (assem2)
{
for (int k=0; k < assem2->nelements(); k++)
{
det = boost::dynamic_pointer_cast<RectangularDetector>( (*assem2)[k] );
if (det)
{
if (det->getName().compare(onebank) == 0) detList.push_back(det);
if (!doOneBank) detList.push_back(det);
}
}
}
}
}
}
}
}
// set-up minimizer
std::string inname = getProperty("InputWorkspace");
std::string outname = inname+"2"; //getProperty("OutputWorkspace");
IAlgorithm_sptr algS = createSubAlgorithm("SortEvents");
algS->setPropertyValue("InputWorkspace",inname);
algS->setPropertyValue("SortBy", "X Value");
algS->executeAsSubAlg();
inputW=algS->getProperty("InputWorkspace");
//Write DetCal File
double baseX,baseY,baseZ,upX,upY,upZ;
std::string filename=getProperty("DetCalFilename");
std::fstream outfile;
outfile.open(filename.c_str(), std::ios::out);
if(detList.size() > 1)
{
outfile << "#\n";
outfile << "# Mantid Optimized .DetCal file for SNAP with TWO detector panels\n";
outfile << "# Old Panel, nominal size and distance at -90 degrees.\n";
outfile << "# New Panel, nominal size and distance at +90 degrees.\n";
//.........这里部分代码省略.........