|
| 1 | +// Copyright CERN and copyright holders of ALICE O2. This software is |
| 2 | +// distributed under the terms of the GNU General Public License v3 (GPL |
| 3 | +// Version 3), copied verbatim in the file "COPYING". |
| 4 | +// |
| 5 | +// See http://alice-o2.web.cern.ch/license for full licensing information. |
| 6 | +// |
| 7 | +// In applying this license CERN does not waive the privileges and immunities |
| 8 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 9 | +// or submit itself to any jurisdiction. |
| 10 | + |
| 11 | +/// |
| 12 | +/// \file TOFCheckDiagnostic.cxx |
| 13 | +/// \author Nicolo' Jacazio |
| 14 | +/// |
| 15 | + |
| 16 | +// QC |
| 17 | +#include "TOF/TOFCheckDiagnostic.h" |
| 18 | +#include "QualityControl/MonitorObject.h" |
| 19 | +#include "QualityControl/Quality.h" |
| 20 | + |
| 21 | +#include <fairlogger/Logger.h> |
| 22 | +// ROOT |
| 23 | +#include <TH1.h> |
| 24 | +#include <TH2.h> |
| 25 | +#include <TPaveText.h> |
| 26 | +#include <TList.h> |
| 27 | + |
| 28 | +using namespace std; |
| 29 | + |
| 30 | +namespace o2::quality_control_modules::tof |
| 31 | +{ |
| 32 | + |
| 33 | +TOFCheckDiagnostic::TOFCheckDiagnostic() |
| 34 | +{ |
| 35 | +} |
| 36 | + |
| 37 | +TOFCheckDiagnostic::~TOFCheckDiagnostic() {} |
| 38 | + |
| 39 | +void TOFCheckDiagnostic::configure(std::string) {} |
| 40 | + |
| 41 | +Quality TOFCheckDiagnostic::check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) |
| 42 | +{ |
| 43 | + |
| 44 | + Quality result = Quality::Null; |
| 45 | + |
| 46 | + for (auto& [moName, mo] : *moMap) { |
| 47 | + (void)moName; |
| 48 | + if (mo->getName() == "hDiagnostic") { |
| 49 | + auto* h = dynamic_cast<TH2F*>(mo->getObject()); |
| 50 | + if (h->GetEntries() == 0) { |
| 51 | + result = Quality::Medium; |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + return result; |
| 56 | +} |
| 57 | + |
| 58 | +std::string TOFCheckDiagnostic::getAcceptedType() { return "TH2F"; } |
| 59 | + |
| 60 | +void TOFCheckDiagnostic::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult) |
| 61 | +{ |
| 62 | + if (mo->getName() == "hDiagnostic") { |
| 63 | + auto* h = dynamic_cast<TH2F*>(mo->getObject()); |
| 64 | + TPaveText* msg = new TPaveText(0.5, 0.5, 0.9, 0.75, "NDC"); |
| 65 | + h->GetListOfFunctions()->Add(msg); |
| 66 | + msg->Draw(); |
| 67 | + msg->SetName(Form("%s_msg", mo->GetName())); |
| 68 | + |
| 69 | + if (checkResult == Quality::Good) { |
| 70 | + LOG(INFO) << "Quality::Good, setting to green"; |
| 71 | + msg->Clear(); |
| 72 | + msg->AddText("OK!"); |
| 73 | + msg->SetFillColor(kGreen); |
| 74 | + // |
| 75 | + h->SetFillColor(kGreen); |
| 76 | + } else if (checkResult == Quality::Bad) { |
| 77 | + LOG(INFO) << "Quality::Bad, setting to red"; |
| 78 | + // |
| 79 | + msg->Clear(); |
| 80 | + msg->AddText("No TOF hits for all events."); |
| 81 | + msg->AddText("Call TOF on-call."); |
| 82 | + msg->SetFillColor(kRed); |
| 83 | + // |
| 84 | + h->SetFillColor(kRed); |
| 85 | + } else if (checkResult == Quality::Medium) { |
| 86 | + LOG(INFO) << "Quality::medium, setting to orange"; |
| 87 | + // |
| 88 | + msg->Clear(); |
| 89 | + msg->AddText("No entries. IF TOF IN RUN"); |
| 90 | + msg->AddText("check the TOF TWiki"); |
| 91 | + msg->SetFillColor(kYellow); |
| 92 | + // |
| 93 | + h->SetFillColor(kOrange); |
| 94 | + } else { |
| 95 | + LOG(INFO) << "Quality::Null, setting to black background"; |
| 96 | + msg->SetFillColor(kBlack); |
| 97 | + } |
| 98 | + } else |
| 99 | + LOG(ERROR) << "Did not get correct histo from " << mo->GetName(); |
| 100 | +} |
| 101 | + |
| 102 | +} // namespace o2::quality_control_modules::tof |
0 commit comments