v1.0.0-rc.31
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include "Definitions.h"
|
||||
|
||||
DetectorGeometry::DetectorGeometry(const std::vector<DetectorModuleGeometry> &in_modules, bool vertical_flip)
|
||||
: modules(in_modules) {
|
||||
: modules(in_modules), modular_detector(true) {
|
||||
if (modules.empty())
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Module number must be positive");
|
||||
|
||||
@@ -24,6 +24,8 @@ DetectorGeometry::DetectorGeometry(const std::vector<DetectorModuleGeometry> &in
|
||||
|
||||
DetectorGeometry::DetectorGeometry(int32_t nmodules, int32_t horizontal_stacking, int32_t gap_x,
|
||||
int32_t gap_y, bool mirror_y) {
|
||||
modular_detector = true;
|
||||
|
||||
if (horizontal_stacking <= 0)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Horizontal stacking must be positive");
|
||||
if (nmodules <= 0)
|
||||
@@ -58,10 +60,20 @@ DetectorGeometry::DetectorGeometry(int32_t nmodules, int32_t horizontal_stacking
|
||||
VerticalFlip();
|
||||
}
|
||||
|
||||
DetectorGeometry::DetectorGeometry(std::pair<int64_t, int64_t> dim) {
|
||||
modular_detector = false;
|
||||
if (dim.first <= 0 || dim.second <= 0)
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Detector dimension must be positive numbers");
|
||||
width = dim.first;
|
||||
height = dim.second;
|
||||
}
|
||||
|
||||
void DetectorGeometry::VerticalFlip() {
|
||||
for (auto &m: modules)
|
||||
m.VerticalFlip(height);
|
||||
}
|
||||
|
||||
int64_t DetectorGeometry::GetDirectionStep(DetectorModuleGeometry::Direction direction) const {
|
||||
switch (direction) {
|
||||
case DetectorModuleGeometry::Direction::Xneg:
|
||||
@@ -78,21 +90,34 @@ int64_t DetectorGeometry::GetDirectionStep(DetectorModuleGeometry::Direction dir
|
||||
}
|
||||
|
||||
int64_t DetectorGeometry::GetModulesNum() const {
|
||||
if (!modular_detector)
|
||||
return 1;
|
||||
return modules.size();
|
||||
}
|
||||
|
||||
int64_t DetectorGeometry::GetWidth() const {
|
||||
return width;
|
||||
int64_t DetectorGeometry::GetWidth(bool geom_transformed) const {
|
||||
if (geom_transformed || !modular_detector)
|
||||
return width;
|
||||
else
|
||||
return RAW_MODULE_COLS;
|
||||
}
|
||||
|
||||
int64_t DetectorGeometry::GetHeight() const {
|
||||
return height;
|
||||
int64_t DetectorGeometry::GetHeight(bool geom_transformed) const {
|
||||
if (geom_transformed || !modular_detector)
|
||||
return height;
|
||||
else
|
||||
return RAW_MODULE_LINES * modules.size();
|
||||
}
|
||||
|
||||
int64_t DetectorGeometry::GetPixel0(int64_t m) const {
|
||||
int64_t DetectorGeometry::GetPixel0(int64_t m, bool geom_transformed) const {
|
||||
if (m == 0 && !modular_detector)
|
||||
return 0;
|
||||
if ((m < 0) || (m >= modules.size()))
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Wrong module number");
|
||||
return modules[m].GetPixel0_X() + width * modules[m].GetPixel0_Y();
|
||||
if (geom_transformed)
|
||||
return modules[m].GetPixel0_X() + width * modules[m].GetPixel0_Y();
|
||||
else
|
||||
return m * RAW_MODULE_SIZE;
|
||||
}
|
||||
|
||||
int64_t DetectorGeometry::GetFastDirectionStep(int64_t m) const {
|
||||
@@ -108,10 +133,16 @@ int64_t DetectorGeometry::GetSlowDirectionStep(int64_t m) const {
|
||||
}
|
||||
|
||||
Coord DetectorGeometry::GetFastDirection(int64_t module_number) const {
|
||||
if ((module_number < 0) || (module_number >= modules.size()))
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Wrong module number");
|
||||
|
||||
return GetDirection(modules[module_number].GetFastAxis());
|
||||
}
|
||||
|
||||
Coord DetectorGeometry::GetSlowDirection(int64_t module_number) const {
|
||||
if ((module_number < 0) || (module_number >= modules.size()))
|
||||
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Wrong module number");
|
||||
|
||||
return GetDirection(modules[module_number].GetSlowAxis());
|
||||
}
|
||||
|
||||
@@ -128,3 +159,7 @@ Coord DetectorGeometry::GetDirection(DetectorModuleGeometry::Direction direction
|
||||
return { 1, 0, 0};
|
||||
}
|
||||
}
|
||||
|
||||
bool DetectorGeometry::IsModularDetector() const {
|
||||
return modular_detector;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user