Skip to content

Commit 3f73676

Browse files
[AFIT-109] Add MIP peak monitoring for FT0
1 parent 61f0362 commit 3f73676

File tree

9 files changed

+756
-4
lines changed

9 files changed

+756
-4
lines changed

Modules/FIT/Common/include/FITCommon/HelperCommon.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include <type_traits>
2727
#include <regex>
2828

29+
#include <boost/algorithm/string.hpp>
30+
#include <boost/algorithm/string/case_conv.hpp>
2931
#include <boost/property_tree/ptree.hpp>
3032

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

5153
template <typename Param_t,
5254
typename = typename std::enable_if<std::is_floating_point<Param_t>::value ||
53-
std::is_same<std::string, Param_t>::value || (std::is_integral<Param_t>::value && !std::is_same<bool, Param_t>::value)>::type>
55+
std::is_same<std::string, Param_t>::value ||
56+
std::is_integral<Param_t>::value>>
5457
inline auto parseParameters(const std::string& param, const std::string& del)
5558
{
5659
std::regex reg(del);
5760
std::sregex_token_iterator first{ param.begin(), param.end(), reg, -1 }, last;
5861
std::vector<Param_t> vecResult;
5962
for (auto it = first; it != last; it++) {
6063
if constexpr (std::is_integral<Param_t>::value && !std::is_same<bool, Param_t>::value) {
61-
vecResult.push_back(std::stoi(*it));
64+
if (!boost::algorithm::trim_copy<std::string>(*it).empty()) {
65+
vecResult.push_back(std::stoi(*it));
66+
}
6267
} else if constexpr (std::is_floating_point<Param_t>::value) {
63-
vecResult.push_back(std::stod(*it));
68+
if (!boost::algorithm::trim_copy<std::string>(*it).empty()) {
69+
vecResult.push_back(std::stof(*it));
70+
}
6471
} else if constexpr (std::is_same<std::string, Param_t>::value) {
6572
vecResult.push_back(*it);
73+
} else if constexpr (std::is_same<bool, Param_t>::value) {
74+
std::string trimmed = boost::algorithm::trim_copy<std::string>(*it);
75+
vecResult.push_back(boost::algorithm::to_lower_copy(trimmed) == "true" || trimmed == "1");
6676
}
6777
}
6878
return vecResult;

Modules/FIT/FIT/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set(MODULE_NAME "O2QcFIT")
44
add_library(${MODULE_NAME})
55

66
target_sources(${MODULE_NAME} PRIVATE src/LevelCheck.cxx)
7+
target_sources(${MODULE_NAME} PRIVATE src/MIPCheck.cxx)
78
target_sources(${MODULE_NAME} PRIVATE src/RawDataMetricTask.cxx)
89
target_sources(${MODULE_NAME} PRIVATE src/RecoFITQcTask.cxx)
910

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

2930
add_root_dictionary(${MODULE_NAME}
3031
HEADERS include/FIT/LevelCheck.h
32+
include/FIT/MIPCheck.h
3133
include/FIT/RawDataMetricTask.h
3234
include/FIT/RecoFITQcTask.h
3335
LINKDEF include/FIT/LinkDef.h)

Modules/FIT/FIT/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# FIT quality control
2+
3+
## Checks
4+
5+
### MIPCheck
6+
7+
The `MIPCheck` checks peaks in channel amplitude spectra. Essentially it is a check on parameters of Gaussian fits of the MIP peaks.
8+
9+
#### Check parameters
10+
11+
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.
12+
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.
13+
14+
| Name | Type | Default value | Comments |
15+
|------------------------|------------------|---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
16+
| `nameObjectToCheck` | `string` | `""` | Name of the MO to check |
17+
| `nPeaksToFit` | `integer` | `2` | Number of MIP peaks to fit. The resulting fit funcion is a sum of `nPeaksToFit` Gaussians. |
18+
| `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. |
19+
| `gausParamsSigma` | list of `float` | `"3.0, 7.0"` | The initial guesses for the MIP peak sigmas. Defaults to 5.0 for omitted peaks. |
20+
| `fitRangeLow` | `float` | `11.0` | Lower limit of the fit |
21+
| `fitRangeHigh` | `float` | `35.0` | Upper limit of the fit |
22+
| `meanWarningsLow` | list of `float` | `""` | Lower warning thresholds for the MIP peak means |
23+
| `meanWarningsHigh` | list of `float` | `""` | Upper warning thresholds for the MIP peak means |
24+
| `meanErrorsLow` | list of `float` | `""` | Lower error thresholds for the MIP peak means |
25+
| `meanErrorsHigh` | list of `float` | `""` | Upper error thresholds for the MIP peak means |
26+
| `sigmaWarnings` | list of `float` | `""` | Sigma warning thresholds |
27+
| `sigmaErrors` | list of `float` | `""` | Sigma error thresholds |
28+
| `drawMeanWarningsLow` | list of `bool` | `"false, false"` | Whether to draw the lower warning thresholds for the MIP peak means |
29+
| `drawMeanWarningsHigh` | list of `bool` | `"false, false"` | Whether to draw the upper warning thresholds for the MIP peak means |
30+
| `drawMeanErrorsLow` | list of `bool` | `"true, true"` | Whether to draw the lower error thresholds for the MIP peak |
31+
| `drawMeanErrorsHigh` | list of `bool` | `"true, true"` | Whether to draw the upper error thresholds for the MIP peak means |
32+
| `drawSigmaWarnings` | list of `bool` | `"false, false"` | Whether to draw the sigma warning thresholds |
33+
| `drawSigmaErrors` | list of `bool` | `"false, false"` | Whether to draw the sigma error thresholds |
34+
| `labelPos` | list of `double` | `"0.15, 0.2, 0.85, 0.45"` | Position of the check label |
35+
36+
#### Check logic
37+
38+
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.
39+
40+
For each peak (pseudo code):
41+
42+
- if the fit fails -> `quality = BAD`
43+
- `if not (meanWarningLow < mean < meanWarningHigh)` -> `quality = MEDIUM`
44+
- `if not (meanErrorLow < mean < meanErrorHigh)` -> `quality = BAD`
45+
- `if not sigma < sigmaWarning` -> `quality = WARNING`
46+
- `if not sigma < sigmaError` -> `quality = BAD`

Modules/FIT/FIT/include/FIT/LinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#pragma link off all functions;
55

66
#pragma link C++ class o2::quality_control_modules::fit::LevelCheck + ;
7+
#pragma link C++ class o2::quality_control_modules::fit::MIPCheck + ;
78
#pragma link C++ class o2::quality_control_modules::fit::RawDataMetricTask + ;
89
#pragma link C++ class o2::quality_control_modules::fit::RecoFITQcTask + ;
910

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
///
13+
/// \file MIPCheck.h
14+
/// \author andreas.molander@cern.ch
15+
///
16+
17+
#ifndef QC_MODULE_FIT_FITMIPCHECK_H
18+
#define QC_MODULE_FIT_FITMIPCHECK_H
19+
20+
#include "QualityControl/CheckInterface.h"
21+
22+
namespace o2::quality_control_modules::fit
23+
{
24+
25+
/// \brief QC check on MIP peaks in channel amplitude spectra. Essentially it is a check on
26+
/// parameters of Gaussian fits of the MIP peaks.
27+
/// \author andreas.molander@cern.ch
28+
class MIPCheck : public o2::quality_control::checker::CheckInterface
29+
{
30+
public:
31+
MIPCheck() = default;
32+
~MIPCheck() override = default;
33+
34+
void configure() override;
35+
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
36+
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
37+
std::string getAcceptedType() override;
38+
void startOfActivity(const Activity& activity) override;
39+
40+
private:
41+
std::shared_ptr<Activity> mActivity;
42+
43+
std::string mNameObjectToCheck = ""; //< Name of the MO to check
44+
45+
/// Number of MIP peaks to fit. The resulting fit funcion is a sum of `mNPeaksToFit` Gaussians.
46+
int mNPeaksToFit = 2;
47+
48+
/// Initial fit paramemters for the gaussian means.
49+
/// If omitted, the 1 MIP peak will default to the amplitude at the ampltude histogram max value.
50+
/// 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).
51+
/// The values are used as initial guesses and are not fixed.
52+
std::vector<float> mGausParamsMeans;
53+
54+
/// The initial fit parameters for the MIP peak sigmas. The values are used as initial guesses and are not fixed.
55+
std::vector<float> mGausParamsSigmas;
56+
57+
float mFitRangeLow = 11.0; //< Lower limit of the fit
58+
59+
float mFitRangeHigh = 35.0; //< Upper limit of the fit
60+
61+
/// Lower warning thresholds for the MIP peak means.
62+
/// The first element is for the first peak and so on.
63+
std::vector<float> mMeanWarningsLow;
64+
65+
/// Upper warning thresholds for the MIP peak means.
66+
/// The first element is for the first peak and so on.
67+
std::vector<float> mMeanWarningsHigh;
68+
69+
/// Lower error thresholds for the MIP peak means.
70+
/// The first element is for the first peak and so on.
71+
std::vector<float> mMeanErrorsLow;
72+
73+
/// Upper error thresholds for the MIP peak means.
74+
/// The first element is for the first peak and so on.
75+
std::vector<float> mMeanErrorsHigh;
76+
77+
/// Sigma warning thresholds.
78+
/// The first element is for the first peak and so on.
79+
std::vector<float> mSigmaWarnings;
80+
81+
/// Sigma error thresholds.
82+
/// The first element is for the first peak and so on.
83+
std::vector<float> mSigmaErrors;
84+
85+
/// Whether to draw the threhold lines.
86+
/// The first element is for the first peak and so on.
87+
std::vector<bool> mDrawMeanWarningsLow;
88+
std::vector<bool> mDrawMeanWarningsHigh;
89+
std::vector<bool> mDrawMeanErrorsLow;
90+
std::vector<bool> mDrawMeanErrorsHigh;
91+
std::vector<bool> mDrawSigmaWarnings;
92+
std::vector<bool> mDrawSigmaErrors;
93+
94+
std::vector<double> mVecLabelPos{ 0.15, 0.2, 0.85, 0.45 }; //< Position of the check label
95+
96+
ClassDefOverride(MIPCheck, 3);
97+
};
98+
99+
} // namespace o2::quality_control_modules::fit
100+
101+
#endif // QC_MODULE_FIT_FITMIPCHECK_H

0 commit comments

Comments
 (0)