Skip to content

Commit b962869

Browse files
sbhawaniBhawani Singh
andauthored
TPCQC:adds IDCvsSACtask error fixed (#1666)
Co-authored-by: Bhawani Singh <bhsingh@cern.ch>
1 parent 9a3ad79 commit b962869

5 files changed

Lines changed: 309 additions & 0 deletions

File tree

Modules/TPC/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ target_sources(O2QcTPC PRIVATE src/PID.cxx
2323
src/QualityReductorTPC.cxx
2424
src/DCSPTemperature.cxx
2525
src/IDCs.cxx
26+
src/IDCsVsSACs.cxx
2627
src/QualityObserver.cxx
2728
src/RatioGeneratorTPC.cxx
2829
src/CheckOfSlices.cxx
@@ -75,6 +76,7 @@ add_root_dictionary(O2QcTPC
7576
include/TPC/QualityReductorTPC.h
7677
include/TPC/DCSPTemperature.h
7778
include/TPC/IDCs.h
79+
include/TPC/IDCsVsSACs.h
7880
include/TPC/QualityObserver.h
7981
include/TPC/RatioGeneratorTPC.h
8082
include/TPC/CheckOfSlices.h
@@ -154,6 +156,7 @@ install(FILES run/tpcQCPID_sampled.json
154156
run/tpcQCTrending_canvas.json
155157
run/tpcQCDCSPTemperature.json
156158
run/tpcQCIDCs.json
159+
run/tpcQCIDCsVsSACs.json
157160
run/tpcQCQualityObserver.json
158161
run/tpcQCRatio_generator.json
159162
run/tpcQCCheckSlices.json
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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 IDCsVsSACs.h
14+
/// \author Bhawani Singh
15+
///
16+
17+
#ifndef QUALITYCONTROL_IDCSVSSACS_H
18+
#define QUALITYCONTROL_IDCSVSSACS_H
19+
20+
// O2 includes
21+
#include "TPCCalibration/IDCContainer.h"
22+
#include "TPCCalibration/IDCCCDBHelper.h"
23+
#include "TPCCalibration/SACCCDBHelper.h"
24+
#include "TPCCalibration/IDCGroupHelperSector.h"
25+
#include "CCDB/CcdbApi.h"
26+
#include "TPCQC/IDCsVsSACs.h"
27+
28+
// QC includes
29+
#include "QualityControl/PostProcessingInterface.h"
30+
31+
// ROOT includes
32+
#include "TCanvas.h"
33+
34+
#include <boost/property_tree/ptree_fwd.hpp>
35+
#include <map>
36+
37+
namespace o2::quality_control_modules::tpc
38+
{
39+
40+
/// \brief Quality Control task for the IDC data of the TPC comparision
41+
/// \author Bhawani Singh
42+
class IDCsVsSACs : public quality_control::postprocessing::PostProcessingInterface
43+
{
44+
public:
45+
/// \brief Constructor
46+
IDCsVsSACs() = default;
47+
/// \brief Destructor
48+
~IDCsVsSACs() = default;
49+
50+
/// \brief Configuration of a post-processing task.
51+
/// Configuration of a post-processing task. Can be overridden if user wants to retrieve the configuration of the task.
52+
/// \param name Name of the task
53+
/// \param config ConfigurationInterface with prefix set to ""
54+
void configure(const boost::property_tree::ptree& config) override;
55+
/// \brief Initialization of a post-processing task.
56+
/// Initialization of a post-processing task. User receives a Trigger which caused the initialization and a service
57+
/// registry with singleton interfaces.
58+
/// \param trigger Trigger which caused the initialization, for example Trigger::SOR
59+
/// \param services Interface containing optional interfaces, for example DatabaseInterface
60+
void initialize(quality_control::postprocessing::Trigger, framework::ServiceRegistryRef) override;
61+
/// \brief Update of a post-processing task.
62+
/// Update of a post-processing task. User receives a Trigger which caused the update and a service
63+
/// registry with singleton interfaces.
64+
/// \param trigger Trigger which caused the initialization, for example Trigger::Period
65+
/// \param services Interface containing optional interfaces, for example DatabaseInterface
66+
void update(quality_control::postprocessing::Trigger, framework::ServiceRegistryRef) override;
67+
/// \brief Finalization of a post-processing task.
68+
/// Finalization of a post-processing task. User receives a Trigger which caused the finalization and a service
69+
/// registry with singleton interfaces.
70+
/// \param trigger Trigger which caused the initialization, for example Trigger::EOR
71+
/// \param services Interface containing optional interfaces, for example DatabaseInterface
72+
void finalize(quality_control::postprocessing::Trigger, framework::ServiceRegistryRef) override;
73+
74+
private:
75+
o2::tpc::IDCCCDBHelper<unsigned char> mCCDBHelper;
76+
/// to have comparision plots of SACs and IDCs
77+
o2::tpc::SACCCDBHelper<unsigned char> mSACs;
78+
o2::tpc::qc::IDCsVsSACs mIDCsVsSACs;
79+
o2::ccdb::CcdbApi mCdbApi;
80+
std::string mHost;
81+
std::unique_ptr<TCanvas> mCompareIDC0andSAC0;
82+
83+
std::unordered_map<std::string, long> mTimestamps; ///< timestamps to look for specific data in the CCDB
84+
std::vector<std::map<std::string, std::string>> mLookupMaps{}; ///< meta data to look for data in the CCDB
85+
std::vector<std::map<std::string, std::string>> mStoreMaps{}; ///< meta data to be stored with the output in the QCDB
86+
std::unordered_map<std::string, std::vector<float>> mRanges; ///< histogram ranges configurable via config file
87+
};
88+
89+
} // namespace o2::quality_control_modules::tpc
90+
91+
#endif // QUALITYCONTROL_IDCSVSSACS_H

Modules/TPC/include/TPC/LinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#pragma link C++ class o2::quality_control_modules::tpc::QualityReductorTPC + ;
2828
#pragma link C++ class o2::quality_control_modules::tpc::DCSPTemperature + ;
2929
#pragma link C++ class o2::quality_control_modules::tpc::IDCs + ;
30+
#pragma link C++ class o2::quality_control_modules::tpc::IDCsVsSACs + ;
3031
#pragma link C++ class o2::quality_control_modules::tpc::QualityObserver + ;
3132
#pragma link C++ class o2::quality_control_modules::tpc::RatioGeneratorTPC + ;
3233
#pragma link C++ class o2::quality_control_modules::tpc::CheckOfSlices + ;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"qc": {
3+
"config": {
4+
"database": {
5+
"implementation": "CCDB",
6+
"host": "ccdb-test.cern.ch:8080",
7+
"username": "not_applicable",
8+
"password": "not_applicable",
9+
"name": "not_applicable"
10+
},
11+
"Activity": {
12+
},
13+
"monitoring": {
14+
"url": "infologger:///debug?qc"
15+
},
16+
"consul": {
17+
"url": ""
18+
},
19+
"conditionDB": {
20+
"url": "http://alice-ccdb.cern.ch"
21+
}
22+
},
23+
"postprocessing": {
24+
"IDCsVsSACs": {
25+
"active": "true",
26+
"className": "o2::quality_control_modules::tpc::IDCsVsSACs",
27+
"moduleName": "QcTPC",
28+
"detectorName": "TPC",
29+
"dataSourceURL": "http://alice-ccdb.cern.ch",
30+
"timestamps_comment": [ "Put the timestamp of the corresponding file you want to look for in the timestamps array.",
31+
"You can either put a timestamp for every object or leave the array empty to take the latest file from the CCDB.",
32+
"An empty array to get the the latest version will be the main use case.",
33+
"The array is mapped to the output objects sequentially",
34+
"If you want to pick the latest file in the CCDB manually, you can use -1."
35+
],
36+
"timestamps": [
37+
{ "IDCZero":"-1" },
38+
{ "SACZero":"-1" }
39+
],
40+
"lookupMetaData_comment": [ "Not used in the current version" ],
41+
"lookupMetaData": [
42+
{
43+
}
44+
],
45+
"storeMetaData_comment": "Not used in the current version",
46+
"storeMetaData": [
47+
{
48+
}
49+
],
50+
"histogramRanges_comment" : [ "nBins", "min", "max" ],
51+
"histogramRanges": [
52+
{ "IDCZero" : [ "250", "0", "2.5"] },
53+
{ "SACZero" : [ "250", "-100", "100" ] }
54+
],
55+
"initTrigger": [
56+
"once"
57+
],
58+
"updateTrigger_comment": "To trigger on a specific file being updated, use e.g. 'newobject:ccdb:TPC/Calib/Noise'",
59+
"updateTrigger": [
60+
"once"
61+
],
62+
"stopTrigger": [
63+
"userorcontrol"
64+
]
65+
}
66+
}
67+
}
68+
}

Modules/TPC/src/IDCsVsSACs.cxx

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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 IDCsVsSACs.cxx
14+
/// \author Bhawani Singh
15+
///
16+
17+
// O2 includes
18+
#include "TPCBase/CDBInterface.h"
19+
#include "TPCBase/CalDet.h"
20+
#include "TPCBase/CalArray.h"
21+
#include "TPCBase/Painter.h"
22+
23+
// QC includes
24+
#include "QualityControl/QcInfoLogger.h"
25+
#include "TPC/IDCsVsSACs.h"
26+
27+
// root includes
28+
#include "TCanvas.h"
29+
30+
#include <fmt/format.h>
31+
32+
using namespace o2::quality_control::postprocessing;
33+
using namespace o2::tpc;
34+
35+
namespace o2::quality_control_modules::tpc
36+
{
37+
38+
void IDCsVsSACs::configure(const boost::property_tree::ptree& config)
39+
{
40+
std::vector<std::string> keyVec{};
41+
std::vector<std::string> valueVec{};
42+
auto& id = getID();
43+
for (const auto& data : config.get_child("qc.postprocessing." + id + ".lookupMetaData")) {
44+
mLookupMaps.emplace_back(std::map<std::string, std::string>());
45+
if (const auto& keys = data.second.get_child_optional("keys"); keys.has_value()) {
46+
for (const auto& key : keys.value()) {
47+
keyVec.emplace_back(key.second.data());
48+
}
49+
}
50+
if (const auto& values = data.second.get_child_optional("values"); values.has_value()) {
51+
for (const auto& value : values.value()) {
52+
valueVec.emplace_back(value.second.data());
53+
}
54+
}
55+
auto vecIter = 0;
56+
if ((keyVec.size() > 0) && (keyVec.size() == valueVec.size())) {
57+
for (const auto& key : keyVec) {
58+
mLookupMaps.back().insert(std::pair<std::string, std::string>(key, valueVec.at(vecIter)));
59+
vecIter++;
60+
}
61+
}
62+
if (keyVec.size() != valueVec.size()) {
63+
ILOG(Error, Support) << "Number of keys and values for lookupMetaData are not matching" << ENDM;
64+
}
65+
keyVec.clear();
66+
valueVec.clear();
67+
}
68+
69+
for (const auto& data : config.get_child("qc.postprocessing." + id + ".storeMetaData")) {
70+
mStoreMaps.emplace_back(std::map<std::string, std::string>());
71+
if (const auto& keys = data.second.get_child_optional("keys"); keys.has_value()) {
72+
for (const auto& key : keys.value()) {
73+
keyVec.emplace_back(key.second.data());
74+
}
75+
}
76+
if (const auto& values = data.second.get_child_optional("values"); values.has_value()) {
77+
for (const auto& value : values.value()) {
78+
valueVec.emplace_back(value.second.data());
79+
}
80+
}
81+
auto vecIter = 0;
82+
if ((keyVec.size() > 0) && (keyVec.size() == valueVec.size())) {
83+
for (const auto& key : keyVec) {
84+
mStoreMaps.back().insert(std::pair<std::string, std::string>(key, valueVec.at(vecIter)));
85+
vecIter++;
86+
}
87+
}
88+
if (keyVec.size() != valueVec.size()) {
89+
ILOG(Error, Support) << "Number of keys and values for storeMetaData are not matching" << ENDM;
90+
}
91+
keyVec.clear();
92+
valueVec.clear();
93+
}
94+
95+
for (const auto& entry : config.get_child("qc.postprocessing." + id + ".histogramRanges")) {
96+
for (const auto& type : entry.second) {
97+
for (const auto& value : type.second) {
98+
mRanges[type.first].emplace_back(std::stof(value.second.data()));
99+
}
100+
}
101+
}
102+
103+
for (const auto& entry : config.get_child("qc.postprocessing." + id + ".timestamps")) {
104+
for (const auto& type : entry.second) {
105+
mTimestamps[type.first] = std::stol(type.second.data());
106+
}
107+
}
108+
109+
mHost = config.get<std::string>("qc.postprocessing." + id + ".dataSourceURL");
110+
}
111+
112+
void IDCsVsSACs::initialize(Trigger, framework::ServiceRegistryRef)
113+
{
114+
mCdbApi.init(mHost);
115+
mCompareIDC0andSAC0 = std::make_unique<TCanvas>("c_mCompareIDC0andSAC0");
116+
getObjectsManager()->startPublishing(mCompareIDC0andSAC0.get());
117+
}
118+
119+
void IDCsVsSACs::update(Trigger, framework::ServiceRegistryRef)
120+
{
121+
mCompareIDC0andSAC0.get()->Clear();
122+
auto idcZeroA = mCdbApi.retrieveFromTFileAny<IDCZero>(CDBTypeMap.at(CDBType::CalIDC0A), std::map<std::string, std::string>{}, mTimestamps["IDCZero"]);
123+
auto idcZeroC = mCdbApi.retrieveFromTFileAny<IDCZero>(CDBTypeMap.at(CDBType::CalIDC0C), std::map<std::string, std::string>{}, mTimestamps["IDCZero"]);
124+
mCCDBHelper.setIDCZero(idcZeroA, Side::A);
125+
mCCDBHelper.setIDCZero(idcZeroC, Side::C);
126+
mCCDBHelper.setIDCZeroScale(true);
127+
128+
auto sacZero = mCdbApi.retrieveFromTFileAny<SACZero>(CDBTypeMap.at(CDBType::CalSAC0), std::map<std::string, std::string>{}, mTimestamps["SACZero"]);
129+
mSACs.setSACZero(sacZero);
130+
mIDCsVsSACs = o2::tpc::qc::IDCsVsSACs(&mCCDBHelper, &mSACs);
131+
mIDCsVsSACs.drawComparisionSACandIDCZero(mCompareIDC0andSAC0.get(), mRanges["IDCZero"].at(0), mRanges["IDCZero"].at(1), mRanges["IDCZero"].at(2), mRanges["SACZero"].at(0), mRanges["SACZero"].at(1), mRanges["SACZero"].at(2));
132+
delete idcZeroA;
133+
delete idcZeroC;
134+
delete sacZero;
135+
136+
mCCDBHelper.setIDCZero(nullptr, Side::A);
137+
mCCDBHelper.setIDCZero(nullptr, Side::C);
138+
mSACs.setSACZero(nullptr);
139+
}
140+
141+
void IDCsVsSACs::finalize(Trigger, framework::ServiceRegistryRef)
142+
{
143+
getObjectsManager()->stopPublishing(mCompareIDC0andSAC0.get());
144+
}
145+
146+
} // namespace o2::quality_control_modules::tpc

0 commit comments

Comments
 (0)