PixelMask: Precalculate raw maskto avoid copying it in the later code
This commit is contained in:
+34
-9
@@ -35,7 +35,20 @@ uint32_t PixelMask::LoadMask(const std::vector<uint32_t> &input_mask, uint8_t bi
|
||||
return ret;
|
||||
}
|
||||
|
||||
void PixelMask::CalcEdgePixels(const DiffractionExperiment &experiment) {
|
||||
void PixelMask::UpdateRawMask(const DiffractionExperiment &experiment) {
|
||||
switch (experiment.GetDetectorType()) {
|
||||
case DetectorType::JUNGFRAU:
|
||||
case DetectorType::EIGER:
|
||||
raw_mask.resize(experiment.GetModulesNum() * RAW_MODULE_SIZE, 0);
|
||||
ConvertedToRawGeometry(experiment, raw_mask.data(), mask.data());
|
||||
break;
|
||||
default:
|
||||
raw_mask.clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PixelMask::CalcEdgePixels_i(const DiffractionExperiment &experiment) {
|
||||
if (experiment.GetDetectorType() == DetectorType::DECTRIS)
|
||||
return;
|
||||
|
||||
@@ -81,21 +94,27 @@ void PixelMask::CalcEdgePixels(const DiffractionExperiment &experiment) {
|
||||
LoadMask(chip_edge_conv, ChipGapPixelBit);
|
||||
}
|
||||
|
||||
std::vector<uint32_t> PixelMask::GetMaskRaw(const DiffractionExperiment &experiment) const {
|
||||
std::vector<uint32_t> ret(experiment.GetModulesNum() * RAW_MODULE_SIZE, 0);
|
||||
ConvertedToRawGeometry(experiment, ret.data(), mask.data());
|
||||
return ret;
|
||||
void PixelMask::CalcEdgePixels(const DiffractionExperiment &experiment) {
|
||||
CalcEdgePixels_i(experiment);
|
||||
UpdateRawMask(experiment);
|
||||
}
|
||||
|
||||
const std::vector<uint32_t> &PixelMask::GetMaskRaw() const {
|
||||
if (raw_mask.empty())
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Raw format not available for this detector");
|
||||
return raw_mask;
|
||||
}
|
||||
|
||||
const std::vector<uint32_t> &PixelMask::GetMask() const {
|
||||
return mask;
|
||||
}
|
||||
|
||||
std::vector<uint32_t> PixelMask::GetMask(const DiffractionExperiment& experiment) const {
|
||||
const std::vector<uint32_t> &PixelMask::GetMask(const DiffractionExperiment& experiment) const {
|
||||
if (experiment.IsGeometryTransformed())
|
||||
return GetMask();
|
||||
else
|
||||
return GetMaskRaw(experiment);
|
||||
return GetMaskRaw();
|
||||
}
|
||||
|
||||
std::vector<uint32_t> PixelMask::GetUserMask() const {
|
||||
@@ -159,7 +178,9 @@ void PixelMask::LoadDetectorBadPixelMask(const DiffractionExperiment &experiment
|
||||
LoadMask(input_mask_conv, ErrorPixelBit);
|
||||
LoadMask(input_mask_rms_conv, NoisyPixelBit);
|
||||
|
||||
CalcEdgePixels(experiment);
|
||||
CalcEdgePixels_i(experiment);
|
||||
|
||||
UpdateRawMask(experiment);
|
||||
}
|
||||
|
||||
PixelMaskStatistics PixelMask::GetStatistics() const {
|
||||
@@ -186,10 +207,12 @@ PixelMaskStatistics PixelMask::GetStatistics() const {
|
||||
void PixelMask::LoadUserMask(const DiffractionExperiment& experiment, const std::vector<uint32_t> &in_mask) {
|
||||
if (in_mask.size() == mask.size()) {
|
||||
LoadMask(in_mask, UserMaskedPixelBit);
|
||||
UpdateRawMask(experiment);
|
||||
} else if (in_mask.size() == experiment.GetModulesNum() * RAW_MODULE_SIZE) {
|
||||
std::vector<uint32_t> tmp(experiment.GetPixelsNumConv(), 0);
|
||||
RawToConvertedGeometry(experiment, tmp.data(), in_mask. data());
|
||||
LoadMask(tmp, UserMaskedPixelBit);
|
||||
UpdateRawMask(experiment);
|
||||
} else
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Size of input user mask invalid");
|
||||
@@ -220,9 +243,10 @@ void PixelMask::LoadDECTRISBadPixelMask(const std::vector<uint32_t> &input_mask)
|
||||
}
|
||||
}
|
||||
}
|
||||
raw_mask = {}; // For DECTRIS - there is no raw mask
|
||||
}
|
||||
|
||||
void PixelMask::LoadDarkBadPixelMask(const std::vector<uint32_t> &input_mask) {
|
||||
void PixelMask::LoadDarkBadPixelMask(const DiffractionExperiment& experiment, const std::vector<uint32_t> &input_mask) {
|
||||
if (input_mask.size() != mask.size())
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Input match doesn't fit the detector ");
|
||||
@@ -238,4 +262,5 @@ void PixelMask::LoadDarkBadPixelMask(const std::vector<uint32_t> &input_mask) {
|
||||
mask[i] &= ~(1 << NoisyPixelBit);
|
||||
}
|
||||
}
|
||||
UpdateRawMask(experiment);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user