|
| 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