From 0bf335079f325a0c827d19278015c2eee12feabf Mon Sep 17 00:00:00 2001 From: Deependra Sharma Date: Thu, 12 Oct 2023 15:56:35 +0530 Subject: [PATCH] Adding Check on TrackletsPerTimeFrame and Warniig for Timeframe withoutytracklets --- Modules/TRD/CMakeLists.txt | 3 +- Modules/TRD/include/TRD/LinkDef.h | 1 + .../include/TRD/TrackletsPerTimeFrameCheck.h | 47 ++++++++ .../TRD/src/TrackletsPerTimeFrameCheck.cxx | 110 ++++++++++++++++++ 4 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 Modules/TRD/include/TRD/TrackletsPerTimeFrameCheck.h create mode 100644 Modules/TRD/src/TrackletsPerTimeFrameCheck.cxx diff --git a/Modules/TRD/CMakeLists.txt b/Modules/TRD/CMakeLists.txt index fc644207fe..0d81cf1722 100644 --- a/Modules/TRD/CMakeLists.txt +++ b/Modules/TRD/CMakeLists.txt @@ -2,7 +2,7 @@ add_library(O2QcTRD) -target_sources(O2QcTRD PRIVATE src/TrackletPerTriggerCheck.cxx src/TRDReductor.cxx src/PulsePositionCheck.cxx src/TrackingTask.cxx src/PulseHeightTrackMatch.cxx src/TrackletsCheck.cxx src/TrackletsTask.cxx src/PulseHeightCheck.cxx src/PulseHeight.cxx src/RawData.cxx src/DigitsTask.cxx +target_sources(O2QcTRD PRIVATE src/TrackletsPerTimeFrameCheck.cxx src/TrackletPerTriggerCheck.cxx src/TRDReductor.cxx src/PulsePositionCheck.cxx src/TrackingTask.cxx src/PulseHeightTrackMatch.cxx src/TrackletsCheck.cxx src/TrackletsTask.cxx src/PulseHeightCheck.cxx src/PulseHeight.cxx src/RawData.cxx src/DigitsTask.cxx src/DigitsCheck.cxx src/TRDTrending.cxx src/TrendingTaskConfigTRD.cxx src/PulseHeightPostProcessing.cxx) target_include_directories( @@ -20,6 +20,7 @@ install(TARGETS O2QcTRD add_root_dictionary(O2QcTRD HEADERS + include/TRD/TrackletsPerTimeFrameCheck.h include/TRD/TrackletPerTriggerCheck.h include/TRD/TRDReductor.h include/TRD/PulsePositionCheck.h diff --git a/Modules/TRD/include/TRD/LinkDef.h b/Modules/TRD/include/TRD/LinkDef.h index f1550feaf9..ea09518096 100644 --- a/Modules/TRD/include/TRD/LinkDef.h +++ b/Modules/TRD/include/TRD/LinkDef.h @@ -18,4 +18,5 @@ #pragma link C++ class o2::quality_control_modules::trd::PulsePositionCheck + ; #pragma link C++ class o2::quality_control_modules::trd::TRDReductor + ; #pragma link C++ class o2::quality_control_modules::trd::TrackletPerTriggerCheck + ; +#pragma link C++ class o2::quality_control_modules::trd::TrackletsPerTimeFrameCheck+; #endif diff --git a/Modules/TRD/include/TRD/TrackletsPerTimeFrameCheck.h b/Modules/TRD/include/TRD/TrackletsPerTimeFrameCheck.h new file mode 100644 index 0000000000..3b43f25ea2 --- /dev/null +++ b/Modules/TRD/include/TRD/TrackletsPerTimeFrameCheck.h @@ -0,0 +1,47 @@ +// 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. + +/// +/// \file TrackletsPerTimeFrameCheck.h +/// \author My Name +/// + +#ifndef QC_MODULE_TRD_TRDTRACKLETSPERTIMEFRAMECHECK_H +#define QC_MODULE_TRD_TRDTRACKLETSPERTIMEFRAMECHECK_H + +#include "QualityControl/CheckInterface.h" + +namespace o2::quality_control_modules::trd +{ + +/// \brief TrackletsPerTimeFrameCheck QC Check +/// \author My Name +class TrackletsPerTimeFrameCheck : public o2::quality_control::checker::CheckInterface +{ + public: + /// Default constructor + TrackletsPerTimeFrameCheck() = default; + /// Destructor + ~TrackletsPerTimeFrameCheck() override = default; + + // Override interface + void configure() override; + Quality check(std::map>* moMap) override; + void beautify(std::shared_ptr mo, Quality checkResult = Quality::Null) override; + std::string getAcceptedType() override; + float mThresholdMeanLow, mThresholdMeanHigh; + + ClassDefOverride(TrackletsPerTimeFrameCheck, 2); +}; + +} // namespace o2::quality_control_modules::trd + +#endif // QC_MODULE_TRD_TRDTRACKLETSPERTIMEFRAMECHECK_H diff --git a/Modules/TRD/src/TrackletsPerTimeFrameCheck.cxx b/Modules/TRD/src/TrackletsPerTimeFrameCheck.cxx new file mode 100644 index 0000000000..d928c2625a --- /dev/null +++ b/Modules/TRD/src/TrackletsPerTimeFrameCheck.cxx @@ -0,0 +1,110 @@ +// 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. + +/// +/// \file TrackletsPerTimeFrameCheck.cxx +/// \author My Name +/// + +#include "TRD/TrackletsPerTimeFrameCheck.h" +#include "QualityControl/MonitorObject.h" +#include "QualityControl/Quality.h" +#include "QualityControl/QcInfoLogger.h" +#include "Common/Utils.h" +// ROOT +#include +#include + +#include + +using namespace std; +using namespace o2::quality_control; +using namespace o2::quality_control_modules::common; + +namespace o2::quality_control_modules::trd +{ + +void TrackletsPerTimeFrameCheck::configure() +{ + ILOG(Debug, Devel) << "initialize TrackletsPerTimeFrameCheck" << ENDM; + + mThresholdMeanHigh = getFromConfig(mCustomParameters, "Upperthreshold", 520.f); + ILOG(Debug, Support) << "using Upperthreshold = " << mThresholdMeanHigh << ENDM; + + mThresholdMeanLow = getFromConfig(mCustomParameters, "Lowerthreshold", 600.f); + ILOG(Debug, Support) << "using Lowerthreshold = " << mThresholdMeanLow << ENDM; +} + +Quality TrackletsPerTimeFrameCheck::check(std::map>* moMap) +{ + Quality result = Quality::Null; + + for (auto& [moName, mo] : *moMap) { + + (void)moName; + if (mo->getName() == "trackletspertimeframe") { + auto* h = dynamic_cast(mo->getObject()); + if (h == nullptr) { + // ILOG(Debug, Support) << "Requested Histogram type does not match with the Histogram in source" << ENDM; + continue; + } + + TPaveText* msg1 = new TPaveText(0.3, 0.7, 0.7, 0.9, "NDC"); // check option "br","NDC" + h->GetListOfFunctions()->Add(msg1); + msg1->SetTextSize(10); + + // Warning about TimeFrame without any tracklets + int UnderFlowTracklets = h->GetBinContent(0); + if(UnderFlowTracklets>0.){ + msg1->AddText(TString::Format("TimeFrame without Tracklets: %d",UnderFlowTracklets)); + } + + // applying check + float MeanTracletPerTimeFrame = h->GetMean(); + if(MeanTracletPerTimeFrame > mThresholdMeanLow && MeanTracletPerTimeFrame < mThresholdMeanHigh){ + TText* Checkmsg = msg1->AddText("Mean is found in bound region: ok"); + Checkmsg->SetTextColor(kGreen); + result = Quality::Good; + }else { + result = Quality::Bad; + TText* Checkmsg = msg1->AddText("Mean is not found in bound region: not ok"); + Checkmsg->SetTextColor(kRed); + result.addReason(FlagReasonFactory::Unknown(), "MeanTracletPerTimeFrame is not in bound region"); + } + } + } + return result; +} + +std::string TrackletsPerTimeFrameCheck::getAcceptedType() { return "TH1"; } + +void TrackletsPerTimeFrameCheck::beautify(std::shared_ptr mo, Quality checkResult) +{ + if (mo->getName() == "trackletspertimeframe") { + auto* h = dynamic_cast(mo->getObject()); + if (h == nullptr) { + // ILOG(Debug, Support) << "Requested Histogram type does not match with the Histogram in source" << ENDM; + return; + } + if (checkResult == Quality::Good) { + h->SetFillColor(kGreen); + } else if (checkResult == Quality::Bad) { + ILOG(Debug, Devel) << "Quality::Bad, setting to red" << ENDM; + h->SetFillColor(kRed); + } else if (checkResult == Quality::Medium) { + ILOG(Debug, Devel) << "Quality::medium, setting to orange" << ENDM; + h->SetFillColor(kOrange); + } + h->SetLineColor(kBlack); + } +} + +} // namespace o2::quality_control_modules::trd