Commit 391f0875 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'MaskCreatorFileWriting' into 'master'

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

See merge request corryvreckan/corryvreckan!450
parents 8f34c275 b993f3e0
Pipeline #2885156 passed with stages
in 25 minutes and 31 seconds
......@@ -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
......
......@@ -117,8 +117,8 @@ bool Detector::isAuxiliary() const {
return static_cast<bool>(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;
}
......
......@@ -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<int, bool> m_masked;
std::string m_maskfile;
std::string m_maskfile_name;
std::string m_maskfile, m_maskfile_name;
};
} // namespace corryvreckan
......
......@@ -61,11 +61,12 @@ void PixelDetector::build_axes(const Configuration& config) {
// region of interest:
m_roi = config.getMatrix<int>("roi", std::vector<std::vector<int>>());
m_maskfile_name = "";
if(config.has("mask_file")) {
m_maskfile_name = config.get<std::string>("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:
......
......@@ -24,6 +24,7 @@ MaskCreator::MaskCreator(Configuration& config, std::shared_ptr<Detector> detect
config_.setDefault<double>("sigma_above_avg_max", 5.);
config_.setDefault<double>("rate_max", 1.);
config_.setDefault<bool>("mask_dead_pixels", false);
config_.setDefault<bool>("write_new_config", false);
m_method = config_.get<std::string>("method");
m_frequency = config_.get<double>("frequency_cut");
......@@ -32,6 +33,7 @@ MaskCreator::MaskCreator(Configuration& config, std::shared_ptr<Detector> detect
m_sigmaMax = config_.get<double>("sigma_above_avg_max");
m_rateMax = config_.get<double>("rate_max");
m_maskDeadPixels = config_.get<bool>("mask_dead_pixels");
m_writeNewConfig = config_.get<bool>("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) {
......
......@@ -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);
};
......
......@@ -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:
......
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