Commit 310d0f4d authored by Jens Kroeger's avatar Jens Kroeger
Browse files

Merge branch 'sqrt12' into 'master'

Fixes to Spatial & TIme Resolution

See merge request !201
parents 39d901bb c04f5a85
Pipeline #1251451 passed with stages
in 20 minutes and 32 seconds
......@@ -285,8 +285,8 @@ All supported rotations are extrinsic active rotations, i.e. the vector itself i
\item The \parameter{number_of_pixels} parameter represents a two-dimensional vector with the number of pixels in the active matrix in the column and row direction, respectively.
\item The \parameter{pixel_pitch} is a two-dimensional vector defining the size of a single pixel.
\item The intrinsic resolution of the detector can be specified using the \parameter{resolution} parameter, a two-dimensional vector holding the position resolution for the column and row directions.
\item The intrinsic time resolution of the detector should be specified using the \parameter{time_resolution} parameter with units of time. This can be used to apply detector specific time cuts in modules.
\item The intrinsic resolution of the detector has to be specified using the \parameter{spatial_resolution} parameter, a two-dimensional vector holding the position resolution for the column and row directions. This value is used to assign the uncertainty of cluster positions. This parameter defaults to the pitch$/\sqrt{12}$ of the respective detector if not specified.
\item The intrinsic time resolution of the detector should be specified using the \parameter{time_resolution} parameter with units of time. This can be used to apply detector specific time cuts in modules. This parameter is only required when using relative time cuts in the analysis.
\item The \parameter{time_offset} can be used to shift the individual detector time frames of reference to e.g.\ account for time of flight effects between different detector planes by adding a fixed offset.
\item Pixels to be masked in the offline analysis can be placed in a separate file specified by the \parameter{mask_file} parameter explained in detail in Section~\ref{sec:masking}.
\item A region of interest in the given detector can be defined using the \parameter{roi} parameter. More details on this functionality can be found in Section~\ref{sec:roi}.
......
......@@ -5,6 +5,7 @@ INCLUDE_DIRECTORIES(SYSTEM ${CORRYVRECKAN_DEPS_INCLUDE_DIRS})
ADD_LIBRARY(CorryvreckanCore SHARED
Corryvreckan.cpp
detector/Detector.cpp
detector/exceptions.cpp
utils/log.cpp
utils/unit.cpp
utils/text.cpp
......
......@@ -17,6 +17,7 @@
#include "Detector.hpp"
#include "core/utils/log.h"
#include "exceptions.h"
using namespace ROOT::Math;
using namespace corryvreckan;
......@@ -66,8 +67,6 @@ Detector::Detector(const Configuration& config) : m_role(DetectorRole::NONE) {
// Auxiliary devices don't have: number_of_pixels, pixel_pitch, spatial_resolution, mask_file, region-of-interest
if(!isAuxiliary()) {
// Intrinsic spatial resolution, no default:
m_spatial_resolution = config.get<ROOT::Math::XYVector>("spatial_resolution");
// Number of pixels:
m_nPixels = config.get<ROOT::Math::DisplacementVector2D<Cartesian2D<int>>>("number_of_pixels");
// Size of the pixels:
......@@ -78,6 +77,14 @@ Detector::Detector(const Configuration& config) : m_role(DetectorRole::NONE) {
LOG(WARNING) << "Pixel pitch unphysical for detector " << m_detectorName << ": " << std::endl
<< Units::display(m_pitch, {"nm", "um", "mm"});
}
// Intrinsic spatial resolution, defaults to pitch/sqrt(12):
m_spatial_resolution = config.get<ROOT::Math::XYVector>("spatial_resolution", m_pitch / std::sqrt(12));
if(!config.has("spatial_resolution")) {
LOG(WARNING) << "Spatial resolution for detector '" << m_detectorName << "' not set." << std::endl
<< "Using pitch/sqrt(12) as default";
}
// region of interest:
m_roi = config.getMatrix<int>("roi", std::vector<std::vector<int>>());
}
......@@ -85,8 +92,12 @@ Detector::Detector(const Configuration& config) : m_role(DetectorRole::NONE) {
m_detectorType = config.get<std::string>("type");
std::transform(m_detectorType.begin(), m_detectorType.end(), m_detectorType.begin(), ::tolower);
m_timeOffset = config.get<double>("time_offset", 0.0);
m_timeResolution = config.get<double>("time_resolution");
// Time resolution - default ot negative number, i.e. unknown. This will trigger an exception
// when calling getTimeResolution
m_timeResolution = config.get<double>("time_resolution", -1.0);
// Initialize the detector, calculate transformations etc
this->initialise();
LOG(TRACE) << "Initialized \"" << m_detectorType << "\": " << m_nPixels.X() << "x" << m_nPixels.Y() << " px, pitch of "
......@@ -96,7 +107,10 @@ Detector::Detector(const Configuration& config) : m_role(DetectorRole::NONE) {
if(m_timeOffset > 0.) {
LOG(TRACE) << "Time offset: " << m_timeOffset;
}
LOG(TRACE) << " Time resolution: " << Units::display(m_timeResolution, {"ms", "us"});
if(m_timeResolution > 0) {
LOG(TRACE) << " Time resolution: " << Units::display(m_timeResolution, {"ms", "us"});
}
if(!isAuxiliary()) {
if(config.has("mask_file")) {
......@@ -109,6 +123,14 @@ Detector::Detector(const Configuration& config) : m_role(DetectorRole::NONE) {
}
}
double Detector::getTimeResolution() const {
if(m_timeResolution > 0) {
return m_timeResolution;
} else {
throw InvalidSettingError(this, "time_resolution", "Time resolution not set but requested");
}
}
std::string Detector::name() const {
return m_detectorName;
}
......
......@@ -145,7 +145,7 @@ namespace corryvreckan {
* @brief Get detector time resolution, used for timing cuts during clustering, track formation, etc.
* @return Time resolutiom of respective detector
*/
double getTimeResolution() const { return m_timeResolution; }
double getTimeResolution() const;
/**
* @brief Update detector position in the world
......
/**
* @file
* @brief Implementation of detector exceptions
*
* @copyright Copyright (c) 2019 CERN and the Corryvreckan authors.
* This software is distributed under the terms of the MIT License, copied verbatim in the file "LICENSE.md".
* In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an
* Intergovernmental Organization or submit itself to any jurisdiction.
*/
#include "exceptions.h"
#include "Detector.hpp"
using namespace corryvreckan;
InvalidSettingError::InvalidSettingError(const Detector* detector, const std::string& key, const std::string& reason) {
error_message_ = "Setting '" + key + "' of detector '" + detector->name() + "' is not valid";
if(!reason.empty()) {
error_message_ += ": " + reason;
}
}
/**
* @file
* @brief Collection of all detector exceptions
*
* @copyright Copyright (c) 2019 CERN and the Corryvreckan authors.
* This software is distributed under the terms of the MIT License, copied verbatim in the file "LICENSE.md".
* In applying this license, CERN does not waive the privileges and immunities granted to it by virtue of its status as an
* Intergovernmental Organization or submit itself to any jurisdiction.
*/
#ifndef CORRYVRECKAN_DETECTOR_EXCEPTIONS_H
#define CORRYVRECKAN_DETECTOR_EXCEPTIONS_H
#include <string>
#include "core/utils/exceptions.h"
#include "core/utils/type.h"
namespace corryvreckan {
/**
* @ingroup Exceptions
* @brief Base class for all detector exceptions in the framework.
*/
class DetectorError : public Exception {};
class Detector;
/**
* @ingroup Exceptions
* @brief Indicates an error with the setting of the detector
*
* Should be raised if the setting of the detector is not compatible with the action attempted
*/
class InvalidSettingError : public DetectorError {
public:
/**
* @brief Construct an error for an invalid setting
* @param detector Detector object containing the problematic setting
* @param key Name of the problematic setting
* @param reason Reason why the value is invalid (empty if no explicit reason)
*/
InvalidSettingError(const Detector* detector, const std::string& key, const std::string& reason = "");
};
} // namespace corryvreckan
#endif /* CORRYVRECKAN_DETECTOR_EXCEPTIONS_H */
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