/// Fetch the properties and set the appropriate member variables
void AbsorptionCorrection::retrieveBaseProperties() {
  double sigma_atten = getProperty("AttenuationXSection"); // in barns
  double sigma_s = getProperty("ScatteringXSection");      // in barns
  double rho = getProperty("SampleNumberDensity");         // in Angstroms-3
  const Material &sampleMaterial = m_inputWS->sample().getShape().material();
  if (sampleMaterial.totalScatterXSection(NeutronAtom::ReferenceLambda) !=
      0.0) {
    if (rho == EMPTY_DBL())
      rho = sampleMaterial.numberDensity();
    if (sigma_s == EMPTY_DBL())
      sigma_s =
          sampleMaterial.totalScatterXSection(NeutronAtom::ReferenceLambda);
    if (sigma_atten == EMPTY_DBL())
      sigma_atten = sampleMaterial.absorbXSection(NeutronAtom::ReferenceLambda);
  } else // Save input in Sample with wrong atomic number and name
  {
    NeutronAtom neutron(0, 0, 0.0, 0.0, sigma_s, 0.0, sigma_s, sigma_atten);

    auto shape = boost::shared_ptr<IObject>(
        m_inputWS->sample().getShape().cloneWithMaterial(
            Material("SetInAbsorptionCorrection", neutron, rho)));
    m_inputWS->mutableSample().setShape(shape);
  }
  rho *= 100; // Will give right units in going from
              // mu in cm^-1 to m^-1 for mu*total flight path( in m )

  // NOTE: the angstrom^-2 to barns and the angstrom^-1 to cm^-1
  // will cancel for mu to give units: cm^-1
  m_refAtten = -sigma_atten * rho / NeutronAtom::ReferenceLambda;
  m_scattering = -sigma_s * rho;

  n_lambda = getProperty("NumberOfWavelengthPoints");

  std::string exp_string = getProperty("ExpMethod");
  if (exp_string == "Normal") // Use the system exp function
    EXPONENTIAL = exp;
  else if (exp_string == "FastApprox") // Use the compact approximation
    EXPONENTIAL = fast_exp;

  // Get the energy mode
  const std::string emodeStr = getProperty("EMode");
  // Convert back to an integer representation
  m_emode = 0;
  if (emodeStr == "Direct")
    m_emode = 1;
  else if (emodeStr == "Indirect")
    m_emode = 2;
  // If inelastic, get the fixed energy and convert it to a wavelength
  if (m_emode) {
    const double efixed = getProperty("Efixed");
    Unit_const_sptr energy = UnitFactory::Instance().create("Energy");
    double factor, power;
    energy->quickConversion(*UnitFactory::Instance().create("Wavelength"),
                            factor, power);
    m_lambdaFixed = factor * std::pow(efixed, power);
  }

  // Call the virtual function for any further properties
  retrieveProperties();
}
/// Fetch the properties and set the appropriate member variables
void AnvredCorrection::retrieveBaseProperties() {
  m_smu = getProperty("LinearScatteringCoef"); // in 1/cm
  m_amu = getProperty("LinearAbsorptionCoef"); // in 1/cm
  m_radius = getProperty("Radius");            // in cm
  m_power_th = getProperty("PowerLambda");     // in cm
  const Material &sampleMaterial = m_inputWS->sample().getMaterial();
  if (sampleMaterial.totalScatterXSection(NeutronAtom::ReferenceLambda) !=
      0.0) {
    double rho = sampleMaterial.numberDensity();
    if (m_smu == EMPTY_DBL())
      m_smu =
          sampleMaterial.totalScatterXSection(NeutronAtom::ReferenceLambda) *
          rho;
    if (m_amu == EMPTY_DBL())
      m_amu = sampleMaterial.absorbXSection(NeutronAtom::ReferenceLambda) * rho;
  } else // Save input in Sample with wrong atomic number and name
  {
    NeutronAtom neutron(static_cast<uint16_t>(EMPTY_DBL()),
                        static_cast<uint16_t>(0), 0.0, 0.0, m_smu, 0.0, m_smu,
                        m_amu);
    Object shape = m_inputWS->sample().getShape(); // copy
    shape.setMaterial(Material("SetInAnvredCorrection", neutron, 1.0));
    m_inputWS->mutableSample().setShape(shape);
  }
  if (m_smu != EMPTY_DBL() && m_amu != EMPTY_DBL())
    g_log.notice() << "LinearScatteringCoef = " << m_smu << " 1/cm\n"
                   << "LinearAbsorptionCoef = " << m_amu << " 1/cm\n"
                   << "Radius = " << m_radius << " cm\n"
                   << "Power Lorentz corrections = " << m_power_th << " \n";
  // Call the virtual function for any further properties
  retrieveProperties();
}
Exemplo n.º 3
0
RenderController::RenderController(int id, int eID, tgd::System* mSystem)
: Controller(id, eID)
, mBodySprite()
, mPreviousPosition()
, mHFrame(0)
, mVFrame(0)
, mCurrentDirection(Down)
{
    retrieveProperties(eID, *mSystem);
}
Exemplo n.º 4
0
/// Fetch the properties and set the appropriate member variables
void AnvredCorrection::retrieveBaseProperties()
{
  smu = getProperty("LinearScatteringCoef"); // in 1/cm
  amu = getProperty("LinearAbsorptionCoef"); // in 1/cm
  radius = getProperty("Radius"); // in cm
  power_th = getProperty("PowerLambda"); // in cm

  // Call the virtual function for any further properties
  retrieveProperties();
}
Exemplo n.º 5
0
/** Executes the algorithm
*  @throw NullPointerException if a getDetector() returns NULL or pressure or wall thickness is not set
*  @throw invalid_argument if the shape of a detector is isn't a cylinder aligned on axis or there is no baseInstrument
*  @throw runtime_error if the SpectraDetectorMap had not been filled
*/
void DetectorEfficiencyCor::exec()
{
  //gets and checks the values passed to the algorithm
  retrieveProperties();

  // wave number that the neutrons originally had
  m_ki = std::sqrt(m_Ei/KSquaredToE);
  
  // Store some information about the instrument setup that will not change
  m_samplePos = m_inputWS->getInstrument()->getSample()->getPos();

  int64_t numHists = m_inputWS->getNumberHistograms();
  double numHists_d = static_cast<double>(numHists);
  const int64_t progStep = static_cast<int64_t>(ceil(numHists_d/100.0));

  PARALLEL_FOR2(m_inputWS,m_outputWS)
  for (int64_t i = 0; i < numHists; ++i )
  {
    PARALLEL_START_INTERUPT_REGION
      
    m_outputWS->setX(i, m_inputWS->refX(i));
    try
    { 
      correctForEfficiency(i);
    }
    catch (Exception::NotFoundError &)
    {
      // if we don't have all the data there will be spectra we can't correct, avoid leaving the workspace part corrected 
      MantidVec& dud = m_outputWS->dataY(i);
      std::transform(dud.begin(),dud.end(),dud.begin(), std::bind2nd(std::multiplies<double>(),0));
      PARALLEL_CRITICAL(deteff_invalid)
      {
        m_spectraSkipped.push_back(m_inputWS->getAxis(1)->spectraNo(i));
      }
    }      

    // make regular progress reports and check for cancelling the algorithm
    if ( i % progStep == 0 )
    {
      progress(static_cast<double>(i)/numHists_d);
      interruption_point();
    }

    PARALLEL_END_INTERUPT_REGION
  }
  PARALLEL_CHECK_INTERUPT_REGION

  logErrors();
  setProperty("OutputWorkspace", m_outputWS);
}