当前位置: 首页>>代码示例>>C++>>正文


C++ IAlgorithm_sptr::executeAsSubAlg方法代码示例

本文整理汇总了C++中IAlgorithm_sptr::executeAsSubAlg方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::executeAsSubAlg方法的具体用法?C++ IAlgorithm_sptr::executeAsSubAlg怎么用?C++ IAlgorithm_sptr::executeAsSubAlg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAlgorithm_sptr的用法示例。


在下文中一共展示了IAlgorithm_sptr::executeAsSubAlg方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: exec

/** Executes the algorithm
 *  @throw Exception::FileError If the calibration file cannot be opened and read successfully
 *  @throw Exception::InstrumentDefinitionError If unable to obtain the source-sample distance
 */
void CaltoDspacemap::exec()
{
  MatrixWorkspace_sptr inputWS = getProperty("InputWorkspace");
  const std::string DFileName = getProperty("DspacemapFile");
  const std::string calFileName = getProperty("CalibrationFile");

  progress(0.0,"Reading calibration file");
  IAlgorithm_sptr alg = createSubAlgorithm("LoadCalFile", 0.0, 0.5, true);
  alg->setProperty("InputWorkspace", inputWS);
  alg->setPropertyValue("CalFilename", calFileName);
  alg->setProperty<bool>("MakeGroupingWorkspace", false);
  alg->setProperty<bool>("MakeOffsetsWorkspace", true);
  alg->setProperty<bool>("MakeMaskWorkspace", false);
  alg->setPropertyValue("WorkspaceName", "temp");
  alg->executeAsSubAlg();
  OffsetsWorkspace_sptr offsetsWS;
  offsetsWS = alg->getProperty("OutputOffsetsWorkspace");

  progress(0.5,"Saving dspacemap file");
  alg = createSubAlgorithm("SaveDspacemap", 0.5, 1.0, true);
  alg->setPropertyValue("DspacemapFile", DFileName);
  alg->setProperty<int>("PadDetID", getProperty("PadDetID"));
  alg->setProperty("InputWorkspace", offsetsWS);
  alg->executeAsSubAlg();
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例2: parser

    /**  Load logs from Nexus file. Logs are expected to be in
    *   /raw_data_1/runlog group of the file. Call to this method must be done
    *   within /raw_data_1 group.
    *   @param ws :: The workspace to load the logs to.
    *   @param period :: The period of this workspace
    */
    void LoadISISNexus2::loadLogs(DataObjects::Workspace2D_sptr ws, int period)
    {
      IAlgorithm_sptr alg = createSubAlgorithm("LoadNexusLogs", 0.0, 0.5);
      alg->setPropertyValue("Filename", this->getProperty("Filename"));
      alg->setProperty<MatrixWorkspace_sptr>("Workspace", ws);
      try
      {
        alg->executeAsSubAlg();
      }
      catch(std::runtime_error&)
      {
        g_log.warning() << "Unable to load run logs. There will be no log "
                        << "data associated with this workspace\n";
        return;
      }
      ws->populateInstrumentParameters();
      // If we loaded an icp_event log then create the necessary period logs 
      if( ws->run().hasProperty("icp_event") )
      {
        Kernel::Property *log = ws->run().getProperty("icp_event");
        LogParser parser(log);
        ws->mutableRun().addProperty(parser.createPeriodLog(period));
        ws->mutableRun().addProperty(parser.createAllPeriodsLog());
      }

    }
开发者ID:,项目名称:,代码行数:32,代码来源:

示例3: movedetector

  void DiffractionEventCalibrateDetectors::movedetector(double x, double y, double z, double rotx, double roty, double rotz,
      std::string detname, MatrixWorkspace_sptr inputW)
  {

    IAlgorithm_sptr alg1 = createSubAlgorithm("MoveInstrumentComponent");
    alg1->setProperty<MatrixWorkspace_sptr>("Workspace", inputW);
    alg1->setPropertyValue("ComponentName", detname);
    //Move in cm for small shifts
    alg1->setProperty("X", x*0.01);
    alg1->setProperty("Y", y*0.01);
    alg1->setProperty("Z", z*0.01);
    alg1->setPropertyValue("RelativePosition", "1");
    alg1->executeAsSubAlg();


    IAlgorithm_sptr algx = createSubAlgorithm("RotateInstrumentComponent");
    algx->setProperty<MatrixWorkspace_sptr>("Workspace", inputW);
    algx->setPropertyValue("ComponentName", detname);
    algx->setProperty("X", 1.0);
    algx->setProperty("Y", 0.0);
    algx->setProperty("Z", 0.0);
    algx->setProperty("Angle", rotx);
    algx->setPropertyValue("RelativeRotation", "1");
    algx->executeAsSubAlg();


    IAlgorithm_sptr algy = createSubAlgorithm("RotateInstrumentComponent");
    algy->setProperty<MatrixWorkspace_sptr>("Workspace", inputW);
    algy->setPropertyValue("ComponentName", detname);
    algy->setProperty("X", 0.0);
    algy->setProperty("Y", 1.0);
    algy->setProperty("Z", 0.0);
    algy->setProperty("Angle", roty);
    algy->setPropertyValue("RelativeRotation", "1");
    algy->executeAsSubAlg();

    IAlgorithm_sptr algz = createSubAlgorithm("RotateInstrumentComponent");
    algz->setProperty<MatrixWorkspace_sptr>("Workspace", inputW);
    algz->setPropertyValue("ComponentName", detname);
    algz->setProperty("X", 0.0);
    algz->setProperty("Y", 0.0);
    algz->setProperty("Z", 1.0);
    algz->setProperty("Angle", rotz);
    algz->setPropertyValue("RelativeRotation", "1");
    algz->executeAsSubAlg();
  }
开发者ID:,项目名称:,代码行数:46,代码来源:

示例4: performMoveComponent

  /**
   * Run the MoveInstrumentComponent algorithm as a child algorithm
   * @param comp_name :: The component name
   * @param zshift :: The shift along the Z-axis
   * @param start_progress :: The starting percentage for progress reporting
   * @param end_progress :: The end percentage for progress reporting
   */
  void LoadLOQDistancesFromRaw::performMoveComponent(const std::string & comp_name, double zshift,
                 double start_progress, double end_progress)
  {
    IAlgorithm_sptr alg = createSubAlgorithm("MoveInstrumentComponent", start_progress, end_progress);
    alg->setPropertyValue("Workspace", getPropertyValue("InputWorkspace"));
    alg->setPropertyValue("ComponentName", comp_name);
    alg->setProperty("Z", zshift);
    alg->setPropertyValue("RelativePosition", "1");
    alg->executeAsSubAlg();

  }
开发者ID:,项目名称:,代码行数:18,代码来源:

示例5: crop

/// Calls CropWorkspace as a sub-algorithm to remove bins from the start or end of a square workspace
void RemoveBins::crop(const double& start, const double& end)
{
  IAlgorithm_sptr childAlg = createSubAlgorithm("CropWorkspace");
  childAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", boost::const_pointer_cast<MatrixWorkspace>(m_inputWorkspace));
  childAlg->setProperty<double>("XMin", start);
  childAlg->setProperty<double>("XMax", end);
  childAlg->executeAsSubAlg();

  // Only get to here if successful
  // Assign the result to the output workspace property
  MatrixWorkspace_sptr outputWS = childAlg->getProperty("OutputWorkspace");
  setProperty("OutputWorkspace",outputWS);
  return;
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例6: doClone

  void CloneMDWorkspace::doClone(const typename MDEventWorkspace<MDE, nd>::sptr ws)
  {
    std::string outWSName = getPropertyValue("OutputWorkspace");
    Progress prog(this, 0.0, 10.0, 100);
    BoxController_sptr bc = ws->getBoxController();

    if (!bc) throw std::runtime_error("Error with InputWorkspace: no BoxController!");
    if (bc->isFileBacked())
    {
      // Generate a new filename to copy to
      prog.report("Copying File");
      std::string originalFile = bc->getFilename();
      std::string outFilename = getPropertyValue("Filename");
      if (outFilename.empty())
      {
        // Auto-generated name
        Poco::Path path = Poco::Path(originalFile).absolute();
        std::string newName = path.getBaseName() + "_clone." + path.getExtension();
        path.setFileName(newName);
        outFilename = path.toString();
      }

      // Perform the copying
      g_log.notice() << "Cloned workspace file being copied to: " << outFilename << std::endl;
      Poco::File(originalFile).copyTo(outFilename);
      g_log.information() << "File copied successfully." << std::endl;

      // Now load it back
      IAlgorithm_sptr alg = createSubAlgorithm("LoadMD", 0.5, 1.0, false);
      alg->setPropertyValue("Filename", outFilename);
      alg->setPropertyValue("FileBackEnd", "1");
      alg->setPropertyValue("Memory", "0"); //TODO: How much memory?
      alg->setPropertyValue("OutputWorkspace", outWSName);
      alg->executeAsSubAlg();

      // Set the output workspace to this
      IMDEventWorkspace_sptr outWS = alg->getProperty("OutputWorkspace");
      this->setProperty("OutputWorkspace", outWS);
    }
    else
    {
      // Perform the clone in memory.
      boost::shared_ptr<MDEventWorkspace<MDE,nd> > outWS(new MDEventWorkspace<MDE,nd>(*ws));
      this->setProperty("OutputWorkspace", boost::dynamic_pointer_cast<IMDEventWorkspace>(outWS) );
    }
  }
开发者ID:,项目名称:,代码行数:46,代码来源:

示例7: moveToBeamCenter

/// Move the detector according to the beam center
void EQSANSLoad::moveToBeamCenter()
{
  // Check that we have a beam center defined, otherwise set the
  // default beam center
  if (isEmpty(m_center_x) || isEmpty(m_center_y))
  {
    EQSANSInstrument::getDefaultBeamCenter(dataWS, m_center_x, m_center_y);
    g_log.information() << "No beam finding method: setting to default ["
      << Poco::NumberFormatter::format(m_center_x, 1) << ", "
      << Poco::NumberFormatter::format(m_center_y, 1) << "]" << std::endl;
    return;
  }

  // Check that the center of the detector really is at (0,0)
  int nx_pixels = (int)(dataWS->getInstrument()->getNumberParameter("number-of-x-pixels")[0]);
  int ny_pixels = (int)(dataWS->getInstrument()->getNumberParameter("number-of-y-pixels")[0]);
  V3D pixel_first = dataWS->getInstrument()->getDetector(0)->getPos();
  int detIDx = EQSANSInstrument::getDetectorFromPixel(nx_pixels-1, 0, dataWS);
  int detIDy = EQSANSInstrument::getDetectorFromPixel(0, ny_pixels-1, dataWS);

  V3D pixel_last_x = dataWS->getInstrument()->getDetector(detIDx)->getPos();
  V3D pixel_last_y = dataWS->getInstrument()->getDetector(detIDy)->getPos();
  double x_offset = (pixel_first.X()+pixel_last_x.X())/2.0;
  double y_offset = (pixel_first.Y()+pixel_last_y.Y())/2.0;
  double beam_ctr_x = 0.0;
  double beam_ctr_y = 0.0;
  EQSANSInstrument::getCoordinateFromPixel(m_center_x, m_center_y, dataWS, beam_ctr_x, beam_ctr_y);

  IAlgorithm_sptr mvAlg = createSubAlgorithm("MoveInstrumentComponent", 0.5, 0.50);
  mvAlg->setProperty<MatrixWorkspace_sptr>("Workspace", dataWS);
  mvAlg->setProperty("ComponentName", "detector1");
  mvAlg->setProperty("X", -x_offset-beam_ctr_x);
  mvAlg->setProperty("Y", -y_offset-beam_ctr_y);
  mvAlg->setProperty("RelativePosition", true);
  mvAlg->executeAsSubAlg();
  m_output_message += "   Beam center offset: " + Poco::NumberFormatter::format(x_offset)
      + ", " + Poco::NumberFormatter::format(y_offset) + " m\n";
  //m_output_message += "   Beam center in real-space: " + Poco::NumberFormatter::format(-x_offset-beam_ctr_x)
  //    + ", " + Poco::NumberFormatter::format(-y_offset-beam_ctr_y) + " m\n";
  g_log.information() << "Moving beam center to " << m_center_x << " " << m_center_y << std::endl;

  dataWS->mutableRun().addProperty("beam_center_x", m_center_x, "pixel", true);
  dataWS->mutableRun().addProperty("beam_center_y", m_center_y, "pixel", true);
  m_output_message += "   Beam center: " + Poco::NumberFormatter::format(m_center_x, 1)
      + ", " + Poco::NumberFormatter::format(m_center_y, 1) + "\n";
}
开发者ID:,项目名称:,代码行数:47,代码来源:

示例8: extractSpec

/** Calls CropWorkspace as a sub-algorithm and passes to it the InputWorkspace property
*  @param specInd :: the index number of the histogram to extract
*  @param start :: the number of the first bin to include (starts counting bins at 0)
*  @param end :: the number of the last bin to include (starts counting bins at 0)
*  @throw out_of_range if start, end or specInd are set outside of the vaild range for the workspace
*  @throw runtime_error if the algorithm just falls over
*  @throw invalid_argument if the input workspace does not have common binning
*/
void GetEi::extractSpec(int64_t specInd, double start, double end)
{
  IAlgorithm_sptr childAlg =
    createSubAlgorithm("CropWorkspace", 100*m_fracCompl, 100*(m_fracCompl+CROP) );
  m_fracCompl += CROP;
  
  childAlg->setPropertyValue( "InputWorkspace",
                              getPropertyValue("InputWorkspace") );
  childAlg->setProperty( "XMin", start);
  childAlg->setProperty( "XMax", end);
  childAlg->setProperty( "StartWorkspaceIndex", specInd);
  childAlg->setProperty( "EndWorkspaceIndex", specInd);
  childAlg->executeAsSubAlg();

  m_tempWS = childAlg->getProperty("OutputWorkspace");

//DEBUGGING CODE uncomment out the line below if you want to see the TOF window that was analysed
//AnalysisDataService::Instance().addOrReplace("croped_dist_del", m_tempWS);
  progress(m_fracCompl);
  interruption_point();
}
开发者ID:,项目名称:,代码行数:29,代码来源:


注:本文中的IAlgorithm_sptr::executeAsSubAlg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。