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