From fd2bc06791591be5e02bdaf77cded36f320cee75 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Fri, 14 Feb 2025 15:02:02 +0100 Subject: [PATCH 01/26] Common: Expand stringToType for more types, fail compilation for unsupported types, use logger Signed-off-by: Felix Schlepper --- Modules/Common/include/Common/Utils.h | 36 ++++++++++++++++++--------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/Modules/Common/include/Common/Utils.h b/Modules/Common/include/Common/Utils.h index 5a84b88a2c..bc8728af34 100644 --- a/Modules/Common/include/Common/Utils.h +++ b/Modules/Common/include/Common/Utils.h @@ -17,9 +17,8 @@ #define QC_MODULE_COMMON_UTILS_H #include -#include -#include +#include "QualityControl/QcInfoLogger.h" #include "QualityControl/CustomParameters.h" namespace o2::quality_control_modules::common @@ -34,24 +33,36 @@ template T stringToType(const std::string& param) { T retVal{}; - if constexpr (std::is_same::value) { + if constexpr (std::is_same_v) { retVal = std::stoi(param); - } else if constexpr (std::is_same::value) { + } else if constexpr (std::is_same_v) { + retVal = std::stol(param); + } else if constexpr (std::is_same_v) { + retVal = std::stoll(param); + } else if constexpr (std::is_same_v) { + retVal = static_cast(std::stoul(param)); + } else if constexpr (std::is_same_v) { + retVal = std::stoul(param); + } else if constexpr (std::is_same_v) { + retVal = std::stoull(param); + } else if constexpr (std::is_same_v) { retVal = param; - } else if constexpr (std::is_same::value) { + } else if constexpr (std::is_same_v) { retVal = std::stof(param); - } else if constexpr (std::is_same::value) { + } else if constexpr (std::is_same_v) { retVal = std::stod(param); - } else if constexpr (std::is_same::value) { + } else if constexpr (std::is_same_v) { + retVal = std::stold(param); + } else if constexpr (std::is_same_v) { if ((param == "true") || (param == "True") || (param == "TRUE") || (param == "1")) { retVal = true; } else if ((param == "false") || (param == "False") || (param == "FALSE") || (param == "0")) { retVal = false; } else { - LOG(error) << "Cannot parse boolean."; + ILOG(Fatal) << "Cannot decode boolean value from param '" << param << "'" << ENDM; } } else { - LOG(error) << "Template type not supported"; + static_assert(false, "Unsupported type!"); } return retVal; } @@ -67,10 +78,11 @@ T getFromConfig(const quality_control::core::CustomParameters& params, const std { const auto itParam = params.find(name.data()); if (itParam == params.end()) { - LOGP(warning, "Missing parameter. Please add '{}': '' to the 'taskParameters'. Using default value {}.", name.data(), retVal); + ILOG(Info, Trace) << "Default parameter - " << name << ": " << retVal << ENDM; } else { const auto& param = itParam->second; - return internal::stringToType(param); + retVal = internal::stringToType(param); + ILOG(Info, Trace) << "Custom parameter - " << name << ": " << retVal << ENDM; } return retVal; } @@ -89,7 +101,7 @@ T getFromExtendedConfig(const quality_control::core::Activity& activity, const q if (auto param = params.atOptional(name, activity)) { parameter = param.value(); } else { - if constexpr (std::is_same::value) { + if constexpr (std::is_same_v) { parameter = params.atOrDefaultValue(name, retVal); } else { parameter = params.atOrDefaultValue(name, std::to_string(retVal)); From f65076f4a7360465e192348cf589b2ab14b0846a Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Fri, 14 Feb 2025 15:30:01 +0100 Subject: [PATCH 02/26] GLO: use getFromConfig Signed-off-by: Felix Schlepper --- Modules/GLO/src/ITSTPCMatchingTask.cxx | 104 ++++++------------------- 1 file changed, 23 insertions(+), 81 deletions(-) diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index 9f58d7ee5e..269b948063 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -20,11 +20,12 @@ #include "QualityControl/QcInfoLogger.h" #include "GLO/ITSTPCMatchingTask.h" #include "Common/Utils.h" + #include #include -#include using matchType = o2::gloqc::MatchITSTPCQC::matchType; +using namespace o2::quality_control_modules::common; namespace o2::quality_control_modules::glo { @@ -33,94 +34,35 @@ void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/) { ILOG(Debug, Devel) << "initialize ITSTPCMatchingTask" << ENDM; // QcInfoLogger is used. FairMQ logs will go to there as well. - if (auto param = mCustomParameters.find("isMC"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - isMC (= use of MC info): " << param->second << ENDM; - mMatchITSTPCQC.setUseMC(o2::quality_control::core::decodeBool(param->second)); - } - - if (auto param = mCustomParameters.find("useTrkPID"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - useTrkPID (= add plots for tracking PID): " << param->second << ENDM; - mMatchITSTPCQC.setUseTrkPID(o2::quality_control::core::decodeBool(param->second)); - } + // MC + mMatchITSTPCQC.setUseMC(getFromConfig(mCustomParameters, "isMC", false)); + mMatchITSTPCQC.setUseTrkPID(getFromConfig(mCustomParameters, "useTrkPID", false)); - /////////////////////////////// Track selections for MatchITSTPCQC //////////////////////////////// // ITS track - if (auto param = mCustomParameters.find("minPtITSCut"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - minPtITSCut (for track selection): " << param->second << ENDM; - mMatchITSTPCQC.setMinPtITSCut(atof(param->second.c_str())); - } - if (auto param = mCustomParameters.find("etaITSCut"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - etaITSCut (for track selection): " << param->second << ENDM; - mMatchITSTPCQC.setEtaITSCut(atof(param->second.c_str())); - } - if (auto param = mCustomParameters.find("minNITSClustersCut"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - minNITSClustersCut (for track selection): " << param->second << ENDM; - mMatchITSTPCQC.setMinNClustersITS(atoi(param->second.c_str())); - } - if (auto param = mCustomParameters.find("maxChi2PerClusterITS"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - maxChi2PerClusterITS (for track selection): " << param->second << ENDM; - mMatchITSTPCQC.setMaxChi2PerClusterITS(atof(param->second.c_str())); - } - // TO DO: define an agreed way to implement the setter for ITS matching (min. # layers, which layers) - // [...] --> exploit the method TrackCuts::setRequireHitsInITSLayers(...) + mMatchITSTPCQC.setMinPtITSCut(getFromConfig(mCustomParameters, "minPtITSCut", 0.1f)); + mMatchITSTPCQC.setEtaITSCut(getFromConfig(mCustomParameters, "minEtaITSCut", 1.4f)); + mMatchITSTPCQC.setEtaITSCut(getFromConfig(mCustomParameters, "etaITSCut", 1.4f)); + mMatchITSTPCQC.setMinNClustersITS(getFromConfig(mCustomParameters, "minNITSClustersCut", 0)); + mMatchITSTPCQC.setMaxChi2PerClusterITS(getFromConfig(mCustomParameters, "maxChi2PerClusterITS", 1e10f)); // TPC track - if (auto param = mCustomParameters.find("minPtTPCCut"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - minPtTPCCut (for track selection): " << param->second << ENDM; - mMatchITSTPCQC.setMinPtTPCCut(atof(param->second.c_str())); - } - if (auto param = mCustomParameters.find("etaTPCCut"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - etaTPCCut (for track selection): " << param->second << ENDM; - mMatchITSTPCQC.setEtaTPCCut(atof(param->second.c_str())); - } - if (auto param = mCustomParameters.find("minNTPCClustersCut"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - minNTPCClustersCut (for track selection): " << param->second << ENDM; - mMatchITSTPCQC.setMinNTPCClustersCut(atoi(param->second.c_str())); - } - if (auto param = mCustomParameters.find("minDCACut"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - minDCACut (for track selection): " << param->second << ENDM; - mMatchITSTPCQC.setMinDCAtoBeamPipeDistanceCut(atof(param->second.c_str())); - } - if (auto param = mCustomParameters.find("minDCACutY"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - minDCACutY (for track selection): " << param->second << ENDM; - mMatchITSTPCQC.setMinDCAtoBeamPipeYCut(atof(param->second.c_str())); - } + mMatchITSTPCQC.setMinPtTPCCut(getFromConfig(mCustomParameters, "minPtTPCCut", 0.1f)); + mMatchITSTPCQC.setEtaTPCCut(getFromConfig(mCustomParameters, "etaTPCCut", 1.4f)); + mMatchITSTPCQC.setMinNTPCClustersCut(getFromConfig(mCustomParameters, "minNTPCClustersCut", 60)); + mMatchITSTPCQC.setMinDCAtoBeamPipeDistanceCut(getFromConfig(mCustomParameters, "minDCACut", 100.f)); + mMatchITSTPCQC.setMinDCAtoBeamPipeYCut(getFromConfig(mCustomParameters, "minDCACutY", 10.f)); // ITS-TPC kinematics - if (auto param = mCustomParameters.find("minPtCut"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - minPtCut (for track selection): " << param->second << ENDM; - mMatchITSTPCQC.setPtCut(atof(param->second.c_str())); - } - if (auto param = mCustomParameters.find("maxPtCut"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - maxPtCut (for track selection): " << param->second << ENDM; - mMatchITSTPCQC.setMaxPtCut(atof(param->second.c_str())); - } - if (auto param = mCustomParameters.find("etaCut"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - EtaCut (for track selection): " << param->second << ENDM; - mMatchITSTPCQC.setEtaCut(atof(param->second.c_str())); - } - - /////////////////////////////// Options for K0 //////////////////////////////// - if (auto param = mCustomParameters.find("doK0QC"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - doK0QC (= do K0 QC): " << param->second << ENDM; - mMatchITSTPCQC.setDoK0QC(o2::quality_control::core::decodeBool(param->second)); - } - + mMatchITSTPCQC.setPtCut(getFromConfig(mCustomParameters, "minPtCut", 0.1f)); + mMatchITSTPCQC.setMaxPtCut(getFromConfig(mCustomParameters, "maxPtCut", 20.f)); + mMatchITSTPCQC.setEtaCut(getFromConfig(mCustomParameters, "etaCut", 1.4f)); + // K0s + mMatchITSTPCQC.setDoK0QC(getFromConfig(mCustomParameters, "doK0QC", true)); + mMatchITSTPCQC.setMaxK0Eta(getFromConfig(mCustomParameters, "maxK0Eta", 0.8f)); + mMatchITSTPCQC.setRefitK0(getFromConfig(mCustomParameters, "refitK0", true)); + mMatchITSTPCQC.setCutK0Mass(getFromConfig(mCustomParameters, "cutK0Mass", 0.05f)); if (auto param = mCustomParameters.find("trackSourcesK0"); param != mCustomParameters.end()) { mMatchITSTPCQC.setTrkSources(o2::dataformats::GlobalTrackID::getSourcesMask(param->second)); } - if (auto param = mCustomParameters.find("maxK0Eta"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - maxK0Eta (for K0 selection): " << param->second << ENDM; - mMatchITSTPCQC.setMaxK0Eta(atof(param->second.c_str())); - } - if (auto param = mCustomParameters.find("refitK0"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - refitK0 ( enable refit K0s): " << param->second << ENDM; - mMatchITSTPCQC.setRefitK0(o2::quality_control::core::decodeBool(param->second)); - } - if (auto param = mCustomParameters.find("cutK0Mass"); param != mCustomParameters.end()) { - ILOG(Debug, Devel) << "Custom parameter - cutK0Mass (cut on the distance to the PDG mass): " << param->second << ENDM; - mMatchITSTPCQC.setCutK0Mass(atof(param->second.c_str())); - } - mMatchITSTPCQC.initDataRequest(); mMatchITSTPCQC.init(); mMatchITSTPCQC.publishHistograms(getObjectsManager()); From 23430d6fc915c122b1697916769bd21fdabc48b6 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Mon, 17 Feb 2025 09:22:18 +0100 Subject: [PATCH 03/26] GLO: limit reported bins Signed-off-by: Felix Schlepper --- Modules/GLO/include/GLO/ITSTPCmatchingCheck.h | 18 ++-- Modules/GLO/src/ITSTPCmatchingCheck.cxx | 93 +++++++++++-------- 2 files changed, 62 insertions(+), 49 deletions(-) diff --git a/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h b/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h index 45b9c52ae5..12de5770e5 100644 --- a/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h +++ b/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h @@ -9,10 +9,9 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// /// \file ITSTPCmatchingCheck.h +/// \brief Check for ITS-TPC sync. matching efficiency /// \author felix.schlepper@cern.ch -/// #ifndef QC_MODULE_GLO_GLOITSTPCMATCHINGCHECK_H #define QC_MODULE_GLO_GLOITSTPCMATCHINGCHECK_H @@ -21,22 +20,22 @@ #include "QualityControl/Quality.h" #include -#include namespace o2::quality_control_modules::glo { /// \brief Check for ITS-TPC sync. matching efficiency /// \author felix.schlepper@cern.ch -class ITSTPCmatchingCheck : public o2::quality_control::checker::CheckInterface +class ITSTPCmatchingCheck final : public o2::quality_control::checker::CheckInterface { public: - Quality check(std::map>* moMap) override; - void beautify(std::shared_ptr mo, Quality checkResult = Quality::Null) override; - void startOfActivity(const Activity& activity) override; + Quality check(std::map>* moMap) final; + void beautify(std::shared_ptr mo, Quality checkResult = Quality::Null) final; + void startOfActivity(const Activity& activity) final; private: - std::vector> findRanges(const std::vector& nums); + std::vector> findRanges(const std::vector& nums) const noexcept; + std::shared_ptr mActivity; // Pt @@ -55,6 +54,9 @@ class ITSTPCmatchingCheck : public o2::quality_control::checker::CheckInterface float mMinEta{ -0.8 }; float mMaxEta{ 0.8 }; + // Other + int mLimitRange{ -1 }; + ClassDefOverride(ITSTPCmatchingCheck, 1); }; diff --git a/Modules/GLO/src/ITSTPCmatchingCheck.cxx b/Modules/GLO/src/ITSTPCmatchingCheck.cxx index 31ff915b37..7842ee0637 100644 --- a/Modules/GLO/src/ITSTPCmatchingCheck.cxx +++ b/Modules/GLO/src/ITSTPCmatchingCheck.cxx @@ -9,35 +9,31 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -/// /// \file ITSTPCmatchingCheck.cxx /// \author felix.schlepper@cern.ch -/// #include "GLO/ITSTPCmatchingCheck.h" #include "QualityControl/MonitorObject.h" #include "QualityControl/Quality.h" +#include +#include #include "QualityControl/QcInfoLogger.h" #include "Common/Utils.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include "Rtypes.h" +#include "TH1.h" +#include "TPaveText.h" +#include "TMath.h" +#include "TArrow.h" +#include "TText.h" +#include "TBox.h" +#include "TLine.h" +#include "TLegend.h" +#include "TFile.h" +#include "TPolyMarker.h" -#include -#include #include "fmt/format.h" +#include using namespace std; using namespace o2::quality_control; @@ -84,13 +80,17 @@ Quality ITSTPCmatchingCheck::check(std::mapGetXaxis()->GetBinLowEdge(binLow), up = eff->GetXaxis()->GetBinUpEdge(binUp); - cBins += fmt::format("{:.1f}-{:.1f},", low, up); + if (mLimitRange >= 0 && ranges.size() > mLimitRange) { + result.updateMetadata("checkPtBins", "too many bad bins"); + } else { + for (const auto& [binLow, binUp] : ranges) { + float low = eff->GetXaxis()->GetBinLowEdge(binLow), up = eff->GetXaxis()->GetBinUpEdge(binUp); + cBins += fmt::format("{:.1f}-{:.1f},", low, up); + } + cBins.pop_back(); // remove last `,` + cBins += " (GeV/c)"; + result.updateMetadata("checkPtBins", cBins); } - cBins.pop_back(); // remove last `,` - cBins += " (GeV/c)"; - result.updateMetadata("checkPtBins", cBins); } } } @@ -122,14 +122,18 @@ Quality ITSTPCmatchingCheck::check(std::mapGetXaxis()->GetBinLowEdge(binLow), up = eff->GetXaxis()->GetBinUpEdge(binUp); - cBins += fmt::format("{:.1f}-{:.1f},", low, up); + if (mLimitRange >= 0 && ranges.size() > mLimitRange) { + result.updateMetadata("checkPhiBins", "too many bad bins"); + } else { + std::string cBins{ "Bad matching efficiency in: " }; + for (const auto& [binLow, binUp] : ranges) { + float low = eff->GetXaxis()->GetBinLowEdge(binLow), up = eff->GetXaxis()->GetBinUpEdge(binUp); + cBins += fmt::format("{:.1f}-{:.1f},", low, up); + } + cBins.pop_back(); // remove last `,` + cBins += " (rad)"; + result.updateMetadata("checkPhiBins", cBins); } - cBins.pop_back(); // remove last `,` - cBins += " (rad)"; - result.updateMetadata("checkPhiBins", cBins); } } } @@ -161,13 +165,17 @@ Quality ITSTPCmatchingCheck::check(std::mapGetXaxis()->GetBinLowEdge(binLow), up = eff->GetXaxis()->GetBinUpEdge(binUp); - cBins += fmt::format("{:.1f}-{:.1f},", low, up); + if (mLimitRange >= 0 && ranges.size() > mLimitRange) { + result.updateMetadata("checkEtaBins", "too many bad bins"); + } else { + std::string cBins{ "Bad matching efficiency in: " }; + for (const auto& [binLow, binUp] : ranges) { + float low = eff->GetXaxis()->GetBinLowEdge(binLow), up = eff->GetXaxis()->GetBinUpEdge(binUp); + cBins += fmt::format("{:.1f}-{:.1f},", low, up); + } + cBins.pop_back(); // remove last `,` + result.updateMetadata("checkEtaBins", cBins); } - cBins.pop_back(); // remove last `,` - result.updateMetadata("checkEtaBins", cBins); } } } @@ -505,13 +513,16 @@ void ITSTPCmatchingCheck::startOfActivity(const Activity& activity) mMinEta = common::getFromExtendedConfig(activity, mCustomParameters, "minEta", -0.8f); mMaxEta = common::getFromExtendedConfig(activity, mCustomParameters, "maxEta", 0.8f); } + + mLimitRange = common::getFromExtendedConfig(activity, mCustomParameters, "limitRanges", 5); } -std::vector> ITSTPCmatchingCheck::findRanges(const std::vector& nums) +std::vector> ITSTPCmatchingCheck::findRanges(const std::vector& nums) const noexcept { std::vector> ranges; - if (nums.empty()) + if (nums.empty()) { return ranges; + } int start = nums[0]; int end = start; @@ -520,11 +531,11 @@ std::vector> ITSTPCmatchingCheck::findRanges(const std::vect if (nums[i] == end + 1) { end = nums[i]; } else { - ranges.push_back(std::make_pair(start, end)); + ranges.emplace_back(start, end); start = end = nums[i]; } } - ranges.push_back(std::make_pair(start, end)); // Add the last range + ranges.emplace_back(start, end); // Add the last range return ranges; } From a453c9c657fbe54b730ae234bbb1bf5ec13d967b Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Mon, 17 Feb 2025 16:30:12 +0100 Subject: [PATCH 04/26] GLO: Task check for sync only once Signed-off-by: Felix Schlepper --- Modules/GLO/include/GLO/ITSTPCMatchingTask.h | 1 + Modules/GLO/src/ITSTPCMatchingTask.cxx | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h index 7aede08136..f95782d151 100644 --- a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h +++ b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h @@ -50,6 +50,7 @@ class ITSTPCMatchingTask final : public TaskInterface private: o2::gloqc::MatchITSTPCQC mMatchITSTPCQC; + bool mIsSync{ false }; std::unique_ptr mEffPt; std::unique_ptr mEffEta; std::unique_ptr mEffPhi; diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index 269b948063..8e1c0056b7 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -32,12 +32,11 @@ namespace o2::quality_control_modules::glo void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/) { - ILOG(Debug, Devel) << "initialize ITSTPCMatchingTask" << ENDM; // QcInfoLogger is used. FairMQ logs will go to there as well. + ILOG(Debug, Devel) << "initialize ITSTPCMatchingTask" << ENDM; // MC mMatchITSTPCQC.setUseMC(getFromConfig(mCustomParameters, "isMC", false)); mMatchITSTPCQC.setUseTrkPID(getFromConfig(mCustomParameters, "useTrkPID", false)); - // ITS track mMatchITSTPCQC.setMinPtITSCut(getFromConfig(mCustomParameters, "minPtITSCut", 0.1f)); mMatchITSTPCQC.setEtaITSCut(getFromConfig(mCustomParameters, "minEtaITSCut", 1.4f)); @@ -54,6 +53,8 @@ void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/) mMatchITSTPCQC.setPtCut(getFromConfig(mCustomParameters, "minPtCut", 0.1f)); mMatchITSTPCQC.setMaxPtCut(getFromConfig(mCustomParameters, "maxPtCut", 20.f)); mMatchITSTPCQC.setEtaCut(getFromConfig(mCustomParameters, "etaCut", 1.4f)); + // Sync + mIsSync = common::getFromConfig(mCustomParameters, "isSync", false); // K0s mMatchITSTPCQC.setDoK0QC(getFromConfig(mCustomParameters, "doK0QC", true)); mMatchITSTPCQC.setMaxK0Eta(getFromConfig(mCustomParameters, "maxK0Eta", 0.8f)); @@ -92,7 +93,7 @@ void ITSTPCMatchingTask::endOfCycle() mMatchITSTPCQC.finalize(); // Sync Mode - if (common::getFromConfig(mCustomParameters, "isSync", false)) { + if (mIsSync) { auto makeRatio = [](TEfficiency* eff) { std::string name = eff->GetName(); name += "_Hist"; From bb95ad208a91111458c8350b4095d1ad7e77f35a Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Wed, 19 Feb 2025 11:36:47 +0100 Subject: [PATCH 05/26] GLO: modify test-json Signed-off-by: Felix Schlepper --- Modules/GLO/glo-itstpc-mtch-qcmn-test.json | 39 +++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json index ac06a47743..dddbd2a254 100644 --- a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json +++ b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json @@ -10,11 +10,12 @@ "maxObjectSize": "20000000" }, "Activity": { - "number": "48", - "type": "2" + "number": "", + "type": "", + "beamType": "PbPb" }, "monitoring": { - "url": "infologger:///debug?qc" + "url": "no-op://" }, "consul": { "url": "" @@ -25,6 +26,10 @@ "infologger": { "filterDiscardDebug": "false", "filterDiscardLevel": "0" + }, + "postprocessing": { + "periodSeconds": 0.01, + "matchAnyRunNumber": "true" } }, "tasks": { @@ -33,35 +38,31 @@ "className": "o2::quality_control_modules::glo::ITSTPCMatchingTask", "moduleName": "QcGLO", "detectorName": "GLO", - "cycleDurationSeconds": "60", + "cycleDurationSeconds": "1", "maxNumberCycles": "-1", "dataSource": { "type": "direct", "query_comment": "checking every matched track", - "query": "trackITSTPC:GLO/TPCITS/0;trackITSTPCABREFS:GLO/TPCITSAB_REFS/0;trackITSTPCABCLID:GLO/TPCITSAB_CLID/0;trackTPC:TPC/TRACKS;trackTPCClRefs:TPC/CLUSREFS;trackITS:ITS/TRACKS/0;trackITSROF:ITS/ITSTrackROF/0;trackITSClIdx:ITS/TRACKCLSID/0;alpparITS:ITS/ALPIDEPARAM/0?lifetime=condition&ccdb-path=ITS/Config/AlpideParam" + "query": "tofcluster:TOF/CLUSTERS/0;matchITSTPCTRDTOF:TOF/MTC_ITSTPCTRD/0;matchTPCTRDTOF/TOF/MTC_TPCTRD/0;matchITSTPCTOF:TOF/MTC_ITSTPC/0;matchTPCTOF:TOF/MTC_TPC/0;trackTPCTOF:TOF/TOFTRACKS_TPC/0;trigTPCTRD:TRD/TRGREC_TPC/0;trackTPCTRD:TRD/MATCH_TPC/0;trigITSTPCTRD:TRD/TRGREC_ITSTPC/0;trackITSTPCTRD:TRD/MATCH_ITSTPC/0;p2decay3body:GLO/PVTX_3BODYREFS/0;decay3body:GLO/DECAYS3BODY/0;decay3bodyIdx:GLO/DECAYS3BODY_IDX/0;p2cascs:GLO/PVTX_CASCREFS/0;cascs:GLO/CASCS/0;cascsIdx:GLO/CASCS_IDX/0;p2v0s:GLO/PVTX_V0REFS/0;v0s:GLO/V0S/0;v0sIdx:GLO/V0S_IDX/0;pvtx_tref:GLO/PVTX_TRMTCREFS/0;pvtx_trmtc:GLO/PVTX_TRMTC/0;pvtx:GLO/PVTX/0;trackITSTPC:GLO/TPCITS/0;trackITSTPCABREFS:GLO/TPCITSAB_REFS/0;trackITSTPCABCLID:GLO/TPCITSAB_CLID/0;trackTPC:TPC/TRACKS;trackTPCClRefs:TPC/CLUSREFS;trackITS:ITS/TRACKS/0;trackITSROF:ITS/ITSTrackROF/0;trackITSClIdx:ITS/TRACKCLSID/0;alpparITS:ITS/ALPIDEPARAM/0?lifetime=condition&ccdb-path=ITS/Config/AlpideParam;SVParam:GLO/SVPARAM/0?lifetime=condition&ccdb-path=GLO/Config/SVertexerParam;clusTPC:TPC/CLUSTERNATIVE;clusTPCshmap:TPC/CLSHAREDMAP/0;trigTPC:TPC/TRIGGERWORDS/0;clusTPCoccmap:TPC/TPCOCCUPANCYMAP/0" }, "taskParameters": { "GID": "ITS-TPC,ITS", "verbose": "false", - "minPtCut": "0.1f", - "etaCut": "1.4f", + "doK0QC": "true", "isSync": "true", - "minNTPCClustersCut": "60", - "minDCACut": "100.f", - "minDCACutY": "10.f" + "trackSourcesK0": "ITS,TPC,ITS-TPC,ITS-TPC-TOF,TPC-TOF,TPC-TRD,ITS-TPC-TRD,TPC-TRD-TOF,ITS-TPC-TOF,ITS-TPC-TRD-TOF" }, "grpGeomRequest": { "geomRequest": "None", - "askGRPECS": "false", - "askGRPLHCIF": "false", + "askGRPECS": "true", + "askGRPLHCIF": "true", "askGRPMagField": "true", "askMatLUT": "false", "askTime": "false", "askOnceAllButField": "true", "needPropagatorD": "false" }, - "saveObjectsToFile": "ITSTPCmatched.root", - "": "For debugging, path to the file where to save. If empty or missing it won't save." + "saveObjectsToFile": "ITSTPCmatched.root" } }, "checks": { @@ -78,7 +79,9 @@ "MOs": [ "mFractionITSTPCmatch_ITS_Hist", "mFractionITSTPCmatchPhi_ITS_Hist", - "mFractionITSTPCmatchEta_ITS_Hist" + "mFractionITSTPCmatchEta_ITS_Hist", + "mK0MassVsPtVsOcc_Cycle_py", + "mK0MassVsPtVsOcc_Integral_py" ] } ], @@ -86,11 +89,9 @@ "default": { "default": { "showPt": "true", - "thresholdPt": "0.5", + "showEta": "true", "showPhi": "true", - "thresholdPhi": "0.3", - "showEta": "1", - "thresholdEta": "0.4" + "showK0s": "true" } } } From 2d2538b02dc3e6b3585940277906525d391d64f4 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Tue, 25 Feb 2025 10:18:01 +0100 Subject: [PATCH 06/26] GLO: reduce memory churn for ratios + allow to disable Signed-off-by: Felix Schlepper --- Modules/GLO/glo-itstpc-mtch-qcmn-test.json | 1 + Modules/GLO/include/GLO/ITSTPCMatchingTask.h | 1 + Modules/GLO/src/ITSTPCMatchingTask.cxx | 75 +++++++++++--------- 3 files changed, 43 insertions(+), 34 deletions(-) diff --git a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json index dddbd2a254..f9ea6b9909 100644 --- a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json +++ b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json @@ -48,6 +48,7 @@ "taskParameters": { "GID": "ITS-TPC,ITS", "verbose": "false", + "doMTCratios": "true", "doK0QC": "true", "isSync": "true", "trackSourcesK0": "ITS,TPC,ITS-TPC,ITS-TPC-TOF,TPC-TOF,TPC-TRD,ITS-TPC-TRD,TPC-TRD-TOF,ITS-TPC-TOF,ITS-TPC-TRD-TOF" diff --git a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h index f95782d151..c475fc6e02 100644 --- a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h +++ b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h @@ -51,6 +51,7 @@ class ITSTPCMatchingTask final : public TaskInterface o2::gloqc::MatchITSTPCQC mMatchITSTPCQC; bool mIsSync{ false }; + bool mDoMTCRatios{ false }; std::unique_ptr mEffPt; std::unique_ptr mEffEta; std::unique_ptr mEffPhi; diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index 8e1c0056b7..972d0ed0c5 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -55,6 +55,8 @@ void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/) mMatchITSTPCQC.setEtaCut(getFromConfig(mCustomParameters, "etaCut", 1.4f)); // Sync mIsSync = common::getFromConfig(mCustomParameters, "isSync", false); + // MTC ratios + mDoMTCRatios = common::getFromConfig(mCustomParameters, "doMTCRatios", false); // K0s mMatchITSTPCQC.setDoK0QC(getFromConfig(mCustomParameters, "doK0QC", true)); mMatchITSTPCQC.setMaxK0Eta(getFromConfig(mCustomParameters, "maxK0Eta", 0.8f)); @@ -94,40 +96,45 @@ void ITSTPCMatchingTask::endOfCycle() // Sync Mode if (mIsSync) { - auto makeRatio = [](TEfficiency* eff) { - std::string name = eff->GetName(); - name += "_Hist"; - auto ratio = std::make_unique(name.c_str(), eff->GetTitle(), - eff->GetPassedHistogram()->GetXaxis()->GetNbins(), - eff->GetPassedHistogram()->GetXaxis()->GetXmin(), - eff->GetPassedHistogram()->GetXaxis()->GetXmax()); - ratio->SetBit(TH1::EStatusBits::kNoStats); - if (!ratio->getNum()->Add(eff->GetPassedHistogram())) { - ILOG(Error) << "Add operation for numerator histogram of " << name << " failed; efficiency will be skewed" << ENDM; - } - if (!ratio->getDen()->Add(eff->GetTotalHistogram())) { - ILOG(Error) << "Add operation for denominator histogram of " << name << " failed; efficiency will be skewed" << ENDM; - } - ratio->GetXaxis()->SetTitle(eff->GetPassedHistogram()->GetXaxis()->GetTitle()); - ratio->GetYaxis()->SetTitle(eff->GetPassedHistogram()->GetYaxis()->GetTitle()); - ratio->Sumw2(); - ratio->setHasBinominalErrors(); - ratio->update(); - return ratio; - }; - - // Pt - mEffPt = makeRatio(mMatchITSTPCQC.getFractionITSTPCmatch(gloqc::MatchITSTPCQC::ITS)); - getObjectsManager()->startPublishing(mEffPt.get(), PublicationPolicy::Once); - getObjectsManager()->setDefaultDrawOptions(mEffPt->GetName(), "logx"); - - // Eta - mEffEta = makeRatio(mMatchITSTPCQC.getFractionITSTPCmatchEta(gloqc::MatchITSTPCQC::ITS)); - getObjectsManager()->startPublishing(mEffEta.get(), PublicationPolicy::Once); - - // Phi - mEffPhi = makeRatio(mMatchITSTPCQC.getFractionITSTPCmatchPhi(gloqc::MatchITSTPCQC::ITS)); - getObjectsManager()->startPublishing(mEffPhi.get(), PublicationPolicy::Once); + if (mDoMTCRatios) { + auto makeRatio = [](std::unique_ptr& ratio, TEfficiency* eff) { + if (ratio) { + ratio->Reset(); + } else { + std::string name = eff->GetName(); + name += "_Hist"; + ratio = std::make_unique(name.c_str(), eff->GetTitle(), + eff->GetPassedHistogram()->GetXaxis()->GetNbins(), + eff->GetPassedHistogram()->GetXaxis()->GetXmin(), + eff->GetPassedHistogram()->GetXaxis()->GetXmax()); + } + ratio->SetBit(TH1::EStatusBits::kNoStats); + if (!ratio->getNum()->Add(eff->GetPassedHistogram())) { + ILOG(Error) << "Add operation for numerator histogram of " << ratio->GetName() << " failed; efficiency will be skewed" << ENDM; + } + if (!ratio->getDen()->Add(eff->GetTotalHistogram())) { + ILOG(Error) << "Add operation for denominator histogram of " << ratio->GetName() << " failed; efficiency will be skewed" << ENDM; + } + ratio->GetXaxis()->SetTitle(eff->GetPassedHistogram()->GetXaxis()->GetTitle()); + ratio->GetYaxis()->SetTitle(eff->GetPassedHistogram()->GetYaxis()->GetTitle()); + ratio->Sumw2(); + ratio->setHasBinominalErrors(); + ratio->update(); + }; + + // Pt + makeRatio(mEffPt, mMatchITSTPCQC.getFractionITSTPCmatch(gloqc::MatchITSTPCQC::ITS)); + getObjectsManager()->startPublishing(mEffPt.get(), PublicationPolicy::Once); + getObjectsManager()->setDefaultDrawOptions(mEffPt->GetName(), "logx"); + + // Eta + makeRatio(mEffEta, mMatchITSTPCQC.getFractionITSTPCmatchEta(gloqc::MatchITSTPCQC::ITS)); + getObjectsManager()->startPublishing(mEffEta.get(), PublicationPolicy::Once); + + // Phi + makeRatio(mEffPhi, mMatchITSTPCQC.getFractionITSTPCmatchPhi(gloqc::MatchITSTPCQC::ITS)); + getObjectsManager()->startPublishing(mEffPhi.get(), PublicationPolicy::Once); + } } } From 04d9c6235b6674f5ff4486cb683bdffc48f8a1ab Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Tue, 25 Feb 2025 10:33:40 +0100 Subject: [PATCH 07/26] GLO: add integrate and cycle k0s histogram Signed-off-by: Felix Schlepper --- Modules/GLO/include/GLO/ITSTPCMatchingTask.h | 11 ++++++ Modules/GLO/src/ITSTPCMatchingTask.cxx | 41 +++++++++++++++++--- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h index c475fc6e02..712d808ef8 100644 --- a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h +++ b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h @@ -21,8 +21,12 @@ #include "GLOQC/MatchITSTPCQC.h" #include "Common/TH1Ratio.h" +#include + #include +#include "TH3F.h" + using namespace o2::quality_control::core; namespace o2::quality_control_modules::glo @@ -51,10 +55,17 @@ class ITSTPCMatchingTask final : public TaskInterface o2::gloqc::MatchITSTPCQC mMatchITSTPCQC; bool mIsSync{ false }; + bool mIsPbPb{ false }; + bool mDoMTCRatios{ false }; std::unique_ptr mEffPt; std::unique_ptr mEffEta; std::unique_ptr mEffPhi; + + bool mDoK0s{ false }; + static constexpr auto mMassK0s{ o2::constants::physics::MassK0Short }; + std::unique_ptr mK0sCycle; + std::unique_ptr mK0sIntegral; }; } // namespace o2::quality_control_modules::glo diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index 972d0ed0c5..86dae28180 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -58,12 +58,14 @@ void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/) // MTC ratios mDoMTCRatios = common::getFromConfig(mCustomParameters, "doMTCRatios", false); // K0s - mMatchITSTPCQC.setDoK0QC(getFromConfig(mCustomParameters, "doK0QC", true)); - mMatchITSTPCQC.setMaxK0Eta(getFromConfig(mCustomParameters, "maxK0Eta", 0.8f)); - mMatchITSTPCQC.setRefitK0(getFromConfig(mCustomParameters, "refitK0", true)); - mMatchITSTPCQC.setCutK0Mass(getFromConfig(mCustomParameters, "cutK0Mass", 0.05f)); - if (auto param = mCustomParameters.find("trackSourcesK0"); param != mCustomParameters.end()) { - mMatchITSTPCQC.setTrkSources(o2::dataformats::GlobalTrackID::getSourcesMask(param->second)); + mMatchITSTPCQC.setDoK0QC((mDoK0s = getFromConfig(mCustomParameters, "doK0QC", false))); + if (mIsSync && mDoK0s) { + mMatchITSTPCQC.setMaxK0Eta(getFromConfig(mCustomParameters, "maxK0Eta", 0.8f)); + mMatchITSTPCQC.setRefitK0(getFromConfig(mCustomParameters, "refitK0", true)); + mMatchITSTPCQC.setCutK0Mass(getFromConfig(mCustomParameters, "cutK0Mass", 0.05f)); + if (auto param = mCustomParameters.find("trackSourcesK0"); param != mCustomParameters.end()) { + mMatchITSTPCQC.setTrkSources(o2::dataformats::GlobalTrackID::getSourcesMask(param->second)); + } } mMatchITSTPCQC.initDataRequest(); @@ -75,6 +77,7 @@ void ITSTPCMatchingTask::startOfActivity(const Activity& activity) { ILOG(Debug, Devel) << "startOfActivity " << activity.mId << ENDM; mMatchITSTPCQC.reset(); + mIsPbPb = activity.mBeamType == "Pb-Pb"; } void ITSTPCMatchingTask::startOfCycle() @@ -135,6 +138,32 @@ void ITSTPCMatchingTask::endOfCycle() makeRatio(mEffPhi, mMatchITSTPCQC.getFractionITSTPCmatchPhi(gloqc::MatchITSTPCQC::ITS)); getObjectsManager()->startPublishing(mEffPhi.get(), PublicationPolicy::Once); } + + if (mDoK0s) { + const auto* k0s = (mIsPbPb) ? mMatchITSTPCQC.getHistoK0MassVsPtVsOccPbPb() : mMatchITSTPCQC.getHistoK0MassVsPtVsOccpp(); + if (!k0s) { + ILOG(Fatal) << "Could not retrieve k0s histogram for beam type: " << mIsPbPb << ENDM; + } + + mK0sCycle.reset(); + mK0sCycle.reset(dynamic_cast(k0s->Clone("mK0sMassVsPtVsOcc_Cycle"))); + if (!mK0sCycle) { + ILOG(Fatal) << "Could not retrieve k0s histogram for current cycle" << ENDM; + } + if (!mK0sIntegral) { + mK0sIntegral.reset(dynamic_cast(k0s->Clone("mK0sMassVsPtVsOcc_Integral"))); + if (!mK0sIntegral) { + ILOG(Fatal) << "Could not retrieve k0s histogram integral" << ENDM; + } + } + mK0sCycle->Reset(); + mK0sCycle->Add(k0s, mK0sIntegral.get(), 1., -1.); + mK0sIntegral->Reset(); + mK0sIntegral->Add(k0s); + + getObjectsManager()->startPublishing(mK0sCycle.get(), PublicationPolicy::Once); + getObjectsManager()->startPublishing(mK0sIntegral.get(), PublicationPolicy::Once); + } } } From e036db8b01d7cfbef9a8e95fe9984879598928a1 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Tue, 25 Feb 2025 10:59:28 +0100 Subject: [PATCH 08/26] GLO: Add fit and trend graph Signed-off-by: Felix Schlepper --- Modules/GLO/include/GLO/ITSTPCMatchingTask.h | 23 ++++++++++ Modules/GLO/src/ITSTPCMatchingTask.cxx | 47 ++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h index 712d808ef8..3bffeb14d9 100644 --- a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h +++ b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h @@ -26,6 +26,8 @@ #include #include "TH3F.h" +#include "TF1.h" +#include "TGraphErrors.h" using namespace o2::quality_control::core; @@ -54,6 +56,8 @@ class ITSTPCMatchingTask final : public TaskInterface private: o2::gloqc::MatchITSTPCQC mMatchITSTPCQC; + unsigned int mNCycle{ 0 }; + bool mIsSync{ false }; bool mIsPbPb{ false }; @@ -66,6 +70,25 @@ class ITSTPCMatchingTask final : public TaskInterface static constexpr auto mMassK0s{ o2::constants::physics::MassK0Short }; std::unique_ptr mK0sCycle; std::unique_ptr mK0sIntegral; + std::unique_ptr mK0sMassTrend; + bool fitK0sMass(TH1* h); + double mBackgroundRangeLeft{ 0.45 }; + double mBackgroundRangeRight{ 0.54 }; + struct FitBackground { + static constexpr int mNPar{ 3 }; + double mRejLeft{ 0.48 }; + double mRejRight{ 0.51 }; + double operator()(double* x, double* p) const + { + if (x[0] > mRejLeft && x[0] < mRejRight) { + TF1::RejectPoint(); + return 0; + } + return p[0] + (p[1] * x[0]) + (p[2] * x[0] * x[0]); + } + } mFitBackground; + std::unique_ptr mBackground; + std::unique_ptr mSignalAndBackground; }; } // namespace o2::quality_control_modules::glo diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index 86dae28180..b310fd9ba1 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -16,6 +16,9 @@ #include #include +#include +#include +#include #include "QualityControl/QcInfoLogger.h" #include "GLO/ITSTPCMatchingTask.h" @@ -66,6 +69,16 @@ void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/) if (auto param = mCustomParameters.find("trackSourcesK0"); param != mCustomParameters.end()) { mMatchITSTPCQC.setTrkSources(o2::dataformats::GlobalTrackID::getSourcesMask(param->second)); } + + mFitBackground.mRejLeft = common::getFromConfig(mCustomParameters, "k0sBackgroundRejLeft", 0.48); + mFitBackground.mRejRight = common::getFromConfig(mCustomParameters, "k0sBackgroundRejRight", 0.51); + mBackgroundRangeLeft = common::getFromConfig(mCustomParameters, "k0sBackgroundRangeLeft", 0.45); + mBackgroundRangeRight = common::getFromConfig(mCustomParameters, "k0sBackgroundRangeRight", 0.54); + mBackground.reset(new TF1("gloFitK0sMassBackground", mFitBackground, mBackgroundRangeLeft, mBackgroundRangeRight, mFitBackground.mNPar)); + mSignalAndBackground.reset(new TF1("gloFitK0sMassSignal", "[0] + [1] * x + [2] * x * x + gaus(3)", mBackgroundRangeLeft, mBackgroundRangeRight)); + mK0sMassTrend.reset(new TGraphErrors); + mK0sMassTrend->SetNameTitle("mK0MassTrend", "K0s Mass + Sigma;Cycle;K0s mass (GeV/c^{2})"); + getObjectsManager()->startPublishing(mK0sMassTrend.get(), PublicationPolicy::ThroughStop); } mMatchITSTPCQC.initDataRequest(); @@ -78,6 +91,7 @@ void ITSTPCMatchingTask::startOfActivity(const Activity& activity) ILOG(Debug, Devel) << "startOfActivity " << activity.mId << ENDM; mMatchITSTPCQC.reset(); mIsPbPb = activity.mBeamType == "Pb-Pb"; + mNCycle = 0; } void ITSTPCMatchingTask::startOfCycle() @@ -163,8 +177,18 @@ void ITSTPCMatchingTask::endOfCycle() getObjectsManager()->startPublishing(mK0sCycle.get(), PublicationPolicy::Once); getObjectsManager()->startPublishing(mK0sIntegral.get(), PublicationPolicy::Once); + + TH1D* h{ nullptr }; + getObjectsManager()->startPublishing((h = mK0sCycle->ProjectionY("mK0sMassVsPtVsOcc_Cycle_pmass")), PublicationPolicy::Once); + if (fitK0sMass(h)) { + mK0sMassTrend->AddPoint(mNCycle, mSignalAndBackground->GetParameter(4)); + mK0sMassTrend->SetPointError(mK0sMassTrend->GetN() - 1, 0., mSignalAndBackground->GetParameter(5)); + } + getObjectsManager()->startPublishing((h = mK0sIntegral->ProjectionY("mK0sMassVsPtVsOcc_Integral_pmass")), PublicationPolicy::Once); + fitK0sMass(h); } } + ++mNCycle; } void ITSTPCMatchingTask::endOfActivity(const Activity& /*activity*/) @@ -183,4 +207,27 @@ void ITSTPCMatchingTask::reset() mEffEta.reset(); } +bool ITSTPCMatchingTask::fitK0sMass(TH1* h) +{ + if (h->GetEntries() == 0) { + ILOG(Warning, Devel) << "Cannot fit empty histogram: " << h->GetName() << ENDM; + return false; + } + TFitResultPtr res = h->Fit(mBackground.get(), "SRNQ"); + if (res->Status() > 1) { + ILOG(Warning, Devel) << "Failed k0s background fit for histogram: " << h->GetName() << ENDM; + return false; + } + mSignalAndBackground->SetParameter(0, mBackground->GetParameter(0)); // p0 + mSignalAndBackground->SetParameter(1, mBackground->GetParameter(1)); // p1 + mSignalAndBackground->SetParameter(2, mBackground->GetParameter(2)); // p2 + mSignalAndBackground->SetParameter(3, h->GetMaximum() - mBackground->Eval(mMassK0s)); // A (best guess) + mSignalAndBackground->SetParameter(4, mMassK0s); // mean + mSignalAndBackground->SetParLimits(4, 0.45, 0.55); // limit + mSignalAndBackground->SetParameter(5, 1e-6); // sigma + mSignalAndBackground->SetParLimits(5, 0.0, 0.2); // limit + h->Fit(mSignalAndBackground.get(), "RMQ"); + return true; +} + } // namespace o2::quality_control_modules::glo From e01def4517faf18dacb04a584a39b81bf4cde1c3 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Tue, 25 Feb 2025 13:27:09 +0100 Subject: [PATCH 09/26] GLO: more stable fit Signed-off-by: Felix Schlepper --- Modules/GLO/src/ITSTPCMatchingTask.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index b310fd9ba1..1e22f1c92f 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -223,9 +223,7 @@ bool ITSTPCMatchingTask::fitK0sMass(TH1* h) mSignalAndBackground->SetParameter(2, mBackground->GetParameter(2)); // p2 mSignalAndBackground->SetParameter(3, h->GetMaximum() - mBackground->Eval(mMassK0s)); // A (best guess) mSignalAndBackground->SetParameter(4, mMassK0s); // mean - mSignalAndBackground->SetParLimits(4, 0.45, 0.55); // limit - mSignalAndBackground->SetParameter(5, 1e-6); // sigma - mSignalAndBackground->SetParLimits(5, 0.0, 0.2); // limit + mSignalAndBackground->SetParameter(5, 0.005); // sigma h->Fit(mSignalAndBackground.get(), "RMQ"); return true; } From c452395790cc6db82e81a73684c3f7f89ba02142 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Tue, 25 Feb 2025 13:28:20 +0100 Subject: [PATCH 10/26] GLO: plots by default off & some cleanup Signed-off-by: Felix Schlepper --- Modules/GLO/include/GLO/ITSTPCmatchingCheck.h | 6 +-- Modules/GLO/src/ITSTPCmatchingCheck.cxx | 43 +++++++------------ 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h b/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h index 12de5770e5..2fc6f7971a 100644 --- a/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h +++ b/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h @@ -34,18 +34,18 @@ class ITSTPCmatchingCheck final : public o2::quality_control::checker::CheckInte void startOfActivity(const Activity& activity) final; private: - std::vector> findRanges(const std::vector& nums) const noexcept; + static std::vector> findRanges(const std::vector& nums) noexcept; std::shared_ptr mActivity; // Pt - bool mShowPt{ true }; + bool mShowPt{ false }; float mMinPt{ 1. }; float mMaxPt{ 1.999 }; float mThresholdPt{ 0.5 }; // Phi - bool mShowPhi{ true }; + bool mShowPhi{ false }; float mThresholdPhi{ 0.3 }; // Eta diff --git a/Modules/GLO/src/ITSTPCmatchingCheck.cxx b/Modules/GLO/src/ITSTPCmatchingCheck.cxx index 7842ee0637..9bab7a8429 100644 --- a/Modules/GLO/src/ITSTPCmatchingCheck.cxx +++ b/Modules/GLO/src/ITSTPCmatchingCheck.cxx @@ -26,10 +26,8 @@ #include "TMath.h" #include "TArrow.h" #include "TText.h" -#include "TBox.h" #include "TLine.h" #include "TLegend.h" -#include "TFile.h" #include "TPolyMarker.h" #include "fmt/format.h" @@ -48,10 +46,10 @@ Quality ITSTPCmatchingCheck::check(std::mapGetName(); - if (mShowPt && mo->getName() == "mFractionITSTPCmatch_ITS_Hist") { + if (mShowPt && moName == "mFractionITSTPCmatch_ITS_Hist") { auto* eff = dynamic_cast(mo->getObject()); if (eff == nullptr) { ILOG(Error) << "Failed cast for ITSTPCmatch_ITS check!" << ENDM; @@ -93,9 +91,7 @@ Quality ITSTPCmatchingCheck::check(std::mapgetName() == "mFractionITSTPCmatchPhi_ITS_Hist") { + } else if (mShowPhi && moName == "mFractionITSTPCmatchPhi_ITS_Hist") { auto* eff = dynamic_cast(mo->getObject()); if (eff == nullptr) { ILOG(Error) << "Failed cast for ITSTPCmatchPhi_ITS check!" << ENDM; @@ -136,9 +132,7 @@ Quality ITSTPCmatchingCheck::check(std::mapgetName() == "mFractionITSTPCmatchEta_ITS_Hist") { + } else if (mShowEta && moName == "mFractionITSTPCmatchEta_ITS_Hist") { auto* eff = dynamic_cast(mo->getObject()); if (eff == nullptr) { ILOG(Error) << "Failed cast for ITSTPCmatchEta_ITS check!" << ENDM; @@ -203,7 +197,9 @@ void ITSTPCmatchingCheck::beautify(std::shared_ptr mo, Quality ch return; } - if (mShowPt && mo->getName() == "mFractionITSTPCmatch_ITS_Hist") { + const auto name = mo->getName(); + + if (mShowPt && name == "mFractionITSTPCmatch_ITS_Hist") { auto* eff = dynamic_cast(mo->getObject()); if (eff == nullptr) { ILOG(Error) << "Failed cast for ITSTPCmatch_ITS_Hist beautify!" << ENDM; @@ -258,11 +254,11 @@ void ITSTPCmatchingCheck::beautify(std::shared_ptr mo, Quality ch auto* good = new TPolyMarker(); good->SetMarkerColor(kGreen); good->SetMarkerStyle(25); - good->SetMarkerSize(2); + good->SetMarkerSize(1); auto* bad = new TPolyMarker(); bad->SetMarkerColor(kRed); bad->SetMarkerStyle(25); - bad->SetMarkerSize(2); + bad->SetMarkerSize(1); auto binLow = eff->FindFixBin(mMinPt), binUp = eff->FindFixBin(mMaxPt); for (int iBin = binLow; iBin <= binUp; ++iBin) { auto x = eff->GetBinCenter(iBin); @@ -304,9 +300,7 @@ void ITSTPCmatchingCheck::beautify(std::shared_ptr mo, Quality ch msg->AddText("Not-handled Quality flag, don't panic..."); } eff->GetListOfFunctions()->Add(msg); - } - - if (mShowPhi && mo->getName() == "mFractionITSTPCmatchPhi_ITS_Hist") { + } else if (mShowPhi && name == "mFractionITSTPCmatchPhi_ITS_Hist") { auto* eff = dynamic_cast(mo->getObject()); if (eff == nullptr) { ILOG(Error) << "Failed cast for ITSTPCmatchPhi_ITS_Hist beautify!" << ENDM; @@ -387,9 +381,7 @@ void ITSTPCmatchingCheck::beautify(std::shared_ptr mo, Quality ch msg->AddText("Not-handled Quality flag, don't panic..."); } eff->GetListOfFunctions()->Add(msg); - } - - if (mShowEta && mo->getName() == "mFractionITSTPCmatchEta_ITS_Hist") { + } else if (mShowEta && name == "mFractionITSTPCmatchEta_ITS_Hist") { auto* eff = dynamic_cast(mo->getObject()); if (eff == nullptr) { ILOG(Error) << "Failed cast for ITSTPCmatchEta_ITS_Hist beautify!" << ENDM; @@ -495,20 +487,17 @@ void ITSTPCmatchingCheck::startOfActivity(const Activity& activity) { mActivity = make_shared(activity); - mShowPt = common::getFromExtendedConfig(activity, mCustomParameters, "showPt", true); - if (mShowPt) { + if ((mShowPt = common::getFromExtendedConfig(activity, mCustomParameters, "showPt", false))) { mThresholdPt = common::getFromExtendedConfig(activity, mCustomParameters, "thresholdPt", 0.5f); mMinPt = common::getFromExtendedConfig(activity, mCustomParameters, "minPt", 1.0f); mMaxPt = common::getFromExtendedConfig(activity, mCustomParameters, "maxPt", 1.999f); } - mShowPhi = common::getFromExtendedConfig(activity, mCustomParameters, "showPhi", true); - if (mShowPt) { + if ((mShowPhi = common::getFromExtendedConfig(activity, mCustomParameters, "showPhi", false))) { mThresholdPhi = common::getFromExtendedConfig(activity, mCustomParameters, "thresholdPhi", 0.3f); } - mShowEta = common::getFromExtendedConfig(activity, mCustomParameters, "showEta", false); - if (mShowEta) { + if ((mShowEta = common::getFromExtendedConfig(activity, mCustomParameters, "showEta", false))) { mThresholdEta = common::getFromExtendedConfig(activity, mCustomParameters, "thresholdEta", 0.4f); mMinEta = common::getFromExtendedConfig(activity, mCustomParameters, "minEta", -0.8f); mMaxEta = common::getFromExtendedConfig(activity, mCustomParameters, "maxEta", 0.8f); @@ -517,7 +506,7 @@ void ITSTPCmatchingCheck::startOfActivity(const Activity& activity) mLimitRange = common::getFromExtendedConfig(activity, mCustomParameters, "limitRanges", 5); } -std::vector> ITSTPCmatchingCheck::findRanges(const std::vector& nums) const noexcept +std::vector> ITSTPCmatchingCheck::findRanges(const std::vector& nums) noexcept { std::vector> ranges; if (nums.empty()) { From 0114aa5411449d8ab0426eeb29d280de76f47575 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Tue, 25 Feb 2025 13:28:48 +0100 Subject: [PATCH 11/26] GLO: beautify check for K0s Signed-off-by: Felix Schlepper --- Modules/GLO/glo-itstpc-mtch-qcmn-test.json | 4 +- Modules/GLO/include/GLO/ITSTPCmatchingCheck.h | 11 ++++- Modules/GLO/src/ITSTPCmatchingCheck.cxx | 46 +++++++++++++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json index f9ea6b9909..a1d087609c 100644 --- a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json +++ b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json @@ -81,8 +81,8 @@ "mFractionITSTPCmatch_ITS_Hist", "mFractionITSTPCmatchPhi_ITS_Hist", "mFractionITSTPCmatchEta_ITS_Hist", - "mK0MassVsPtVsOcc_Cycle_py", - "mK0MassVsPtVsOcc_Integral_py" + "mK0sMassVsPtVsOcc_Cycle_pmass", + "mK0sMassVsPtVsOcc_Integral_pmass" ] } ], diff --git a/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h b/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h index 2fc6f7971a..4915ca1a4f 100644 --- a/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h +++ b/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h @@ -19,6 +19,8 @@ #include "QualityControl/CheckInterface.h" #include "QualityControl/Quality.h" +#include + #include namespace o2::quality_control_modules::glo @@ -54,10 +56,17 @@ class ITSTPCmatchingCheck final : public o2::quality_control::checker::CheckInte float mMinEta{ -0.8 }; float mMaxEta{ 0.8 }; + // K0s + bool mShowK0s{ false }; + float mAccRelError{ 0.02 }; + float mAccUncertainty{ 2 }; + static constexpr auto mMassK0s{ o2::constants::physics::MassK0Short }; + // Other int mLimitRange{ -1 }; + bool mIsPbPb{ false }; - ClassDefOverride(ITSTPCmatchingCheck, 1); + ClassDefOverride(ITSTPCmatchingCheck, 2); }; } // namespace o2::quality_control_modules::glo diff --git a/Modules/GLO/src/ITSTPCmatchingCheck.cxx b/Modules/GLO/src/ITSTPCmatchingCheck.cxx index 9bab7a8429..582160526e 100644 --- a/Modules/GLO/src/ITSTPCmatchingCheck.cxx +++ b/Modules/GLO/src/ITSTPCmatchingCheck.cxx @@ -22,6 +22,7 @@ #include "Rtypes.h" #include "TH1.h" +#include "TF1.h" #include "TPaveText.h" #include "TMath.h" #include "TArrow.h" @@ -480,6 +481,45 @@ void ITSTPCmatchingCheck::beautify(std::shared_ptr mo, Quality ch msg->AddText("Not-handled Quality flag, don't panic..."); } eff->GetListOfFunctions()->Add(msg); + } else if (mShowK0s && (name == "mK0sMassVsPtVsOcc_Cycle_pmass" || name == "mK0sMassVsPtVsOcc_Integral_pmass")) { + auto* h = dynamic_cast(mo->getObject()); + if (!h) { + ILOG(Error) << "Failed cast for " << name << " beautify!" << ENDM; + return; + } + auto isCycle = name.find("Cycle") != std::string::npos; + auto msg = new TPaveText(0.6, 0.6, 0.88, 0.88, "NDC;NB"); + h->SetTitle(Form("K0s invariant mass (integrated over #it{p}_{T} and occupancy, %s);K0s mass (GeV/c^{2});entries", (isCycle) ? "current cycle" : "integrated")); + const auto fSignal = (TF1*)h->GetListOfFunctions()->FindObject("gloFitK0sMassSignal"); + if (!fSignal) { + msg->AddText("Fit: Not Performed"); + msg->SetFillColor(kRed); + msg->SetTextColor(kWhite); + } else { + auto unc = std::abs(mMassK0s - fSignal->GetParameter(4)) / fSignal->GetParameter(5); + auto rerr = std::abs(mMassK0s - fSignal->GetParameter(4)) / mMassK0s; + auto max = h->GetMaximum(), min = h->GetMinimum(), textp{ (max - min) * 0.1 }; + auto l = new TLine(mMassK0s, 0, mMassK0s, max); + l->SetLineStyle(kDotted); + h->GetListOfFunctions()->Add(l); + auto t = new TText(mMassK0s - 0.025, textp, "PDG K0s"); + h->GetListOfFunctions()->Add(t); + if (unc > mAccUncertainty || rerr > mAccRelError) { + msg->AddText("Fit: BAD"); + msg->AddText("Not converged"); + msg->AddText(Form("Discrepant %.2f", unc)); + msg->AddText(Form("RError %.2f%%", rerr * 1e2)); + msg->SetFillColor(kRed); + msg->SetTextColor(kWhite); + } else { + msg->AddText("Fit: GOOD"); + msg->AddText(Form("Mass %.1f #pm %.1f (MeV)", fSignal->GetParameter(4) * 1e3, fSignal->GetParameter(5) * 1e3)); + msg->AddText(Form("Consistent %.2f", unc)); + msg->AddText(Form("RError %.2f%%", rerr * 1e2)); + msg->SetFillColor(kGreen); + } + } + h->GetListOfFunctions()->Add(msg); } } @@ -503,7 +543,13 @@ void ITSTPCmatchingCheck::startOfActivity(const Activity& activity) mMaxEta = common::getFromExtendedConfig(activity, mCustomParameters, "maxEta", 0.8f); } + if ((mShowK0s = common::getFromExtendedConfig(activity, mCustomParameters, "showK0s", false))) { + mAccRelError = common::getFromExtendedConfig(activity, mCustomParameters, "acceptableK0sRError", 0.2f); + mAccUncertainty = common::getFromExtendedConfig(activity, mCustomParameters, "acceptableK0sUncertainty", 2.f); + } + mLimitRange = common::getFromExtendedConfig(activity, mCustomParameters, "limitRanges", 5); + mIsPbPb = activity.mBeamType == "Pb-Pb"; } std::vector> ITSTPCmatchingCheck::findRanges(const std::vector& nums) noexcept From 773f6bd5c2af66b9bd8a290eb8a6833294c068e1 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Tue, 25 Feb 2025 19:55:18 +0100 Subject: [PATCH 12/26] GLO: Add MTC Trending Signed-off-by: Felix Schlepper --- Modules/GLO/glo-itstpc-mtch-qcmn-test.json | 4 ++- Modules/GLO/include/GLO/ITSTPCMatchingTask.h | 5 +++ Modules/GLO/src/ITSTPCMatchingTask.cxx | 33 +++++++++++++++++--- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json index a1d087609c..1e203a65e8 100644 --- a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json +++ b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json @@ -48,8 +48,10 @@ "taskParameters": { "GID": "ITS-TPC,ITS", "verbose": "false", - "doMTCratios": "true", + "doMTCRatios": "true", + "doTrendingPt": "true", "doK0QC": "true", + "doTrendingK0s": "true", "isSync": "true", "trackSourcesK0": "ITS,TPC,ITS-TPC,ITS-TPC-TOF,TPC-TOF,TPC-TRD,ITS-TPC-TRD,TPC-TRD-TOF,ITS-TPC-TOF,ITS-TPC-TRD-TOF" }, diff --git a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h index 3bffeb14d9..bfbff3bfdd 100644 --- a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h +++ b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h @@ -66,10 +66,15 @@ class ITSTPCMatchingTask final : public TaskInterface std::unique_ptr mEffEta; std::unique_ptr mEffPhi; + bool mDoPtTrending{ false }; + float mTrendingBinPt{ 1.0 }; + std::unique_ptr mTrendingPt; + bool mDoK0s{ false }; static constexpr auto mMassK0s{ o2::constants::physics::MassK0Short }; std::unique_ptr mK0sCycle; std::unique_ptr mK0sIntegral; + bool mDoK0sMassTrending{ false }; std::unique_ptr mK0sMassTrend; bool fitK0sMass(TH1* h); double mBackgroundRangeLeft{ 0.45 }; diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index 1e22f1c92f..8f980bdc60 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -60,6 +60,20 @@ void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/) mIsSync = common::getFromConfig(mCustomParameters, "isSync", false); // MTC ratios mDoMTCRatios = common::getFromConfig(mCustomParameters, "doMTCRatios", false); + mDoPtTrending = common::getFromConfig(mCustomParameters, "doTrendingPt", false); + mTrendingBinPt = common::getFromConfig(mCustomParameters, "trendingBinPt", 1.0f); + if (mDoPtTrending && !mDoMTCRatios) { + ILOG(Fatal) << "Cannot do pt trending while ratios are disabled!" << ENDM; + } else if (mDoPtTrending) { + mTrendingPt.reset(new TGraph); + mTrendingPt->SetNameTitle("mPtTrending", Form("ITS-TPC matching efficiency trending at %.1f GeV/c;Cycle;Efficiency", mTrendingBinPt)); + mTrendingPt->GetHistogram()->SetMinimum(0.0); + mTrendingPt->GetHistogram()->SetMaximum(1.05); + mTrendingPt->SetMarkerSize(2); + mTrendingPt->SetMarkerStyle(20); + mTrendingPt->SetMarkerColor(kGreen); + getObjectsManager()->startPublishing(mTrendingPt.get(), PublicationPolicy::ThroughStop); + } // K0s mMatchITSTPCQC.setDoK0QC((mDoK0s = getFromConfig(mCustomParameters, "doK0QC", false))); if (mIsSync && mDoK0s) { @@ -76,9 +90,17 @@ void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/) mBackgroundRangeRight = common::getFromConfig(mCustomParameters, "k0sBackgroundRangeRight", 0.54); mBackground.reset(new TF1("gloFitK0sMassBackground", mFitBackground, mBackgroundRangeLeft, mBackgroundRangeRight, mFitBackground.mNPar)); mSignalAndBackground.reset(new TF1("gloFitK0sMassSignal", "[0] + [1] * x + [2] * x * x + gaus(3)", mBackgroundRangeLeft, mBackgroundRangeRight)); - mK0sMassTrend.reset(new TGraphErrors); - mK0sMassTrend->SetNameTitle("mK0MassTrend", "K0s Mass + Sigma;Cycle;K0s mass (GeV/c^{2})"); - getObjectsManager()->startPublishing(mK0sMassTrend.get(), PublicationPolicy::ThroughStop); + + if ((mDoK0sMassTrending = common::getFromConfig(mCustomParameters, "doTrendingK0s", false))) { + mK0sMassTrend.reset(new TGraphErrors); + mK0sMassTrend->SetNameTitle("mK0MassTrend", "K0s Mass + Sigma;Cycle;K0s mass (GeV/c^{2})"); + mK0sMassTrend->SetMarkerSize(2); + mK0sMassTrend->SetMarkerStyle(20); + mK0sMassTrend->SetMarkerColor(kGreen); + mK0sMassTrend->GetHistogram()->SetMinimum(mBackgroundRangeLeft); + mK0sMassTrend->GetHistogram()->SetMaximum(mBackgroundRangeRight); + getObjectsManager()->startPublishing(mK0sMassTrend.get(), PublicationPolicy::ThroughStop); + } } mMatchITSTPCQC.initDataRequest(); @@ -143,6 +165,9 @@ void ITSTPCMatchingTask::endOfCycle() makeRatio(mEffPt, mMatchITSTPCQC.getFractionITSTPCmatch(gloqc::MatchITSTPCQC::ITS)); getObjectsManager()->startPublishing(mEffPt.get(), PublicationPolicy::Once); getObjectsManager()->setDefaultDrawOptions(mEffPt->GetName(), "logx"); + if (mDoPtTrending) { + mTrendingPt->AddPoint(mNCycle, mEffPt->GetBinContent(mEffPt->FindBin(mTrendingBinPt))); + } // Eta makeRatio(mEffEta, mMatchITSTPCQC.getFractionITSTPCmatchEta(gloqc::MatchITSTPCQC::ITS)); @@ -180,7 +205,7 @@ void ITSTPCMatchingTask::endOfCycle() TH1D* h{ nullptr }; getObjectsManager()->startPublishing((h = mK0sCycle->ProjectionY("mK0sMassVsPtVsOcc_Cycle_pmass")), PublicationPolicy::Once); - if (fitK0sMass(h)) { + if (fitK0sMass(h) && mDoK0sMassTrending) { mK0sMassTrend->AddPoint(mNCycle, mSignalAndBackground->GetParameter(4)); mK0sMassTrend->SetPointError(mK0sMassTrend->GetN() - 1, 0., mSignalAndBackground->GetParameter(5)); } From 941e3f12b1114020dd0992f143d79b1c0d4d8ff4 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Wed, 5 Mar 2025 10:04:21 +0100 Subject: [PATCH 13/26] GLO: change to system includes Signed-off-by: Felix Schlepper --- Modules/GLO/include/GLO/ITSTPCMatchingTask.h | 6 ++-- Modules/GLO/src/ITSTPCmatchingCheck.cxx | 30 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h index bfbff3bfdd..89e7b30471 100644 --- a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h +++ b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h @@ -25,9 +25,9 @@ #include -#include "TH3F.h" -#include "TF1.h" -#include "TGraphErrors.h" +#include +#include +#include using namespace o2::quality_control::core; diff --git a/Modules/GLO/src/ITSTPCmatchingCheck.cxx b/Modules/GLO/src/ITSTPCmatchingCheck.cxx index 582160526e..3c716ccabd 100644 --- a/Modules/GLO/src/ITSTPCmatchingCheck.cxx +++ b/Modules/GLO/src/ITSTPCmatchingCheck.cxx @@ -20,18 +20,18 @@ #include "QualityControl/QcInfoLogger.h" #include "Common/Utils.h" -#include "Rtypes.h" -#include "TH1.h" -#include "TF1.h" -#include "TPaveText.h" -#include "TMath.h" -#include "TArrow.h" -#include "TText.h" -#include "TLine.h" -#include "TLegend.h" -#include "TPolyMarker.h" - -#include "fmt/format.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #include using namespace std; @@ -84,7 +84,7 @@ Quality ITSTPCmatchingCheck::check(std::mapGetXaxis()->GetBinLowEdge(binLow), up = eff->GetXaxis()->GetBinUpEdge(binUp); - cBins += fmt::format("{:.1f}-{:.1f},", low, up); + cBins += std::format("{:.1f}-{:.1f},", low, up); } cBins.pop_back(); // remove last `,` cBins += " (GeV/c)"; @@ -125,7 +125,7 @@ Quality ITSTPCmatchingCheck::check(std::mapGetXaxis()->GetBinLowEdge(binLow), up = eff->GetXaxis()->GetBinUpEdge(binUp); - cBins += fmt::format("{:.1f}-{:.1f},", low, up); + cBins += std::format("{:.1f}-{:.1f},", low, up); } cBins.pop_back(); // remove last `,` cBins += " (rad)"; @@ -166,7 +166,7 @@ Quality ITSTPCmatchingCheck::check(std::mapGetXaxis()->GetBinLowEdge(binLow), up = eff->GetXaxis()->GetBinUpEdge(binUp); - cBins += fmt::format("{:.1f}-{:.1f},", low, up); + cBins += std::format("{:.1f}-{:.1f},", low, up); } cBins.pop_back(); // remove last `,` result.updateMetadata("checkEtaBins", cBins); From 4f97f84cfe83d99f1346078e7b48bc4942d08ba2 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Wed, 5 Mar 2025 11:34:50 +0100 Subject: [PATCH 14/26] GLO: Use TrendingTask for K0s mass Signed-off-by: Felix Schlepper --- Modules/GLO/CMakeLists.txt | 101 +++++++------- Modules/GLO/glo-itstpc-mtch-qcmn-pp-test.json | 53 +++++++ Modules/GLO/glo-itstpc-mtch-qcmn-test.json | 47 ++++++- Modules/GLO/include/GLO/Helpers.h | 132 ++++++++++++++++++ Modules/GLO/include/GLO/ITSTPCMatchingTask.h | 38 +---- Modules/GLO/include/GLO/ITSTPCmatchingCheck.h | 4 +- Modules/GLO/include/GLO/K0sFitReductor.h | 35 +++++ Modules/GLO/include/GLO/LinkDef.h | 9 +- Modules/GLO/src/ITSTPCMatchingTask.cxx | 76 ++-------- Modules/GLO/src/ITSTPCmatchingCheck.cxx | 16 +-- Modules/GLO/src/K0sFitReductor.cxx | 31 ++++ 11 files changed, 376 insertions(+), 166 deletions(-) create mode 100644 Modules/GLO/glo-itstpc-mtch-qcmn-pp-test.json create mode 100644 Modules/GLO/include/GLO/Helpers.h create mode 100644 Modules/GLO/include/GLO/K0sFitReductor.h create mode 100644 Modules/GLO/src/K0sFitReductor.cxx diff --git a/Modules/GLO/CMakeLists.txt b/Modules/GLO/CMakeLists.txt index 0f4d2b425e..4fdde069ba 100644 --- a/Modules/GLO/CMakeLists.txt +++ b/Modules/GLO/CMakeLists.txt @@ -1,73 +1,80 @@ # ---- Library ---- -# add_compile_options(-O0 -g -fPIC) add_library(O2QcGLO) -target_sources(O2QcGLO PRIVATE src/ITSTPCmatchingCheck.cxx src/MeanVertexValidator.cxx src/MeanVertexPostProcessing.cxx src/MeanVertexCheck.cxx src/VertexingQcTask.cxx src/ITSTPCMatchingTask.cxx src/DataCompressionQcTask.cxx src/CTFSizeTask.cxx) +target_sources( + O2QcGLO + PRIVATE src/ITSTPCMatchingTask.cxx + src/ITSTPCmatchingCheck.cxx + src/K0sFitReductor.cxx + src/MeanVertexValidator.cxx + src/MeanVertexPostProcessing.cxx + src/MeanVertexCheck.cxx + src/VertexingQcTask.cxx + src/DataCompressionQcTask.cxx + src/CTFSizeTask.cxx) target_include_directories( O2QcGLO - PUBLIC $ - $ + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) -target_link_libraries(O2QcGLO - PUBLIC - O2QualityControl - O2::Steer - O2::DataFormatsGlobalTracking - O2::DataFormatsITS - O2::DataFormatsCalibration - O2::GlobalTracking - O2::GLOQC - O2QcCommon) +target_link_libraries( + O2QcGLO + PUBLIC O2QualityControl + O2::Steer + O2::DataFormatsGlobalTracking + O2::DataFormatsITS + O2::DataFormatsCalibration + O2::GlobalTracking + O2::GLOQC + O2QcCommon) -install(TARGETS O2QcGLO - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install( + TARGETS O2QcGLO + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) # install json files -install(FILES ITSTPCmatchedTracks_external.json - ITSTPCmatchedTracks.json - ITSTPCmatchedTracks_direct.json - vertexing-qc-direct.json - vertexing-qc-direct-mc.json - vertexing-qc.json - vertexing-qc-mc.json - dataCompression-qc.json - glo-mean-vtx-post-processing.json - DESTINATION etc - ) +install( + FILES ITSTPCmatchedTracks_external.json + ITSTPCmatchedTracks.json + ITSTPCmatchedTracks_direct.json + vertexing-qc-direct.json + vertexing-qc-direct-mc.json + vertexing-qc.json + vertexing-qc-mc.json + dataCompression-qc.json + glo-mean-vtx-post-processing.json + DESTINATION etc) -add_root_dictionary(O2QcGLO - HEADERS - include/GLO/MeanVertexValidator.h - include/GLO/MeanVertexPostProcessing.h - include/GLO/MeanVertexCheck.h - include/GLO/VertexingQcTask.h - include/GLO/ITSTPCMatchingTask.h - include/GLO/DataCompressionQcTask.h - include/GLO/CTFSizeTask.h - include/GLO/ITSTPCmatchingCheck.h - LINKDEF include/GLO/LinkDef.h) +add_root_dictionary( + O2QcGLO + HEADERS include/GLO/MeanVertexValidator.h + include/GLO/MeanVertexPostProcessing.h + include/GLO/MeanVertexCheck.h + include/GLO/VertexingQcTask.h + include/GLO/DataCompressionQcTask.h + include/GLO/CTFSizeTask.h + include/GLO/ITSTPCMatchingTask.h + include/GLO/ITSTPCmatchingCheck.h + include/GLO/K0sFitReductor.h + LINKDEF include/GLO/LinkDef.h) -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/GLO - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/QualityControl") +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/GLO DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/QualityControl") # ---- Test(s) ---- -#set(TEST_SRCS test/testQcGLO.cxx) # uncomment to reenable the test which was empty +# set(TEST_SRCS test/testQcGLO.cxx) # uncomment to reenable the test which was empty foreach(test ${TEST_SRCS}) get_filename_component(test_name ${test} NAME) string(REGEX REPLACE ".cxx" "" test_name ${test_name}) add_executable(${test_name} ${test}) - target_link_libraries(${test_name} - PRIVATE O2QcGLO Boost::unit_test_framework) + target_link_libraries(${test_name} PRIVATE O2QcGLO Boost::unit_test_framework) add_test(NAME ${test_name} COMMAND ${test_name}) - set_property(TARGET ${test_name} - PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) + set_property(TARGET ${test_name} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests) set_tests_properties(${test_name} PROPERTIES TIMEOUT 20) endforeach() diff --git a/Modules/GLO/glo-itstpc-mtch-qcmn-pp-test.json b/Modules/GLO/glo-itstpc-mtch-qcmn-pp-test.json new file mode 100644 index 0000000000..63b6501d20 --- /dev/null +++ b/Modules/GLO/glo-itstpc-mtch-qcmn-pp-test.json @@ -0,0 +1,53 @@ +"qc": { + "config": { + "database": { + "implementation": "CCDB", + "host": "ccdb-test.cern.ch:8080" + }, + "Activity": {}, + "monitoring": { + "url": "infologger:///debug?qc" + } + }, + "postprocessing": { + "K0sTrendingTask": { + "active": "true", + "taskName": "K0sTrendingTask", + "className": "o2::quality_control::postprocessing::TrendingTask", + "moduleName": "QcGLO", + "detectorName": "GLO", + "dataSources": [ + { + "type": "repository", + "path": "TST/MO/)json" + + taskName + R"json(", + "name": "testHistoTrending", + "reductorName": "o2::quality_control_modules::glo::K0sFitReductor", + "moduleName": "QcGLO" + } + ], + "plots": [ + { + "name": "mean_of_histogram", + "title": "Mean trend of the testHistoTrending histogram", + "graphs": [{ + "varexp": "testHistoTrending.mean:time", + "selection": "", + "option": "*L" + }] + }, + { + "name": "quality_histogram", + "title": "Histogram of qualities", + "varexp": ")json" + + checkName + R"json(.level", + "selection": "", + "option": "" + } + ], + "initTrigger": [], + "updateTrigger": [], + "stopTrigger": [] + } + } +} diff --git a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json index 1e203a65e8..60cd4163bf 100644 --- a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json +++ b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json @@ -49,9 +49,7 @@ "GID": "ITS-TPC,ITS", "verbose": "false", "doMTCRatios": "true", - "doTrendingPt": "true", "doK0QC": "true", - "doTrendingK0s": "true", "isSync": "true", "trackSourcesK0": "ITS,TPC,ITS-TPC,ITS-TPC-TOF,TPC-TOF,TPC-TRD,ITS-TPC-TRD,TPC-TRD-TOF,ITS-TPC-TOF,ITS-TPC-TRD-TOF" }, @@ -99,6 +97,51 @@ } } } + }, + "postprocessing": { + "K0sMassTrend": { + "active": "true", + "className": "o2::quality_control::postprocessing::TrendingTask", + "moduleName": "QcGLO", + "detectorName": "GLO", + "resumeTrend": "false", + "initTrigger": [ + "once" + ], + "updateTrigger": [ + "newobject:qcdb:GLO/MO/ITSTPCMatchingTask/gloFitK0sMassSignal" + ], + "stopTrigger": [ + "usercontrol" + ], + "dataSources": [ + { + "type": "repository", + "path": "GLO/MO/ITSTPCMatchingTask", + "names": [ + "gloFitK0sMassSignal" + ], + "reductorName": "o2::quality_control_modules::glo::K0sFitReductor", + "moduleName": "QcGLO" + } + ], + "plots": [ + { + "name": "glo_k0s_mass_trending", + "title": "Fitted K0s mass", + "varexp": "gloFitK0sMassSignal.mean:time", + "option": "*L", + "graphAxisLabel": "K0s mass (GeV/c^{2}):time" + }, + { + "name": "glo_k0s_sigma_trending", + "title": "Fitted K0s sigma", + "varexp": "gloFitK0sMassSignal.sigma:time", + "option": "*L", + "graphAxisLabel": "#sigma_{K0s mass (GeV/c^{2})}:time" + } + ] + } } } } diff --git a/Modules/GLO/include/GLO/Helpers.h b/Modules/GLO/include/GLO/Helpers.h new file mode 100644 index 0000000000..79d0f5a750 --- /dev/null +++ b/Modules/GLO/include/GLO/Helpers.h @@ -0,0 +1,132 @@ +// 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. + +#ifndef QC_MODULE_GLO_HELPERS_H +#define QC_MODULE_GLO_HELPERS_H + +#include "QualityControl/QcInfoLogger.h" +#include "QualityControl/CustomParameters.h" +#include "QualityControl/Activity.h" +#include "Common/Utils.h" + +#include + +#include + +#include +#include +#include +#include + +namespace o2::quality_control_modules::glo::helpers +{ + +// Simple class to fit K0s mass +struct K0sFitter { + enum Parameters : uint8_t { + // Background + Pol0 = 0, + Pol1 = 1, + Pol2 = 2, + // K0s + Amplitude = 3, + Mass = 4, + Sigma = 5, + }; + static constexpr auto mMassK0s{ o2::constants::physics::MassK0Short }; + double mBackgroundRangeLeft{ 0.45 }; + double mBackgroundRangeRight{ 0.54 }; + struct FitBackground { + static constexpr int mNPar{ 3 }; + double mRejLeft{ 0.48 }; + double mRejRight{ 0.51 }; + double operator()(double* x, double* p) const + { + if (x[0] > mRejLeft && x[0] < mRejRight) { + TF1::RejectPoint(); + return 0; + } + return p[0] + (p[1] * x[0]) + (p[2] * x[0] * x[0]); + } + } mFitBackground; + std::unique_ptr mBackground; + std::unique_ptr mSignalAndBackground; + + void init(o2::quality_control::core::CustomParameters const& pars) + { + mFitBackground.mRejLeft = common::getFromConfig(pars, "k0sBackgroundRejLeft", 0.48); + mFitBackground.mRejRight = common::getFromConfig(pars, "k0sBackgroundRejRight", 0.51); + mBackgroundRangeLeft = common::getFromConfig(pars, "k0sBackgroundRangeLeft", 0.45); + mBackgroundRangeRight = common::getFromConfig(pars, "k0sBackgroundRangeRight", 0.54); + initImpl(); + } + + void init(o2::quality_control::core::CustomParameters const& pars, o2::quality_control::core::Activity const& activity) + { + mFitBackground.mRejLeft = common::getFromExtendedConfig(activity, pars, "k0sBackgroundRejLeft", 0.48); + mFitBackground.mRejRight = common::getFromExtendedConfig(activity, pars, "k0sBackgroundRejRight", 0.51); + mBackgroundRangeLeft = common::getFromExtendedConfig(activity, pars, "k0sBackgroundRangeLeft", 0.45); + mBackgroundRangeRight = common::getFromExtendedConfig(activity, pars, "k0sBackgroundRangeRight", 0.54); + initImpl(); + } + + void initImpl() + { + mBackground.reset(new TF1("gloFitK0sMassBackground", mFitBackground, mBackgroundRangeLeft, mBackgroundRangeRight, mFitBackground.mNPar)); + mSignalAndBackground.reset(new TF1("gloFitK0sMassSignal", "[0] + [1] * x + [2] * x * x + gaus(3)", mBackgroundRangeLeft, mBackgroundRangeRight)); + } + + bool fit(TH1* h, bool add = false) + { + if (h->GetEntries() == 0) { + ILOG(Warning, Devel) << "Cannot fit empty histogram: " << h->GetName() << ENDM; + return false; + } + TFitResultPtr res = h->Fit(mBackground.get(), "SRNQ"); + if (res->Status() > 1) { + ILOG(Warning, Devel) << "Failed k0s background fit for histogram: " << h->GetName() << ENDM; + return false; + } + mSignalAndBackground->SetParameter(Parameters::Pol0, mBackground->GetParameter(Parameters::Pol0)); + mSignalAndBackground->SetParameter(Parameters::Pol1, mBackground->GetParameter(Parameters::Pol1)); + mSignalAndBackground->SetParameter(Parameters::Pol2, mBackground->GetParameter(Parameters::Pol2)); + mSignalAndBackground->SetParameter(Parameters::Amplitude, h->GetMaximum() - mBackground->Eval(mMassK0s)); + mSignalAndBackground->SetParameter(Parameters::Mass, mMassK0s); + mSignalAndBackground->SetParameter(Parameters::Sigma, 0.005); + mSignalAndBackground->SetParLimits(Parameters::Sigma, 1e-6, 1); + h->Fit(mSignalAndBackground.get(), (add) ? "RMQ" : "RMQ0"); + return true; + } + + auto getMass() const noexcept + { + return mSignalAndBackground->GetParameter(4); + } + + auto getSigma() const noexcept + { + return mSignalAndBackground->GetParameter(5); + } + + auto getUncertainty() const noexcept + { + return std::abs(mMassK0s - getMass()) / getSigma(); + } + + auto getRelativeError() const noexcept + { + return std::abs(mMassK0s - getMass()) / mMassK0s; + } +}; + +} // namespace o2::quality_control_modules::glo::helpers + +#endif diff --git a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h index 89e7b30471..6435841af6 100644 --- a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h +++ b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h @@ -20,14 +20,13 @@ #include "QualityControl/TaskInterface.h" #include "GLOQC/MatchITSTPCQC.h" #include "Common/TH1Ratio.h" +#include "GLO/Helpers.h" #include #include #include -#include -#include using namespace o2::quality_control::core; @@ -39,12 +38,6 @@ namespace o2::quality_control_modules::glo class ITSTPCMatchingTask final : public TaskInterface { public: - /// \brief Constructor - ITSTPCMatchingTask() = default; - /// Destructor - ~ITSTPCMatchingTask() override = default; - - // Definition of the methods for the template method pattern void initialize(o2::framework::InitContext& ctx) override; void startOfActivity(const Activity& activity) override; void startOfCycle() override; @@ -56,8 +49,6 @@ class ITSTPCMatchingTask final : public TaskInterface private: o2::gloqc::MatchITSTPCQC mMatchITSTPCQC; - unsigned int mNCycle{ 0 }; - bool mIsSync{ false }; bool mIsPbPb{ false }; @@ -66,34 +57,11 @@ class ITSTPCMatchingTask final : public TaskInterface std::unique_ptr mEffEta; std::unique_ptr mEffPhi; - bool mDoPtTrending{ false }; - float mTrendingBinPt{ 1.0 }; - std::unique_ptr mTrendingPt; - bool mDoK0s{ false }; - static constexpr auto mMassK0s{ o2::constants::physics::MassK0Short }; + bool mPublishK0s3D{ false }; std::unique_ptr mK0sCycle; std::unique_ptr mK0sIntegral; - bool mDoK0sMassTrending{ false }; - std::unique_ptr mK0sMassTrend; - bool fitK0sMass(TH1* h); - double mBackgroundRangeLeft{ 0.45 }; - double mBackgroundRangeRight{ 0.54 }; - struct FitBackground { - static constexpr int mNPar{ 3 }; - double mRejLeft{ 0.48 }; - double mRejRight{ 0.51 }; - double operator()(double* x, double* p) const - { - if (x[0] > mRejLeft && x[0] < mRejRight) { - TF1::RejectPoint(); - return 0; - } - return p[0] + (p[1] * x[0]) + (p[2] * x[0] * x[0]); - } - } mFitBackground; - std::unique_ptr mBackground; - std::unique_ptr mSignalAndBackground; + helpers::K0sFitter mK0sFitter; }; } // namespace o2::quality_control_modules::glo diff --git a/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h b/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h index 4915ca1a4f..98090b46a5 100644 --- a/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h +++ b/Modules/GLO/include/GLO/ITSTPCmatchingCheck.h @@ -19,7 +19,7 @@ #include "QualityControl/CheckInterface.h" #include "QualityControl/Quality.h" -#include +#include "GLO/Helpers.h" #include @@ -60,7 +60,7 @@ class ITSTPCmatchingCheck final : public o2::quality_control::checker::CheckInte bool mShowK0s{ false }; float mAccRelError{ 0.02 }; float mAccUncertainty{ 2 }; - static constexpr auto mMassK0s{ o2::constants::physics::MassK0Short }; + helpers::K0sFitter mK0sFitter; // Other int mLimitRange{ -1 }; diff --git a/Modules/GLO/include/GLO/K0sFitReductor.h b/Modules/GLO/include/GLO/K0sFitReductor.h new file mode 100644 index 0000000000..394897a33e --- /dev/null +++ b/Modules/GLO/include/GLO/K0sFitReductor.h @@ -0,0 +1,35 @@ +// 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. + +#ifndef QUALITYCONTROL_K0SFITREDUCTOR_H +#define QUALITYCONTROL_K0SFITREDUCTOR_H + +#include "QualityControl/ReductorTObject.h" + +namespace o2::quality_control_modules::glo +{ + +class K0sFitReductor final : public quality_control::postprocessing::ReductorTObject +{ + void* getBranchAddress() final { return &mStats; }; + const char* getBranchLeafList() final { return "mean/D:sigma"; }; + void update(TObject* obj) override; + + private: + struct { + Double_t mean; + Double_t stddev; + } mStats; +}; + +} // namespace o2::quality_control_modules::glo + +#endif diff --git a/Modules/GLO/include/GLO/LinkDef.h b/Modules/GLO/include/GLO/LinkDef.h index db72a3196f..f21315dd6e 100644 --- a/Modules/GLO/include/GLO/LinkDef.h +++ b/Modules/GLO/include/GLO/LinkDef.h @@ -3,16 +3,15 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class o2::quality_control_modules::glo::VertexingQcTask + ; -#pragma link C++ class o2::quality_control_modules::glo::ITSTPCMatchingTask + ; +#pragma link C++ class o2::quality_control_modules::glo::CTFSize + ; #pragma link C++ class o2::quality_control_modules::glo::DataCompressionQcTask + ; #pragma link C++ class o2::quality_control_modules::glo::MeanVertexPostProcessing + ; - #pragma link C++ class o2::quality_control_modules::glo::MeanVertexCheck + ; #pragma link C++ class o2::quality_control_modules::glo::MeanVertexValidator + ; +#pragma link C++ class o2::quality_control_modules::glo::VertexingQcTask + ; -#pragma link C++ class o2::quality_control_modules::glo::CTFSize + ; +#pragma link C++ class o2::quality_control_modules::glo::ITSTPCMatchingTask + ; #pragma link C++ class o2::quality_control_modules::glo::ITSTPCmatchingCheck + ; - +#pragma link C++ class o2::quality_control_modules::glo::K0sFitReductor + ; #endif diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index 8f980bdc60..2787b0c7a4 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -14,11 +14,7 @@ /// \author Chiara Zampolli /// -#include -#include #include -#include -#include #include "QualityControl/QcInfoLogger.h" #include "GLO/ITSTPCMatchingTask.h" @@ -60,20 +56,6 @@ void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/) mIsSync = common::getFromConfig(mCustomParameters, "isSync", false); // MTC ratios mDoMTCRatios = common::getFromConfig(mCustomParameters, "doMTCRatios", false); - mDoPtTrending = common::getFromConfig(mCustomParameters, "doTrendingPt", false); - mTrendingBinPt = common::getFromConfig(mCustomParameters, "trendingBinPt", 1.0f); - if (mDoPtTrending && !mDoMTCRatios) { - ILOG(Fatal) << "Cannot do pt trending while ratios are disabled!" << ENDM; - } else if (mDoPtTrending) { - mTrendingPt.reset(new TGraph); - mTrendingPt->SetNameTitle("mPtTrending", Form("ITS-TPC matching efficiency trending at %.1f GeV/c;Cycle;Efficiency", mTrendingBinPt)); - mTrendingPt->GetHistogram()->SetMinimum(0.0); - mTrendingPt->GetHistogram()->SetMaximum(1.05); - mTrendingPt->SetMarkerSize(2); - mTrendingPt->SetMarkerStyle(20); - mTrendingPt->SetMarkerColor(kGreen); - getObjectsManager()->startPublishing(mTrendingPt.get(), PublicationPolicy::ThroughStop); - } // K0s mMatchITSTPCQC.setDoK0QC((mDoK0s = getFromConfig(mCustomParameters, "doK0QC", false))); if (mIsSync && mDoK0s) { @@ -84,23 +66,8 @@ void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/) mMatchITSTPCQC.setTrkSources(o2::dataformats::GlobalTrackID::getSourcesMask(param->second)); } - mFitBackground.mRejLeft = common::getFromConfig(mCustomParameters, "k0sBackgroundRejLeft", 0.48); - mFitBackground.mRejRight = common::getFromConfig(mCustomParameters, "k0sBackgroundRejRight", 0.51); - mBackgroundRangeLeft = common::getFromConfig(mCustomParameters, "k0sBackgroundRangeLeft", 0.45); - mBackgroundRangeRight = common::getFromConfig(mCustomParameters, "k0sBackgroundRangeRight", 0.54); - mBackground.reset(new TF1("gloFitK0sMassBackground", mFitBackground, mBackgroundRangeLeft, mBackgroundRangeRight, mFitBackground.mNPar)); - mSignalAndBackground.reset(new TF1("gloFitK0sMassSignal", "[0] + [1] * x + [2] * x * x + gaus(3)", mBackgroundRangeLeft, mBackgroundRangeRight)); - - if ((mDoK0sMassTrending = common::getFromConfig(mCustomParameters, "doTrendingK0s", false))) { - mK0sMassTrend.reset(new TGraphErrors); - mK0sMassTrend->SetNameTitle("mK0MassTrend", "K0s Mass + Sigma;Cycle;K0s mass (GeV/c^{2})"); - mK0sMassTrend->SetMarkerSize(2); - mK0sMassTrend->SetMarkerStyle(20); - mK0sMassTrend->SetMarkerColor(kGreen); - mK0sMassTrend->GetHistogram()->SetMinimum(mBackgroundRangeLeft); - mK0sMassTrend->GetHistogram()->SetMaximum(mBackgroundRangeRight); - getObjectsManager()->startPublishing(mK0sMassTrend.get(), PublicationPolicy::ThroughStop); - } + mPublishK0s3D = getFromConfig(mCustomParameters, "publishK0s3D", false); + mK0sFitter.init(mCustomParameters); } mMatchITSTPCQC.initDataRequest(); @@ -113,7 +80,6 @@ void ITSTPCMatchingTask::startOfActivity(const Activity& activity) ILOG(Debug, Devel) << "startOfActivity " << activity.mId << ENDM; mMatchITSTPCQC.reset(); mIsPbPb = activity.mBeamType == "Pb-Pb"; - mNCycle = 0; } void ITSTPCMatchingTask::startOfCycle() @@ -165,9 +131,6 @@ void ITSTPCMatchingTask::endOfCycle() makeRatio(mEffPt, mMatchITSTPCQC.getFractionITSTPCmatch(gloqc::MatchITSTPCQC::ITS)); getObjectsManager()->startPublishing(mEffPt.get(), PublicationPolicy::Once); getObjectsManager()->setDefaultDrawOptions(mEffPt->GetName(), "logx"); - if (mDoPtTrending) { - mTrendingPt->AddPoint(mNCycle, mEffPt->GetBinContent(mEffPt->FindBin(mTrendingBinPt))); - } // Eta makeRatio(mEffEta, mMatchITSTPCQC.getFractionITSTPCmatchEta(gloqc::MatchITSTPCQC::ITS)); @@ -200,20 +163,20 @@ void ITSTPCMatchingTask::endOfCycle() mK0sIntegral->Reset(); mK0sIntegral->Add(k0s); - getObjectsManager()->startPublishing(mK0sCycle.get(), PublicationPolicy::Once); - getObjectsManager()->startPublishing(mK0sIntegral.get(), PublicationPolicy::Once); + if (mPublishK0s3D) { + getObjectsManager()->startPublishing(mK0sCycle.get(), PublicationPolicy::Once); + getObjectsManager()->startPublishing(mK0sIntegral.get(), PublicationPolicy::Once); + } TH1D* h{ nullptr }; getObjectsManager()->startPublishing((h = mK0sCycle->ProjectionY("mK0sMassVsPtVsOcc_Cycle_pmass")), PublicationPolicy::Once); - if (fitK0sMass(h) && mDoK0sMassTrending) { - mK0sMassTrend->AddPoint(mNCycle, mSignalAndBackground->GetParameter(4)); - mK0sMassTrend->SetPointError(mK0sMassTrend->GetN() - 1, 0., mSignalAndBackground->GetParameter(5)); + if (mK0sFitter.fit(h)) { + getObjectsManager()->startPublishing(mK0sFitter.mSignalAndBackground.get(), PublicationPolicy::Once); } + getObjectsManager()->startPublishing((h = mK0sIntegral->ProjectionY("mK0sMassVsPtVsOcc_Integral_pmass")), PublicationPolicy::Once); - fitK0sMass(h); } } - ++mNCycle; } void ITSTPCMatchingTask::endOfActivity(const Activity& /*activity*/) @@ -232,25 +195,4 @@ void ITSTPCMatchingTask::reset() mEffEta.reset(); } -bool ITSTPCMatchingTask::fitK0sMass(TH1* h) -{ - if (h->GetEntries() == 0) { - ILOG(Warning, Devel) << "Cannot fit empty histogram: " << h->GetName() << ENDM; - return false; - } - TFitResultPtr res = h->Fit(mBackground.get(), "SRNQ"); - if (res->Status() > 1) { - ILOG(Warning, Devel) << "Failed k0s background fit for histogram: " << h->GetName() << ENDM; - return false; - } - mSignalAndBackground->SetParameter(0, mBackground->GetParameter(0)); // p0 - mSignalAndBackground->SetParameter(1, mBackground->GetParameter(1)); // p1 - mSignalAndBackground->SetParameter(2, mBackground->GetParameter(2)); // p2 - mSignalAndBackground->SetParameter(3, h->GetMaximum() - mBackground->Eval(mMassK0s)); // A (best guess) - mSignalAndBackground->SetParameter(4, mMassK0s); // mean - mSignalAndBackground->SetParameter(5, 0.005); // sigma - h->Fit(mSignalAndBackground.get(), "RMQ"); - return true; -} - } // namespace o2::quality_control_modules::glo diff --git a/Modules/GLO/src/ITSTPCmatchingCheck.cxx b/Modules/GLO/src/ITSTPCmatchingCheck.cxx index 3c716ccabd..4ae6338fc4 100644 --- a/Modules/GLO/src/ITSTPCmatchingCheck.cxx +++ b/Modules/GLO/src/ITSTPCmatchingCheck.cxx @@ -490,19 +490,18 @@ void ITSTPCmatchingCheck::beautify(std::shared_ptr mo, Quality ch auto isCycle = name.find("Cycle") != std::string::npos; auto msg = new TPaveText(0.6, 0.6, 0.88, 0.88, "NDC;NB"); h->SetTitle(Form("K0s invariant mass (integrated over #it{p}_{T} and occupancy, %s);K0s mass (GeV/c^{2});entries", (isCycle) ? "current cycle" : "integrated")); - const auto fSignal = (TF1*)h->GetListOfFunctions()->FindObject("gloFitK0sMassSignal"); - if (!fSignal) { - msg->AddText("Fit: Not Performed"); + if (!mK0sFitter.fit(h, true)) { + msg->AddText("Fit: Failed"); msg->SetFillColor(kRed); msg->SetTextColor(kWhite); } else { - auto unc = std::abs(mMassK0s - fSignal->GetParameter(4)) / fSignal->GetParameter(5); - auto rerr = std::abs(mMassK0s - fSignal->GetParameter(4)) / mMassK0s; + auto unc = mK0sFitter.getUncertainty(); + auto rerr = mK0sFitter.getRelativeError(); auto max = h->GetMaximum(), min = h->GetMinimum(), textp{ (max - min) * 0.1 }; - auto l = new TLine(mMassK0s, 0, mMassK0s, max); + auto l = new TLine(mK0sFitter.mMassK0s, 0, mK0sFitter.mMassK0s, max); l->SetLineStyle(kDotted); h->GetListOfFunctions()->Add(l); - auto t = new TText(mMassK0s - 0.025, textp, "PDG K0s"); + auto t = new TText(mK0sFitter.mMassK0s - 0.025, textp, "PDG K0s"); h->GetListOfFunctions()->Add(t); if (unc > mAccUncertainty || rerr > mAccRelError) { msg->AddText("Fit: BAD"); @@ -513,7 +512,7 @@ void ITSTPCmatchingCheck::beautify(std::shared_ptr mo, Quality ch msg->SetTextColor(kWhite); } else { msg->AddText("Fit: GOOD"); - msg->AddText(Form("Mass %.1f #pm %.1f (MeV)", fSignal->GetParameter(4) * 1e3, fSignal->GetParameter(5) * 1e3)); + msg->AddText(Form("Mass %.1f #pm %.1f (MeV)", mK0sFitter.getMass() * 1e3, mK0sFitter.getSigma() * 1e3)); msg->AddText(Form("Consistent %.2f", unc)); msg->AddText(Form("RError %.2f%%", rerr * 1e2)); msg->SetFillColor(kGreen); @@ -546,6 +545,7 @@ void ITSTPCmatchingCheck::startOfActivity(const Activity& activity) if ((mShowK0s = common::getFromExtendedConfig(activity, mCustomParameters, "showK0s", false))) { mAccRelError = common::getFromExtendedConfig(activity, mCustomParameters, "acceptableK0sRError", 0.2f); mAccUncertainty = common::getFromExtendedConfig(activity, mCustomParameters, "acceptableK0sUncertainty", 2.f); + mK0sFitter.init(mCustomParameters, activity); } mLimitRange = common::getFromExtendedConfig(activity, mCustomParameters, "limitRanges", 5); diff --git a/Modules/GLO/src/K0sFitReductor.cxx b/Modules/GLO/src/K0sFitReductor.cxx new file mode 100644 index 0000000000..dbb3b6fdbe --- /dev/null +++ b/Modules/GLO/src/K0sFitReductor.cxx @@ -0,0 +1,31 @@ +// 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. + +#include "GLO/K0sFitReductor.h" +#include "GLO/Helpers.h" + +#include + +namespace o2::quality_control_modules::glo +{ + +void K0sFitReductor::update(TObject* obj) +{ + auto f = dynamic_cast(obj); + if (!f) { + return; + } + + mStats.mean = f->GetParameter(helpers::K0sFitter::Parameters::Mass); + mStats.stddev = f->GetParameter(helpers::K0sFitter::Parameters::Sigma); +} + +} // namespace o2::quality_control_modules::glo From c890a18e12fdcec06d82b7bc54cf430d5e3d430c Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Fri, 7 Mar 2025 15:14:39 +0100 Subject: [PATCH 15/26] GLO: generalize reductor Signed-off-by: Felix Schlepper --- Modules/GLO/CMakeLists.txt | 4 ++-- Modules/GLO/include/GLO/{K0sFitReductor.h => Reductors.h} | 0 Modules/GLO/src/{K0sFitReductor.cxx => Reductors.cxx} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename Modules/GLO/include/GLO/{K0sFitReductor.h => Reductors.h} (100%) rename Modules/GLO/src/{K0sFitReductor.cxx => Reductors.cxx} (96%) diff --git a/Modules/GLO/CMakeLists.txt b/Modules/GLO/CMakeLists.txt index 4fdde069ba..5bcb337d41 100644 --- a/Modules/GLO/CMakeLists.txt +++ b/Modules/GLO/CMakeLists.txt @@ -6,7 +6,7 @@ target_sources( O2QcGLO PRIVATE src/ITSTPCMatchingTask.cxx src/ITSTPCmatchingCheck.cxx - src/K0sFitReductor.cxx + src/Reductors.cxx src/MeanVertexValidator.cxx src/MeanVertexPostProcessing.cxx src/MeanVertexCheck.cxx @@ -59,7 +59,7 @@ add_root_dictionary( include/GLO/CTFSizeTask.h include/GLO/ITSTPCMatchingTask.h include/GLO/ITSTPCmatchingCheck.h - include/GLO/K0sFitReductor.h + include/GLO/Reductors.h LINKDEF include/GLO/LinkDef.h) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/GLO DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/QualityControl") diff --git a/Modules/GLO/include/GLO/K0sFitReductor.h b/Modules/GLO/include/GLO/Reductors.h similarity index 100% rename from Modules/GLO/include/GLO/K0sFitReductor.h rename to Modules/GLO/include/GLO/Reductors.h diff --git a/Modules/GLO/src/K0sFitReductor.cxx b/Modules/GLO/src/Reductors.cxx similarity index 96% rename from Modules/GLO/src/K0sFitReductor.cxx rename to Modules/GLO/src/Reductors.cxx index dbb3b6fdbe..33c0912ad4 100644 --- a/Modules/GLO/src/K0sFitReductor.cxx +++ b/Modules/GLO/src/Reductors.cxx @@ -9,7 +9,7 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#include "GLO/K0sFitReductor.h" +#include "GLO/Reductors.h" #include "GLO/Helpers.h" #include From 9419ff1894a74ba65e337dc63944309815448d70 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Fri, 7 Mar 2025 16:20:29 +0100 Subject: [PATCH 16/26] GLO: Add mtc pt trending Signed-off-by: Felix Schlepper --- Modules/GLO/glo-itstpc-mtch-qcmn-test.json | 40 ++++++++++++++++++++ Modules/GLO/include/GLO/ITSTPCMatchingTask.h | 4 ++ Modules/GLO/include/GLO/LinkDef.h | 1 + Modules/GLO/include/GLO/Reductors.h | 20 ++++++++-- Modules/GLO/src/ITSTPCMatchingTask.cxx | 11 +++++- Modules/GLO/src/Reductors.cxx | 12 +++++- 6 files changed, 82 insertions(+), 6 deletions(-) diff --git a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json index 60cd4163bf..5bba7f0cd7 100644 --- a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json +++ b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json @@ -49,6 +49,7 @@ "GID": "ITS-TPC,ITS", "verbose": "false", "doMTCRatios": "true", + "doMTCTrending": "true", "doK0QC": "true", "isSync": "true", "trackSourcesK0": "ITS,TPC,ITS-TPC,ITS-TPC-TOF,TPC-TOF,TPC-TRD,ITS-TPC-TRD,TPC-TRD-TOF,ITS-TPC-TOF,ITS-TPC-TRD-TOF" @@ -131,6 +132,7 @@ "title": "Fitted K0s mass", "varexp": "gloFitK0sMassSignal.mean:time", "option": "*L", + "graphYRange": "0.45:0.55", "graphAxisLabel": "K0s mass (GeV/c^{2}):time" }, { @@ -138,9 +140,47 @@ "title": "Fitted K0s sigma", "varexp": "gloFitK0sMassSignal.sigma:time", "option": "*L", + "graphYRange": "0:0.01", "graphAxisLabel": "#sigma_{K0s mass (GeV/c^{2})}:time" } ] + }, + "MTCTrend": { + "active": "true", + "className": "o2::quality_control::postprocessing::TrendingTask", + "moduleName": "QcGLO", + "detectorName": "GLO", + "resumeTrend": "false", + "initTrigger": [ + "once" + ], + "updateTrigger": [ + "newobject:qcdb:GLO/MO/ITSTPCMatchingTask/gloMTCTrendingObject" + ], + "stopTrigger": [ + "usercontrol" + ], + "dataSources": [ + { + "type": "repository", + "path": "GLO/MO/ITSTPCMatchingTask", + "names": [ + "gloMTCTrendingObject" + ], + "reductorName": "o2::quality_control_modules::glo::MTCReductor", + "moduleName": "QcGLO" + } + ], + "plots": [ + { + "name": "glo_mtc_pt_trending", + "title": "MTC #it{p}_{T} trending", + "varexp": "gloMTCTrendingObject.pt:time", + "option": "*L", + "graphYRange": "0:1.02", + "graphAxisLabel": "MTC:time" + } + ] } } } diff --git a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h index 6435841af6..95e21fd7ca 100644 --- a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h +++ b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h @@ -21,6 +21,7 @@ #include "GLOQC/MatchITSTPCQC.h" #include "Common/TH1Ratio.h" #include "GLO/Helpers.h" +#include "GLO/Reductors.h" #include @@ -56,6 +57,9 @@ class ITSTPCMatchingTask final : public TaskInterface std::unique_ptr mEffPt; std::unique_ptr mEffEta; std::unique_ptr mEffPhi; + bool mDoMTCTrending{ false }; + float mMTCTrendingPt{ 1.5 }; + std::unique_ptr mMTCTrendingObject; bool mDoK0s{ false }; bool mPublishK0s3D{ false }; diff --git a/Modules/GLO/include/GLO/LinkDef.h b/Modules/GLO/include/GLO/LinkDef.h index f21315dd6e..67810a81b4 100644 --- a/Modules/GLO/include/GLO/LinkDef.h +++ b/Modules/GLO/include/GLO/LinkDef.h @@ -14,4 +14,5 @@ #pragma link C++ class o2::quality_control_modules::glo::ITSTPCMatchingTask + ; #pragma link C++ class o2::quality_control_modules::glo::ITSTPCmatchingCheck + ; #pragma link C++ class o2::quality_control_modules::glo::K0sFitReductor + ; +#pragma link C++ class o2::quality_control_modules::glo::MTCReductor + ; #endif diff --git a/Modules/GLO/include/GLO/Reductors.h b/Modules/GLO/include/GLO/Reductors.h index 394897a33e..44625faf5c 100644 --- a/Modules/GLO/include/GLO/Reductors.h +++ b/Modules/GLO/include/GLO/Reductors.h @@ -20,13 +20,25 @@ namespace o2::quality_control_modules::glo class K0sFitReductor final : public quality_control::postprocessing::ReductorTObject { void* getBranchAddress() final { return &mStats; }; - const char* getBranchLeafList() final { return "mean/D:sigma"; }; - void update(TObject* obj) override; + const char* getBranchLeafList() final { return "mean/F:sigma/F"; }; + void update(TObject* obj) final; private: struct { - Double_t mean; - Double_t stddev; + Float_t mean; + Float_t sigma; + } mStats; +}; + +class MTCReductor final : public quality_control::postprocessing::ReductorTObject +{ + void* getBranchAddress() final { return &mStats; }; + const char* getBranchLeafList() final { return "pt/F"; }; + void update(TObject* obj) final; + + private: + struct { + Float_t pt; } mStats; }; diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index 2787b0c7a4..863adb542c 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -55,7 +55,12 @@ void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/) // Sync mIsSync = common::getFromConfig(mCustomParameters, "isSync", false); // MTC ratios - mDoMTCRatios = common::getFromConfig(mCustomParameters, "doMTCRatios", false); + if ((mDoMTCRatios = common::getFromConfig(mCustomParameters, "doMTCRatios", false))) { + if ((mDoMTCTrending = getFromConfig(mCustomParameters, "doMTCTrending", false))) { + mMTCTrendingPt = getFromConfig(mCustomParameters, "trendingPt", 1.5f); + mMTCTrendingObject.reset(new TF1("gloMTCTrendingObject", "pol0")); + } + } // K0s mMatchITSTPCQC.setDoK0QC((mDoK0s = getFromConfig(mCustomParameters, "doK0QC", false))); if (mIsSync && mDoK0s) { @@ -131,6 +136,10 @@ void ITSTPCMatchingTask::endOfCycle() makeRatio(mEffPt, mMatchITSTPCQC.getFractionITSTPCmatch(gloqc::MatchITSTPCQC::ITS)); getObjectsManager()->startPublishing(mEffPt.get(), PublicationPolicy::Once); getObjectsManager()->setDefaultDrawOptions(mEffPt->GetName(), "logx"); + if (mDoMTCTrending) { + mMTCTrendingObject->SetParameter(0, mEffPt->GetBinContent(mEffPt->FindBin(mMTCTrendingPt))); + getObjectsManager()->startPublishing(mMTCTrendingObject.get(), PublicationPolicy::Once); + } // Eta makeRatio(mEffEta, mMatchITSTPCQC.getFractionITSTPCmatchEta(gloqc::MatchITSTPCQC::ITS)); diff --git a/Modules/GLO/src/Reductors.cxx b/Modules/GLO/src/Reductors.cxx index 33c0912ad4..c5664926c2 100644 --- a/Modules/GLO/src/Reductors.cxx +++ b/Modules/GLO/src/Reductors.cxx @@ -25,7 +25,17 @@ void K0sFitReductor::update(TObject* obj) } mStats.mean = f->GetParameter(helpers::K0sFitter::Parameters::Mass); - mStats.stddev = f->GetParameter(helpers::K0sFitter::Parameters::Sigma); + mStats.sigma = f->GetParameter(helpers::K0sFitter::Parameters::Sigma); +} + +void MTCReductor::update(TObject* obj) +{ + auto f = dynamic_cast(obj); + if (!f) { + return; + } + + mStats.pt = f->GetParameter(0); } } // namespace o2::quality_control_modules::glo From 482c500d0ff10f83452fdaadf002ee0d03adb858 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Mon, 10 Mar 2025 11:15:23 +0100 Subject: [PATCH 17/26] GLO: based mtc trending on histo Signed-off-by: Felix Schlepper --- Modules/GLO/glo-itstpc-mtch-qcmn-test.json | 9 ++++----- Modules/GLO/include/GLO/ITSTPCMatchingTask.h | 3 --- Modules/GLO/src/ITSTPCMatchingTask.cxx | 11 +---------- Modules/GLO/src/Reductors.cxx | 7 ++++--- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json index 5bba7f0cd7..70fd5e9997 100644 --- a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json +++ b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json @@ -49,7 +49,6 @@ "GID": "ITS-TPC,ITS", "verbose": "false", "doMTCRatios": "true", - "doMTCTrending": "true", "doK0QC": "true", "isSync": "true", "trackSourcesK0": "ITS,TPC,ITS-TPC,ITS-TPC-TOF,TPC-TOF,TPC-TRD,ITS-TPC-TRD,TPC-TRD-TOF,ITS-TPC-TOF,ITS-TPC-TRD-TOF" @@ -155,7 +154,7 @@ "once" ], "updateTrigger": [ - "newobject:qcdb:GLO/MO/ITSTPCMatchingTask/gloMTCTrendingObject" + "newobject:qcdb:GLO/MO/ITSTPCMatchingTask/mFractionITSTPCmatch_ITS_Hist" ], "stopTrigger": [ "usercontrol" @@ -165,7 +164,7 @@ "type": "repository", "path": "GLO/MO/ITSTPCMatchingTask", "names": [ - "gloMTCTrendingObject" + "mFractionITSTPCmatch_ITS_Hist" ], "reductorName": "o2::quality_control_modules::glo::MTCReductor", "moduleName": "QcGLO" @@ -174,8 +173,8 @@ "plots": [ { "name": "glo_mtc_pt_trending", - "title": "MTC #it{p}_{T} trending", - "varexp": "gloMTCTrendingObject.pt:time", + "title": "MTC at #it{p}_{T}=1.5 trending", + "varexp": "mFractionITSTPCmatch_ITS_Hist.pt:time", "option": "*L", "graphYRange": "0:1.02", "graphAxisLabel": "MTC:time" diff --git a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h index 95e21fd7ca..7624573939 100644 --- a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h +++ b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h @@ -57,9 +57,6 @@ class ITSTPCMatchingTask final : public TaskInterface std::unique_ptr mEffPt; std::unique_ptr mEffEta; std::unique_ptr mEffPhi; - bool mDoMTCTrending{ false }; - float mMTCTrendingPt{ 1.5 }; - std::unique_ptr mMTCTrendingObject; bool mDoK0s{ false }; bool mPublishK0s3D{ false }; diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index 863adb542c..2787b0c7a4 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -55,12 +55,7 @@ void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/) // Sync mIsSync = common::getFromConfig(mCustomParameters, "isSync", false); // MTC ratios - if ((mDoMTCRatios = common::getFromConfig(mCustomParameters, "doMTCRatios", false))) { - if ((mDoMTCTrending = getFromConfig(mCustomParameters, "doMTCTrending", false))) { - mMTCTrendingPt = getFromConfig(mCustomParameters, "trendingPt", 1.5f); - mMTCTrendingObject.reset(new TF1("gloMTCTrendingObject", "pol0")); - } - } + mDoMTCRatios = common::getFromConfig(mCustomParameters, "doMTCRatios", false); // K0s mMatchITSTPCQC.setDoK0QC((mDoK0s = getFromConfig(mCustomParameters, "doK0QC", false))); if (mIsSync && mDoK0s) { @@ -136,10 +131,6 @@ void ITSTPCMatchingTask::endOfCycle() makeRatio(mEffPt, mMatchITSTPCQC.getFractionITSTPCmatch(gloqc::MatchITSTPCQC::ITS)); getObjectsManager()->startPublishing(mEffPt.get(), PublicationPolicy::Once); getObjectsManager()->setDefaultDrawOptions(mEffPt->GetName(), "logx"); - if (mDoMTCTrending) { - mMTCTrendingObject->SetParameter(0, mEffPt->GetBinContent(mEffPt->FindBin(mMTCTrendingPt))); - getObjectsManager()->startPublishing(mMTCTrendingObject.get(), PublicationPolicy::Once); - } // Eta makeRatio(mEffEta, mMatchITSTPCQC.getFractionITSTPCmatchEta(gloqc::MatchITSTPCQC::ITS)); diff --git a/Modules/GLO/src/Reductors.cxx b/Modules/GLO/src/Reductors.cxx index c5664926c2..81a1787055 100644 --- a/Modules/GLO/src/Reductors.cxx +++ b/Modules/GLO/src/Reductors.cxx @@ -13,6 +13,7 @@ #include "GLO/Helpers.h" #include +#include namespace o2::quality_control_modules::glo { @@ -30,12 +31,12 @@ void K0sFitReductor::update(TObject* obj) void MTCReductor::update(TObject* obj) { - auto f = dynamic_cast(obj); - if (!f) { + auto h = dynamic_cast(obj); + if (!h) { return; } - mStats.pt = f->GetParameter(0); + mStats.pt = (float)h->GetBinContent(h->FindBin(1.5)); } } // namespace o2::quality_control_modules::glo From 1d4499ebb81e9b497bd181c618744acbc3af5c55 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Mon, 10 Mar 2025 16:26:25 +0100 Subject: [PATCH 18/26] GLO: Add PV multiplicity vs ITS tracks Signed-off-by: Felix Schlepper --- Modules/GLO/glo-itstpc-mtch-qcmn-test.json | 1 + Modules/GLO/include/GLO/ITSTPCMatchingTask.h | 5 +++ Modules/GLO/src/ITSTPCMatchingTask.cxx | 32 +++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json index 70fd5e9997..9aa98b3e7c 100644 --- a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json +++ b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json @@ -50,6 +50,7 @@ "verbose": "false", "doMTCRatios": "true", "doK0QC": "true", + "doPVITSQC": "true", "isSync": "true", "trackSourcesK0": "ITS,TPC,ITS-TPC,ITS-TPC-TOF,TPC-TOF,TPC-TRD,ITS-TPC-TRD,TPC-TRD-TOF,ITS-TPC-TOF,ITS-TPC-TRD-TOF" }, diff --git a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h index 7624573939..c8bcb4a957 100644 --- a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h +++ b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h @@ -27,6 +27,7 @@ #include +#include #include using namespace o2::quality_control::core; @@ -63,6 +64,10 @@ class ITSTPCMatchingTask final : public TaskInterface std::unique_ptr mK0sCycle; std::unique_ptr mK0sIntegral; helpers::K0sFitter mK0sFitter; + + bool mDoPVITS{ false }; + std::unique_ptr mPVITSCycle; + std::unique_ptr mPVITSIntegral; }; } // namespace o2::quality_control_modules::glo diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index 2787b0c7a4..f121d3794f 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -15,6 +15,7 @@ /// #include +#include #include "QualityControl/QcInfoLogger.h" #include "GLO/ITSTPCMatchingTask.h" @@ -38,7 +39,6 @@ void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/) mMatchITSTPCQC.setUseTrkPID(getFromConfig(mCustomParameters, "useTrkPID", false)); // ITS track mMatchITSTPCQC.setMinPtITSCut(getFromConfig(mCustomParameters, "minPtITSCut", 0.1f)); - mMatchITSTPCQC.setEtaITSCut(getFromConfig(mCustomParameters, "minEtaITSCut", 1.4f)); mMatchITSTPCQC.setEtaITSCut(getFromConfig(mCustomParameters, "etaITSCut", 1.4f)); mMatchITSTPCQC.setMinNClustersITS(getFromConfig(mCustomParameters, "minNITSClustersCut", 0)); mMatchITSTPCQC.setMaxChi2PerClusterITS(getFromConfig(mCustomParameters, "maxChi2PerClusterITS", 1e10f)); @@ -69,6 +69,8 @@ void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/) mPublishK0s3D = getFromConfig(mCustomParameters, "publishK0s3D", false); mK0sFitter.init(mCustomParameters); } + // PV + mDoPVITS = common::getFromConfig(mCustomParameters, "doPVITSQC", false); mMatchITSTPCQC.initDataRequest(); mMatchITSTPCQC.init(); @@ -176,6 +178,34 @@ void ITSTPCMatchingTask::endOfCycle() getObjectsManager()->startPublishing((h = mK0sIntegral->ProjectionY("mK0sMassVsPtVsOcc_Integral_pmass")), PublicationPolicy::Once); } + + if (mDoPVITS) { + const auto* h = mMatchITSTPCQC.getHistoPVNContVsITSTracks(); + if (!h) { + ILOG(Fatal) << "Could not retrieve pv ITS histogram!" << ENDM; + } + + mPVITSCycle.reset(); + mPVITSCycle.reset(dynamic_cast(h->Clone("mPVNContVsITSTracks_Cycle"))); + if (!mPVITSCycle) { + ILOG(Fatal) << "Could not retrieve pv ITS histogram for current cycle!" << ENDM; + } + if (!mPVITSIntegral) { + mPVITSIntegral.reset(dynamic_cast(h->Clone("mPVNContVsITSTracks_Integral"))); + if (!mPVITSIntegral) { + ILOG(Fatal) << "Could not retrieve pv ITS histogram for integral!" << ENDM; + } + } + mPVITSCycle->Reset(); + mPVITSCycle->Add(h, mPVITSCycle.get(), 1., -1.); + mPVITSIntegral->Reset(); + mPVITSIntegral->Add(h); + + getObjectsManager()->startPublishing(mPVITSCycle.get(), PublicationPolicy::Once); + getObjectsManager()->startPublishing(mPVITSIntegral.get(), PublicationPolicy::Once); + getObjectsManager()->startPublishing(mPVITSCycle->ProfileX(), PublicationPolicy::Once); + getObjectsManager()->startPublishing(mPVITSIntegral->ProfileX(), PublicationPolicy::Once); + } } } From 2ee92ba783a94eb06713aed8ae932d795e8c9fb0 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Mon, 10 Mar 2025 21:50:53 +0100 Subject: [PATCH 19/26] GLO: Add PV-ITS trending Signed-off-by: Felix Schlepper --- Modules/GLO/glo-itstpc-mtch-qcmn-test.json | 51 ++++++++++++++++++++++ Modules/GLO/include/GLO/Helpers.h | 6 +-- Modules/GLO/include/GLO/LinkDef.h | 2 + Modules/GLO/include/GLO/Reductors.h | 23 ++++++++-- Modules/GLO/src/Reductors.cxx | 30 +++++++++++++ 5 files changed, 105 insertions(+), 7 deletions(-) diff --git a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json index 9aa98b3e7c..5214604875 100644 --- a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json +++ b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json @@ -181,6 +181,57 @@ "graphAxisLabel": "MTC:time" } ] + }, + "PVITSTrend": { + "active": "true", + "className": "o2::quality_control::postprocessing::TrendingTask", + "moduleName": "QcGLO", + "detectorName": "GLO", + "resumeTrend": "false", + "initTrigger": [ + "once" + ], + "updateTrigger": [ + "newobject:qcdb:GLO/MO/ITSTPCMatchingTask/mPVNContVsITSTracks_Cycle_pfx" + ], + "stopTrigger": [ + "usercontrol" + ], + "dataSources": [ + { + "type": "repository", + "path": "GLO/MO/ITSTPCMatchingTask", + "names": [ + "mPVNContVsITSTracks_Cycle_pfx" + ], + "reductorName": "o2::quality_control_modules::glo::PVITSReductor", + "reductorParameters": { + "default": { + "default": { + "r0": "1000", + "r1": "7000" + } + } + }, + "moduleName": "QcGLO" + } + ], + "plots": [ + { + "name": "glo_pvits_pol0_trending", + "title": "PV-ITS Fit pol0 trending", + "varexp": "mPVNContVsITSTracks_Cycle_pfx.pol0:time", + "option": "*L", + "graphAxisLabel": "pol0:time" + }, + { + "name": "glo_pvits_pol1_trending", + "title": "PV-ITS Fit pol1 trending", + "varexp": "mPVNContVsITSTracks_Cycle_pfx.pol1:time", + "option": "*L", + "graphAxisLabel": "pol1:time" + } + ] } } } diff --git a/Modules/GLO/include/GLO/Helpers.h b/Modules/GLO/include/GLO/Helpers.h index 79d0f5a750..68fdc5e7e1 100644 --- a/Modules/GLO/include/GLO/Helpers.h +++ b/Modules/GLO/include/GLO/Helpers.h @@ -23,8 +23,6 @@ #include #include -#include -#include namespace o2::quality_control_modules::glo::helpers { @@ -90,8 +88,8 @@ struct K0sFitter { ILOG(Warning, Devel) << "Cannot fit empty histogram: " << h->GetName() << ENDM; return false; } - TFitResultPtr res = h->Fit(mBackground.get(), "SRNQ"); - if (res->Status() > 1) { + Int_t res = h->Fit(mBackground.get(), "RNQ"); + if (res) { ILOG(Warning, Devel) << "Failed k0s background fit for histogram: " << h->GetName() << ENDM; return false; } diff --git a/Modules/GLO/include/GLO/LinkDef.h b/Modules/GLO/include/GLO/LinkDef.h index 67810a81b4..8abcb91cf0 100644 --- a/Modules/GLO/include/GLO/LinkDef.h +++ b/Modules/GLO/include/GLO/LinkDef.h @@ -15,4 +15,6 @@ #pragma link C++ class o2::quality_control_modules::glo::ITSTPCmatchingCheck + ; #pragma link C++ class o2::quality_control_modules::glo::K0sFitReductor + ; #pragma link C++ class o2::quality_control_modules::glo::MTCReductor + ; +#pragma link C++ class o2::quality_control_modules::glo::PVITSReductor + ; + #endif diff --git a/Modules/GLO/include/GLO/Reductors.h b/Modules/GLO/include/GLO/Reductors.h index 44625faf5c..e02f6dfef8 100644 --- a/Modules/GLO/include/GLO/Reductors.h +++ b/Modules/GLO/include/GLO/Reductors.h @@ -14,6 +14,8 @@ #include "QualityControl/ReductorTObject.h" +#include + namespace o2::quality_control_modules::glo { @@ -25,8 +27,8 @@ class K0sFitReductor final : public quality_control::postprocessing::ReductorTOb private: struct { - Float_t mean; - Float_t sigma; + Float_t mean{ 0. }; + Float_t sigma{ 0. }; } mStats; }; @@ -38,10 +40,25 @@ class MTCReductor final : public quality_control::postprocessing::ReductorTObjec private: struct { - Float_t pt; + Float_t pt{ 0. }; } mStats; }; +class PVITSReductor final : public quality_control::postprocessing::ReductorTObject +{ + void* getBranchAddress() final { return &mStats; }; + const char* getBranchLeafList() final; + void update(TObject* obj) final; + + private: + struct { + Float_t pol0{ 0. }; + Float_t pol1{ 0. }; + } mStats; + + Double_t mR0{ 0 }, mR1{ 0 }; +}; + } // namespace o2::quality_control_modules::glo #endif diff --git a/Modules/GLO/src/Reductors.cxx b/Modules/GLO/src/Reductors.cxx index 81a1787055..04db507608 100644 --- a/Modules/GLO/src/Reductors.cxx +++ b/Modules/GLO/src/Reductors.cxx @@ -9,11 +9,16 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +#include "Common/Utils.h" + #include "GLO/Reductors.h" #include "GLO/Helpers.h" #include #include +#include +#include +#include namespace o2::quality_control_modules::glo { @@ -39,4 +44,29 @@ void MTCReductor::update(TObject* obj) mStats.pt = (float)h->GetBinContent(h->FindBin(1.5)); } +const char* PVITSReductor::getBranchLeafList() +{ + mR0 = common::internal::stringToType(mCustomParameters.atOrDefaultValue("r0", "0")); + mR1 = common::internal::stringToType(mCustomParameters.atOrDefaultValue("r1", "0")); + + return "pol0/F:pol1/F"; +}; + +void PVITSReductor::update(TObject* obj) +{ + auto p = dynamic_cast(obj); + if (!p) { + return; + } + + auto res = p->Fit("pol1", "QSNC", "", mR0, mR1); + printf("Fitting from %f to %f -> %d\n", mR0, mR1, (int)res); + if ((Int_t)res != 0) { + return; + } + + mStats.pol0 = (Float_t)res->Parameter(0); + mStats.pol1 = (Float_t)res->Parameter(1); +} + } // namespace o2::quality_control_modules::glo From 9b5a6ca1325dd3fd14dbe9bb5b102c6c1a967ed5 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Thu, 13 Mar 2025 13:55:16 +0100 Subject: [PATCH 20/26] GLO: Make MTC reductor configurable Signed-off-by: Felix Schlepper --- Modules/GLO/glo-itstpc-mtch-qcmn-test.json | 57 ++++++++++++++++++++-- Modules/GLO/include/GLO/Reductors.h | 8 +-- Modules/GLO/src/Reductors.cxx | 14 ++++-- 3 files changed, 69 insertions(+), 10 deletions(-) diff --git a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json index 5214604875..cf993372e9 100644 --- a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json +++ b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json @@ -145,7 +145,7 @@ } ] }, - "MTCTrend": { + "MTCTrend1": { "active": "true", "className": "o2::quality_control::postprocessing::TrendingTask", "moduleName": "QcGLO", @@ -168,14 +168,65 @@ "mFractionITSTPCmatch_ITS_Hist" ], "reductorName": "o2::quality_control_modules::glo::MTCReductor", + "reductorParameters": { + "default": { + "default": { + "pt": "1.5" + } + } + }, "moduleName": "QcGLO" } ], "plots": [ { - "name": "glo_mtc_pt_trending", + "name": "glo_mtc_pt15_trending", "title": "MTC at #it{p}_{T}=1.5 trending", - "varexp": "mFractionITSTPCmatch_ITS_Hist.pt:time", + "varexp": "mFractionITSTPCmatch_ITS_Hist.mtc:time", + "option": "*L", + "graphYRange": "0:1.02", + "graphAxisLabel": "MTC:time" + } + ] + }, + "MTCTrend2": { + "active": "true", + "className": "o2::quality_control::postprocessing::TrendingTask", + "moduleName": "QcGLO", + "detectorName": "GLO", + "resumeTrend": "false", + "initTrigger": [ + "once" + ], + "updateTrigger": [ + "newobject:qcdb:GLO/MO/ITSTPCMatchingTask/mFractionITSTPCmatch_ITS_Hist" + ], + "stopTrigger": [ + "usercontrol" + ], + "dataSources": [ + { + "type": "repository", + "path": "GLO/MO/ITSTPCMatchingTask", + "names": [ + "mFractionITSTPCmatch_ITS_Hist" + ], + "reductorName": "o2::quality_control_modules::glo::MTCReductor", + "reductorParameters": { + "default": { + "default": { + "pt": "0.5" + } + } + }, + "moduleName": "QcGLO" + } + ], + "plots": [ + { + "name": "glo_mtc_pt05_trending", + "title": "MTC at #it{p}_{T}=0.5 trending", + "varexp": "mFractionITSTPCmatch_ITS_Hist.mtc:time", "option": "*L", "graphYRange": "0:1.02", "graphAxisLabel": "MTC:time" diff --git a/Modules/GLO/include/GLO/Reductors.h b/Modules/GLO/include/GLO/Reductors.h index e02f6dfef8..49a6ca89ba 100644 --- a/Modules/GLO/include/GLO/Reductors.h +++ b/Modules/GLO/include/GLO/Reductors.h @@ -35,13 +35,15 @@ class K0sFitReductor final : public quality_control::postprocessing::ReductorTOb class MTCReductor final : public quality_control::postprocessing::ReductorTObject { void* getBranchAddress() final { return &mStats; }; - const char* getBranchLeafList() final { return "pt/F"; }; + const char* getBranchLeafList() final; void update(TObject* obj) final; private: struct { - Float_t pt{ 0. }; + Float_t mtc{ 0. }; } mStats; + + Float_t mPt{ 0 }; }; class PVITSReductor final : public quality_control::postprocessing::ReductorTObject @@ -56,7 +58,7 @@ class PVITSReductor final : public quality_control::postprocessing::ReductorTObj Float_t pol1{ 0. }; } mStats; - Double_t mR0{ 0 }, mR1{ 0 }; + Float_t mR0{ 0 }, mR1{ 0 }; }; } // namespace o2::quality_control_modules::glo diff --git a/Modules/GLO/src/Reductors.cxx b/Modules/GLO/src/Reductors.cxx index 04db507608..6106720910 100644 --- a/Modules/GLO/src/Reductors.cxx +++ b/Modules/GLO/src/Reductors.cxx @@ -34,6 +34,13 @@ void K0sFitReductor::update(TObject* obj) mStats.sigma = f->GetParameter(helpers::K0sFitter::Parameters::Sigma); } +const char* MTCReductor::getBranchLeafList() +{ + mPt = common::internal::stringToType(mCustomParameters.atOrDefaultValue("pt", "0")); + + return "mtc/F"; +}; + void MTCReductor::update(TObject* obj) { auto h = dynamic_cast(obj); @@ -41,13 +48,13 @@ void MTCReductor::update(TObject* obj) return; } - mStats.pt = (float)h->GetBinContent(h->FindBin(1.5)); + mStats.mtc = (float)h->GetBinContent(h->FindBin(mPt)); } const char* PVITSReductor::getBranchLeafList() { - mR0 = common::internal::stringToType(mCustomParameters.atOrDefaultValue("r0", "0")); - mR1 = common::internal::stringToType(mCustomParameters.atOrDefaultValue("r1", "0")); + mR0 = common::internal::stringToType(mCustomParameters.atOrDefaultValue("r0", "0")); + mR1 = common::internal::stringToType(mCustomParameters.atOrDefaultValue("r1", "0")); return "pol0/F:pol1/F"; }; @@ -60,7 +67,6 @@ void PVITSReductor::update(TObject* obj) } auto res = p->Fit("pol1", "QSNC", "", mR0, mR1); - printf("Fitting from %f to %f -> %d\n", mR0, mR1, (int)res); if ((Int_t)res != 0) { return; } From 49e1c8b60eea8294fef0b1c3550ac043d455cd32 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Thu, 13 Mar 2025 13:55:26 +0100 Subject: [PATCH 21/26] GLO: Document parameters in README Signed-off-by: Felix Schlepper --- Modules/GLO/README.md | 89 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 Modules/GLO/README.md diff --git a/Modules/GLO/README.md b/Modules/GLO/README.md new file mode 100644 index 0000000000..d74675c6e1 --- /dev/null +++ b/Modules/GLO/README.md @@ -0,0 +1,89 @@ +# GLO +Documents the available task in the module and their parameters. +## ITS-TPC Matching Task +### Parameters +#### MC + - `isMC=false` produce additional MC plots + - `useTrkPID=false` propagate tracks with their pid hypothesis +#### ITS + - `minPtITSCut=0.1f` minimum ITS track momentum + - `etaITSCut=1.4f` maximum ITS track eta + - `minNITSClustersCut=0` minimum number of ITS clusters + - `maxChi2PerClusterITS=1e10f` maximum chi2/ITS cluster +#### TPC + - `minPtTPCCut=0.1f` minimum TPC track momentum + - `etaITSCut=1.4f` maximum ITS track eta + - `minTPCClustersCut=60` minimum number of TPC clusters + - `minDCACut=100.f` minimum TPC track DCA Z + - `minDCACutY=10.f` minimum TPC track DCA Y +#### ITS-TPC + - `minPtCut=0.1f` minimum ITS-TPC momentum + - `maxPtCut=20.f` maximum ITS-TPC momentum + - `etaCut=1.4f` maximum ITS-TPC track eta +#### Additional sync parameters + - `isSync=false` synchronous processing, needed for all following parameters +#### MTC ratios + - `doMTCRatios=false` produce MTC ratio plots +#### K0s + - `doK0QC=false` produce K0s plots + - `maxK0Eta=0.8f` maximum K0s eta + - `refitK0=false` refit K0 prongs + - `cutK0Mass=0.05f` cut around K0s peak + - `trackSourcesK0` SVertexer input sources + - `publishK0s3D=false` publish 3D cycle,integral histograms + + K0Fitter options +#### ITS-PV + - `doPVITSQC=false` produce ITS vs PV plots + +## ITS-TPC Matching Check +### Parameters +#### Pt + - `showPt=false` show check on MTC pt + - `thresholdPt=0.5f` threshold on MTC pt + - `minPt=1.0f` check range left + - `maxPt=1.999f` check range right +#### Phi + - `showPhi=false` show check on MTC phi + - `thresholdPhi=0.3f` threshold on MTC phi +#### Eta + - `showEta=false` show check on MTC eta + - `thresholdEta=0.4f` threshold on MTC eta + - `minEta=-0.8f` check range left + - `maxEta=0.8f` check range right +#### K0 + - `showK0s=false` show check on K0s mass + - `acceptableK0sRError=0.2f` acceptable relative error to pdg value + - `acceptableK0sUncertainty=0.2f` acceptable uncertainty to pdg value + + K0Fitter options +#### Other + - `limitRanges=5` maximum number of bad intervals shown + +## K0sFitReductor +Trends mean and sigma of fit. +### Output + - `mean` aggregated mass value + - `sigma` aggregated sigma value + +## MTCReductor +Trends MTC at given pt. +### Output + - `mtc` mtc efficiency +### Parameters + - `pt` take value at this pt + +## PVITSReductor +Trends constant + slope of straight line fit in given range. +### Output + - `pol0` constant + - `pol1` slope +### Parameters + - `r0` start fit range + - `r1` end fit range + +## K0Fitter +Does a `pol2 + Gaus` fit. +### Parameters + - `k0sBackgroundRejLeft=0.48` reject region in background fit from left side of mass peak + - `k0sBackgroundRejRight=0.51` reject region in background fit to right side of mass peak + - `k0sBackgroundRangeLeft=0.45` absolute left range to fit background + - `k0sBackgroundRangeRight=0.54` absolute right range to fit background From 38c542928d3b0a3b8c9ed0b667b0af99db21e205 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Fri, 14 Mar 2025 11:13:04 +0100 Subject: [PATCH 22/26] GLO: K0s yield trending Signed-off-by: Felix Schlepper --- Modules/GLO/glo-itstpc-mtch-qcmn-pp-test.json | 53 ----------- Modules/GLO/glo-itstpc-mtch-qcmn-test.json | 44 +++++++-- Modules/GLO/include/GLO/Reductors.h | 11 ++- Modules/GLO/src/ITSTPCMatchingTask.cxx | 91 ++++++++++--------- Modules/GLO/src/Reductors.cxx | 9 +- 5 files changed, 99 insertions(+), 109 deletions(-) delete mode 100644 Modules/GLO/glo-itstpc-mtch-qcmn-pp-test.json diff --git a/Modules/GLO/glo-itstpc-mtch-qcmn-pp-test.json b/Modules/GLO/glo-itstpc-mtch-qcmn-pp-test.json deleted file mode 100644 index 63b6501d20..0000000000 --- a/Modules/GLO/glo-itstpc-mtch-qcmn-pp-test.json +++ /dev/null @@ -1,53 +0,0 @@ -"qc": { - "config": { - "database": { - "implementation": "CCDB", - "host": "ccdb-test.cern.ch:8080" - }, - "Activity": {}, - "monitoring": { - "url": "infologger:///debug?qc" - } - }, - "postprocessing": { - "K0sTrendingTask": { - "active": "true", - "taskName": "K0sTrendingTask", - "className": "o2::quality_control::postprocessing::TrendingTask", - "moduleName": "QcGLO", - "detectorName": "GLO", - "dataSources": [ - { - "type": "repository", - "path": "TST/MO/)json" + - taskName + R"json(", - "name": "testHistoTrending", - "reductorName": "o2::quality_control_modules::glo::K0sFitReductor", - "moduleName": "QcGLO" - } - ], - "plots": [ - { - "name": "mean_of_histogram", - "title": "Mean trend of the testHistoTrending histogram", - "graphs": [{ - "varexp": "testHistoTrending.mean:time", - "selection": "", - "option": "*L" - }] - }, - { - "name": "quality_histogram", - "title": "Histogram of qualities", - "varexp": ")json" + - checkName + R"json(.level", - "selection": "", - "option": "" - } - ], - "initTrigger": [], - "updateTrigger": [], - "stopTrigger": [] - } - } -} diff --git a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json index cf993372e9..f88a3ca388 100644 --- a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json +++ b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json @@ -15,13 +15,7 @@ "beamType": "PbPb" }, "monitoring": { - "url": "no-op://" - }, - "consul": { - "url": "" - }, - "conditionDB": { - "url": "alice-ccdb.cern.ch" + "url": "infologger:///debug?qc" }, "infologger": { "filterDiscardDebug": "false", @@ -145,6 +139,42 @@ } ] }, + "K0sYieldTrend": { + "active": "true", + "className": "o2::quality_control::postprocessing::TrendingTask", + "moduleName": "QcGLO", + "detectorName": "GLO", + "resumeTrend": "false", + "initTrigger": [ + "once" + ], + "updateTrigger": [ + "newobject:qcdb:GLO/MO/ITSTPCMatchingTask/gloFitK0sMassSignal" + ], + "stopTrigger": [ + "usercontrol" + ], + "dataSources": [ + { + "type": "repository", + "path": "GLO/MO/ITSTPCMatchingTask", + "names": [ + "gloFitK0sMassSignal" + ], + "reductorName": "o2::quality_control_modules::glo::K0sFitReductor", + "moduleName": "QcGLO" + } + ], + "plots": [ + { + "name": "glo_k0s_yield_trending", + "title": "Fitted K0s yield", + "varexp": "gloFitK0sMassSignal.yield:time", + "option": "*L", + "graphAxisLabel": "K0s Yield:time" + } + ] + }, "MTCTrend1": { "active": "true", "className": "o2::quality_control::postprocessing::TrendingTask", diff --git a/Modules/GLO/include/GLO/Reductors.h b/Modules/GLO/include/GLO/Reductors.h index 49a6ca89ba..0965268a91 100644 --- a/Modules/GLO/include/GLO/Reductors.h +++ b/Modules/GLO/include/GLO/Reductors.h @@ -22,13 +22,14 @@ namespace o2::quality_control_modules::glo class K0sFitReductor final : public quality_control::postprocessing::ReductorTObject { void* getBranchAddress() final { return &mStats; }; - const char* getBranchLeafList() final { return "mean/F:sigma/F"; }; + const char* getBranchLeafList() final { return "yield/F:mean/F:sigma/F"; }; void update(TObject* obj) final; private: struct { - Float_t mean{ 0. }; - Float_t sigma{ 0. }; + Float_t yield{ -1. }; + Float_t mean{ -1. }; + Float_t sigma{ -1. }; } mStats; }; @@ -40,10 +41,10 @@ class MTCReductor final : public quality_control::postprocessing::ReductorTObjec private: struct { - Float_t mtc{ 0. }; + Float_t mtc{ -1. }; } mStats; - Float_t mPt{ 0 }; + Float_t mPt{ -1. }; }; class PVITSReductor final : public quality_control::postprocessing::ReductorTObject diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index f121d3794f..0a3e93a26b 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -143,6 +143,36 @@ void ITSTPCMatchingTask::endOfCycle() getObjectsManager()->startPublishing(mEffPhi.get(), PublicationPolicy::Once); } + if (mDoPVITS) { + const auto* h = mMatchITSTPCQC.getHistoPVNContVsITSTracks(); + if (!h) { + ILOG(Fatal) << "Could not retrieve pv ITS histogram!" << ENDM; + } + + mPVITSCycle.reset(); + mPVITSCycle.reset(dynamic_cast(h->Clone("mPVNContVsITSTracks_Cycle"))); + if (!mPVITSCycle) { + ILOG(Fatal) << "Could not retrieve pv ITS histogram for current cycle!" << ENDM; + } + if (!mPVITSIntegral) { + mPVITSIntegral.reset(dynamic_cast(h->Clone("mPVNContVsITSTracks_Integral"))); + if (!mPVITSIntegral) { + ILOG(Fatal) << "Could not retrieve pv ITS histogram for integral!" << ENDM; + } + } + if (mPVITSCycle->GetEntries() != h->GetEntries()) { + mPVITSCycle->Reset(); + mPVITSCycle->Add(h, mPVITSCycle.get(), 1., -1.); + mPVITSIntegral->Reset(); + mPVITSIntegral->Add(h); + + getObjectsManager()->startPublishing(mPVITSCycle.get(), PublicationPolicy::Once); + getObjectsManager()->startPublishing(mPVITSIntegral.get(), PublicationPolicy::Once); + getObjectsManager()->startPublishing(mPVITSCycle->ProfileX(), PublicationPolicy::Once); + getObjectsManager()->startPublishing(mPVITSIntegral->ProfileX(), PublicationPolicy::Once); + } + } + if (mDoK0s) { const auto* k0s = (mIsPbPb) ? mMatchITSTPCQC.getHistoK0MassVsPtVsOccPbPb() : mMatchITSTPCQC.getHistoK0MassVsPtVsOccpp(); if (!k0s) { @@ -160,51 +190,28 @@ void ITSTPCMatchingTask::endOfCycle() ILOG(Fatal) << "Could not retrieve k0s histogram integral" << ENDM; } } - mK0sCycle->Reset(); - mK0sCycle->Add(k0s, mK0sIntegral.get(), 1., -1.); - mK0sIntegral->Reset(); - mK0sIntegral->Add(k0s); - - if (mPublishK0s3D) { - getObjectsManager()->startPublishing(mK0sCycle.get(), PublicationPolicy::Once); - getObjectsManager()->startPublishing(mK0sIntegral.get(), PublicationPolicy::Once); - } - - TH1D* h{ nullptr }; - getObjectsManager()->startPublishing((h = mK0sCycle->ProjectionY("mK0sMassVsPtVsOcc_Cycle_pmass")), PublicationPolicy::Once); - if (mK0sFitter.fit(h)) { - getObjectsManager()->startPublishing(mK0sFitter.mSignalAndBackground.get(), PublicationPolicy::Once); - } - - getObjectsManager()->startPublishing((h = mK0sIntegral->ProjectionY("mK0sMassVsPtVsOcc_Integral_pmass")), PublicationPolicy::Once); - } - - if (mDoPVITS) { - const auto* h = mMatchITSTPCQC.getHistoPVNContVsITSTracks(); - if (!h) { - ILOG(Fatal) << "Could not retrieve pv ITS histogram!" << ENDM; - } + if (k0s->GetEntries() != mK0sIntegral->GetEntries()) { + mK0sCycle->Reset(); + mK0sCycle->Add(k0s, mK0sIntegral.get(), 1., -1.); + mK0sIntegral->Reset(); + mK0sIntegral->Add(k0s); + + if (mPublishK0s3D) { + getObjectsManager()->startPublishing(mK0sCycle.get(), PublicationPolicy::Once); + getObjectsManager()->startPublishing(mK0sIntegral.get(), PublicationPolicy::Once); + } - mPVITSCycle.reset(); - mPVITSCycle.reset(dynamic_cast(h->Clone("mPVNContVsITSTracks_Cycle"))); - if (!mPVITSCycle) { - ILOG(Fatal) << "Could not retrieve pv ITS histogram for current cycle!" << ENDM; - } - if (!mPVITSIntegral) { - mPVITSIntegral.reset(dynamic_cast(h->Clone("mPVNContVsITSTracks_Integral"))); - if (!mPVITSIntegral) { - ILOG(Fatal) << "Could not retrieve pv ITS histogram for integral!" << ENDM; + TH1D* h{ nullptr }; + getObjectsManager()->startPublishing((h = mK0sCycle->ProjectionY("mK0sMassVsPtVsOcc_Cycle_pmass")), PublicationPolicy::Once); + if (mK0sFitter.fit(h)) { + if (mDoPVITS && mPVITSCycle->GetEntries() != 0) { + mK0sFitter.mSignalAndBackground->SetParameter(helpers::K0sFitter::Parameters::Pol0, mPVITSCycle->GetEntries()); + } + getObjectsManager()->startPublishing(mK0sFitter.mSignalAndBackground.get(), PublicationPolicy::Once); } + + getObjectsManager()->startPublishing((h = mK0sIntegral->ProjectionY("mK0sMassVsPtVsOcc_Integral_pmass")), PublicationPolicy::Once); } - mPVITSCycle->Reset(); - mPVITSCycle->Add(h, mPVITSCycle.get(), 1., -1.); - mPVITSIntegral->Reset(); - mPVITSIntegral->Add(h); - - getObjectsManager()->startPublishing(mPVITSCycle.get(), PublicationPolicy::Once); - getObjectsManager()->startPublishing(mPVITSIntegral.get(), PublicationPolicy::Once); - getObjectsManager()->startPublishing(mPVITSCycle->ProfileX(), PublicationPolicy::Once); - getObjectsManager()->startPublishing(mPVITSIntegral->ProfileX(), PublicationPolicy::Once); } } } diff --git a/Modules/GLO/src/Reductors.cxx b/Modules/GLO/src/Reductors.cxx index 6106720910..9d85cae250 100644 --- a/Modules/GLO/src/Reductors.cxx +++ b/Modules/GLO/src/Reductors.cxx @@ -30,8 +30,13 @@ void K0sFitReductor::update(TObject* obj) return; } - mStats.mean = f->GetParameter(helpers::K0sFitter::Parameters::Mass); - mStats.sigma = f->GetParameter(helpers::K0sFitter::Parameters::Sigma); + mStats.mean = (Float_t)f->GetParameter(helpers::K0sFitter::Parameters::Mass); + mStats.sigma = (Float_t)f->GetParameter(helpers::K0sFitter::Parameters::Sigma); + if (auto ncol = (Float_t)f->GetParameter(helpers::K0sFitter::Parameters::Pol0); ncol > 0.) { + mStats.yield = (Float_t)f->GetParameter(helpers::K0sFitter::Parameters::Amplitude) * mStats.sigma / ncol; + } else { + mStats.yield = -1; + } } const char* MTCReductor::getBranchLeafList() From c35f62d14e3eb91699d5449e7c26513dfd9c8184 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Fri, 14 Mar 2025 14:50:53 +0100 Subject: [PATCH 23/26] GLO: K0s optionally separating mass in low Occ and low pt and high Signed-off-by: Felix Schlepper --- Modules/GLO/README.md | 2 ++ Modules/GLO/glo-itstpc-mtch-qcmn-test.json | 6 +++++- Modules/GLO/include/GLO/ITSTPCMatchingTask.h | 6 ++++++ Modules/GLO/src/ITSTPCMatchingTask.cxx | 15 +++++++++++++++ Modules/GLO/src/ITSTPCmatchingCheck.cxx | 14 ++++++++++++-- 5 files changed, 40 insertions(+), 3 deletions(-) diff --git a/Modules/GLO/README.md b/Modules/GLO/README.md index d74675c6e1..6920c38977 100644 --- a/Modules/GLO/README.md +++ b/Modules/GLO/README.md @@ -31,6 +31,8 @@ Documents the available task in the module and their parameters. - `cutK0Mass=0.05f` cut around K0s peak - `trackSourcesK0` SVertexer input sources - `publishK0s3D=false` publish 3D cycle,integral histograms + - `splitK0sMassOccupancy=float` splitting point in TPC occupancy to define low and high region by default off + - `splitK0sMassPt=float` splitting point in pt to define low and high region by default off + K0Fitter options #### ITS-PV - `doPVITSQC=false` produce ITS vs PV plots diff --git a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json index f88a3ca388..21f836789b 100644 --- a/Modules/GLO/glo-itstpc-mtch-qcmn-test.json +++ b/Modules/GLO/glo-itstpc-mtch-qcmn-test.json @@ -76,8 +76,12 @@ "mFractionITSTPCmatch_ITS_Hist", "mFractionITSTPCmatchPhi_ITS_Hist", "mFractionITSTPCmatchEta_ITS_Hist", + "mK0sMassVsPtVsOcc_Integral_pmass", "mK0sMassVsPtVsOcc_Cycle_pmass", - "mK0sMassVsPtVsOcc_Integral_pmass" + "mK0sMassVsPtVsOcc_Cycle_pmass_lowOcc", + "mK0sMassVsPtVsOcc_Cycle_pmass_lowPt", + "mK0sMassVsPtVsOcc_Cycle_pmass_highOcc", + "mK0sMassVsPtVsOcc_Cycle_pmass_highPt" ] } ], diff --git a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h index c8bcb4a957..af148c5aac 100644 --- a/Modules/GLO/include/GLO/ITSTPCMatchingTask.h +++ b/Modules/GLO/include/GLO/ITSTPCMatchingTask.h @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -49,6 +50,9 @@ class ITSTPCMatchingTask final : public TaskInterface void reset() override; private: + template + static constexpr T OptValue = std::numeric_limits::max(); + o2::gloqc::MatchITSTPCQC mMatchITSTPCQC; bool mIsSync{ false }; @@ -61,6 +65,8 @@ class ITSTPCMatchingTask final : public TaskInterface bool mDoK0s{ false }; bool mPublishK0s3D{ false }; + float mSplitTPCOccupancy{ OptValue }; + float mSplitPt{ OptValue }; std::unique_ptr mK0sCycle; std::unique_ptr mK0sIntegral; helpers::K0sFitter mK0sFitter; diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index 0a3e93a26b..003d797ab2 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -67,6 +67,8 @@ void ITSTPCMatchingTask::initialize(o2::framework::InitContext& /*ctx*/) } mPublishK0s3D = getFromConfig(mCustomParameters, "publishK0s3D", false); + mSplitTPCOccupancy = getFromConfig(mCustomParameters, "splitK0sMassOccupancy", mSplitTPCOccupancy); + mSplitPt = getFromConfig(mCustomParameters, "splitK0sMassPt", mSplitPt); mK0sFitter.init(mCustomParameters); } // PV @@ -203,6 +205,19 @@ void ITSTPCMatchingTask::endOfCycle() TH1D* h{ nullptr }; getObjectsManager()->startPublishing((h = mK0sCycle->ProjectionY("mK0sMassVsPtVsOcc_Cycle_pmass")), PublicationPolicy::Once); + + if (mSplitTPCOccupancy != OptValue) { + auto splitOccBin = mK0sCycle->GetZaxis()->FindBin(mSplitTPCOccupancy); + getObjectsManager()->startPublishing(mK0sCycle->ProjectionY("mK0sMassVsPtVsOcc_Cycle_pmass_lowOcc", 0, -1, 0, splitOccBin - 1), PublicationPolicy::Once); + getObjectsManager()->startPublishing(mK0sCycle->ProjectionY("mK0sMassVsPtVsOcc_Cycle_pmass_highOcc", 0, -1, splitOccBin), PublicationPolicy::Once); + } + + if (mSplitPt != OptValue) { + auto splitPtBin = mK0sCycle->GetXaxis()->FindBin(mSplitPt); + getObjectsManager()->startPublishing(mK0sCycle->ProjectionY("mK0sMassVsPtVsOcc_Cycle_pmass_lowPt", 0, splitPtBin - 1), PublicationPolicy::Once); + getObjectsManager()->startPublishing(mK0sCycle->ProjectionY("mK0sMassVsPtVsOcc_Cycle_pmass_highPt", splitPtBin), PublicationPolicy::Once); + } + if (mK0sFitter.fit(h)) { if (mDoPVITS && mPVITSCycle->GetEntries() != 0) { mK0sFitter.mSignalAndBackground->SetParameter(helpers::K0sFitter::Parameters::Pol0, mPVITSCycle->GetEntries()); diff --git a/Modules/GLO/src/ITSTPCmatchingCheck.cxx b/Modules/GLO/src/ITSTPCmatchingCheck.cxx index 4ae6338fc4..c2ef7ce2e9 100644 --- a/Modules/GLO/src/ITSTPCmatchingCheck.cxx +++ b/Modules/GLO/src/ITSTPCmatchingCheck.cxx @@ -481,15 +481,25 @@ void ITSTPCmatchingCheck::beautify(std::shared_ptr mo, Quality ch msg->AddText("Not-handled Quality flag, don't panic..."); } eff->GetListOfFunctions()->Add(msg); - } else if (mShowK0s && (name == "mK0sMassVsPtVsOcc_Cycle_pmass" || name == "mK0sMassVsPtVsOcc_Integral_pmass")) { + } else if (mShowK0s && (name.starts_with("mK0sMassVsPtVsOcc_Cycle_pmass") || name.starts_with("mK0sMassVsPtVsOcc_Integral_pmass"))) { auto* h = dynamic_cast(mo->getObject()); if (!h) { ILOG(Error) << "Failed cast for " << name << " beautify!" << ENDM; return; } auto isCycle = name.find("Cycle") != std::string::npos; + auto isHigh = name.find("high") != std::string::npos; + auto isLow = name.find("low") != std::string::npos; + auto isOcc = name.ends_with("Occ"); + auto isPt = name.ends_with("Pt"); auto msg = new TPaveText(0.6, 0.6, 0.88, 0.88, "NDC;NB"); - h->SetTitle(Form("K0s invariant mass (integrated over #it{p}_{T} and occupancy, %s);K0s mass (GeV/c^{2});entries", (isCycle) ? "current cycle" : "integrated")); + if (!isLow && !isHigh) { + h->SetTitle(Form("K0s invariant mass (integrated over #it{p}_{T} and occupancy, %s);K0s mass (GeV/c^{2});entries", (isCycle) ? "last cycle" : "integrated")); + } else { + h->SetTitle(Form("K0s invariant mass (integrated over%s#it{p}_{T} and%soccupancy, last cycle);K0s mass (GeV/c^{2});entries", + (isPt) ? ((isLow) ? " low " : " high ") : " ", + (isOcc) ? ((isLow) ? " low " : " high ") : " ")); + } if (!mK0sFitter.fit(h, true)) { msg->AddText("Fit: Failed"); msg->SetFillColor(kRed); From 69d519594c75a68c17681012feee5029820308a6 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Fri, 14 Mar 2025 16:10:20 +0100 Subject: [PATCH 24/26] GLO: Take different plot for PbPb for PV-ITS Signed-off-by: Felix Schlepper --- Modules/GLO/src/ITSTPCMatchingTask.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index 003d797ab2..aec0e9283e 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -146,7 +146,7 @@ void ITSTPCMatchingTask::endOfCycle() } if (mDoPVITS) { - const auto* h = mMatchITSTPCQC.getHistoPVNContVsITSTracks(); + const auto* h = (mIsPbPb) ? mMatchITSTPCQC.getHistoPVNContVsITSTracksPbPb() : mMatchITSTPCQC.getHistoPVNContVsITSTracks(); if (!h) { ILOG(Fatal) << "Could not retrieve pv ITS histogram!" << ENDM; } From 9d77a3cccb4c5b08415818777adaee220b87d3a1 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Wed, 23 Apr 2025 07:02:31 +0200 Subject: [PATCH 25/26] GLO: comment PV-ITS code for now --- Modules/GLO/README.md | 2 +- Modules/GLO/src/ITSTPCMatchingTask.cxx | 54 +++++++++++++------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Modules/GLO/README.md b/Modules/GLO/README.md index 6920c38977..5366fbfba2 100644 --- a/Modules/GLO/README.md +++ b/Modules/GLO/README.md @@ -35,7 +35,7 @@ Documents the available task in the module and their parameters. - `splitK0sMassPt=float` splitting point in pt to define low and high region by default off + K0Fitter options #### ITS-PV - - `doPVITSQC=false` produce ITS vs PV plots + - `doPVITSQC=false` produce ITS vs PV plots (not implemented yet) ## ITS-TPC Matching Check ### Parameters diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index aec0e9283e..596e7c52e6 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -146,33 +146,33 @@ void ITSTPCMatchingTask::endOfCycle() } if (mDoPVITS) { - const auto* h = (mIsPbPb) ? mMatchITSTPCQC.getHistoPVNContVsITSTracksPbPb() : mMatchITSTPCQC.getHistoPVNContVsITSTracks(); - if (!h) { - ILOG(Fatal) << "Could not retrieve pv ITS histogram!" << ENDM; - } - - mPVITSCycle.reset(); - mPVITSCycle.reset(dynamic_cast(h->Clone("mPVNContVsITSTracks_Cycle"))); - if (!mPVITSCycle) { - ILOG(Fatal) << "Could not retrieve pv ITS histogram for current cycle!" << ENDM; - } - if (!mPVITSIntegral) { - mPVITSIntegral.reset(dynamic_cast(h->Clone("mPVNContVsITSTracks_Integral"))); - if (!mPVITSIntegral) { - ILOG(Fatal) << "Could not retrieve pv ITS histogram for integral!" << ENDM; - } - } - if (mPVITSCycle->GetEntries() != h->GetEntries()) { - mPVITSCycle->Reset(); - mPVITSCycle->Add(h, mPVITSCycle.get(), 1., -1.); - mPVITSIntegral->Reset(); - mPVITSIntegral->Add(h); - - getObjectsManager()->startPublishing(mPVITSCycle.get(), PublicationPolicy::Once); - getObjectsManager()->startPublishing(mPVITSIntegral.get(), PublicationPolicy::Once); - getObjectsManager()->startPublishing(mPVITSCycle->ProfileX(), PublicationPolicy::Once); - getObjectsManager()->startPublishing(mPVITSIntegral->ProfileX(), PublicationPolicy::Once); - } + // const auto* h = (mIsPbPb) ? mMatchITSTPCQC.getHistoPVNContVsITSTracksPbPb() : mMatchITSTPCQC.getHistoPVNContVsITSTracks(); + // if (!h) { + // ILOG(Fatal) << "Could not retrieve pv ITS histogram!" << ENDM; + // } + + // mPVITSCycle.reset(); + // mPVITSCycle.reset(dynamic_cast(h->Clone("mPVNContVsITSTracks_Cycle"))); + // if (!mPVITSCycle) { + // ILOG(Fatal) << "Could not retrieve pv ITS histogram for current cycle!" << ENDM; + // } + // if (!mPVITSIntegral) { + // mPVITSIntegral.reset(dynamic_cast(h->Clone("mPVNContVsITSTracks_Integral"))); + // if (!mPVITSIntegral) { + // ILOG(Fatal) << "Could not retrieve pv ITS histogram for integral!" << ENDM; + // } + // } + // if (mPVITSCycle->GetEntries() != h->GetEntries()) { + // mPVITSCycle->Reset(); + // mPVITSCycle->Add(h, mPVITSCycle.get(), 1., -1.); + // mPVITSIntegral->Reset(); + // mPVITSIntegral->Add(h); + + // getObjectsManager()->startPublishing(mPVITSCycle.get(), PublicationPolicy::Once); + // getObjectsManager()->startPublishing(mPVITSIntegral.get(), PublicationPolicy::Once); + // getObjectsManager()->startPublishing(mPVITSCycle->ProfileX(), PublicationPolicy::Once); + // getObjectsManager()->startPublishing(mPVITSIntegral->ProfileX(), PublicationPolicy::Once); + // } } if (mDoK0s) { From 5ef2e559069415726d0f44cb9385d019b0d89561 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Wed, 23 Apr 2025 11:35:45 +0200 Subject: [PATCH 26/26] Update Modules/GLO/src/ITSTPCMatchingTask.cxx Co-authored-by: Piotr Konopka --- Modules/GLO/src/ITSTPCMatchingTask.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/GLO/src/ITSTPCMatchingTask.cxx b/Modules/GLO/src/ITSTPCMatchingTask.cxx index 596e7c52e6..b9730292fc 100644 --- a/Modules/GLO/src/ITSTPCMatchingTask.cxx +++ b/Modules/GLO/src/ITSTPCMatchingTask.cxx @@ -83,7 +83,7 @@ void ITSTPCMatchingTask::startOfActivity(const Activity& activity) { ILOG(Debug, Devel) << "startOfActivity " << activity.mId << ENDM; mMatchITSTPCQC.reset(); - mIsPbPb = activity.mBeamType == "Pb-Pb"; + mIsPbPb = activity.mBeamType == "PbPb"; } void ITSTPCMatchingTask::startOfCycle()