Newer
Older
Doucet, Mathieu
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidDataHandling/GetMaskedDetectors.h"
#include "MantidAPI/SpectraDetectorMap.h"
#include "MantidKernel/ArrayProperty.h"
#include <set>
namespace Mantid
{
namespace DataHandling
{
// Register the algorithm into the algorithm factory
DECLARE_ALGORITHM(GetMaskedDetectors)
using namespace Kernel;
using namespace API;
/// (Empty) Constructor
GetMaskedDetectors::GetMaskedDetectors() {}
/// Destructor
GetMaskedDetectors::~GetMaskedDetectors() {}
void GetMaskedDetectors::init()
{
declareProperty(
new WorkspaceProperty<>("InputWorkspace","", Direction::Input),
"The name of the workspace that will be used as input for the algorithm" );
declareProperty(new ArrayProperty<int>("DetectorList", new NullValidator<std::vector<int> >, Direction::Output),
"A coma separated list or array containing a list of masked detector ID's" );
}
void GetMaskedDetectors::exec()
{
// Get the input workspace
const MatrixWorkspace_sptr WS = getProperty("InputWorkspace");
// List masked of detector IDs
std::vector<int> detectorList;
// Loop through every spectrum and get the list of masked detector IDs
for ( int i=0; i<WS->getNumberHistograms(); i++ )
{
Geometry::IDetector_const_sptr det = WS->getDetector(i);
if ( det->isMasked() )
{
detectorList.push_back(i);
}
}
setProperty("DetectorList", detectorList);
}
} // namespace DataHandling
} // namespace Mantid