-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TRD]: Check on hc2d #2152
[TRD]: Check on hc2d #2152
Changes from all commits
d856b03
b10ab18
fb16979
e0ea255
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// 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 CheckOnHc2d.h | ||
/// \author My Name | ||
/// | ||
|
||
#ifndef QC_MODULE_TRD_TRDCHECKONHC2D_H | ||
#define QC_MODULE_TRD_TRDCHECKONHC2D_H | ||
|
||
// O2 | ||
#include "CCDB/BasicCCDBManager.h" | ||
#include "DataFormatsTRD/NoiseCalibration.h" | ||
#include <DataFormatsTRD/Constants.h> | ||
|
||
// QC | ||
#include "QualityControl/CheckInterface.h" | ||
|
||
using namespace o2::trd::constants; | ||
|
||
namespace o2::quality_control_modules::trd | ||
{ | ||
|
||
/// \brief Example QC Check | ||
/// \author My Name | ||
class CheckOnHc2d : public o2::quality_control::checker::CheckInterface | ||
{ | ||
public: | ||
/// Default constructor | ||
CheckOnHc2d() = default; | ||
/// Destructor | ||
~CheckOnHc2d() 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; | ||
void reset() override; | ||
void startOfActivity(const Activity& activity) override; | ||
void endOfActivity(const Activity& activity) override; | ||
|
||
private: | ||
int mTimestamp; | ||
o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; | ||
const std::array<int, o2::trd::constants::MAXCHAMBER>* mChamberStatus = nullptr; | ||
std::shared_ptr<Activity> mActivity; | ||
std::string mCcdbPath; | ||
|
||
ClassDefOverride(CheckOnHc2d, 3); | ||
}; | ||
|
||
} // namespace o2::quality_control_modules::trd | ||
|
||
#endif // QC_MODULE_TRD_TRDCHECKONHC2D_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
// 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 CheckOnHc2d.cxx | ||
/// \author Deependra Sharma | ||
/// | ||
|
||
#include "TRD/CheckOnHc2d.h" | ||
#include "QualityControl/MonitorObject.h" | ||
#include "QualityControl/Quality.h" | ||
#include "QualityControl/QcInfoLogger.h" | ||
// ROOT | ||
#include <TH2.h> | ||
|
||
#include "TRD/TRDHelpers.h" | ||
#include <DataFormatsQualityControl/FlagReasons.h> | ||
#include "DataFormatsTRD/HelperMethods.h" | ||
|
||
using namespace std; | ||
using namespace o2::quality_control; | ||
using Helper = o2::trd::HelperMethods; | ||
|
||
namespace o2::quality_control_modules::trd | ||
{ | ||
|
||
void CheckOnHc2d::configure() | ||
{ | ||
// if (auto param = mCustomParameters.find("ccdbtimestamp"); param != mCustomParameters.end()) { | ||
// mTimestamp = std::stol(mCustomParameters["ccdbtimestamp"]); | ||
// ILOG(Debug, Support) << "configure() : using ccdbtimestamp = " << mTimestamp << ENDM; | ||
// } else { | ||
// mTimestamp = o2::ccdb::getCurrentTimestamp(); | ||
// ILOG(Debug, Support) << "configure() : using default timestam of now = " << mTimestamp << ENDM; | ||
// } | ||
|
||
if (auto param = mCustomParameters.find("ccdbPath"); param != mCustomParameters.end()) { | ||
mCcdbPath = mCustomParameters["ccdbPath"]; | ||
ILOG(Debug, Support) << "configure() : using ccdb path = " << mCcdbPath << ENDM; | ||
} else { | ||
|
||
ILOG(Warning, Trace) << "provided ccdb path in config not found" << ENDM; | ||
mCcdbPath = "TRD/Calib/DCSDPsFedChamberStatus"; | ||
ILOG(Warning, Trace) << "using ccdb path =" << mCcdbPath << ENDM; | ||
} | ||
|
||
// auto& mgr = o2::ccdb::BasicCCDBManager::instance(); | ||
// mgr.setTimestamp(mTimestamp); | ||
// mChamberStatus = mgr.get<std::array<int, MAXCHAMBER>>("TRD/Calib/DCSDPsFedChamberStatus"); | ||
|
||
// mChamberStatus = retrieveConditionAny<std::array<int, MAXCHAMBER>>(mCcdbPath, {}, mTimestamp); | ||
|
||
|
||
} | ||
|
||
Quality CheckOnHc2d::check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) | ||
{ | ||
Quality result1 = Quality::Null; | ||
Quality result2 = Quality::Null; | ||
Quality overAllQuality = Quality::Null; | ||
|
||
for (auto& [moName, mo] : *moMap) { | ||
|
||
(void)moName; | ||
if (mo->getName() == "trackletsperHC2D") { | ||
auto* h = dynamic_cast<TH2F*>(mo->getObject()); | ||
if (!h) { | ||
ILOG(Debug, Trace) << "Requested Object Not Found" << ENDM; | ||
return overAllQuality; | ||
// return result1; | ||
} | ||
auto timeStamp = mo->getValidity().getMin(); | ||
mChamberStatus = retrieveConditionAny<std::array<int, MAXCHAMBER>>(mCcdbPath, {}, timeStamp); | ||
|
||
if (mChamberStatus == nullptr) { | ||
ILOG(Info, Support) << "mChamberStatus is null, no chamber status to display" << ENDM; | ||
} | ||
|
||
result1 = Quality::Good; | ||
// int nMaskedHC = 0; | ||
// int nMaskedChInASec; | ||
for (int i = 0; i < h->GetNbinsX(); i++) { // loop along sector_side | ||
// nMaskedChInASec = 0; | ||
for (int j = 0; j < h->GetNbinsY(); j++) { // loop along stack_layer | ||
double content = h->GetBinContent(i, j); | ||
|
||
if (content == 0) { // if half-chamber is empty | ||
int sector = i / 2; | ||
int side = i % 2; | ||
int stack = j / NLAYER; | ||
int layer = j % NLAYER; | ||
int det = Helper::getDetector(sector, stack, layer); | ||
int hcid = det * 2 + side; | ||
|
||
if (!TRDHelpers::isHalfChamberMasked(hcid, mChamberStatus)) { // if half-chamber is not masked | ||
result1 = Quality::Bad; | ||
result1.addReason(FlagReasonFactory::Unknown(), "some half chambers are empty while they are not masked!"); | ||
return result1; | ||
} // endif chamber is not masked | ||
|
||
// else{ | ||
// nMaskedHC++; | ||
// nMaskedChInASec++; | ||
// if(nMaskedHC > int(NCHAMBER*2*0.4) ){ // if nMaskedHC is greator than 40% of all chambers | ||
// result1 = Quality::Bad; | ||
// result1.addReason(FlagReasonFactory::Unknown(), "more than 40 percent chambers are masked!"); | ||
// return result1; | ||
// } | ||
// if(nMaskedChInASec == NCHAMBERPERSEC){ //if entire sector is masked | ||
// result1 = Quality::Bad; | ||
// result1.addReason(FlagReasonFactory::Unknown(), "some sectors are entirely masked"); | ||
// return result1; | ||
// } | ||
// } | ||
|
||
} // endif empty half-chamber | ||
} // stack_layer loop ends | ||
} // sector_side loop ends | ||
|
||
result2 = Quality::Good; | ||
int nMaskedHC = 0; // total number of masked half-chamber | ||
int nMaskedHChInASec = 1; // total number of masked half-chamber in a sector | ||
int currentSector = -1, oldSector = -1; | ||
for (int hcid = 0; hcid < MAXCHAMBER * 2; ++hcid) { | ||
currentSector = Helper::getSector(hcid / 2); | ||
if (TRDHelpers::isHalfChamberMasked(hcid, mChamberStatus)) { | ||
ILOG(Debug, Trace) << "Masked half Chamber id =" << hcid << ENDM; | ||
nMaskedHC++; | ||
if (nMaskedHC > (NCHAMBER * 2 * 0.4)) { // if nMaskedHC is greator than 40% of all chambers | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 40% should be a parameter that we can change from the json file |
||
result2 = Quality::Bad; | ||
result2.addReason(FlagReasonFactory::Unknown(), "more than 40 percent chambers are masked!"); | ||
return result2; | ||
} | ||
if (oldSector == currentSector) { // if chambers are masked within same sector | ||
nMaskedHChInASec++; | ||
if (nMaskedHChInASec == NCHAMBERPERSEC * 2) { // if entire sector is masked | ||
result2 = Quality::Bad; | ||
result2.addReason(FlagReasonFactory::Unknown(), "some sectors are entirely masked"); | ||
return result2; | ||
} | ||
} else { | ||
nMaskedHChInASec = 1; | ||
} | ||
} // endif masked chamber | ||
oldSector = currentSector; | ||
} // hcid loop ends | ||
|
||
overAllQuality = Quality::Good; | ||
if (result1 == Quality::Good && result2 == Quality::Good) { | ||
overAllQuality = Quality::Good; | ||
overAllQuality.addReason(FlagReasonFactory::Unknown(), "All unmasked chambers working well!"); | ||
return overAllQuality; | ||
} | ||
} | ||
} | ||
return overAllQuality; | ||
// return result1; | ||
} | ||
|
||
std::string CheckOnHc2d::getAcceptedType() { return "TH2"; } | ||
|
||
void CheckOnHc2d::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult) | ||
{ | ||
if (mo->getName() == "trackletsperHC2D") { | ||
auto* h = dynamic_cast<TH2F*>(mo->getObject()); | ||
|
||
if (checkResult == Quality::Good) { | ||
h->SetFillColor(kGreen); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does one see it if the histogram fill color for a TH2 changes if we draw it with COLZ option? I think we need a text box here |
||
} 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); | ||
} | ||
} | ||
|
||
void CheckOnHc2d::reset() | ||
{ | ||
ILOG(Debug, Devel) << "CheckOnHc2d::reset" << ENDM; | ||
} | ||
|
||
void CheckOnHc2d::startOfActivity(const Activity& activity) | ||
{ | ||
ILOG(Debug, Devel) << "CheckOnHc2d::start : " << activity.mId << ENDM; | ||
mActivity = make_shared<Activity>(activity); | ||
} | ||
|
||
void CheckOnHc2d::endOfActivity(const Activity& activity) | ||
{ | ||
ILOG(Debug, Devel) << "CheckOnHc2d::end : " << activity.mId << ENDM; | ||
} | ||
|
||
} // namespace o2::quality_control_modules::trd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this method at all?