Mantid
Loading...
Searching...
No Matches
ComponentCreationHelper.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7/*********************************************************************************
8 * PLEASE READ THIS!!!!!!!
9 *
10 * This collection of functions MAY NOT be used in any test from a package
11 *below
12 * Geometry (e.g. Kernel).
13 * Conversely, this file MAY NOT be modified to use anything from a package
14 * higher than Geometry (e.g. API, DataObjects, ...)
15 *********************************************************************************/
16//------------------------------------------------------------------------------
17// Includes
18//------------------------------------------------------------------------------
34#include "MantidKernel/Matrix.h"
35#include "MantidKernel/Quat.h"
37#include "MantidKernel/V2D.h"
38
39#include <Poco/Path.h>
40#include <algorithm>
41#include <memory>
42
43using namespace Mantid::Geometry;
47
49//----------------------------------------------------------------------------------------------
50
54std::string cappedCylinderXML(double radius, double height, const Mantid::Kernel::V3D &baseCentre,
55 const Mantid::Kernel::V3D &axis, const std::string &id) {
56 std::ostringstream xml;
57 xml << "<cylinder id=\"" << id << "\">"
58 << "<centre-of-bottom-base x=\"" << baseCentre.X() << "\" y=\"" << baseCentre.Y() << "\" z=\"" << baseCentre.Z()
59 << "\"/>"
60 << "<axis x=\"" << axis.X() << "\" y=\"" << axis.Y() << "\" z=\"" << axis.Z() << "\"/>"
61 << "<radius val=\"" << radius << "\" />"
62 << "<height val=\"" << height << "\" />"
63 << "</cylinder>";
64 return xml.str();
65}
66
70std::shared_ptr<CSGObject> createCappedCylinder(double radius, double height, const V3D &baseCentre, const V3D &axis,
71 const std::string &id) {
72 return ShapeFactory().createShape(cappedCylinderXML(radius, height, baseCentre, axis, id));
73}
74
75void addSourceToInstrument(Instrument_sptr &instrument, const V3D &sourcePos, const std::string &name) {
76 ObjComponent *source = new ObjComponent(name, IObject_sptr(new CSGObject), instrument.get());
77 source->setPos(sourcePos);
78 instrument->add(source);
79 instrument->markAsSource(source);
80}
81//----------------------------------------------------------------------------------------------
82
86std::string hollowCylinderXML(double innerRadius, double outerRadius, double height,
87 const Mantid::Kernel::V3D &baseCentre, const Mantid::Kernel::V3D &axis,
88 const std::string &id) {
89 std::ostringstream xml;
90 xml << "<hollow-cylinder id=\"" << id << "\">"
91 << "<centre-of-bottom-base x=\"" << baseCentre.X() << "\" y=\"" << baseCentre.Y() << "\" z=\"" << baseCentre.Z()
92 << "\"/>"
93 << "<axis x=\"" << axis.X() << "\" y=\"" << axis.Y() << "\" z=\"" << axis.Z() << "\"/>"
94 << "<inner-radius val=\"" << innerRadius << "\" />"
95 << "<outer-radius val=\"" << outerRadius << "\" />"
96 << "<height val=\"" << height << "\" />"
97 << "</hollow-cylinder>";
98 return xml.str();
99}
100
104std::shared_ptr<CSGObject> createHollowCylinder(double innerRadius, double outerRadius, double height,
105 const V3D &baseCentre, const V3D &axis, const std::string &id) {
106 return ShapeFactory().createShape(hollowCylinderXML(innerRadius, outerRadius, height, baseCentre, axis, id));
107}
108
109void addSampleToInstrument(Instrument_sptr &instrument, const V3D &samplePos) {
110 Component *sample = new Component("sample", instrument.get());
111 instrument->setPos(samplePos);
112 instrument->add(sample);
113 instrument->markAsSamplePos(sample);
114}
115
116//----------------------------------------------------------------------------------------------
117
121std::string sphereXML(double radius, const V3D &centre, const std::string &id) {
122 std::ostringstream xml;
123 xml << "<sphere id=\"" << id << "\">"
124 << "<centre x=\"" << centre.X() << "\" y=\"" << centre.Y() << "\" z=\"" << centre.Z() << "\" />"
125 << "<radius val=\"" << radius << "\" />"
126 << "</sphere>";
127 return xml.str();
128}
129
133std::shared_ptr<CSGObject> createSphere(double radius, const V3D &centre, const std::string &id) {
134 ShapeFactory shapeMaker;
135 return shapeMaker.createShape(sphereXML(radius, centre, id));
136}
137
138std::string cuboidXML(double xHalfLength, double yHalfLength, double zHalfLength, const V3D &centrePos,
139 const std::string &id) {
140 const double szX = xHalfLength;
141 const double szY = (yHalfLength == -1.0 ? szX : yHalfLength);
142 const double szZ = (zHalfLength == -1.0 ? szX : zHalfLength);
143
144 // top\bottom along z
145 V3D leftFrontBottom{szX, -szY, -szZ};
146 V3D leftFrontTop{szX, -szY, szZ};
147 V3D leftBackBottom{-szX, -szY, -szZ};
148 V3D rightFrontBottom{szX, szY, -szZ};
149
150 leftFrontBottom += centrePos;
151 leftFrontTop += centrePos;
152 leftBackBottom += centrePos;
153 rightFrontBottom += centrePos;
154
155 std::ostringstream xmlShapeStream;
156 xmlShapeStream << " <cuboid id=\"" << id << "\"> "
157 << "<left-front-bottom-point x=\"" << leftFrontBottom.X() << "\" y=\"" << leftFrontBottom.Y()
158 << "\" z=\"" << leftFrontBottom.Z() << "\" /> "
159 << "<left-front-top-point x=\"" << leftFrontTop.X() << "\" y=\"" << leftFrontTop.Y() << "\" z=\""
160 << leftFrontTop.Z() << "\" /> "
161 << "<left-back-bottom-point x=\"" << leftBackBottom.X() << "\" y=\"" << leftBackBottom.Y()
162 << "\" z=\"" << leftBackBottom.Z() << "\" /> "
163 << "<right-front-bottom-point x=\"" << rightFrontBottom.X() << "\" y=\"" << rightFrontBottom.Y()
164 << "\" z=\"" << rightFrontBottom.Z() << "\" /> "
165 << "</cuboid>";
166
167 return xmlShapeStream.str();
168}
169
170//----------------------------------------------------------------------------------------------
172std::shared_ptr<CSGObject> createCuboid(double xHalfLength, double yHalfLength, double zHalfLength,
173 const V3D &centrePos, const std::string &id) {
174 ShapeFactory shapeCreator;
175 return shapeCreator.createShape(cuboidXML(xHalfLength, yHalfLength, zHalfLength, centrePos, id));
176}
177
188std::shared_ptr<CSGObject> createCuboid(double xHalfLength, double yHalfLength, double zHalfLength, double angle,
189 const Mantid::Kernel::V3D &axis) {
190 // top\bottom along z
191 V3D leftFrontBottom{xHalfLength, -yHalfLength, -zHalfLength};
192 V3D leftFrontTop{xHalfLength, -yHalfLength, zHalfLength};
193 V3D leftBackBottom{-xHalfLength, -yHalfLength, -zHalfLength};
194 V3D rightFrontBottom{xHalfLength, yHalfLength, -zHalfLength};
195 Quat rotation(angle, axis);
197 leftFrontBottom.rotate(rotMatrix);
198 leftFrontTop.rotate(rotMatrix);
199 leftBackBottom.rotate(rotMatrix);
200 rightFrontBottom.rotate(rotMatrix);
201 std::ostringstream xmlShapeStream;
202 xmlShapeStream << " <cuboid id=\"detector-shape\"> "
203 << "<left-front-bottom-point x=\"" << leftFrontBottom.X() << "\" y=\"" << leftFrontBottom.Y()
204 << "\" z=\"" << leftFrontBottom.Z() << "\" /> "
205 << "<left-front-top-point x=\"" << leftFrontTop.X() << "\" y=\"" << leftFrontTop.Y() << "\" z=\""
206 << leftFrontTop.Z() << "\" /> "
207 << "<left-back-bottom-point x=\"" << leftBackBottom.X() << "\" y=\"" << leftBackBottom.Y()
208 << "\" z=\"" << leftBackBottom.Z() << "\" /> "
209 << "<right-front-bottom-point x=\"" << rightFrontBottom.X() << "\" y=\"" << rightFrontBottom.Y()
210 << "\" z=\"" << rightFrontBottom.Z() << "\" /> "
211 << "</cuboid>";
212
213 std::string xmlCuboidShape(xmlShapeStream.str());
214 ShapeFactory shapeCreator;
215 auto cuboidShape = shapeCreator.createShape(xmlCuboidShape);
216 return cuboidShape;
217}
218
219//----------------------------------------------------------------------------------------------
223std::shared_ptr<CompAssembly> createTestAssemblyOfFourCylinders() {
224 std::shared_ptr<CompAssembly> bank = std::make_shared<CompAssembly>("BankName");
225 // One object
226 auto pixelShape =
227 ComponentCreationHelper::createCappedCylinder(0.5, 1.5, V3D(0.0, 0.0, 0.0), V3D(0., 1.0, 0.), "tube");
228 // Four object components
229 for (size_t i = 1; i < 5; ++i) {
230 ObjComponent *physicalPixel = new ObjComponent("pixel", pixelShape);
231 physicalPixel->setPos(static_cast<double>(i), 0.0, 0.0);
232 bank->add(physicalPixel);
233 }
234
235 return bank;
236}
237
242std::shared_ptr<CSGObject> createHollowShell(double innerRadius, double outerRadius, const V3D &centre) {
243 std::string wholeXML = sphereXML(innerRadius, centre, "inner") + "\n" + sphereXML(outerRadius, centre, "outer") +
244 "\n" + "<algebra val=\"(outer (# inner))\" />";
245
246 ShapeFactory shapeMaker;
247 return shapeMaker.createShape(wholeXML);
248}
249
250//----------------------------------------------------------------------------------------------
254std::shared_ptr<DetectorGroup> createDetectorGroupWith5CylindricalDetectors() {
255 const int ndets = 5;
256 std::vector<std::shared_ptr<const IDetector>> groupMembers(ndets);
257 // One object
258 auto detShape = ComponentCreationHelper::createCappedCylinder(0.5, 1.5, V3D(0.0, 0.0, 0.0), V3D(0., 1.0, 0.), "tube");
259 for (int i = 0; i < ndets; ++i) {
260 std::ostringstream os;
261 os << "d" << i;
262 auto det = std::make_shared<Detector>(os.str(), i + 1, detShape, nullptr);
263 det->setPos(static_cast<double>(i + 1), 2.0, 2.0);
264 groupMembers[i] = det;
265 }
266
267 return std::make_shared<DetectorGroup>(groupMembers);
268}
269
270//----------------------------------------------------------------------------------------------
274std::shared_ptr<DetectorGroup> createDetectorGroupWithNCylindricalDetectorsWithGaps(unsigned int nDet, double gap) {
275
276 std::vector<std::shared_ptr<const IDetector>> groupMembers(nDet);
277 // One object
278 auto detShape = ComponentCreationHelper::createCappedCylinder(0.5, 1.5, V3D(0.0, 0.0, 0.0), V3D(0., 1.0, 0.), "tube");
279 for (unsigned int i = 0; i < nDet; ++i) {
280 std::ostringstream os;
281 os << "d" << i;
282 auto det = std::make_shared<Detector>(os.str(), i + 1, detShape, nullptr);
283 det->setPos(double(-0.5 * nDet + i) + gap, 2.0, 2.0);
284 groupMembers[i] = det;
285 }
286
287 return std::make_shared<DetectorGroup>(groupMembers);
288}
289
290std::vector<std::unique_ptr<IDetector>> createVectorOfCylindricalDetectors(const double R_min, const double R_max,
291 const double z0) {
292 std::vector<std::unique_ptr<IDetector>> allDetectors;
293 // One object
294 double R0 = 0.5;
295 double h = 1.5;
296 auto detShape = ComponentCreationHelper::createCappedCylinder(R0, h, V3D(0.0, 0.0, 0.0), V3D(0., 1.0, 0.), "tube");
297
298 auto NY = int(ceil(2 * R_max / h) + 1);
299 auto NX = int(ceil(2 * R_max / R0) + 1);
300 double y_bl = NY * h;
301 double x_bl = NX * R0;
302
303 double Rmin2(R_min * R_min), Rmax2(R_max * R_max);
304
305 int ic(0);
306 for (int j = 0; j < NY; j++) {
307 double y = -0.5 * y_bl + j * h;
308 for (int i = 0; i < NX; i++) {
309 double x = -0.5 * x_bl + i * R0;
310 double Rsq = x * x + y * y;
311 if (Rsq >= Rmin2 && Rsq < Rmax2) {
312 std::ostringstream os;
313 os << "d" << ic;
314 auto det = std::make_unique<Detector>(os.str(), ic + 1, detShape, nullptr);
315 det->setPos(x, y, z0);
316 allDetectors.emplace_back(std::move(det));
317 }
318
319 ic++;
320 }
321 }
322 return allDetectors;
323}
324
325//----------------------------------------------------------------------------------------------
329std::shared_ptr<DetectorGroup> createRingOfCylindricalDetectors(const double R_min, const double R_max,
330 const double z0) {
331
332 auto vecOfDetectors = createVectorOfCylindricalDetectors(R_min, R_max, z0);
333 std::vector<std::shared_ptr<const IDetector>> groupMembers;
334 groupMembers.reserve(vecOfDetectors.size());
335 std::transform(vecOfDetectors.begin(), vecOfDetectors.end(), std::back_inserter(groupMembers),
336 [](auto &det) { return std::move(det); });
337 return std::make_shared<DetectorGroup>(std::move(groupMembers));
338}
339
341 const Mantid::Kernel::V3D &samplePos, const double cylRadius,
342 const double cylHeight) {
343 auto testInst = std::make_shared<Instrument>("basic");
344
345 // One object
346 auto pixelShape = ComponentCreationHelper::createCappedCylinder(cylRadius, cylHeight, V3D(0.0, -cylHeight / 2.0, 0.0),
347 V3D(0., 1.0, 0.), "pixel-shape");
348
349 // Just increment pixel IDs
350 int pixelID = 1;
351
352 for (int banknum = 1; banknum <= num_banks; banknum++) {
353 // Make a new bank
354 std::ostringstream bankname;
355 bankname << "bank" << banknum;
356 CompAssembly *bank = new CompAssembly(bankname.str());
357
358 // Nine object components
359 for (int i = -1; i < 2; ++i) {
360 for (int j = -1; j < 2; ++j) {
361 std::ostringstream lexer;
362 lexer << "pixel-(" << j << ";" << i << ")";
363 Detector *physicalPixel = new Detector(lexer.str(), pixelID, pixelShape, bank);
364 const double xpos = j * (cylRadius * 2.0);
365 const double ypos = i * cylHeight;
366 physicalPixel->setPos(xpos, ypos, 0.0);
367 pixelID++;
368 bank->add(physicalPixel);
369 testInst->markAsDetector(physicalPixel);
370 }
371 }
372
373 testInst->add(bank);
374 bank->setPos(V3D(0.0, 0.0, 5.0 * banknum));
375 }
376
377 addSourceToInstrument(testInst, sourcePos);
378 addSampleToInstrument(testInst, samplePos);
379
380 return testInst;
381}
382
384createCylInstrumentWithVerticalOffsetsSpecified(size_t nTubes, const std::vector<double> &verticalOffsets,
385 size_t nDetsPerTube, double xMin, double xMax, double yMin,
386 double yMax) {
387 // Pixel shape
388 const double ySpan = (yMax - yMin);
389 const double xSpan = (xMax - xMin);
390 const double tubeDiameter = xSpan / static_cast<double>(nTubes); // No gaps between tubes
391 const double cylRadius = tubeDiameter / 2; // No gaps between tubes
392 const double cylHeight = ySpan / static_cast<double>(nDetsPerTube);
393 const double bankZPos = 2;
394 const double sourceZPos = -10;
395 const double sampleZPos = 0;
396
397 auto pixelShape = ComponentCreationHelper::createCappedCylinder(cylRadius, cylHeight, V3D(0.0, 0.0, 0.0),
398 V3D(0., 1.0, 0.), "pixel-shape");
399 auto instrument = std::make_shared<Instrument>("instrument_with_tubes");
400 CompAssembly *bank = new CompAssembly("sixteenpack");
401 for (size_t i = 0; i < nTubes; ++i) {
402 ObjCompAssembly *tube = new ObjCompAssembly("tube" + std::to_string(i));
403 for (size_t j = 0; j < nDetsPerTube; ++j) {
404
405 auto id = static_cast<int>(i * nDetsPerTube + j);
406 Detector *physicalPixel = new Detector("det-" + std::to_string(id), id, pixelShape, tube);
407 tube->add(physicalPixel);
408 physicalPixel->setPos(V3D(0, static_cast<double>(j) * cylHeight, 0));
409 instrument->markAsDetector(physicalPixel);
410 }
411 tube->setPos(V3D(xMin + static_cast<double>(i) * tubeDiameter, -ySpan / 2 + verticalOffsets[i], 0));
412 tube->setOutline(tube->createOutline());
413 bank->add(tube);
414 }
415 bank->setPos(V3D(0, 0, bankZPos));
416 instrument->add(bank);
417 instrument->setReferenceFrame(
418 std::make_shared<ReferenceFrame>(Mantid::Geometry::Y /*up*/, Mantid::Geometry::Z /*along*/, Left, "0,0,0"));
419 addSourceToInstrument(instrument, V3D(0, 0, sourceZPos));
420 addSampleToInstrument(instrument, V3D(0, 0, sampleZPos));
421 return instrument;
422}
423
428bool double_cmprsn(double x1, double x2) {
429 const double TOL(1.e-4);
431}
433 const std::vector<double> &polar,
434 const std::vector<double> &azim) {
435
436 auto testInst = std::make_shared<Instrument>("processed");
437 // find characteristic sizes of the detectors;
438 double dAzi_min(FLT_MAX);
439 double dPol_min(FLT_MAX);
440 double L2_min(FLT_MAX);
441 double dAzi, dPol;
442 std::vector<double> az(azim);
443 std::vector<double> po(polar);
444 std::sort(az.begin(), az.end());
445 std::sort(po.begin(), po.end());
446 // very crude identification of interdetector distance; no need in more
447 // accurate caluclations for example;
448 for (size_t i = 0; i < L2.size(); i++) {
449 if (L2[i] < L2_min)
450 L2_min = L2[i];
451 for (size_t j = i + 1; j < L2.size(); j++) {
452 if (!double_cmprsn(az[i], az[j])) {
453 dAzi = std::fabs(az[i] - az[j]);
454 if (dAzi < dAzi_min)
455 dAzi_min = dAzi;
456 }
457 if (!double_cmprsn(po[i], po[j])) {
458 dPol = std::fabs(po[i] - po[j]);
459 if (dPol < dPol_min)
460 dPol_min = dPol;
461 }
462 }
463 }
464 double cylRadius = L2_min * sin(dAzi_min * 0.5);
465 double cylHeight = 2 * L2_min * sin(dPol_min * 0.5);
466
467 // One object
468 auto pixelShape = ComponentCreationHelper::createCappedCylinder(cylRadius, cylHeight, V3D(0.0, -cylHeight / 2.0, 0.0),
469 V3D(0., 1.0, 0.), "pixel-shape");
470 // Just increment pixel ID's
471 int pixelID = 1;
472 // one bank
473 CompAssembly *bank = new CompAssembly("det_ass");
474
475 for (size_t i = 0; i < azim.size(); i++) {
476 Detector *physicalPixel = new Detector("det" + std::to_string(i), pixelID, pixelShape, bank);
477 double zpos = L2[i] * cos(polar[i]);
478 double xpos = L2[i] * sin(polar[i]) * cos(azim[i]);
479 double ypos = L2[i] * sin(polar[i]) * sin(azim[i]);
480 physicalPixel->setPos(xpos, ypos, zpos);
481 pixelID++;
482 bank->add(physicalPixel);
483 testInst->markAsDetector(physicalPixel);
484 }
485 testInst->add(bank);
486 bank->setPos(V3D(0., 0., 0.));
487
488 addSourceToInstrument(testInst, V3D(0.0, 0.0, -L2_min));
489 addSampleToInstrument(testInst, V3D(0.0, 0.0, 0.0));
490
491 return testInst;
492}
493
494//----------------------------------------------------------------------------------------------
495
496void addRectangularBank(Instrument &testInstrument, int idStart, int pixels, double pixelSpacing,
497 const std::string &bankName, const V3D &bankPos, const Quat &bankRot) {
498
499 const double cylRadius(pixelSpacing / 2);
500 const double cylHeight(0.0002);
501 // One object
502 auto pixelShape = ComponentCreationHelper::createCappedCylinder(cylRadius, cylHeight, V3D(0.0, -cylHeight / 2.0, 0.0),
503 V3D(0., 1.0, 0.), "pixel-shape");
504
505 auto *bank = new RectangularDetector(bankName);
506 bank->initialize(pixelShape, pixels, 0.0, pixelSpacing, pixels, 0.0, pixelSpacing, idStart, true, pixels);
507
508 // Mark them all as detectors
509 for (int x = 0; x < pixels; x++)
510 for (int y = 0; y < pixels; y++) {
511 std::shared_ptr<Detector> detector = bank->getAtXY(x, y);
512 if (detector)
513 // Mark it as a detector (add to the instrument cache)
514 testInstrument.markAsDetector(detector.get());
515 }
516
517 testInstrument.add(bank);
518 bank->setPos(bankPos);
519 bank->setRot(bankRot);
520}
521
522//----------------------------------------------------------------------------------------------
538Instrument_sptr createTestInstrumentRectangular(int num_banks, int pixels, double pixelSpacing,
539 double bankDistanceFromSample, bool addMonitor,
540 const std::string &instrumentName) {
541 auto testInst = std::make_shared<Instrument>(instrumentName);
542
543 for (int banknum = 1; banknum <= num_banks; banknum++) {
544 // Make a new bank
545 std::ostringstream bankName;
546 bankName << "bank" << banknum;
547 V3D bankPos(0.0, 0.0, bankDistanceFromSample * banknum);
548 Quat bankRot{}; // Identity
549 addRectangularBank(*testInst, banknum * pixels * pixels, pixels, pixelSpacing, bankName.str(), bankPos, bankRot);
550 }
551
552 if (addMonitor) {
553 // A monitor
554 auto *mon = new Detector("test-monitor", 2 /*detector id*/, nullptr);
555 testInst->add(mon);
556 testInst->markAsMonitor(mon);
557 }
558
559 addSourceToInstrument(testInst, V3D(0.0, 0.0, -10.0), "source");
560 addSampleToInstrument(testInst, V3D(0.0, 0.0, 0.0));
561
562 return testInst;
563}
564
565//----------------------------------------------------------------------------------------------
577Instrument_sptr createTestInstrumentRectangular2(int num_banks, int pixels, double pixelSpacing) {
578
579 const auto instrName = "basic_rect";
580 auto testInst = std::make_shared<Instrument>(instrName);
581
582 const double cylRadius(pixelSpacing / 2);
583 const double cylHeight(0.0002);
584 // One object
585 auto pixelShape = ComponentCreationHelper::createCappedCylinder(cylRadius, cylHeight, V3D(0.0, -cylHeight / 2.0, 0.0),
586 V3D(0., 1.0, 0.), "pixel-shape");
587
588 for (int banknum = 1; banknum <= num_banks; banknum++) {
589 // Make a new bank
590 std::ostringstream bankname;
591 bankname << "bank" << banknum;
592 auto *bank = new RectangularDetector(bankname.str());
593 bank->initialize(pixelShape, pixels, -pixels * pixelSpacing / 2.0, pixelSpacing, pixels,
594 -pixels * pixelSpacing / 2.0, pixelSpacing, (banknum - 1) * pixels * pixels, true, pixels);
595
596 // Mark them all as detectors
597 for (int x = 0; x < pixels; x++)
598 for (int y = 0; y < pixels; y++) {
599 std::shared_ptr<Detector> detector = bank->getAtXY(x, y);
600 if (detector)
601 // Mark it as a detector (add to the instrument cache)
602 testInst->markAsDetector(detector.get());
603 }
604
605 testInst->add(bank);
606 // Place the center.
607 bank->setPos(V3D(1.0 * banknum, 0.0, 0.0));
608 // rotate detector 90 degrees along vertical
609 bank->setRot(Quat(90.0, V3D(0, 1, 0)));
610 }
611
612 addSourceToInstrument(testInst, V3D(0.0, 0.0, -10.0));
613 addSampleToInstrument(testInst, V3D(0.0, 0.0, 0.0));
614
615 return testInst;
616}
617
629Instrument_sptr createTestUnnamedRectangular2(int num_banks, int pixels, double pixelSpacing) {
630 auto testInst = std::make_shared<Instrument>("");
631
632 const double cylRadius(pixelSpacing / 2);
633 const double cylHeight(0.0002);
634 // One object
635 auto pixelShape = ComponentCreationHelper::createCappedCylinder(cylRadius, cylHeight, V3D(0.0, -cylHeight / 2.0, 0.0),
636 V3D(0., 1.0, 0.), "pixel-shape");
637
638 for (int banknum = 1; banknum <= num_banks; banknum++) {
639 // Make a new bank
640 std::ostringstream bankname;
641 bankname << "";
642
643 RectangularDetector *bank = new RectangularDetector(bankname.str());
644 bank->initialize(pixelShape, pixels, -pixels * pixelSpacing / 2.0, pixelSpacing, pixels,
645 -pixels * pixelSpacing / 2.0, pixelSpacing, (banknum - 1) * pixels * pixels, true, pixels);
646
647 // Mark them all as detectors
648 for (int x = 0; x < pixels; x++)
649 for (int y = 0; y < pixels; y++) {
650 std::shared_ptr<Detector> detector = bank->getAtXY(x, y);
651 if (detector)
652 // Mark it as a detector (add to the instrument cache)
653 testInst->markAsDetector(detector.get());
654 }
655
656 testInst->add(bank);
657 // Place the center.
658 bank->setPos(V3D(1.0 * banknum, 0.0, 0.0));
659 // rotate detector 90 degrees along vertical
660 bank->setRot(Quat(90.0, V3D(0, 1, 0)));
661 }
662
663 addSourceToInstrument(testInst, V3D(0.0, 0.0, -10.0));
664 addSampleToInstrument(testInst, V3D(0.0, 0.0, 0.0));
665
666 return testInst;
667}
668
675 Instrument_sptr instrument = std::make_shared<Instrument>();
676
677 V3D place_holder_pos(0, 0, 0);
678
679 // A source
680 ObjComponent *place_holder_0 = new ObjComponent("place_holder");
681 place_holder_0->setPos(place_holder_pos);
682 place_holder_0->setShape(createSphere(0.01, V3D(0, 0, 0), "1"));
683 instrument->add(place_holder_0);
684 instrument->markAsSource(place_holder_0);
685
686 // A sample
687 Component *place_holder_1 = new Component("place_holder");
688 place_holder_1->setPos(place_holder_pos);
689 instrument->add(place_holder_1);
690 instrument->markAsSamplePos(place_holder_1);
691
692 return instrument;
693}
708 const Mantid::Kernel::V3D &detectorPos) {
709 Instrument_sptr instrument = std::make_shared<Instrument>();
710 instrument->setReferenceFrame(
711 std::make_shared<ReferenceFrame>(Mantid::Geometry::Y /*up*/, Mantid::Geometry::X /*along*/, Left, "0,0,0"));
712
713 // A source
714 ObjComponent *source = new ObjComponent("source");
715 source->setPos(sourcePos);
716 source->setShape(createSphere(0.01 /*1cm*/, V3D(0, 0, 0), "1"));
717 instrument->add(source);
718 instrument->markAsSource(source);
719
720 // A sample
721 Component *sample = new Component("some-surface-holder");
722 sample->setPos(samplePos);
723 instrument->add(sample);
724 instrument->markAsSamplePos(sample);
725
726 // A detector
727 Detector *det = new Detector("point-detector", 1 /*detector id*/, nullptr);
728 det->setPos(detectorPos);
729 det->setShape(createSphere(0.01 /*1cm*/, V3D(0, 0, 0), "1"));
730 instrument->add(det);
731 instrument->markAsDetector(det);
732
733 return instrument;
734}
735
748 const Mantid::Kernel::Quat &monitorRot) {
749 Instrument_sptr instrument = std::make_shared<Instrument>();
750 instrument->setReferenceFrame(
751 std::make_shared<ReferenceFrame>(Mantid::Geometry::Y /*up*/, Mantid::Geometry::X /*along*/, Left, "0,0,0"));
752
753 instrument->setName("test-instrument-with-monitor");
754
755 // A source
756 auto *source = new ObjComponent("source");
757 source->setPos(V3D(-10, 0, 0));
758 source->setShape(createSphere(0.01 /*1cm*/, V3D(0, 0, 0), "1"));
759 instrument->add(source);
760 instrument->markAsSource(source);
761
762 // A sample
763 auto *sample = new Component("some-surface-holder");
764 sample->setPos(V3D(0, 0, 0));
765 instrument->add(sample);
766 instrument->markAsSamplePos(sample);
767
768 // A detector
769 auto *det = new Detector("point-detector", 1 /*detector id*/, nullptr);
770 det->setPos(V3D(0, 0, 10));
771 det->setShape(createSphere(0.01 /*1cm*/, V3D(0, 0, 0), "1"));
772 instrument->add(det);
773 instrument->markAsDetector(det);
774
775 // A monitor
776 auto *mon = new Detector("test-monitor", 2 /*detector id*/, nullptr);
777 mon->setPos(monitorPos);
778 mon->setRot(monitorRot);
779 mon->setShape(createSphere(0.01 /*1cm*/, V3D(0, 0, 0), "1"));
780 instrument->add(mon);
781 instrument->markAsMonitor(mon);
782
783 return instrument;
784}
785
786/*
787An instrument creation helper allowing you to include/omit
788source/sample for unit test of exception handling.
789*
790* @param haveSource : bool option to have source in instrument
791* @param haveSample : bool option to have sample in instrument
792* @param haveDetector : bool option to have detector in instrument
793*/
794Instrument_sptr createInstrumentWithOptionalComponents(bool haveSource, bool haveSample, bool haveDetector) {
795
796 Instrument_sptr instrument = std::make_shared<Instrument>();
797
798 // A source
799 if (haveSource) {
800 ObjComponent *source = new ObjComponent("source");
801
802 instrument->add(source);
803 instrument->markAsSource(source);
804 }
805
806 // A sample
807 if (haveSample) {
808 Component *sample = new Component("some-sample");
809
810 instrument->add(sample);
811 instrument->markAsSamplePos(sample);
812 }
813
814 // A detector
815 if (haveDetector) {
816 Detector *det = new Detector("point-detector", 1 /*detector id*/, nullptr);
817
818 instrument->add(det);
819 instrument->markAsDetector(det);
820 }
821
822 return instrument;
823}
824
842 const Mantid::Kernel::V3D &samplePos,
843 const Mantid::Kernel::V3D &detectorPos,
844 const Mantid::Kernel::Quat &relativeBankRotation,
845 const Mantid::Kernel::Quat &relativeDetRotation,
846 const Mantid::Kernel::V3D &detOffset) {
847 Instrument_sptr instrument = std::make_shared<Instrument>();
848 instrument->setReferenceFrame(
849 std::make_shared<ReferenceFrame>(Mantid::Geometry::Y /*up*/, Mantid::Geometry::Z /*along*/, Left, "0,0,0"));
850
851 instrument->setName("test-instrument-with-detector-rotations");
852
853 // A source
854 ObjComponent *source = new ObjComponent("source");
855 source->setPos(sourcePos);
856 source->setShape(createSphere(0.01 /*1cm*/, V3D(0, 0, 0), "1"));
857 instrument->add(source);
858 instrument->markAsSource(source);
859
860 // A sample
861 Component *sample = new Component("some-surface-holder");
862 sample->setPos(samplePos);
863 instrument->add(sample);
864 instrument->markAsSamplePos(sample);
865
866 // A detector
867 Detector *det = new Detector("point-detector", 1 /*detector id*/, nullptr);
868 det->setPos(detOffset); // defaults to {0,0,0} if no input
869 det->setShape(createSphere(0.01 /*1cm*/, V3D(0, 0, 0), "1"));
870 det->setRot(relativeDetRotation);
871 instrument->markAsDetector(det);
872
873 auto compAss = new ObjCompAssembly("detector-stage");
874 compAss->add(det);
875 compAss->setPos(detectorPos);
876 compAss->setRot(relativeBankRotation);
877
878 instrument->add(compAss);
879
880 return instrument;
881}
882
897 const Mantid::Kernel::V3D &samplePos,
898 const Mantid::Kernel::V3D &detectorPos,
899 const Mantid::Kernel::Quat &relativeSourceRotation) {
900 Instrument_sptr instrument = std::make_shared<Instrument>();
901 instrument->setReferenceFrame(
902 std::make_shared<ReferenceFrame>(Mantid::Geometry::Y /*up*/, Mantid::Geometry::Z /*along*/, Left, "0,0,0"));
903
904 instrument->setName("test-instrument");
905
906 // A source
907 ObjComponent *source = new ObjComponent("source");
908 source->setPos(sourcePos);
909 source->setShape(createSphere(0.01 /*1cm*/, V3D(0, 0, 0), "1"));
910 source->setRot(relativeSourceRotation);
911 instrument->add(source);
912 instrument->markAsSource(source);
913
914 // A sample
915 Component *sample = new Component("some-surface-holder");
916 sample->setPos(samplePos);
917 instrument->add(sample);
918 instrument->markAsSamplePos(sample);
919
920 // A detector
921 Detector *det = new Detector("point-detector", 1 /*detector id*/, nullptr);
922 det->setPos({0, 0, 0}); // No offset relative to parent CompAssembly
923 det->setShape(createSphere(0.01 /*1cm*/, V3D(0, 0, 0), "1"));
924 instrument->markAsDetector(det);
925
926 auto compAss = new ObjCompAssembly("detector-stage");
927 compAss->add(det);
928 compAss->setPos(detectorPos);
929
930 instrument->add(compAss);
931
932 return instrument;
933}
934
935CompAssembly *makeBank(size_t width, size_t height, Instrument *instrument) {
936
937 auto width_d = double(width);
938 auto height_d = double(height);
939 static int bankNo = 1;
940 auto bank = new CompAssembly("Bank" + std::to_string(bankNo++));
941 static size_t id = 1;
942 for (size_t i = 0; i < width; ++i) {
943 for (size_t j = 0; j < height; ++j) {
944 Detector *det = new Detector("pixel", int(id++) /*detector id*/, bank);
945 det->setPos(V3D{double(i), double(j), double(0)});
946 det->setShape(createSphere(0.01 /*1cm*/, V3D(0, 0, 0), "1"));
947 bank->add(det);
948 instrument->markAsDetector(det);
949 }
950 }
951 bank->setPos(V3D{width_d / 2, height_d / 2, 0});
952
953 return bank;
954}
955
957 const Mantid::Kernel::V3D &trolley1Pos, const Mantid::Kernel::V3D &trolley2Pos) {
958
959 /*
960 This has been generated for comparison with newer Instrument designs. It is
961 therefore not
962 an exact representation of an instrument one might expect to create for SANS.
963 */
964 auto instrument = std::make_shared<Instrument>();
965
966 instrument->setReferenceFrame(
967 std::make_shared<ReferenceFrame>(Mantid::Geometry::Y /*up*/, Mantid::Geometry::Z /*along*/, Left, "0,0,0"));
968
969 addSourceToInstrument(instrument, sourcePos);
970 addSampleToInstrument(instrument, samplePos);
971
972 size_t width = 100;
973 size_t height = 100;
974
975 CompAssembly *trolley1 = new CompAssembly("Trolley1");
976 trolley1->setPos(trolley1Pos);
977 CompAssembly *trolley2 = new CompAssembly("Trolley2");
978 trolley2->setPos(trolley2Pos);
979
980 CompAssembly *N = makeBank(width, height, instrument.get());
981 trolley1->add(N);
982 CompAssembly *E = makeBank(width, height, instrument.get());
983 trolley1->add(E);
984 CompAssembly *S = makeBank(width, height, instrument.get());
985 trolley1->add(S);
986 CompAssembly *W = makeBank(width, height, instrument.get());
987 trolley1->add(W);
988
989 CompAssembly *l_curtain = makeBank(width, height, instrument.get());
990 trolley2->add(l_curtain);
991 CompAssembly *r_curtain = makeBank(width, height, instrument.get());
992 trolley2->add(r_curtain);
993
994 instrument->add(trolley1);
995 instrument->add(trolley2);
996 return instrument;
997}
998
999Mantid::Geometry::Instrument_sptr createInstrumentWithPSDTubes(const size_t nTubes, const size_t nPixelsPerTube,
1000 bool mirrorTubes) {
1001 // Need a tube based instrument.
1002 //
1003 // Pixels will be numbered simply from 1->nTubes*nPixelsPerTube with a 1:1
1004 // mapping
1005 //
1006 // Tubes will be located at 1 m from the sample (0, 0, 0) from 0 -> 90 deg
1007 // If mirror is set to true they will go from 0 -> -90 deg
1008 Instrument_sptr testInst(new Instrument("PSDTubeInst"));
1009 int xDirection(1);
1010 if (mirrorTubes)
1011 xDirection = -1;
1012
1013 testInst->setReferenceFrame(
1014 std::make_shared<ReferenceFrame>(Mantid::Geometry::Y, Mantid::Geometry::Z, Mantid::Geometry::X, Right, "0,0,0"));
1015
1016 // Pixel shape
1017 const double pixelRadius(0.01);
1018 const double pixelHeight(0.003);
1019 const double radius(1.0);
1020 const auto pixelShape = ComponentCreationHelper::createCappedCylinder(
1021 pixelRadius, pixelHeight, V3D(0.0, -0.5 * pixelHeight, 0.0), V3D(0.0, 1.0, 0.0), "pixelShape");
1022
1023 const auto tubeShape = ComponentCreationHelper::createCappedCylinder(
1024 pixelRadius, pixelHeight, V3D(0.0, -0.5 * pixelHeight * (double)nPixelsPerTube, 0.0), V3D(0.0, 1.0, 0.0),
1025 "tubeShape");
1026
1027 for (size_t i = 0; i < nTubes; ++i) {
1028 std::ostringstream lexer;
1029 lexer << "tube-" << i;
1030 const auto theta = (M_PI / 2.0) * double(i) / (double(nTubes) - 1);
1031 auto x = xDirection * radius * sin(theta);
1032 // A small correction to make testing easier where the instrument is
1033 // mirrored
1034 if (i == 0 && xDirection < 0)
1035 x = -1e-32;
1036 const auto z = radius * cos(theta);
1037 ObjCompAssembly *tube = new ObjCompAssembly(lexer.str());
1038 tube->setShape(tubeShape);
1039 tube->setPos(V3D(x, 0.0, z));
1040 for (size_t j = 0; j < nPixelsPerTube; ++j) {
1041 lexer.str("");
1042 lexer << "pixel-" << i * nPixelsPerTube + j;
1043 Detector *pixel = new Detector(lexer.str(), int(i * nPixelsPerTube + j + 1), pixelShape, tube);
1044 const double xpos = 0.0;
1045 const double ypos = double(j) * pixelHeight;
1046 pixel->setPos(xpos, ypos, 0.0);
1047 tube->add(pixel);
1048 testInst->markAsDetector(pixel);
1049 }
1050 testInst->add(tube);
1051 }
1052 addSourceToInstrument(testInst, V3D(0.0, 0.0, -1.0));
1053 addSampleToInstrument(testInst, V3D(0.0, 0.0, 0.0));
1054
1055 return testInst;
1056}
1057} // namespace ComponentCreationHelper
std::string name
Definition Run.cpp:60
double height
Definition GetAllEi.cpp:155
const double TOL
Mantid::Kernel::Quat(ComponentInfo::* rotation)(const size_t) const
Constructive Solid Geometry object.
Definition CSGObject.h:51
Class for Assembly of geometric components.
int add(IComponent *) override
Add a component to the assembly.
Component is a wrapper for a Component which can modify some of its parameters, e....
Definition Component.h:42
void setRot(const Kernel::Quat &) override
Set the orientation Kernel::Quaternion relative to parent (if present)
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.
Definition Detector.h:30
virtual void setPos(double, double, double)=0
Set the IComponent position, x, y, z respective to parent (if present)
virtual void setRot(const Kernel::Quat &)=0
Set the orientation Kernel::Quaternion relative to parent (if present)
Base Instrument Class.
Definition Instrument.h:47
void markAsDetector(const IDetector *)
mark a Component which has already been added to the Instrument (as a child comp.) to be a Detector c...
Class for Assembly of geometric components.
void setOutline(std::shared_ptr< const IObject > obj)
Sets the outline shape for this assembly.
int add(IComponent *) override
Add a component to the assembly.
std::shared_ptr< IObject > createOutline()
Set the outline of the assembly.
Object Component class, this class brings together the physical attributes of the component to the po...
void setShape(std::shared_ptr< const IObject > newShape)
Set a new shape on the component void setShape(std::shared_ptr<const IObject> newShape);.
RectangularDetector is a type of CompAssembly, an assembly of components.
std::shared_ptr< Detector > getAtXY(const int X, const int Y) const
Return a pointer to the component in the assembly at the (X,Y) pixel position.
void initialize(std::shared_ptr< IObject > shape, int xpixels, double xstart, double xstep, int ypixels, double ystart, double ystep, int idstart, bool idfillbyfirst_y, int idstepbyrow, int idstep=1)
Create all the detector pixels of this rectangular detector.
Class originally intended to be used with the DataHandling 'LoadInstrument' algorithm.
std::shared_ptr< CSGObject > createShape(Poco::XML::Element *pElem)
Creates a geometric object from a DOM-element-node pointing to an element whose child nodes contain t...
Class for quaternions.
Definition Quat.h:39
std::vector< double > getRotation(bool check_normalisation=false, bool throw_on_errors=false) const
returns the rotation matrix defined by this quaternion as an 9-point
Definition Quat.cpp:453
Implements a 2-dimensional vector embedded in a 3D space, i.e.
Definition V2D.h:29
Class for 3D vectors.
Definition V3D.h:34
constexpr double X() const noexcept
Get x.
Definition V3D.h:238
constexpr double Y() const noexcept
Get y.
Definition V3D.h:239
constexpr double Z() const noexcept
Get z.
Definition V3D.h:240
std::string cappedCylinderXML(double radius, double height, const Mantid::Kernel::V3D &baseCentre, const Mantid::Kernel::V3D &axis, const std::string &id)
Return the appropriate XML for the requested cylinder.
std::shared_ptr< Mantid::Geometry::DetectorGroup > createDetectorGroupWith5CylindricalDetectors()
Create a detector group containing 5 detectors.
Mantid::Geometry::Instrument_sptr createCylInstrumentWithDetInGivenPositions(const std::vector< double > &L2, const std::vector< double > &polar, const std::vector< double > &azim)
create instrument with cylindrical detectors located in specific angular positions
Mantid::Geometry::Instrument_sptr createTestInstrumentCylindrical(int num_banks, const Mantid::Kernel::V3D &sourcePos=Mantid::Kernel::V3D(0.0, 0.0, -10.), const Mantid::Kernel::V3D &samplePos=Mantid::Kernel::V3D(), const double cylRadius=0.004, const double cylHeight=0.0002)
Create an test instrument with n panels of 9 cylindrical detectors, a source and a sample position.
std::shared_ptr< Mantid::Geometry::CSGObject > createHollowCylinder(double innerRadius, double outerRadius, double height, const Mantid::Kernel::V3D &baseCentre, const Mantid::Kernel::V3D &axis, const std::string &id)
Create a hollow cylinder object.
Mantid::Geometry::Instrument_sptr createMinimalInstrument(const Mantid::Kernel::V3D &sourcePos, const Mantid::Kernel::V3D &samplePos, const Mantid::Kernel::V3D &detectorPos)
Creates a mimimal valid virtual instrument.
std::string sphereXML(double radius, const Mantid::Kernel::V3D &centre, const std::string &id)
Return the XML for a sphere.
std::shared_ptr< Mantid::Geometry::DetectorGroup > createDetectorGroupWithNCylindricalDetectorsWithGaps(unsigned int nDet=4, double gap=0.01)
Create a detector group containing n detectors with gaps.
std::shared_ptr< Mantid::Geometry::DetectorGroup > createRingOfCylindricalDetectors(const double R_min=4.5, const double R_max=5, const double z000000000000000=4)
Create a detector group containing detectors ring R_min – min radius of the ring R_max – max radius o...
Mantid::Geometry::Instrument_sptr createEmptyInstrument()
Creates a geometrically nonsensical virtual instrument to be populated with detectors later.
Mantid::Geometry::Instrument_sptr createSimpleInstrumentWithRotation(const Mantid::Kernel::V3D &sourcePos, const Mantid::Kernel::V3D &samplePos, const Mantid::Kernel::V3D &detectorPos, const Mantid::Kernel::Quat &relativeBankRotation, const Mantid::Kernel::Quat &relativeDetRotation, const Mantid::Kernel::V3D &detOffset=Mantid::Kernel::V3D(0, 0, 0))
createSimpleInstrumentWithRotation, creates the most simple possible definition of an instrument in w...
Mantid::Geometry::Instrument_sptr sansInstrument(const Mantid::Kernel::V3D &sourcePos, const Mantid::Kernel::V3D &samplePos, const Mantid::Kernel::V3D &trolley1Pos, const Mantid::Kernel::V3D &trolley2Pos)
bool double_cmprsn(double x1, double x2)
create instrument with cylindrical detectors located in specific positions
void addSourceToInstrument(Mantid::Geometry::Instrument_sptr &instrument, const Mantid::Kernel::V3D &sourcePos, const std::string &name="moderator")
Add a source with given name and sourcePos to given instrument.
std::shared_ptr< Mantid::Geometry::CSGObject > createSphere(double radius, const Mantid::Kernel::V3D &centre=Mantid::Kernel::V3D(), const std::string &id="sp-1")
Create a sphere object.
Mantid::Geometry::Instrument_sptr createInstrumentWithOptionalComponents(bool haveSource, bool haveSample, bool haveDetector)
Mantid::Geometry::Instrument_sptr createInstrumentWithSourceRotation(const Mantid::Kernel::V3D &sourcePos, const Mantid::Kernel::V3D &samplePos, const Mantid::Kernel::V3D &detectorPos, const Mantid::Kernel::Quat &relativeSourceRotation)
createInstrumentWithSourceRotation, from createSimpleInstrumentWithRotation.
Mantid::Geometry::Instrument_sptr createTestInstrumentRectangular2(int num_banks, int pixels, double pixelSpacing=0.008)
Create an test instrument with n panels of rectangular detectors, pixels*pixels in size,...
std::string hollowCylinderXML(double innerRadius, double outerRadius, double height, const Mantid::Kernel::V3D &baseCentre, const Mantid::Kernel::V3D &axis, const std::string &id)
Return the XML for a hollow cylinder.
std::shared_ptr< Mantid::Geometry::CSGObject > createCuboid(double xHalfLength, double yHalfLength=-1.0, double zHalfLength=-1.0, const Mantid::Kernel::V3D &centre={0.0, 0.0, 0.0}, const std::string &id="detector-shape")
Create a cuboid shape.
std::vector< std::unique_ptr< Mantid::Geometry::IDetector > > createVectorOfCylindricalDetectors(const double R_min=4.5, const double R_max=5, const double z000000000000000=4)
Create a detector vector containing detectors ring R_min – min radius of the ring R_max – max radius ...
Mantid::Geometry::Instrument_sptr createCylInstrumentWithVerticalOffsetsSpecified(size_t nTubes, const std::vector< double > &verticalOffsets, size_t nDetsPerTube, double xMin, double xMax, double yMin, double yMax)
Creates a single flat bank with cylindrical (tubes) of detectors.
std::shared_ptr< Mantid::Geometry::CompAssembly > createTestAssemblyOfFourCylinders()
Create a component assembly at the origin made up of 4 cylindrical detectors.
void addSampleToInstrument(Mantid::Geometry::Instrument_sptr &instrument, const Mantid::Kernel::V3D &samplePos)
A set of helper functions for creating various component structures for the unit tests.
std::shared_ptr< Mantid::Geometry::CSGObject > createHollowShell(double innerRadius, double outerRadius, const Mantid::Kernel::V3D &centre=Mantid::Kernel::V3D())
Create a hollow shell, i.e.
Mantid::Geometry::Instrument_sptr createMinimalInstrumentWithMonitor(const Mantid::Kernel::V3D &monitorPos, const Mantid::Kernel::Quat &monitorRot)
createMinimalInstrumentWithMonitor, creates the most simple possible definition of an instrument with...
void addRectangularBank(Mantid::Geometry::Instrument &testInstrument, int idStart, int pixels, double pixelSpacing, const std::string &bankName, const Mantid::Kernel::V3D &bankPos, const Mantid::Kernel::Quat &bankRot)
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.
Mantid::Geometry::Instrument_sptr createTestUnnamedRectangular2(int num_banks, int pixels, double pixelSpacing=0.008)
Create an test instrument with multiple nameless banks.
Mantid::Geometry::Instrument_sptr createInstrumentWithPSDTubes(const size_t nTubes=3, const size_t nPixelsPerTube=50, const bool mirrorTubes=false)
Mantid::Geometry::Instrument_sptr createTestInstrumentRectangular(int num_banks, int pixels, double pixelSpacing=0.008, double bankDistanceFromSample=5.0, bool addMonitor=false, const std::string &instrumentName="basic_rect")
Create a test instrument with n panels of rectangular detectors, pixels*pixels in size,...
CompAssembly * makeBank(size_t width, size_t height, Instrument *instrument)
std::string cuboidXML(double xHalfLength, double yHalfLength=-1.0, double zHalfLength=-1.0, const Mantid::Kernel::V3D &centre={0.0, 0.0, 0.0}, const std::string &id="detector-shape")
std::shared_ptr< Instrument > Instrument_sptr
Shared pointer to an instrument object.
std::shared_ptr< IObject > IObject_sptr
Typdef for a shared pointer.
Definition IObject.h:93
MANTID_KERNEL_DLL bool withinRelativeDifference(T const x, T const y, S const tolerance)
Test whether x, y are within relative tolerance tol.
Mantid::Kernel::Matrix< double > DblMatrix
Definition Matrix.h:206
std::string to_string(const wide_integer< Bits, Signed > &n)