Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions Modules/FIT/Common/include/FITCommon/HelperCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <type_traits>
#include <regex>

#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/property_tree/ptree.hpp>

#include "QualityControl/QcInfoLogger.h"
Expand All @@ -50,19 +52,27 @@ inline ValueType getConfigFromPropertyTree(const boost::property_tree::ptree& co

template <typename Param_t,
typename = typename std::enable_if<std::is_floating_point<Param_t>::value ||
std::is_same<std::string, Param_t>::value || (std::is_integral<Param_t>::value && !std::is_same<bool, Param_t>::value)>::type>
std::is_same<std::string, Param_t>::value ||
std::is_integral<Param_t>::value>>
inline auto parseParameters(const std::string& param, const std::string& del)
{
std::regex reg(del);
std::sregex_token_iterator first{ param.begin(), param.end(), reg, -1 }, last;
std::vector<Param_t> vecResult;
for (auto it = first; it != last; it++) {
if constexpr (std::is_integral<Param_t>::value && !std::is_same<bool, Param_t>::value) {
vecResult.push_back(std::stoi(*it));
if (!boost::algorithm::trim_copy<std::string>(*it).empty()) {
vecResult.push_back(std::stoi(*it));
}
} else if constexpr (std::is_floating_point<Param_t>::value) {
vecResult.push_back(std::stod(*it));
if (!boost::algorithm::trim_copy<std::string>(*it).empty()) {
vecResult.push_back(std::stof(*it));
}
} else if constexpr (std::is_same<std::string, Param_t>::value) {
vecResult.push_back(*it);
} else if constexpr (std::is_same<bool, Param_t>::value) {
std::string trimmed = boost::algorithm::trim_copy<std::string>(*it);
vecResult.push_back(boost::algorithm::to_lower_copy(trimmed) == "true" || trimmed == "1");
}
}
return vecResult;
Expand Down
2 changes: 2 additions & 0 deletions Modules/FIT/FIT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(MODULE_NAME "O2QcFIT")
add_library(${MODULE_NAME})

target_sources(${MODULE_NAME} PRIVATE src/LevelCheck.cxx)
target_sources(${MODULE_NAME} PRIVATE src/MIPCheck.cxx)
target_sources(${MODULE_NAME} PRIVATE src/RawDataMetricTask.cxx)
target_sources(${MODULE_NAME} PRIVATE src/RecoFITQcTask.cxx)

Expand All @@ -28,6 +29,7 @@ install(TARGETS ${MODULE_NAME}

add_root_dictionary(${MODULE_NAME}
HEADERS include/FIT/LevelCheck.h
include/FIT/MIPCheck.h
include/FIT/RawDataMetricTask.h
include/FIT/RecoFITQcTask.h
LINKDEF include/FIT/LinkDef.h)
Expand Down
46 changes: 46 additions & 0 deletions Modules/FIT/FIT/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# FIT quality control

## Checks

### MIPCheck

The `MIPCheck` checks peaks in channel amplitude spectra. Essentially it is a check on parameters of Gaussian fits of the MIP peaks.

#### Check parameters

The parameters of the check are listed in the table below. For all parameters that take a list as argument, the items in the list corresponds to the different peaks; the first item is for the 1 MIP peak and so on.
If a threshold argument is omitted, that threshold will not be checked. This way, it is also possible to disable checks for a threshold for only some of the peaks. To disable a check for the first peak, but keep it for subsequent peaks, a negative value will also disable a check.

| Name | Type | Default value | Comments |
|------------------------|------------------|---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `nameObjectToCheck` | `string` | `""` | Name of the MO to check |
| `nPeaksToFit` | `integer` | `2` | Number of MIP peaks to fit. The resulting fit funcion is a sum of `nPeaksToFit` Gaussians. |
| `gausParamsMeans` | list of `float` | `""` | Initial fit paramemters for the gaussian means. If omitted, the 1 MIP peak will default to the amplitude at the ampltude histogram max value. Other peaks will default to multiples of the initial 1 MIP peak mean (2 MIP peak mean = 2 * 1 MIP peak mean, and so on). The values are used as initial guesses and are not fixed. |
| `gausParamsSigma` | list of `float` | `"3.0, 7.0"` | The initial guesses for the MIP peak sigmas. Defaults to 5.0 for omitted peaks. |
| `fitRangeLow` | `float` | `11.0` | Lower limit of the fit |
| `fitRangeHigh` | `float` | `35.0` | Upper limit of the fit |
| `meanWarningsLow` | list of `float` | `""` | Lower warning thresholds for the MIP peak means |
| `meanWarningsHigh` | list of `float` | `""` | Upper warning thresholds for the MIP peak means |
| `meanErrorsLow` | list of `float` | `""` | Lower error thresholds for the MIP peak means |
| `meanErrorsHigh` | list of `float` | `""` | Upper error thresholds for the MIP peak means |
| `sigmaWarnings` | list of `float` | `""` | Sigma warning thresholds |
| `sigmaErrors` | list of `float` | `""` | Sigma error thresholds |
| `drawMeanWarningsLow` | list of `bool` | `"false, false"` | Whether to draw the lower warning thresholds for the MIP peak means |
| `drawMeanWarningsHigh` | list of `bool` | `"false, false"` | Whether to draw the upper warning thresholds for the MIP peak means |
| `drawMeanErrorsLow` | list of `bool` | `"true, true"` | Whether to draw the lower error thresholds for the MIP peak |
| `drawMeanErrorsHigh` | list of `bool` | `"true, true"` | Whether to draw the upper error thresholds for the MIP peak means |
| `drawSigmaWarnings` | list of `bool` | `"false, false"` | Whether to draw the sigma warning thresholds |
| `drawSigmaErrors` | list of `bool` | `"false, false"` | Whether to draw the sigma error thresholds |
| `labelPos` | list of `double` | `"0.15, 0.2, 0.85, 0.45"` | Position of the check label |

#### Check logic

The check produces the worst quality it finds among the listed checks below. For each failed check, a quality flag is added to the quality that explains the problem.

For each peak (pseudo code):

- if the fit fails -> `quality = BAD`
- `if not (meanWarningLow < mean < meanWarningHigh)` -> `quality = MEDIUM`
- `if not (meanErrorLow < mean < meanErrorHigh)` -> `quality = BAD`
- `if not sigma < sigmaWarning` -> `quality = WARNING`
- `if not sigma < sigmaError` -> `quality = BAD`
1 change: 1 addition & 0 deletions Modules/FIT/FIT/include/FIT/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma link off all functions;

#pragma link C++ class o2::quality_control_modules::fit::LevelCheck + ;
#pragma link C++ class o2::quality_control_modules::fit::MIPCheck + ;
#pragma link C++ class o2::quality_control_modules::fit::RawDataMetricTask + ;
#pragma link C++ class o2::quality_control_modules::fit::RecoFITQcTask + ;

Expand Down
101 changes: 101 additions & 0 deletions Modules/FIT/FIT/include/FIT/MIPCheck.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// 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.

///
/// \file MIPCheck.h
/// \author andreas.molander@cern.ch
///

#ifndef QC_MODULE_FIT_FITMIPCHECK_H
#define QC_MODULE_FIT_FITMIPCHECK_H

#include "QualityControl/CheckInterface.h"

namespace o2::quality_control_modules::fit
{

/// \brief QC check on MIP peaks in channel amplitude spectra. Essentially it is a check on
/// parameters of Gaussian fits of the MIP peaks.
/// \author andreas.molander@cern.ch
class MIPCheck : public o2::quality_control::checker::CheckInterface
{
public:
MIPCheck() = default;
~MIPCheck() override = default;

void configure() override;
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
std::string getAcceptedType() override;
void startOfActivity(const Activity& activity) override;

private:
std::shared_ptr<Activity> mActivity;

std::string mNameObjectToCheck = ""; //< Name of the MO to check

/// Number of MIP peaks to fit. The resulting fit funcion is a sum of `mNPeaksToFit` Gaussians.
int mNPeaksToFit = 2;

/// Initial fit paramemters for the gaussian means.
/// If omitted, the 1 MIP peak will default to the amplitude at the ampltude histogram max value.
/// Other peaks will default to multiples of the initial 1 MIP peak mean (2 MIP peak mean = 2 * 1 MIP peak mean, and so on).
/// The values are used as initial guesses and are not fixed.
std::vector<float> mGausParamsMeans;

/// The initial fit parameters for the MIP peak sigmas. The values are used as initial guesses and are not fixed.
std::vector<float> mGausParamsSigmas;

float mFitRangeLow = 11.0; //< Lower limit of the fit

float mFitRangeHigh = 35.0; //< Upper limit of the fit

/// Lower warning thresholds for the MIP peak means.
/// The first element is for the first peak and so on.
std::vector<float> mMeanWarningsLow;

/// Upper warning thresholds for the MIP peak means.
/// The first element is for the first peak and so on.
std::vector<float> mMeanWarningsHigh;

/// Lower error thresholds for the MIP peak means.
/// The first element is for the first peak and so on.
std::vector<float> mMeanErrorsLow;

/// Upper error thresholds for the MIP peak means.
/// The first element is for the first peak and so on.
std::vector<float> mMeanErrorsHigh;

/// Sigma warning thresholds.
/// The first element is for the first peak and so on.
std::vector<float> mSigmaWarnings;

/// Sigma error thresholds.
/// The first element is for the first peak and so on.
std::vector<float> mSigmaErrors;

/// Whether to draw the threhold lines.
/// The first element is for the first peak and so on.
std::vector<bool> mDrawMeanWarningsLow;
std::vector<bool> mDrawMeanWarningsHigh;
std::vector<bool> mDrawMeanErrorsLow;
std::vector<bool> mDrawMeanErrorsHigh;
std::vector<bool> mDrawSigmaWarnings;
std::vector<bool> mDrawSigmaErrors;

std::vector<double> mVecLabelPos{ 0.15, 0.2, 0.85, 0.45 }; //< Position of the check label

ClassDefOverride(MIPCheck, 3);
};

} // namespace o2::quality_control_modules::fit

#endif // QC_MODULE_FIT_FITMIPCHECK_H
Loading