-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding combined check on tracklet count per trigger and per timeframe
- Loading branch information
1 parent
b74caaa
commit eee85cc
Showing
4 changed files
with
244 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |