13
13
#include " MantidDataHandling/LoadEventNexus.h"
14
14
#include " MantidDataHandling/LoadEventNexusIndexSetup.h"
15
15
#include " MantidDataObjects/EventList.h"
16
+ #include " MantidDataObjects/MaskWorkspace.h"
16
17
#include " MantidDataObjects/TableWorkspace.h"
17
18
#include " MantidDataObjects/Workspace2D.h"
18
19
#include " MantidDataObjects/WorkspaceCreation.h"
@@ -33,6 +34,7 @@ using Mantid::API::FileProperty;
33
34
using Mantid::API::ITableWorkspace_sptr;
34
35
using Mantid::API::MatrixWorkspace_sptr;
35
36
using Mantid::API::WorkspaceProperty;
37
+ using Mantid::DataObjects::MaskWorkspace_sptr;
36
38
using Mantid::DataObjects::Workspace2D;
37
39
using Mantid::Kernel::ArrayLengthValidator;
38
40
using Mantid::Kernel::ArrayProperty;
@@ -120,12 +122,15 @@ template <typename CountsType> class ProcessEventsTask {
120
122
public:
121
123
ProcessEventsTask (const Histogrammer *histogrammer, const std::vector<uint32_t > *detids,
122
124
const std::vector<float > *tofs, const AlignAndFocusPowderSlim::BankCalibration *calibration,
123
- std::vector<CountsType> *y_temp)
124
- : m_histogrammer(histogrammer), m_detids(detids), m_tofs(tofs), m_calibration(calibration), y_temp(y_temp) {}
125
+ std::vector<CountsType> *y_temp, const std::set<detid_t > *masked)
126
+ : m_histogrammer(histogrammer), m_detids(detids), m_tofs(tofs), m_calibration(calibration), y_temp(y_temp),
127
+ masked (masked) {}
125
128
126
129
void operator ()(const tbb::blocked_range<size_t > &range) const {
127
130
for (size_t i = range.begin (); i < range.end (); ++i) {
128
131
const auto detid = static_cast <detid_t >(m_detids->at (i));
132
+ if (masked->contains (detid))
133
+ continue ;
129
134
const auto tof = static_cast <double >(m_tofs->at (i)) * m_calibration->value (detid);
130
135
131
136
const auto binnum = m_histogrammer->findBin (tof);
@@ -140,6 +145,7 @@ template <typename CountsType> class ProcessEventsTask {
140
145
const std::vector<float > *m_tofs;
141
146
const AlignAndFocusPowderSlim::BankCalibration *m_calibration;
142
147
std::vector<CountsType> *y_temp;
148
+ const std::set<detid_t > *masked;
143
149
};
144
150
145
151
template <typename Type> class MinMax {
@@ -390,7 +396,8 @@ void AlignAndFocusPowderSlim::exec() {
390
396
addTimer (" setup" + entry_name, startTimeSetup, std::chrono::high_resolution_clock::now ());
391
397
392
398
const auto startTimeProcess = std::chrono::high_resolution_clock::now ();
393
- ProcessEventsTask task (&histogrammer, event_detid.get (), event_time_of_flight.get (), &calibration, &y_temp);
399
+ ProcessEventsTask task (&histogrammer, event_detid.get (), event_time_of_flight.get (), &calibration, &y_temp,
400
+ &m_masked);
394
401
tbb::parallel_for (tbb::blocked_range<size_t >(0 , numEvent), task);
395
402
auto &y_values = spectrum.dataY ();
396
403
std::copy (y_temp.cbegin (), y_temp.cend (), y_values.begin ());
@@ -525,7 +532,7 @@ void AlignAndFocusPowderSlim::loadCalFile(const Mantid::API::Workspace_sptr &inp
525
532
alg->setPropertyValue (" Filename" , filename);
526
533
alg->setProperty <bool >(" MakeCalWorkspace" , true );
527
534
alg->setProperty <bool >(" MakeGroupingWorkspace" , false );
528
- alg->setProperty <bool >(" MakeMaskWorkspace" , false );
535
+ alg->setProperty <bool >(" MakeMaskWorkspace" , true );
529
536
alg->setPropertyValue (" WorkspaceName" , " temp" );
530
537
alg->executeAsChildAlg ();
531
538
@@ -535,6 +542,10 @@ void AlignAndFocusPowderSlim::loadCalFile(const Mantid::API::Workspace_sptr &inp
535
542
const double detc = calibrationWS->cell <double >(row, 1 );
536
543
m_calibration.emplace (detid, 1 . / detc);
537
544
}
545
+
546
+ const MaskWorkspace_sptr maskWS = alg->getProperty (" OutputMaskWorkspace" );
547
+ m_masked = maskWS->getMaskedDetectors ();
548
+ g_log.debug () << " Masked detectors: " << m_masked.size () << ' \n ' ;
538
549
}
539
550
540
551
// ------------------------ BankCalibration object
0 commit comments