|
| 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 PostProcessDiagnosticPerCrate.cxx |
| 13 | +/// \brief Post processing to rearrange TOF information at the level of the crate (maybe we should do the opposite..) |
| 14 | +/// \author Nicolo' Jacazio and Francesca Ercolessi |
| 15 | +/// \since 11/09/2020 |
| 16 | +/// |
| 17 | + |
| 18 | +// QC includes |
| 19 | +#include "TOF/PostProcessDiagnosticPerCrate.h" |
| 20 | +#include "QualityControl/MonitorObject.h" |
| 21 | +#include "QualityControl/QcInfoLogger.h" |
| 22 | + |
| 23 | +// ROOT includes |
| 24 | +#include <TH2F.h> |
| 25 | +#include <TCanvas.h> |
| 26 | + |
| 27 | +using namespace o2::quality_control::postprocessing; |
| 28 | + |
| 29 | +namespace o2::quality_control_modules::tof |
| 30 | +{ |
| 31 | + |
| 32 | +const std::string PostProcessDiagnosticPerCrate::mCCDBPath = "qc/TOF/MO/TaskDiagnostics/"; |
| 33 | +const int PostProcessDiagnosticPerCrate::mNWords = 32; |
| 34 | +const int PostProcessDiagnosticPerCrate::mNSlots = 14; |
| 35 | + |
| 36 | +PostProcessDiagnosticPerCrate::~PostProcessDiagnosticPerCrate() |
| 37 | +{ |
| 38 | +} |
| 39 | + |
| 40 | +void PostProcessDiagnosticPerCrate::initialize(Trigger, framework::ServiceRegistry& services) |
| 41 | +{ |
| 42 | + int counter = 0; |
| 43 | + for (auto& i : mCrates) { |
| 44 | + i.reset(new TH2F(Form("hCrate%i", counter), |
| 45 | + Form("Crate%i;Word;Slot", counter), |
| 46 | + mNWords, 0, mNWords, mNSlots, 0, mNSlots)); |
| 47 | + counter++; |
| 48 | + } |
| 49 | + |
| 50 | + // Setting up services |
| 51 | + mDatabase = &services.get<o2::quality_control::repository::DatabaseInterface>(); |
| 52 | +} |
| 53 | + |
| 54 | +void PostProcessDiagnosticPerCrate::update(Trigger, framework::ServiceRegistry&) |
| 55 | +{ |
| 56 | + ILOG(Info) << "UPDATING !" << ENDM; |
| 57 | + for (int slot = 0; slot < mNSlots; slot++) { // Loop over slots |
| 58 | + std::string moName = "DRMCounter"; |
| 59 | + if (slot == 1) { |
| 60 | + moName = "LTMCounter"; |
| 61 | + } else if (slot > 1) { |
| 62 | + moName = Form("TRMCounterSlot%i", slot); |
| 63 | + } |
| 64 | + ILOG(Info) << "Processing slot " << slot << " from " << moName << ENDM; |
| 65 | + auto mo = mDatabase->retrieveMO(mCCDBPath, moName); |
| 66 | + TH2F* moH = static_cast<TH2F*>(mo ? mo->getObject() : nullptr); |
| 67 | + if (moH) { |
| 68 | + for (int crate = 0; crate < moH->GetNbinsY(); crate++) { // Loop over crates |
| 69 | + ILOG(Info) << "Processing crate " << crate << ENDM; |
| 70 | + if (static_cast<unsigned int>(crate) > mCrates.size()) { |
| 71 | + ILOG(Fatal) << "Crate counter is too large " << ENDM; |
| 72 | + } |
| 73 | + for (int word = 0; word < moH->GetNbinsX(); word++) { // Loop over words |
| 74 | + ILOG(Info) << "Processing word " << word << ENDM; |
| 75 | + if (crate > mNWords) { |
| 76 | + ILOG(Fatal) << "Word counter is too large " << ENDM; |
| 77 | + } |
| 78 | + mCrates[crate]->SetBinContent(word + 1, slot + 1, moH->GetBinContent(word + 1, crate + 1)); |
| 79 | + } |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | + ILOG(Info) << "DONE UPDATING !" << ENDM; |
| 84 | +} |
| 85 | + |
| 86 | +void PostProcessDiagnosticPerCrate::finalize(Trigger, framework::ServiceRegistry&) |
| 87 | +{ |
| 88 | + ILOG(Info) << "FINALIZING !" << ENDM; |
| 89 | + |
| 90 | + for (auto& i : mCrates) { |
| 91 | + TCanvas* c = new TCanvas(i->GetName(), i->GetName()); |
| 92 | + i->Draw(); |
| 93 | + auto mo = std::make_shared<o2::quality_control::core::MonitorObject>(c, "PostProcessDiagnosticPerCrate", "TOF"); |
| 94 | + mo->setIsOwner(false); |
| 95 | + mDatabase->storeMO(mo); |
| 96 | + |
| 97 | + // It should delete everything inside. Confirmed by trying to delete histo after and getting a segfault. |
| 98 | + delete c; |
| 99 | + } |
| 100 | + ILOG(Info) << "DONE FINALIZING !" << ENDM; |
| 101 | +} |
| 102 | + |
| 103 | +} // namespace o2::quality_control_modules::tof |
0 commit comments