Skip to content

Commit 78bc952

Browse files
[EMCAL-525] Implemented new checkers for EMCAL cell task (#2310)
* [EMCAL-525] Implemented new checkers for EMCAL cell task -CellTimeCalibCheck - checker for peaks in the cell time distribution * Made suggested changes to CellTimeCalibCheck.cxx * [EMCAL-525] Applied clang format to CellTimeCalibCheck.cxx, added checkers for CellAmpCheck and TrendGraphCheck * [EMCAL-525] Fixed clang format on TrendGraphCheck.h & merge conflict on CMakeLists.txt * [EMCAL-525] Fixed CMake file
1 parent 71b0269 commit 78bc952

8 files changed

Lines changed: 575 additions & 3 deletions

File tree

Modules/EMCAL/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
add_library(O2QcEMCAL)
44

5-
6-
target_sources(O2QcEMCAL PRIVATE src/TriggerTask.cxx src/PedestalTask.cxx src/BCTask.cxx src/RawErrorCheck.cxx src/RawTask.cxx src/RawCheck.cxx src/CellTask.cxx src/CellCheck.cxx src/DigitsQcTask.cxx src/DigitCheck.cxx src/OccupancyReductor.cxx src/OccupancyToFECReductor.cxx src/ClusterTask.cxx src/RawErrorTask.cxx src/CalibMonitoringTask.cxx src/SupermoduleProjectorTask.cxx src/BadChannelMapReductor.cxx src/TimeCalibParamReductor.cxx src/SupermoduleProjectionReductor.cxx src/SubdetectorProjectionReductor.cxx src/BCVisualization.cxx src/CalibCheck.cxx src/NumPatchesPerFastORCheck.cxx src/PedestalChannelCheck.cxx src/RawErrorCheckAll.cxx)
7-
5+
target_sources(O2QcEMCAL PRIVATE src/TriggerTask.cxx src/PedestalTask.cxx src/BCTask.cxx src/RawErrorCheck.cxx src/RawTask.cxx src/RawCheck.cxx src/CellTask.cxx src/CellCheck.cxx src/DigitsQcTask.cxx src/DigitCheck.cxx src/OccupancyReductor.cxx src/OccupancyToFECReductor.cxx src/ClusterTask.cxx src/RawErrorTask.cxx src/CalibMonitoringTask.cxx src/SupermoduleProjectorTask.cxx src/BadChannelMapReductor.cxx src/TimeCalibParamReductor.cxx src/SupermoduleProjectionReductor.cxx src/SubdetectorProjectionReductor.cxx src/BCVisualization.cxx src/CalibCheck.cxx src/NumPatchesPerFastORCheck.cxx src/PedestalChannelCheck.cxx src/RawErrorCheckAll.cxx src/CellTimeCalibCheck.cxx src/CellAmpCheck.cxx src/TrendGraphCheck.cxx)
86

97
target_include_directories(
108
O2QcEMCAL
@@ -40,8 +38,12 @@ add_root_dictionary(O2QcEMCAL
4038
include/EMCAL/NumPatchesPerFastORCheck.h
4139
include/EMCAL/PedestalChannelCheck.h
4240
include/EMCAL/RawErrorCheckAll.h
41+
include/EMCAL/CellTimeCalibCheck.h
42+
include/EMCAL/CellAmpCheck.h
43+
include/EMCAL/TrendGraphCheck.h
4344
LINKDEF include/EMCAL/LinkDef.h)
4445

46+
4547
install(TARGETS O2QcEMCAL
4648
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
4749
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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
3+
// holders. 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 CellAmpCheck.h
14+
/// \author Ananya Rai
15+
///
16+
17+
#ifndef QC_MODULE_EMCAL_EMCALCELLAMPCHECK_H
18+
#define QC_MODULE_EMCAL_EMCALCELLAMPCHECK_H
19+
20+
#include "QualityControl/CheckInterface.h"
21+
#include <TH1.h>
22+
23+
namespace o2::quality_control_modules::emcal
24+
{
25+
26+
/// \brief Check whether cell amplitude is okay by comparing with reference
27+
/// histogram
28+
///
29+
/// \author Ananya Rai
30+
class CellAmpCheck : public o2::quality_control::checker::CheckInterface
31+
{
32+
public:
33+
/// Default constructor
34+
CellAmpCheck() = default;
35+
/// Destructor
36+
~CellAmpCheck() override = default;
37+
38+
// Override interface
39+
void configure() override;
40+
Quality
41+
check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
42+
void beautify(std::shared_ptr<MonitorObject> mo,
43+
Quality checkResult = Quality::Null) override;
44+
std::string getAcceptedType() override;
45+
46+
private:
47+
// /************************************************
48+
// * reference histograms *
49+
// ************************************************/
50+
TH1* mCellAmpReference = nullptr;
51+
/************************************************
52+
* Chi Square threshold cuts *
53+
************************************************/
54+
double mChiSqMedThresh =
55+
3; ///< If ChiSq greater than this value, quality is medium
56+
double mChiSqBadThresh = 5; ///< threshold of bad ChiSq
57+
ClassDefOverride(CellAmpCheck, 2);
58+
};
59+
60+
} // namespace o2::quality_control_modules::emcal
61+
62+
#endif // QC_MODULE_EMCAL_EMCALCELLAMPCHECK_H
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 CellTimeCalibCheck.h
14+
/// \author Ananya Rai
15+
///
16+
17+
#ifndef QC_MODULE_EMCAL_EMCALCELLTIMECALIBCHECK_H
18+
#define QC_MODULE_EMCAL_EMCALCELLTIMECALIBCHECK_H
19+
20+
#include "QualityControl/CheckInterface.h"
21+
22+
namespace o2::quality_control_modules::emcal
23+
{
24+
25+
/// \brief Check for the existence of secondary peaks above some threshold value
26+
///
27+
/// \author Ananya Rai
28+
class CellTimeCalibCheck : public o2::quality_control::checker::CheckInterface
29+
{
30+
public:
31+
/// Default constructor
32+
CellTimeCalibCheck() = default;
33+
/// Destructor
34+
~CellTimeCalibCheck() override = default;
35+
36+
// Override interface
37+
void configure() override;
38+
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
39+
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
40+
std::string getAcceptedType() override;
41+
42+
private:
43+
/************************************************
44+
* threshold cuts *
45+
************************************************/
46+
double mSigmaTSpectrum = 0.1; ///< TSpectrum parameter sigma
47+
double mThreshTSpectrum = 0.01; ///< TSpectrum parameter threshold
48+
49+
ClassDefOverride(CellTimeCalibCheck, 2);
50+
};
51+
52+
} // namespace o2::quality_control_modules::emcal
53+
54+
#endif // QC_MODULE_EMCAL_EMCALCELLTIMECALIBCHECK_H

Modules/EMCAL/include/EMCAL/LinkDef.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
#pragma link C++ class o2::quality_control_modules::emcal::TriggerTask + ;
3030
#pragma link C++ class o2::quality_control_modules::emcal::NumPatchesPerFastORCheck + ;
3131
#pragma link C++ class o2::quality_control_modules::emcal::PedestalChannelCheck + ;
32+
#pragma link C++ class o2::quality_control_modules::emcal::CellTimeCalibCheck + ;
33+
#pragma link C++ class o2::quality_control_modules::emcal::CellAmpCheck + ;
34+
#pragma link C++ class o2::quality_control_modules::emcal::TrendGraphCheck + ;
3235

3336
#pragma link C++ class o2::quality_control_modules::emcal::RawErrorCheckAll + ;
3437

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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
3+
// holders. 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 TrendGraphCheck.h
14+
/// \author Ananya Rai
15+
///
16+
17+
#ifndef QC_MODULE_EMCAL_EMCALTRENDGRAPHCHECK_H
18+
#define QC_MODULE_EMCAL_EMCALTRENDGRAPHCHECK_H
19+
20+
#include "QualityControl/CheckInterface.h"
21+
22+
namespace o2::quality_control_modules::emcal
23+
{
24+
25+
/// \brief Check if the trend rate is as expected.
26+
///
27+
/// \author Ananya Rai
28+
class TrendGraphCheck : public o2::quality_control::checker::CheckInterface
29+
{
30+
public:
31+
/// Default constructor
32+
TrendGraphCheck() = default;
33+
/// Destructor
34+
~TrendGraphCheck() override = default;
35+
36+
// Override interface
37+
void configure() override;
38+
Quality
39+
check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
40+
void beautify(std::shared_ptr<MonitorObject> mo,
41+
Quality checkResult = Quality::Null) override;
42+
std::string getAcceptedType() override;
43+
44+
private:
45+
/************************************************
46+
* threshold cuts *
47+
************************************************/
48+
int mPeriodMovAvg = 5; ///< Period for moving average
49+
double mBadThresholdLow =
50+
10; ///< If rate lower than this threshold - medium, keep checking
51+
double mBadThresholdHigh =
52+
1000; ///< If rate higher than this thereshold - medium, keep checking
53+
double mBadDiff =
54+
20; ///< If difference is higher than this between consecutive rates - bad
55+
56+
ClassDefOverride(TrendGraphCheck, 5);
57+
};
58+
59+
} // namespace o2::quality_control_modules::emcal
60+
61+
#endif // QC_MODULE_EMCAL_EMCALTRENDGRAPHCHECK_H

Modules/EMCAL/src/CellAmpCheck.cxx

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#include "EMCAL/CellAmpCheck.h"
2+
#include "QualityControl/MonitorObject.h"
3+
#include "QualityControl/QcInfoLogger.h"
4+
#include "QualityControl/Quality.h"
5+
6+
// ROOT
7+
#include <ROOT/TSeq.hxx>
8+
#include <TCanvas.h>
9+
#include <TH1.h>
10+
#include <TH2.h>
11+
#include <TLatex.h>
12+
#include <TList.h>
13+
#include <TPaveText.h>
14+
#include <TRobustEstimator.h>
15+
#include <iostream>
16+
#include <string>
17+
#include <vector>
18+
19+
using namespace std;
20+
21+
namespace o2::quality_control_modules::emcal
22+
{
23+
void CellAmpCheck::configure()
24+
{
25+
// configure threshold-based checkers
26+
auto nChiSqMedThresh = mCustomParameters.find("ChiSqMedThresh");
27+
if (nChiSqMedThresh != mCustomParameters.end()) {
28+
try {
29+
mChiSqMedThresh = std::stod(nChiSqMedThresh->second);
30+
} catch (std::exception& e) {
31+
ILOG(Error, Support) << "Value " << nChiSqMedThresh->second.data()
32+
<< " not a double" << ENDM;
33+
}
34+
}
35+
36+
auto nBadChiSqThresh = mCustomParameters.find("BadChiSqThresh");
37+
if (nBadChiSqThresh != mCustomParameters.end()) {
38+
try {
39+
mChiSqBadThresh = std::stod(nBadChiSqThresh->second);
40+
} catch (std::exception& e) {
41+
ILOG(Error, Support) << "Value " << nBadChiSqThresh->second.data()
42+
<< " not a double" << ENDM;
43+
}
44+
}
45+
}
46+
47+
Quality CellAmpCheck::check(
48+
std::map<std::string, std::shared_ptr<MonitorObject>>* moMap)
49+
{
50+
if (!mCellAmpReference) {
51+
// Load reference histogram from the CCDB
52+
mCellAmpReference =
53+
this->retrieveConditionAny<TH1>("EMC/QCREF/CellAmpCalibCheck");
54+
}
55+
if (!mCellAmpReference) {
56+
// If histogram not found print out error message
57+
ILOG(Error, Support) << "Could not find the reference histogram!" << ENDM;
58+
}
59+
60+
Quality result = Quality::Good;
61+
for (auto& [moName, mo] : *moMap) {
62+
if (mo->getName() == "cellAmplitudeCalib_PHYS") {
63+
64+
auto* h = dynamic_cast<TH1*>(mo->getObject());
65+
h->Scale(1. / h->Integral());
66+
mCellAmpReference->Scale(1. / mCellAmpReference->Integral());
67+
68+
Double_t chisq_val = h->Chi2Test(mCellAmpReference, "UU NORM CHI2/NDF");
69+
if (chisq_val > mChiSqMedThresh) {
70+
result = Quality::Medium;
71+
}
72+
if (mChiSqBadThresh < chisq_val) {
73+
result = Quality::Bad;
74+
}
75+
}
76+
}
77+
return result;
78+
}
79+
80+
std::string CellAmpCheck::getAcceptedType() { return "TH1"; }
81+
82+
void CellAmpCheck::beautify(std::shared_ptr<MonitorObject> mo,
83+
Quality checkResult)
84+
{
85+
if (mo->getName() == "cellAmplitudeCalib_PHYS") {
86+
auto* h = dynamic_cast<TH1*>(mo->getObject());
87+
TPaveText* msg = new TPaveText(0.5, 0.5, 0.9, 0.75, "NDC");
88+
h->GetListOfFunctions()->Add(msg);
89+
msg->SetName(Form("%s_msg", mo->GetName()));
90+
if (checkResult == Quality::Good) {
91+
//
92+
msg->Clear();
93+
msg->AddText("Cell amplitude within expectations.");
94+
msg->SetFillColor(kGreen);
95+
msg->Draw();
96+
//
97+
h->SetFillColor(kGreen);
98+
} else if (checkResult == Quality::Bad) {
99+
ILOG(Debug, Devel) << "Quality::Bad, setting to red" << ENDM;
100+
msg->Clear();
101+
msg->AddText("Suspicious cell amplitude detected.");
102+
msg->AddText("If NOT a technical run,");
103+
msg->AddText("call EMCAL on-call.");
104+
msg->Draw();
105+
h->SetFillColor(kRed);
106+
} else if (checkResult == Quality::Medium) {
107+
ILOG(Debug, Devel) << "Quality::medium, setting to orange" << ENDM;
108+
msg->Clear();
109+
msg->AddText("WARNING: Deviation from expectations. Keep monitoring");
110+
msg->Draw();
111+
h->SetFillColor(kOrange);
112+
}
113+
h->SetLineColor(kBlack);
114+
}
115+
}
116+
} // namespace o2::quality_control_modules::emcal

0 commit comments

Comments
 (0)