Commit 4b8c68d4 authored by Jens Dopke's avatar Jens Dopke
Browse files

Adding the option to write out the mask from MaskCreator, if no mask existed beforehand.

parent 8f34c275
...@@ -117,8 +117,8 @@ bool Detector::isAuxiliary() const { ...@@ -117,8 +117,8 @@ bool Detector::isAuxiliary() const {
return static_cast<bool>(m_role & DetectorRole::AUXILIARY); return static_cast<bool>(m_role & DetectorRole::AUXILIARY);
} }
// Functions to set and check channel masking // Function to set the channel maskfile
void Detector::set_mask_file(std::string file) { void Detector::maskFile(std::string file) {
m_maskfile = file; m_maskfile = file;
} }
......
...@@ -208,6 +208,12 @@ namespace corryvreckan { ...@@ -208,6 +208,12 @@ namespace corryvreckan {
*/ */
std::string calibrationFile() const { return m_calibrationfile; } std::string calibrationFile() const { return m_calibrationfile; }
/**
* @brief Set the file with pixel mask information
* @param file New mask file name
*/
void maskFile(std::string file);
/** /**
* @brief Get path of the file with pixel mask information * @brief Get path of the file with pixel mask information
* @return Path of the pixel mask file * @return Path of the pixel mask file
...@@ -340,8 +346,6 @@ namespace corryvreckan { ...@@ -340,8 +346,6 @@ namespace corryvreckan {
// Different in Pixel/Strip Detector // Different in Pixel/Strip Detector
virtual void configure_pos_and_orientation(Configuration& config) const = 0; virtual void configure_pos_and_orientation(Configuration& config) const = 0;
// Functions to set and check channel masking
void set_mask_file(std::string file);
virtual void process_mask_file() = 0; virtual void process_mask_file() = 0;
// Detector information // Detector information
...@@ -366,7 +370,6 @@ namespace corryvreckan { ...@@ -366,7 +370,6 @@ namespace corryvreckan {
// List of masked channels // List of masked channels
std::map<int, bool> m_masked; std::map<int, bool> m_masked;
std::string m_maskfile; std::string m_maskfile;
std::string m_maskfile_name;
}; };
} // namespace corryvreckan } // namespace corryvreckan
......
...@@ -62,10 +62,9 @@ void PixelDetector::build_axes(const Configuration& config) { ...@@ -62,10 +62,9 @@ void PixelDetector::build_axes(const Configuration& config) {
m_roi = config.getMatrix<int>("roi", std::vector<std::vector<int>>()); m_roi = config.getMatrix<int>("roi", std::vector<std::vector<int>>());
if(config.has("mask_file")) { if(config.has("mask_file")) {
m_maskfile_name = config.get<std::string>("mask_file");
std::string mask_file = config.getPath("mask_file", true); std::string mask_file = config.getPath("mask_file", true);
LOG(DEBUG) << "Adding mask to detector \"" << config.getName() << "\", reading from " << mask_file; LOG(DEBUG) << "Adding mask to detector \"" << config.getName() << "\", reading from " << mask_file;
set_mask_file(mask_file); maskFile(mask_file);
process_mask_file(); process_mask_file();
} }
} }
...@@ -191,8 +190,8 @@ void PixelDetector::configure_detector(Configuration& config) const { ...@@ -191,8 +190,8 @@ void PixelDetector::configure_detector(Configuration& config) const {
config.set("spatial_resolution", m_spatial_resolution, {"um"}); config.set("spatial_resolution", m_spatial_resolution, {"um"});
// Pixel mask file: // Pixel mask file:
if(!m_maskfile_name.empty()) { if(!m_maskfile.empty()) {
config.set("mask_file", m_maskfile_name); config.set("mask_file", m_maskfile);
} }
// Region-of-interest: // Region-of-interest:
......
...@@ -24,6 +24,7 @@ MaskCreator::MaskCreator(Configuration& config, std::shared_ptr<Detector> detect ...@@ -24,6 +24,7 @@ MaskCreator::MaskCreator(Configuration& config, std::shared_ptr<Detector> detect
config_.setDefault<double>("sigma_above_avg_max", 5.); config_.setDefault<double>("sigma_above_avg_max", 5.);
config_.setDefault<double>("rate_max", 1.); config_.setDefault<double>("rate_max", 1.);
config_.setDefault<bool>("mask_dead_pixels", false); config_.setDefault<bool>("mask_dead_pixels", false);
config_.setDefault<bool>("write_new_config", false);
m_method = config_.get<std::string>("method"); m_method = config_.get<std::string>("method");
m_frequency = config_.get<double>("frequency_cut"); m_frequency = config_.get<double>("frequency_cut");
...@@ -32,6 +33,7 @@ MaskCreator::MaskCreator(Configuration& config, std::shared_ptr<Detector> detect ...@@ -32,6 +33,7 @@ MaskCreator::MaskCreator(Configuration& config, std::shared_ptr<Detector> detect
m_sigmaMax = config_.get<double>("sigma_above_avg_max"); m_sigmaMax = config_.get<double>("sigma_above_avg_max");
m_rateMax = config_.get<double>("rate_max"); m_rateMax = config_.get<double>("rate_max");
m_maskDeadPixels = config_.get<bool>("mask_dead_pixels"); m_maskDeadPixels = config_.get<bool>("mask_dead_pixels");
m_writeNewConfig = config_.get<bool>("write_new_config");
} }
void MaskCreator::initialize() { void MaskCreator::initialize() {
...@@ -262,6 +264,8 @@ void MaskCreator::writeMaskFiles() { ...@@ -262,6 +264,8 @@ void MaskCreator::writeMaskFiles() {
} }
} }
LOG(STATUS) << m_detector->getName() << " mask written to: " << std::endl << maskfile_path; LOG(STATUS) << m_detector->getName() << " mask written to: " << std::endl << maskfile_path;
if(m_writeNewConfig)
m_detector->maskFile(maskfile_path);
} }
double MaskCreator::estimateDensityAtPosition(const TH2D* values, int i, int j, int bwi, int bwj) { double MaskCreator::estimateDensityAtPosition(const TH2D* values, int i, int j, int bwi, int bwj) {
......
...@@ -68,7 +68,7 @@ namespace corryvreckan { ...@@ -68,7 +68,7 @@ namespace corryvreckan {
int m_bandwidthCol, m_bandwidthRow; int m_bandwidthCol, m_bandwidthRow;
double m_sigmaMax, m_rateMax; double m_sigmaMax, m_rateMax;
int m_numEvents, binsOccupancy; int m_numEvents, binsOccupancy;
bool m_maskDeadPixels; bool m_maskDeadPixels, m_writeNewConfig;
static inline void fillDist(const TH2D* values, TH1D* dist); static inline void fillDist(const TH2D* values, TH1D* dist);
}; };
......
...@@ -24,6 +24,7 @@ No masks are applied in this module as this is done by the respective event load ...@@ -24,6 +24,7 @@ No masks are applied in this module as this is done by the respective event load
* `sigma_above_avg_max`: Cut for noisy pixels, number of standard deviations above average, defaults to `5`. Only used in `localdensity` mode. * `sigma_above_avg_max`: Cut for noisy pixels, number of standard deviations above average, defaults to `5`. Only used in `localdensity` mode.
* `rate_max`: Maximum rate, defaults to `1`. Only used in `localdensity` mode. * `rate_max`: Maximum rate, defaults to `1`. Only used in `localdensity` mode.
* `mask_dead_pixels`: If `true`, the module will search for pixels without any recorded hits and add them to the mask file. Default is `false`. * `mask_dead_pixels`: If `true`, the module will search for pixels without any recorded hits and add them to the mask file. Default is `false`.
* `write_new_config`: If `true` and the detector config did not previously hold a mask file, then the new mask file is added to the outgoing config. Default is `false`.
### Plots produced ### Plots produced
For each detector the following plots are produced: For each detector the following plots are produced:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment