28 : m_detectorID(detectorID) {
34 throw std::invalid_argument(
"MCInteractionStatistics() - Sample enviroment has zero components.");
36 }
catch (std::runtime_error &) {
41 for (
size_t i = 0; i < env->
nelements(); i++) {
57 if (componentIndex == -1) {
75 double scatterAngleDegrees = scatteredDirec.
angle(-toStart) * 180. / M_PI;
79 [&totalScatterPoints](
const auto &stat) { totalScatterPoints += stat.usedPointCount; });
91 std::stringstream scatterPointSummary;
92 scatterPointSummary << std::fixed;
93 scatterPointSummary << std::setprecision(2);
95 scatterPointSummary <<
"Scatter point statistics" << std::endl;
96 scatterPointSummary <<
"========================" << std::endl;
98 scatterPointSummary <<
"Detector ID: " <<
m_detectorID << std::endl;
103 totalScatterPointsGenerated += stat.generatedPointCount;
104 totalScatterPointsUsed += stat.usedPointCount;
107 scatterPointSummary <<
"Total scatter points generated: " << totalScatterPointsGenerated << std::endl;
108 scatterPointSummary <<
"Total scatter points used: " << totalScatterPointsUsed << std::endl;
116 percentage =
static_cast<double>(
m_envScatterPoints[i].usedPointCount) / totalScatterPointsUsed * 100;
118 <<
"): " <<
m_envScatterPoints[i].usedPointCount <<
" (" << percentage <<
"%)" << std::endl;
121 scatterPointSummary <<
"Scattering angle mean (degrees)=" <<
m_scatterAngleMean << std::endl;
122 scatterPointSummary <<
"Scattering angle sd (degrees)=" <<
m_scatterAngleSD << std::endl;
124 return scatterPointSummary.str();
This class stores information about the sample used in particular run.
const Geometry::SampleEnvironment & getEnvironment() const
Get a reference to the sample's environment.
void UpdateScatterPointCounts(int componentIndex, bool pointUsed)
Update the scatter point counts.
std::string generateScatterPointStats()
Log a debug string summarising which parts of the environment the simulated scatter points occurred i...
double m_scatterAngleMean
void UpdateScatterAngleStats(const Kernel::V3D &toStart, const Kernel::V3D &scatteredDirec)
Update the scattering angle statistics.
ScatterPointStat m_sampleScatterPoints
MCInteractionStatistics(detid_t detectorID, const API::Sample &sample)
Construct the statistics object.
std::vector< ScatterPointStat > m_envScatterPoints
Defines a single instance of a SampleEnvironment.
const IObject & getComponent(const size_t index) const
Returns the requested IObject.
double angle(const V3D &) const
Angle between this and another vector.
Helper class which provides the Collimation Length for SANS instruments.
int32_t detid_t
Typedef for a detector ID.