Mantid
Loading...
Searching...
No Matches
PeakShapeDetectorBin.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2024 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 +
8#include "MantidJson/Json.h"
10#include <json/json.h>
11
12#include <utility>
13
14namespace Mantid::DataObjects {
15
24PeakShapeDetectorBin::PeakShapeDetectorBin(const std::vector<std::tuple<int32_t, double, double>> &detectorBinList,
25 Kernel::SpecialCoordinateSystem frame, std::string algorithmName,
26 int algorithmVersion)
27 : PeakShapeBase(frame, std::move(algorithmName), algorithmVersion), m_detectorBinList(detectorBinList) {
28
29 if (detectorBinList.size() == 0) {
30 throw std::invalid_argument("No data provided for detector data");
31 }
32}
33
37
38std::string PeakShapeDetectorBin::toJSON() const {
39 Json::Value root;
41 Json::Value detBinList;
42 for (auto const &[detectorId, startX, endX] : m_detectorBinList) {
43 Json::Value detBinVal;
44 detBinVal["detId"] = Json::Value(detectorId);
45 detBinVal["startX"] = Json::Value(startX);
46 detBinVal["endX"] = Json::Value(endX);
47 detBinList.append(detBinVal);
48 }
49
50 root["detectors"] = detBinList;
51 return Mantid::JsonHelpers::jsonToString(root);
52}
53
55
57
58const std::string PeakShapeDetectorBin::detectorBinShapeName() { return "detectorbin"; }
59
60} // namespace Mantid::DataObjects
PeakShapeBase : Base class for concrete PeakShapes containing common code.
void buildCommon(Json::Value &root) const
Build common parts of outgoing JSON serialization.
bool operator==(const PeakShapeBase &other) const
Equals operator.
PeakShapeDetectorBin : PeakShape representing detector ids and integration limits of a peak.
std::string toJSON() const override
PeakShape interface.
PeakShapeDetectorBin(const std::vector< std::tuple< int32_t, double, double > > &detectorBinList, Kernel::SpecialCoordinateSystem frame, std::string algorithmName=std::string(), int algorithmVersion=-1)
Create PeakShapeDetectorBin.
std::vector< std::tuple< int32_t, double, double > > m_detectorBinList
Mantid::Geometry::PeakShape * clone() const override
Clone PeakShapeDetectorBin.
bool operator==(const PeakShapeDetectorBin &other) const
Equals operator.
std::string shapeName() const override
Get the peak shape.
PeakShape : Abstract type to describes the shape of a peak.
Definition PeakShape.h:20
SpecialCoordinateSystem
Special coordinate systems for Q3D.
STL namespace.