22 const std::string &instrumentName) {
23 auto instrument = std::make_shared<Instrument>(instrumentName);
24 instrument->setReferenceFrame(std::make_shared<ReferenceFrame>(
Y,
Z,
Right,
""));
26 const double pixelRadius(0.05);
30 const double detZPos(5.0);
32 auto ndets =
static_cast<int>(
workspace.getNumberHistograms());
35 for (
int i = 0; i < ndets; ++i) {
36 std::ostringstream lexer;
37 lexer <<
"pixel-" << i <<
")";
39 new Detector(lexer.str(),
workspace.getAxis(1)->spectraNo(i), pixelShape, instrument.get());
43 const double ypos = ycount * 2.0 * pixelRadius;
44 physicalPixel->
setPos(0.0, ypos, detZPos);
45 instrument->add(physicalPixel);
46 instrument->markAsDetector(physicalPixel);
47 instrument->setXmlText(
"Fake XML");
55 monitor1->
setPos(0.0, 0.0, -9.0);
56 instrument->add(monitor1);
57 instrument->markAsMonitor(monitor1);
58 workspace.getSpectrum(ndets).setDetectorID(ndets + 1);
62 monitor2->
setPos(0.0, 0.0, -2.0);
63 instrument->add(monitor2);
64 instrument->markAsMonitor(monitor2);
65 workspace.getSpectrum(ndets + 1).setDetectorID(ndets + 2);
73 instrument->add(source);
74 instrument->markAsSource(source);
78 instrument->setPos(0.0, 0.0, 0.0);
79 instrument->add(sample);
80 instrument->markAsSamplePos(sample);
83 instrument->add(chop_pos);
88 const int nlong,
const double anginc,
89 const std::string &instrumentName) {
90 V3D samplePosition(0., 0., 0.);
91 V3D sourcePosition(0., 0., -14.);
93 Instrument_sptr instrument = std::make_shared<Instrument>(instrumentName);
94 instrument->setReferenceFrame(
104 constexpr double deg2rad = M_PI / 180.0;
105 const double angincRad = anginc *
deg2rad;
106 constexpr double R = 1.0;
107 for (
int lat = 0; lat < nlat; ++lat) {
108 for (
int lng = 0; lng < nlong; ++lng) {
109 std::stringstream buffer;
110 buffer <<
"detector_" << i;
112 auto latrad = lat * angincRad;
113 auto longrad = lng * angincRad;
114 detPos[1] = R * sin(latrad);
115 const double ct = R * cos(latrad);
116 detPos[2] = ct * cos(longrad);
117 detPos[0] = ct * sin(longrad);
121 workspace.getSpectrum(i).addDetectorID(i);
125 instrument->add(compAss);
137 const std::string &
name) {
140 instrument->add(component);
151 const std::string &
name) {
153 instrument->markAsSamplePos(sample);
163 const std::string &
name) {
165 instrument->markAsSource(source);
176 const std::string &
name) {
179 instrument->add(monitor);
180 instrument->markAsMonitor(monitor);
196 instrument->markAsDetector(detector);
198 compAss->
add(detector);
200 instrument->add(detector);
IPeaksWorkspace_sptr workspace
Base MatrixWorkspace Abstract Class.
Component is a wrapper for a Component which can modify some of its parameters, e....
void setPos(double, double, double) override
Set the IComponent position, x, y, z respective to parent (if present)
This class represents a detector - i.e.
detid_t getID() const override
Gets the detector id.
Class for Assembly of geometric components.
int add(IComponent *) override
Add a component to the assembly.
Object Component class, this class brings together the physical attributes of the component to the po...
std::shared_ptr< Mantid::Geometry::CSGObject > createSphere(double radius, const Mantid::Kernel::V3D ¢re=Mantid::Kernel::V3D(), const std::string &id="sp-1")
Create a sphere object.
std::shared_ptr< Mantid::Geometry::CSGObject > createCuboid(double xHalfLength, double yHalfLength=-1.0, double zHalfLength=-1.0, const Mantid::Kernel::V3D ¢re={0.0, 0.0, 0.0}, const std::string &id="detector-shape")
Create a cuboid shape.
std::shared_ptr< Mantid::Geometry::CSGObject > createCappedCylinder(double radius, double height, const Mantid::Kernel::V3D &baseCentre, const Mantid::Kernel::V3D &axis, const std::string &id)
Create a capped cylinder object.
void addMonitor(Mantid::Geometry::Instrument_sptr &instrument, const Mantid::Kernel::V3D &position, const int ID, const std::string &name)
Adds a monitor to an instrument.
void addSource(Mantid::Geometry::Instrument_sptr &instrument, const Mantid::Kernel::V3D &position, const std::string &name)
Adds a source to an instrument.
void addFullInstrumentToWorkspace(Mantid::API::MatrixWorkspace &workspace, bool includeMonitors, bool startYNegative, const std::string &instrumentName)
void addInstrumentWithGeographicalDetectorsToWorkspace(Mantid::API::MatrixWorkspace &workspace, const int nlat, const int nlong, const double anginc, const std::string &instrumentName)
void addSample(Mantid::Geometry::Instrument_sptr &instrument, const Mantid::Kernel::V3D &position, const std::string &name)
Adds a sample to an instrument.
Mantid::Geometry::Component * addComponent(Mantid::Geometry::Instrument_sptr &instrument, const Mantid::Kernel::V3D &position, const std::string &name)
Adds a component to an instrument.
void addDetector(Mantid::Geometry::Instrument_sptr &instrument, const Mantid::Kernel::V3D &position, const int ID, const std::string &name, Mantid::Geometry::ObjCompAssembly *compAss=nullptr)
Adds a detector to an instrument.
std::shared_ptr< Instrument > Instrument_sptr
Shared pointer to an instrument object.
std::shared_ptr< IObject > IObject_sptr
Typdef for a shared pointer.
Helper class which provides the Collimation Length for SANS instruments.