|
| 1 | +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. |
| 2 | +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
| 3 | +// All rights not expressly granted are reserved. |
| 4 | +// |
| 5 | +// This software is distributed under the terms of the GNU General Public |
| 6 | +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". |
| 7 | +// |
| 8 | +// In applying this license CERN does not waive the privileges and immunities |
| 9 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 10 | +// or submit itself to any jurisdiction. |
| 11 | +#include "EMCAL/NumPhysTriggCheck.h" |
| 12 | +#include "QualityControl/MonitorObject.h" |
| 13 | +#include "QualityControl/Quality.h" |
| 14 | +#include "QualityControl/QcInfoLogger.h" |
| 15 | +// ROOT |
| 16 | +#include <TCanvas.h> |
| 17 | +#include <TGraph.h> |
| 18 | +#include <TPaveText.h> |
| 19 | +#include <TLatex.h> |
| 20 | +#include <TList.h> |
| 21 | +#include <TLine.h> |
| 22 | +#include <TRobustEstimator.h> |
| 23 | +#include <ROOT/TSeq.hxx> |
| 24 | +#include <iostream> |
| 25 | +#include <vector> |
| 26 | + |
| 27 | +using namespace std; |
| 28 | + |
| 29 | +namespace o2::quality_control_modules::emcal |
| 30 | +{ |
| 31 | + |
| 32 | +void NumPhysTriggCheck::configure() |
| 33 | +{ |
| 34 | + // configure threshold-based checkers for bad quality |
| 35 | + auto fracToMaxGood = mCustomParameters.find("FracToMaxGood"); |
| 36 | + if (fracToMaxGood != mCustomParameters.end()) { |
| 37 | + try { |
| 38 | + mFracToMaxGood = std::stof(fracToMaxGood->second); |
| 39 | + } catch (std::exception& e) { |
| 40 | + ILOG(Error, Support) << fmt::format("Value {} not a float", fracToMaxGood->second.data()) << ENDM; |
| 41 | + } |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +Quality NumPhysTriggCheck::check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) |
| 46 | +{ |
| 47 | + auto mo = moMap->begin()->second; |
| 48 | + Quality result = Quality::Good; |
| 49 | + |
| 50 | + if (mo->getName().find("NPhysTriggersTFSlice") != std::string::npos) { |
| 51 | + auto Can = dynamic_cast<TCanvas*>(mo->getObject()); |
| 52 | + if (Can == nullptr) { |
| 53 | + return Quality::Null; |
| 54 | + } |
| 55 | + TGraph* gr = nullptr; |
| 56 | + TList* primitives = Can->GetListOfPrimitives(); |
| 57 | + for (TObject* obj : *primitives) { |
| 58 | + if (obj->InheritsFrom("TGraph")) { |
| 59 | + gr = (TGraph*)obj; |
| 60 | + break; |
| 61 | + } |
| 62 | + } |
| 63 | + if (gr == nullptr) { |
| 64 | + return Quality::Null; |
| 65 | + } |
| 66 | + if (gr->GetN() == 0) { |
| 67 | + return Quality::Bad; |
| 68 | + } |
| 69 | + double maxVal = 0.; |
| 70 | + for (int i = 0; i < gr->GetN(); ++i) { |
| 71 | + if (gr->GetPointY(i) > maxVal) { |
| 72 | + maxVal = gr->GetPointY(i); |
| 73 | + } |
| 74 | + } |
| 75 | + double currentVal = gr->GetPointY(gr->GetN() - 1); |
| 76 | + if (currentVal < mFracToMaxGood * maxVal) { |
| 77 | + result = Quality::Bad; |
| 78 | + } |
| 79 | + } |
| 80 | + |
| 81 | + return result; |
| 82 | +} |
| 83 | + |
| 84 | +std::string NumPhysTriggCheck::getAcceptedType() { return "TCanvas"; } |
| 85 | + |
| 86 | +void NumPhysTriggCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult) |
| 87 | +{ |
| 88 | + if (mo->getName().find("NPhysTriggersTFSlice") != std::string::npos) { |
| 89 | + auto Can = dynamic_cast<TCanvas*>(mo->getObject()); |
| 90 | + if (Can == nullptr) { |
| 91 | + return; |
| 92 | + } |
| 93 | + |
| 94 | + Can->cd(); |
| 95 | + TPaveText* msg = new TPaveText(0.17, 0.2, 0.5, 0.3, "NDC"); |
| 96 | + msg->SetName(Form("%s_msg", mo->GetName())); |
| 97 | + |
| 98 | + if (checkResult == Quality::Good) { |
| 99 | + // |
| 100 | + msg->Clear(); |
| 101 | + msg->AddText("Data quality: GOOD"); |
| 102 | + msg->SetFillColor(kGreen); |
| 103 | + msg->Draw("same"); |
| 104 | + Can->Update(); |
| 105 | + } else if (checkResult == Quality::Bad) { |
| 106 | + ILOG(Debug, Devel) << "Quality::Bad << ENDM"; |
| 107 | + msg->Clear(); |
| 108 | + msg->AddText("Data quality: BAD"); |
| 109 | + msg->SetFillColor(kRed); |
| 110 | + msg->Draw("same"); |
| 111 | + Can->Update(); |
| 112 | + } |
| 113 | + } |
| 114 | +} |
| 115 | +} // namespace o2::quality_control_modules::emcal |
0 commit comments