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);
54 monitor1->
setPos(0.0, 0.0, -9.0);
55 instrument->add(monitor1);
56 instrument->markAsMonitor(monitor1);
57 workspace.getSpectrum(ndets).setDetectorID(ndets + 1);
61 monitor2->
setPos(0.0, 0.0, -2.0);
62 instrument->add(monitor2);
63 instrument->markAsMonitor(monitor2);
64 workspace.getSpectrum(ndets + 1).setDetectorID(ndets + 2);
72 instrument->add(source);
73 instrument->markAsSource(source);
77 instrument->setPos(0.0, 0.0, 0.0);
78 instrument->add(sample);
79 instrument->markAsSamplePos(sample);
82 instrument->add(chop_pos);
87 const int nlong,
const double anginc,
88 const std::string &instrumentName) {
89 V3D samplePosition(0., 0., 0.);
90 V3D sourcePosition(0., 0., -14.);
92 Instrument_sptr instrument = std::make_shared<Instrument>(instrumentName);
93 instrument->setReferenceFrame(
103 constexpr double deg2rad = M_PI / 180.0;
104 const double angincRad = anginc *
deg2rad;
105 constexpr double R = 1.0;
106 for (
int lat = 0; lat < nlat; ++lat) {
107 for (
int lng = 0; lng < nlong; ++lng) {
108 std::stringstream buffer;
109 buffer <<
"detector_" << i;
111 auto latrad = lat * angincRad;
112 auto longrad = lng * angincRad;
113 detPos[1] = R * sin(latrad);
114 const double ct = R * cos(latrad);
115 detPos[2] = ct * cos(longrad);
116 detPos[0] = ct * sin(longrad);
120 workspace.getSpectrum(i).addDetectorID(i);
124 instrument->add(compAss);
136 const std::string &name) {
139 instrument->add(component);
150 const std::string &name) {
152 instrument->markAsSamplePos(sample);
162 const std::string &name) {
164 instrument->markAsSource(source);
175 const std::string &name) {
176 auto *monitor =
new Detector(name, ID,
nullptr);
178 instrument->add(monitor);
179 instrument->markAsMonitor(monitor);
195 instrument->markAsDetector(detector);
197 compAss->
add(detector);
199 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.