diff --git a/README.md b/README.md index a7a8a219839c2937110f4f8607ce8e4493acba15..e43c363f754dca0cfcbf1aa25da1d637969d0366 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ The following authors, in alphabetical order, have contributed to Corryvreckan: * Matthew Daniel Buckland, University of Liverpool, @mbucklan * Carsten Daniel Burgard, DESY, @cburgard * Manuel Colocci, CERN, @mcolocci +* Jens Dopke, STFC RAL, @jdopke * Nicolò Jacazio, CERN, @njacazio * Chun Cheng, DESY, @chengc * Dominik Dannheim, CERN, @dannheim diff --git a/src/core/detector/Detector.cpp b/src/core/detector/Detector.cpp index e611b4964f1311cfff1c0bcde9f85bad0caadc25..8d1edef67d3d22c30a2a17677f2b3ded980ed9a6 100644 --- a/src/core/detector/Detector.cpp +++ b/src/core/detector/Detector.cpp @@ -117,8 +117,8 @@ bool Detector::isAuxiliary() const { return static_cast(m_role & DetectorRole::AUXILIARY); } -// Functions to set and check channel masking -void Detector::set_mask_file(std::string file) { +// Function to set the channel maskfile +void Detector::maskFile(std::string file) { m_maskfile = file; } diff --git a/src/core/detector/Detector.hpp b/src/core/detector/Detector.hpp index b2a81465d33eec3fa18c6e817fb5f6cfc305fe28..3ad0fbf394662878e4c480be02ee346594af28d0 100644 --- a/src/core/detector/Detector.hpp +++ b/src/core/detector/Detector.hpp @@ -208,6 +208,12 @@ namespace corryvreckan { */ 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 * @return Path of the pixel mask file @@ -340,8 +346,6 @@ namespace corryvreckan { // Different in Pixel/Strip Detector 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; // Detector information @@ -365,8 +369,7 @@ namespace corryvreckan { // List of masked channels std::map m_masked; - std::string m_maskfile; - std::string m_maskfile_name; + std::string m_maskfile, m_maskfile_name; }; } // namespace corryvreckan diff --git a/src/core/detector/PixelDetector.cpp b/src/core/detector/PixelDetector.cpp index 20fc2f6bc7b07b40ae2e055dc2794f6f038cfa2f..d83cab6af2a87b06c6b4cb7db01d6c23a8661b9e 100644 --- a/src/core/detector/PixelDetector.cpp +++ b/src/core/detector/PixelDetector.cpp @@ -61,11 +61,12 @@ void PixelDetector::build_axes(const Configuration& config) { // region of interest: m_roi = config.getMatrix("roi", std::vector>()); + m_maskfile_name = ""; if(config.has("mask_file")) { m_maskfile_name = config.get("mask_file"); std::string mask_file = config.getPath("mask_file", true); LOG(DEBUG) << "Adding mask to detector \"" << config.getName() << "\", reading from " << mask_file; - set_mask_file(mask_file); + maskFile(mask_file); process_mask_file(); } } @@ -191,8 +192,12 @@ void PixelDetector::configure_detector(Configuration& config) const { config.set("spatial_resolution", m_spatial_resolution, {"um"}); // Pixel mask file: - if(!m_maskfile_name.empty()) { - config.set("mask_file", m_maskfile_name); + if(!m_maskfile.empty()) { + if(m_maskfile_name.empty()) { + config.set("mask_file", m_maskfile); + } else { + config.set("mask_file", m_maskfile_name); + } } // Region-of-interest: diff --git a/src/modules/MaskCreator/MaskCreator.cpp b/src/modules/MaskCreator/MaskCreator.cpp index 1415d1f032e72b47c25bec29fe384b668214fb00..8c8cfd338a6789abbf64d95abc83038674302f55 100644 --- a/src/modules/MaskCreator/MaskCreator.cpp +++ b/src/modules/MaskCreator/MaskCreator.cpp @@ -24,6 +24,7 @@ MaskCreator::MaskCreator(Configuration& config, std::shared_ptr detect config_.setDefault("sigma_above_avg_max", 5.); config_.setDefault("rate_max", 1.); config_.setDefault("mask_dead_pixels", false); + config_.setDefault("write_new_config", false); m_method = config_.get("method"); m_frequency = config_.get("frequency_cut"); @@ -32,6 +33,7 @@ MaskCreator::MaskCreator(Configuration& config, std::shared_ptr detect m_sigmaMax = config_.get("sigma_above_avg_max"); m_rateMax = config_.get("rate_max"); m_maskDeadPixels = config_.get("mask_dead_pixels"); + m_writeNewConfig = config_.get("write_new_config"); } void MaskCreator::initialize() { @@ -262,6 +264,9 @@ void MaskCreator::writeMaskFiles() { } } 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) { diff --git a/src/modules/MaskCreator/MaskCreator.h b/src/modules/MaskCreator/MaskCreator.h index f7bb19dbc7ed4e5f30f3dbbc0e22bc0219f9666e..152da2a55df015870a921b228644658ff4f59ae4 100644 --- a/src/modules/MaskCreator/MaskCreator.h +++ b/src/modules/MaskCreator/MaskCreator.h @@ -68,7 +68,7 @@ namespace corryvreckan { int m_bandwidthCol, m_bandwidthRow; double m_sigmaMax, m_rateMax; int m_numEvents, binsOccupancy; - bool m_maskDeadPixels; + bool m_maskDeadPixels, m_writeNewConfig; static inline void fillDist(const TH2D* values, TH1D* dist); }; diff --git a/src/modules/MaskCreator/README.md b/src/modules/MaskCreator/README.md index 8bf187de3941c3e026bf1fc9714cc7fe675ea8fa..72b77d182bebe40aed38374311431b84ce3c9cda 100644 --- a/src/modules/MaskCreator/README.md +++ b/src/modules/MaskCreator/README.md @@ -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. * `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`. +* `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 For each detector the following plots are produced: