|
| 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 | + |
| 12 | +/// |
| 13 | +/// \file CTFSizeTask.cxx |
| 14 | +/// \author Ole Schmidt |
| 15 | +/// |
| 16 | + |
| 17 | +#include <TH1F.h> |
| 18 | +#include <TMath.h> |
| 19 | +#include "QualityControl/QcInfoLogger.h" |
| 20 | +#include "GLO/CTFSizeTask.h" |
| 21 | +#include <Framework/InputRecord.h> |
| 22 | + |
| 23 | +using namespace o2::detectors; |
| 24 | + |
| 25 | +namespace o2::quality_control_modules::glo |
| 26 | +{ |
| 27 | + |
| 28 | +CTFSize::~CTFSize() |
| 29 | +{ |
| 30 | +} |
| 31 | + |
| 32 | +std::tuple<int, float, float> CTFSize::getBinningFromConfig(o2::detectors::DetID::ID iDet, const Activity& activity) const |
| 33 | +{ |
| 34 | + std::string cfKey = "binning"; |
| 35 | + cfKey += DetID::getName(iDet); |
| 36 | + std::string binning = mCustomParameters.atOptional(cfKey, activity).value_or(mDefaultBinning[iDet]); |
| 37 | + auto nBins = std::stoi(binning.substr(0, binning.find(","))); |
| 38 | + binning.erase(0, binning.find(",") + 1); |
| 39 | + auto xMin = std::stof(binning.substr(0, binning.find(","))); |
| 40 | + binning.erase(0, binning.find(",") + 1); |
| 41 | + auto xMax = std::stof(binning.substr(0, binning.find(","))); |
| 42 | + return std::make_tuple(nBins, xMin, xMax); |
| 43 | +} |
| 44 | + |
| 45 | +void CTFSize::initialize(o2::framework::InitContext& /*ctx*/) |
| 46 | +{ |
| 47 | + // default lower limit from pp run 549884 and upper limit from PbPb run 543918, each limit with some margin |
| 48 | + mDefaultBinning[DetID::ITS] = "1000, 1e2, 1e5"; |
| 49 | + mDefaultBinning[DetID::TPC] = "1000, 1e3, 1e6"; |
| 50 | + mDefaultBinning[DetID::TRD] = "1000, 1e2, 1e5"; |
| 51 | + mDefaultBinning[DetID::TOF] = "1000, 10, 1e4"; |
| 52 | + mDefaultBinning[DetID::PHS] = "100, 10, 1e3"; |
| 53 | + mDefaultBinning[DetID::CPV] = "100, 10, 3e4"; |
| 54 | + mDefaultBinning[DetID::EMC] = "1000, 100, 5e5"; |
| 55 | + mDefaultBinning[DetID::HMP] = "100, 1, 300"; |
| 56 | + mDefaultBinning[DetID::MFT] = "1000, 1e2, 1e4"; |
| 57 | + mDefaultBinning[DetID::MCH] = "100, 1e3, 5e4"; |
| 58 | + mDefaultBinning[DetID::MID] = "100, 10, 500"; |
| 59 | + mDefaultBinning[DetID::ZDC] = "100, 1e3, 1e4"; |
| 60 | + mDefaultBinning[DetID::FT0] = "100, 1, 500"; |
| 61 | + mDefaultBinning[DetID::FV0] = "100, 1, 400"; |
| 62 | + mDefaultBinning[DetID::FDD] = "100, 1, 100"; |
| 63 | + mDefaultBinning[DetID::CTP] = "100, 1, 100"; |
| 64 | + mDefaultBinning[DetID::TST] = "1, 0, 1"; |
| 65 | + |
| 66 | + constexpr int nLogBins = 100; |
| 67 | + float xBins[nLogBins + 1]; |
| 68 | + float xBinLogMin = 0.f; |
| 69 | + float xBinLogMax = 11.f; |
| 70 | + float logBinWidth = (xBinLogMax - xBinLogMin) / nLogBins; |
| 71 | + for (int iBin = 0; iBin <= nLogBins; ++iBin) { |
| 72 | + xBins[iBin] = TMath::Power(10, xBinLogMin + iBin * logBinWidth); |
| 73 | + } |
| 74 | + for (int iDet = 0; iDet < DetID::CTP + 1; ++iDet) { |
| 75 | + mHistSizesLog[iDet] = new TH1F(Form("hSizeLog_%s", DetID::getName(iDet)), Form("%s CTF size per TF;Byte;counts", DetID::getName(iDet)), nLogBins, xBins); |
| 76 | + getObjectsManager()->startPublishing(mHistSizesLog[iDet]); |
| 77 | + getObjectsManager()->setDefaultDrawOptions(mHistSizesLog[iDet]->GetName(), "logx"); |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +void CTFSize::startOfActivity(const Activity& activity) |
| 82 | +{ |
| 83 | + if (!mPublishingDone) { |
| 84 | + for (int iDet = 0; iDet < DetID::CTP + 1; ++iDet) { |
| 85 | + auto binning = getBinningFromConfig(iDet, activity); |
| 86 | + std::string unit = (iDet == DetID::EMC || iDet == DetID::CPV) ? "B" : "kB"; |
| 87 | + mHistSizes[iDet] = new TH1F(Form("hSize_%s", DetID::getName(iDet)), Form("%s CTF size per TF;%s;counts", DetID::getName(iDet), unit.c_str()), std::get<0>(binning), std::get<1>(binning), std::get<2>(binning)); |
| 88 | + getObjectsManager()->startPublishing(mHistSizes[iDet]); |
| 89 | + } |
| 90 | + mPublishingDone = true; |
| 91 | + } |
| 92 | + reset(); |
| 93 | +} |
| 94 | + |
| 95 | +void CTFSize::startOfCycle() |
| 96 | +{ |
| 97 | + // reset(); |
| 98 | +} |
| 99 | + |
| 100 | +void CTFSize::monitorData(o2::framework::ProcessingContext& ctx) |
| 101 | +{ |
| 102 | + const auto sizes = ctx.inputs().get<std::array<size_t, DetID::CTP + 1>>("ctfSizes"); |
| 103 | + for (int iDet = 0; iDet <= DetID::CTP; ++iDet) { |
| 104 | + std::cout << DetID::getName(iDet) << ": " << sizes[iDet] << std::endl; |
| 105 | + float conversion = (iDet == DetID::EMC || iDet == DetID::CPV) ? 1.f : 1024.f; // EMC and CPV can sent <1kB per CTF |
| 106 | + mHistSizes[iDet]->Fill(sizes[iDet] / conversion); |
| 107 | + mHistSizesLog[iDet]->Fill(sizes[iDet]); |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +void CTFSize::endOfCycle() |
| 112 | +{ |
| 113 | +} |
| 114 | + |
| 115 | +void CTFSize::endOfActivity(const Activity& /*activity*/) |
| 116 | +{ |
| 117 | +} |
| 118 | + |
| 119 | +void CTFSize::reset() |
| 120 | +{ |
| 121 | + for (auto h : mHistSizes) { |
| 122 | + if (h) { |
| 123 | + h->Reset(); |
| 124 | + } |
| 125 | + } |
| 126 | + for (auto h : mHistSizesLog) { |
| 127 | + if (h) { |
| 128 | + h->Reset(); |
| 129 | + } |
| 130 | + } |
| 131 | +} |
| 132 | + |
| 133 | +} // namespace o2::quality_control_modules::glo |
0 commit comments