50 const std::string ionNameStr =
getProperty(
"IonName");
51 const std::string ffwsStr =
getProperty(
"FormFactorWorkspace");
52 const bool isHist = inputWS->isHistogramData();
53 const int64_t numHists = inputWS->getNumberHistograms();
54 const int64_t specSize = inputWS->blocksize();
57 int64_t numAxes = inputWS->axes();
59 std::vector<double> Qvals;
61 for (iax = 0; iax < numAxes; iax++) {
62 Axis *QAxis = inputWS->getAxis(iax);
63 std::string unitID = QAxis->
unit()->unitID();
64 if (unitID ==
"MomentumTransfer") {
67 if (isHist || iax > 0) {
68 int64_t nQ = QAxis->
length() - 1;
69 for (int64_t iQ = 0; iQ < nQ; iQ++) {
70 Qvals.emplace_back(0.5 *
71 (QAxis->
getValue(
static_cast<size_t>(iQ)) + QAxis->
getValue(
static_cast<size_t>(iQ + 1))));
74 int64_t nQ = QAxis->
length();
75 for (int64_t iQ = 0; iQ < nQ; iQ++) {
76 Qvals.emplace_back(QAxis->
getValue(
static_cast<size_t>(iQ)));
83 throw std::runtime_error(
"Expected a MatrixWorkspace with a "
84 "MomentumTransfer axis. Cannot apply form factor "
85 "without knowing Q.");
91 std::vector<double> FF;
92 FF.reserve(Qvals.size());
94 std::transform(Qvals.begin(), Qvals.end(), std::back_inserter(FF),
95 [&ion](
double qval) { return ion.analyticalFormFactor(qval * qval); });
97 if (!ffwsStr.empty()) {
98 HistogramBuilder builder;
99 builder.setX(Qvals.size());
100 builder.setY(FF.size());
102 ffws->mutableX(0).assign(Qvals.begin(), Qvals.end());
103 ffws->mutableY(0).assign(FF.begin(), FF.end());
104 ffws->getAxis(0)->unit() = UnitFactory::Instance().create(
"MomentumTransfer");
105 ffws->setYUnitLabel(
"F(Q)");
111 for (int64_t i = 0; i < numHists; i++) {
112 auto &
Y = outputWS->mutableY(i);
113 auto &E = outputWS->mutableE(i);
114 for (int64_t j = 0; j < specSize; j++) {
115 double ff = (iax == 0) ? FF[j] : FF[i];