177 g_log.
information() <<
"Preprocessing detector locations in a target reciprocal space\n";
182 if ((!source) || (!sample)) {
183 g_log.
error() <<
" Instrument is not fully defined. Can not identify "
184 "source or sample\n";
186 "Instrument not sufficiently defined: failed to get source and/or "
192 double L1 = source->getDistance(*sample);
193 targWS->logs()->addProperty<
double>(
"L1", L1,
true);
194 g_log.
debug() <<
"Source-sample distance: " << L1 <<
'\n';
197 inputWS->getTitle());
200 std::string InstrName = inputWS->getInstrumentName();
201 targWS->logs()->addProperty<std::string>(
"InstrumentName", InstrName,
203 targWS->logs()->addProperty<
bool>(
"FakeDetectors",
false,
true);
206 auto &sp2detMap = targWS->getColVector<
size_t>(
"spec2detMap");
207 auto &detId = targWS->getColVector<int32_t>(
"DetectorID");
208 auto &detIDMap = targWS->getColVector<
size_t>(
"detIDMap");
209 auto &L2 = targWS->getColVector<
double>(
"L2");
210 auto &TwoTheta = targWS->getColVector<
double>(
"TwoTheta");
211 auto &Azimuthal = targWS->getColVector<
double>(
"Azimuthal");
212 auto &detDir = targWS->getColVector<
Kernel::V3D>(
"DetDirections");
213 auto &DIFA = targWS->getColVector<
double>(
"DIFA");
214 auto &DIFC = targWS->getColVector<
double>(
"DIFC");
215 auto &TZERO = targWS->getColVector<
double>(
"TZERO");
218 auto Efi = targWS->getLogs()->getPropertyValueAsType<
double>(
"Ei");
219 float *pEfixedArray(
nullptr);
220 const auto &componentInfo = inputWS->componentInfo();
221 const auto &detectorInfo = inputWS->detectorInfo();
223 pEfixedArray = targWS->getColDataArray<
float>(
"eFixed");
226 int *pMasksArray(
nullptr);
228 pMasksArray = targWS->getColDataArray<
int>(
"detMask");
232 size_t nHist = targWS->rowCount();
235 uint32_t liveDetectorsCount(0);
236 const auto &spectrumInfo = inputWS->spectrumInfo();
237 for (
size_t i = 0; i < nHist; i++) {
238 sp2detMap[i] = std::numeric_limits<uint64_t>::quiet_NaN();
239 detId[i] = std::numeric_limits<int32_t>::quiet_NaN();
240 detIDMap[i] = std::numeric_limits<uint64_t>::quiet_NaN();
241 L2[i] = std::numeric_limits<double>::quiet_NaN();
242 DIFC[i] = std::numeric_limits<double>::quiet_NaN();
243 TwoTheta[i] = std::numeric_limits<double>::quiet_NaN();
244 Azimuthal[i] = std::numeric_limits<double>::quiet_NaN();
247 if (!spectrumInfo.hasDetectors(i) || spectrumInfo.isMonitor(i))
251 bool maskDetector = spectrumInfo.isMasked(i);
253 *(pMasksArray + liveDetectorsCount) = maskDetector ? 1 : 0;
254 else if (maskDetector)
258 const auto firstDetIndex = spectrumInfo.firstDetectorIndex(i);
261 sp2detMap[i] = liveDetectorsCount;
262 detId[liveDetectorsCount] = int32_t(detectorInfo.detid(firstDetIndex));
263 detIDMap[liveDetectorsCount] = i;
264 L2[liveDetectorsCount] = spectrumInfo.l2(i);
266 double polar = spectrumInfo.twoTheta(i);
267 double azim = spectrumInfo.phi(i);
268 TwoTheta[liveDetectorsCount] = polar;
269 Azimuthal[liveDetectorsCount] = azim;
271 std::vector<int> warningDets;
272 auto diffConsts = spectrumInfo.diffractometerConstants(i, warningDets);
278 double sPhi = sin(polar);
279 double ez = cos(polar);
280 double ex = sPhi * cos(azim);
281 double ey = sPhi * sin(azim);
283 detDir[liveDetectorsCount].setX(ex);
284 detDir[liveDetectorsCount].setY(ey);
285 detDir[liveDetectorsCount].setZ(ez);
295 if (spectrumInfo.hasUniqueDetector(i)) {
297 const auto eFixed = componentInfo.getNumberParameter(firstDetIndex,
"eFixed");
299 Efi = eFixed.front();
300 }
catch (std::runtime_error &) {
304 *(pEfixedArray + liveDetectorsCount) =
static_cast<float>(Efi);
307 liveDetectorsCount++;
309 theProgress.
report(i,
"Preprocessing detectors");
311 targWS->logs()->addProperty<uint32_t>(
"ActualDetectorsNum", liveDetectorsCount,
true);
314 g_log.
information() <<
"Finished preprocessing detector locations. Found: " << liveDetectorsCount
315 <<
" detectors out of: " << nHist <<
" histograms\n";
354 targWS->logs()->addProperty<
double>(
"L1", 1.,
true);
356 targWS->logs()->addProperty<std::string>(
"InstrumentName",
"FakeInstrument",
true);
357 targWS->logs()->addProperty<
bool>(
"FakeDetectors",
true,
true);
360 auto &sp2detMap = targWS->getColVector<
size_t>(
"spec2detMap");
361 auto &detId = targWS->getColVector<int32_t>(
"DetectorID");
362 auto &detIDMap = targWS->getColVector<
size_t>(
"detIDMap");
363 auto &L2 = targWS->getColVector<
double>(
"L2");
364 auto &TwoTheta = targWS->getColVector<
double>(
"TwoTheta");
365 auto &Azimuthal = targWS->getColVector<
double>(
"Azimuthal");
366 auto &detDir = targWS->getColVector<
Kernel::V3D>(
"DetDirections");
370 size_t nHist = targWS->rowCount();
371 targWS->logs()->addProperty<uint32_t>(
"ActualDetectorsNum", uint32_t(nHist),
true);
375 for (
size_t i = 0; i < nHist; i++) {
377 detId[i] =
static_cast<detid_t>(i);