Skip to content

Commit

Permalink
adding combined check on tracklet count per trigger and per timeframe
Browse files Browse the repository at this point in the history
  • Loading branch information
deependra170598 committed Oct 16, 2023
1 parent b74caaa commit eee85cc
Show file tree
Hide file tree
Showing 4 changed files with 244 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Modules/TRD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

add_library(O2QcTRD)

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
target_sources(O2QcTRD PRIVATE src/TrackletCountCheck.cxx 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(
Expand All @@ -20,6 +20,7 @@ install(TARGETS O2QcTRD

add_root_dictionary(O2QcTRD
HEADERS
include/TRD/TrackletCountCheck.h
include/TRD/TrackletsPerTimeFrameCheck.h
include/TRD/TrackletPerTriggerCheck.h
include/TRD/TRDReductor.h
Expand Down
1 change: 1 addition & 0 deletions Modules/TRD/include/TRD/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
#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 + ;
#pragma link C++ class o2::quality_control_modules::trd::TrackletCountCheck+;
#endif
51 changes: 51 additions & 0 deletions Modules/TRD/include/TRD/TrackletCountCheck.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// 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 TrackletCountCheck.h
/// \author My Name
///

#ifndef QC_MODULE_TRD_TRDTRACKLETCOUNTCHECK_H
#define QC_MODULE_TRD_TRDTRACKLETCOUNTCHECK_H

#include "QualityControl/CheckInterface.h"

namespace o2::quality_control_modules::trd
{

/// \brief Example QC Check
/// \author My Name
class TrackletCountCheck : public o2::quality_control::checker::CheckInterface
{
public:
/// Default constructor
TrackletCountCheck() = default;
/// Destructor
~TrackletCountCheck() override = default;

// Override interface
void configure() override;
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
std::string getAcceptedType() override;
float mThresholdMeanLowPerTrigger,mThresholdMeanHighPerTrigger, mThresholdMeanLowPerTimeFrame,mThresholdMeanHighPerTimeFrame;
int mStatThresholdPerTrigger;
Quality mResultPertrigger;
Quality mResultPerTimeFrame;
Quality mFinalResult;

ClassDefOverride(TrackletCountCheck, 2);
};

} // namespace o2::quality_control_modules::trd

#endif // QC_MODULE_TRD_TRDTRACKLETCOUNTCHECK_H
190 changes: 190 additions & 0 deletions Modules/TRD/src/TrackletCountCheck.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
// 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 TrackletCountCheck.cxx
/// \author My Name
///

#include "TRD/TrackletCountCheck.h"
#include "QualityControl/MonitorObject.h"
#include "QualityControl/Quality.h"
#include "QualityControl/QcInfoLogger.h"
#include "Common/Utils.h"
// ROOT
#include <TH1.h>
#include <TPaveText.h>

#include <DataFormatsQualityControl/FlagReasons.h>

using namespace std;
using namespace o2::quality_control;
using namespace o2::quality_control_modules::common;

namespace o2::quality_control_modules::trd
{

void TrackletCountCheck::configure()
{
ILOG(Debug, Devel) << "initializing TrackletCountCheck" << ENDM;

mThresholdMeanHighPerTimeFrame = getFromConfig<float>(mCustomParameters, "UpperthresholdPerTimeFrame", 520.f);
ILOG(Debug, Support) << "using Upperthreshold Per Timeframe= " << mThresholdMeanHighPerTimeFrame << ENDM;

mThresholdMeanLowPerTimeFrame = getFromConfig<float>(mCustomParameters, "LowerthresholdPerTimeFrame", 600.f);
ILOG(Debug, Support) << "using Lowerthreshold Per Timeframe= " << mThresholdMeanLowPerTimeFrame << ENDM;

mThresholdMeanHighPerTrigger = getFromConfig<float>(mCustomParameters, "UpperthresholdPerTrigger", 520.f);
ILOG(Debug, Support) << "using Upperthreshold Per Trigger= " << mThresholdMeanHighPerTrigger << ENDM;

mThresholdMeanLowPerTrigger = getFromConfig<float>(mCustomParameters, "LowerthresholdPerTrigger", 500.f);
ILOG(Debug, Support) << "using Lowerthreshold Per Trigger= " << mThresholdMeanLowPerTrigger << ENDM;

mStatThresholdPerTrigger = getFromConfig<int>(mCustomParameters, "StatThresholdPerTrigger", 1000);
ILOG(Debug, Support) << "using StatThreshold Per Trigger= " << mStatThresholdPerTrigger << ENDM;
}

Quality TrackletCountCheck::check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap)
{
mResultPertrigger = Quality::Null;
mResultPerTimeFrame = Quality::Null;

for (auto& [moName, mo] : *moMap) {

(void)moName;
if (mo->getName() == "trackletsperevent") {
auto* h = dynamic_cast<TH1F*>(mo->getObject());
if (h == nullptr) {
// ILOG(Debug, Support) << "Requested Histogram type does not match with the Histogram in source" << ENDM;
continue;
}
// warning about statistics available
TPaveText* msg1 = new TPaveText(0.3, 0.7, 0.7, 0.9, "NDC"); // check option "br","NDC"
h->GetListOfFunctions()->Add(msg1);
msg1->SetTextSize(10);
int Entries = h->GetEntries();
if (Entries > mStatThresholdPerTrigger) {
msg1->AddText(TString::Format("Hist Can't be ignored. Stat is enough. Entries: %d > Threshold: %d", Entries, mStatThresholdPerTrigger));
// msg1->SetTextColor(kGreen);
} else if (Entries > 0) {
msg1->AddText(TString::Format("Hist Can be ignored. Stat is low. Entries: %d < Threshold: %d", Entries, mStatThresholdPerTrigger));
// msg1->SetTextColor(kYellow);
} else if (Entries == 0) {
msg1->AddText(TString::Format("Hist is empty. Entries: %d < Threshold: %d", Entries, mStatThresholdPerTrigger));
msg1->SetTextColor(kRed);
}

// Warning about triggers without any tracklets
int UnderFlowTrackletsPerTrigger = h->GetBinContent(0);
if (UnderFlowTrackletsPerTrigger > 0.) {
msg1->AddText(TString::Format("Triggers without Tracklets: %d", UnderFlowTrackletsPerTrigger));
}

// applying check
float MeanTrackletPertrigger = h->GetMean();
if (MeanTrackletPertrigger > mThresholdMeanLowPerTrigger && MeanTrackletPertrigger < mThresholdMeanHighPerTrigger) {
TText* Checkmsg = msg1->AddText("Mean Per Trigger is found in bound region: ok");
Checkmsg->SetTextColor(kGreen);
mResultPertrigger = Quality::Good;
} else {
mResultPertrigger = Quality::Bad;
TText* Checkmsg = msg1->AddText("Mean PerTrigger is not found in bound region: not ok");
Checkmsg->SetTextColor(kRed);
mResultPertrigger.addReason(FlagReasonFactory::Unknown(), "MeanTrackletPertrigger is not in bound region");
}
}
if (mo->getName() == "trackletspertimeframe") {
auto* h2 = dynamic_cast<TH1F*>(mo->getObject());
if (h2 == nullptr) {
// ILOG(Debug, Support) << "Requested Histogram type does not match with the Histogram in source" << ENDM;
continue;
}

TPaveText* msg2 = new TPaveText(0.3, 0.7, 0.7, 0.9, "NDC"); // check option "br","NDC"
h2->GetListOfFunctions()->Add(msg2);
msg2->SetTextSize(10);

// Warning about TimeFrame without any tracklets
int UnderFlowTrackletsPertrigger = h2->GetBinContent(0);
if (UnderFlowTrackletsPertrigger > 0.) {
msg2->AddText(TString::Format("TimeFrame without Tracklets: %d", UnderFlowTrackletsPertrigger));
}

// applying check
float MeanTrackletPerTimeFrame = h2->GetMean();
if (MeanTrackletPerTimeFrame > mThresholdMeanLowPerTimeFrame && MeanTrackletPerTimeFrame < mThresholdMeanHighPerTimeFrame) {
TText* Checkmsg2 = msg2->AddText("Mean Per Timeframe is found in bound region: ok");
Checkmsg2->SetTextColor(kGreen);
mResultPerTimeFrame = Quality::Good;
} else {
mResultPerTimeFrame = Quality::Bad;
TText* Checkmsg2 = msg2->AddText("Mean per Timeframe is not found in bound region: not ok");
Checkmsg2->SetTextColor(kRed);
mResultPerTimeFrame.addReason(FlagReasonFactory::Unknown(), "MeanTrackletPerTimeFrame is not in bound region");
}
}
}
if(mResultPertrigger == Quality::Null && mResultPerTimeFrame == Quality::Null){
mFinalResult = Quality::Null;
mFinalResult.addReason(FlagReasonFactory::Unknown(),"Quality of both trackletspertimeframe and trackletsperevent is unknown");
} else if((mResultPertrigger == Quality::Null && mResultPerTimeFrame == Quality::Good)||(mResultPertrigger == Quality::Good && mResultPerTimeFrame == Quality::Null)){
mFinalResult = Quality::Medium;
mFinalResult.addReason(FlagReasonFactory::Unknown(),"Quality of any of trackletspertimeframe and trackletsperevent is unknown");
} else if(mResultPertrigger == Quality::Bad || mResultPerTimeFrame ==Quality::Bad){
mFinalResult = Quality::Bad;
mFinalResult.addReason(FlagReasonFactory::Unknown(),"Quality of both or any of trackletspertimeframe and trackletsperevent is bad");
} else {
mFinalResult = Quality::Good;
}
return mFinalResult;
}

std::string TrackletCountCheck::getAcceptedType() { return "TH1"; }

void TrackletCountCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
{
if (mo->getName() == "trackletsperevent") {
auto* h1 = dynamic_cast<TH1F*>(mo->getObject());
if (h1 == nullptr) {
// ILOG(Debug, Support) << "Requested Histogram type does not match with the Histogram in source" << ENDM;
return;
}
if (mResultPertrigger == Quality::Good) {
h1->SetFillColor(kGreen);
} else if (mResultPertrigger == Quality::Bad) {
ILOG(Debug, Devel) << "Quality::Bad, setting to red" << ENDM;
h1->SetFillColor(kRed);
} else if (mResultPertrigger == Quality::Medium) {
ILOG(Debug, Devel) << "Quality::medium, setting to orange" << ENDM;
h1->SetFillColor(kOrange);
}
h1->SetLineColor(kBlack);
}
if(mo->getName() == "trackletspertimeframe"){
auto* h2 = dynamic_cast<TH1F*>(mo->getObject());
if (h2 == nullptr) {
// ILOG(Debug, Support) << "Requested Histogram type does not match with the Histogram in source" << ENDM;
return;
}
if (mResultPerTimeFrame == Quality::Good) {
h2->SetFillColor(kGreen);
} else if (mResultPerTimeFrame == Quality::Bad) {
ILOG(Debug, Devel) << "Quality::Bad, setting to red" << ENDM;
h2->SetFillColor(kRed);
} else if (mResultPerTimeFrame == Quality::Medium) {
ILOG(Debug, Devel) << "Quality::medium, setting to orange" << ENDM;
h2->SetFillColor(kOrange);
}
h2->SetLineColor(kBlack);
}
}

} // namespace o2::quality_control_modules::trd

0 comments on commit eee85cc

Please sign in to comment.