|
| 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 PostProcessingLuminometer.cxx |
| 14 | +/// \author Francesca Ercolessi francesca.ercolessi@cern.ch |
| 15 | +/// |
| 16 | + |
| 17 | +#include "TOF/PostProcessingLuminometer.h" |
| 18 | +#include "QualityControl/QcInfoLogger.h" |
| 19 | +#include "QualityControl/DatabaseInterface.h" |
| 20 | + |
| 21 | +#include "TOF/Utils.h" |
| 22 | + |
| 23 | +#include <TH1F.h> |
| 24 | +#include <TH2F.h> |
| 25 | +#include <boost/property_tree/ptree.hpp> |
| 26 | + |
| 27 | +using namespace o2::quality_control::postprocessing; |
| 28 | + |
| 29 | +namespace o2::quality_control_modules::tof |
| 30 | +{ |
| 31 | + |
| 32 | +PostProcessingLuminometer::~PostProcessingLuminometer() |
| 33 | +{ |
| 34 | +} |
| 35 | + |
| 36 | +void PostProcessingLuminometer::configure(const boost::property_tree::ptree& config) |
| 37 | +{ |
| 38 | + if (const auto& customConfigs = config.get_child_optional("qc.postprocessing." + getID() + ".customization"); customConfigs.has_value()) { |
| 39 | + for (const auto& customConfig : customConfigs.value()) { // Plot configuration |
| 40 | + if (const auto& customNames = customConfig.second.get_child_optional("name"); customNames.has_value()) { |
| 41 | + if (customConfig.second.get<std::string>("name") == "Nbins") { |
| 42 | + mBins = customConfig.second.get<int>("value"); |
| 43 | + ILOG(Info, Support) << "Setting Nbins to " << mBins << ENDM; |
| 44 | + } else if (customConfig.second.get<std::string>("name") == "MaxValue") { |
| 45 | + mMaxRange = customConfig.second.get<float>("value"); |
| 46 | + ILOG(Info, Support) << "Setting Nbins to " << mMaxRange << ENDM; |
| 47 | + } else if (customConfig.second.get<std::string>("name") == "CCDBPath") { |
| 48 | + mCCDBPath = customConfig.second.get<std::string>("value"); |
| 49 | + ILOG(Info, Support) << "Setting CCDBPath to " << mCCDBPath << ENDM; |
| 50 | + } else if (customConfig.second.get<std::string>("name") == "ActiveThr") { |
| 51 | + mActiveThr = customConfig.second.get<float>("value"); |
| 52 | + ILOG(Info, Support) << "Setting mActiveThr to " << mActiveThr << ENDM; |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +void PostProcessingLuminometer::initialize(Trigger, framework::ServiceRegistryRef services) |
| 60 | +{ |
| 61 | + float bin_width = mMaxRange / mBins; |
| 62 | + mHistoOrbitsInTFEfficiency.reset(); |
| 63 | + mHistoOrbitsInTFEfficiency = std::make_shared<TH1F>("OrbitsInTFEfficiency", "Fraction of orbits in TF;Fraction of orbits in TF; Counts x n_{crates} ", mBins, bin_width / 2, mMaxRange + bin_width / 2); |
| 64 | + getObjectsManager()->startPublishing(mHistoOrbitsInTFEfficiency.get()); |
| 65 | + |
| 66 | + mHistoLuminometer.reset(); |
| 67 | + mHistoLuminometer = std::make_shared<TH1F>("Luminometer", "Luminometer; ; hit_{TOF}/(eff_{RO}f_{active}) ", 1000, 0., 10000); |
| 68 | + getObjectsManager()->startPublishing(mHistoLuminometer.get()); |
| 69 | + |
| 70 | + mDatabase = &services.get<o2::quality_control::repository::DatabaseInterface>(); |
| 71 | +} |
| 72 | + |
| 73 | +void PostProcessingLuminometer::update(Trigger t, framework::ServiceRegistryRef) |
| 74 | +{ |
| 75 | + ILOG(Info, Support) << "Trigger type is: " << t.triggerType << ", the timestamp is " << t.timestamp << ENDM; |
| 76 | + |
| 77 | + if (mHistoOrbitsInTFEfficiency) { |
| 78 | + mHistoOrbitsInTFEfficiency->Reset(); |
| 79 | + } |
| 80 | + if (mHistoLuminometer){ |
| 81 | + mHistoLuminometer->Reset(); |
| 82 | + } |
| 83 | + |
| 84 | + TH1F* tempPerCrateHisto[72]; // 72 crates |
| 85 | + for (int i = 0; i < 72; i++) { // loop over crates |
| 86 | + tempPerCrateHisto[i] = nullptr; |
| 87 | + } |
| 88 | + |
| 89 | + auto moEfficiency = mDatabase->retrieveMO(mCCDBPath, mMOEfficiency, t.timestamp, t.activity); |
| 90 | + auto moActiveChannels = mDatabase->retrieveMO(mCCDBPath, mMOActiveChannels, t.timestamp, t.activity); |
| 91 | + auto moMultiplicity = mDatabase->retrieveMO(mCCDBPath, mMOMultiplicity, t.timestamp, t.activity); |
| 92 | + |
| 93 | + float ROeff = 1.; |
| 94 | + float hitMult = 0.; |
| 95 | + float activeCh = 1.; |
| 96 | + |
| 97 | + // Readout efficiency |
| 98 | + TH2F* moHEfficiency = static_cast<TH2F*>(moEfficiency ? moEfficiency->getObject() : nullptr); |
| 99 | + if (moHEfficiency) { |
| 100 | + ILOG(Info, Support) << "Found MO " << mMOEfficiency << " in path " << mCCDBPath << ENDM; |
| 101 | + for (int i = 0; i < 72; i++) { // loop over crates |
| 102 | + tempPerCrateHisto[i] = (TH1F*)moHEfficiency->ProjectionY(Form("hPerCrate%i", i), i + 1, i + 1); |
| 103 | + mHistoOrbitsInTFEfficiency->Fill(tempPerCrateHisto[i]->Integral() / (32.f * 3.f)); // 32 orbits in Time Frame, 3 readout windows per orbit |
| 104 | + } |
| 105 | + } else { |
| 106 | + ILOG(Warning) << "Did not find MO " << mMOEfficiency << " in path " << mCCDBPath << ENDM; |
| 107 | + } |
| 108 | + |
| 109 | + if (mHistoOrbitsInTFEfficiency) { |
| 110 | + ROeff = mHistoOrbitsInTFEfficiency->GetMean(); |
| 111 | + } |
| 112 | + |
| 113 | + // Active channels |
| 114 | + TH2F* moHActiveChannels = static_cast<TH2F*>(moActiveChannels ? moActiveChannels->getObject() : nullptr); |
| 115 | + if (moHActiveChannels) { |
| 116 | + ILOG(Info, Support) << "Found MO " << mMOActiveChannels << " in path " << mCCDBPath << ENDM; |
| 117 | + |
| 118 | + int counterAll = 0; |
| 119 | + int counterActive = 0; |
| 120 | + |
| 121 | + for (int i = 1; i <= moHActiveChannels->GetNbinsX(); i++) { |
| 122 | + for (int j = 1; j <= moHActiveChannels->GetNbinsY(); j++) { |
| 123 | + counterAll++; |
| 124 | + |
| 125 | + if (moHActiveChannels->GetBinContent(i,j)>mActiveThr){ |
| 126 | + counterActive++; |
| 127 | + } |
| 128 | + } |
| 129 | + } |
| 130 | + |
| 131 | + activeCh = (float)counterActive/counterAll; |
| 132 | + } else { |
| 133 | + ILOG(Warning) << "Did not find MO " << mMOActiveChannels << " in path " << mCCDBPath << ENDM; |
| 134 | + } |
| 135 | + |
| 136 | + // Multiplicity |
| 137 | + TH1F* moHMultiplicity = static_cast<TH1F*>(moMultiplicity ? moMultiplicity->getObject() : nullptr); |
| 138 | + if (moHMultiplicity) { |
| 139 | + ILOG(Info, Support) << "Found MO " << mMOMultiplicity << " in path " << mCCDBPath << ENDM; |
| 140 | + hitMult = moHMultiplicity->GetMean(); |
| 141 | + } else { |
| 142 | + ILOG(Warning) << "Did not find MO " << mMOMultiplicity << " in path " << mCCDBPath << ENDM; |
| 143 | + } |
| 144 | + |
| 145 | + mHistoLuminometer->Fill(hitMult/(activeCh*ROeff)); |
| 146 | +} |
| 147 | + |
| 148 | +void PostProcessingLuminometer::finalize(Trigger, framework::ServiceRegistryRef) |
| 149 | +{ |
| 150 | + // Only if you don't want it to be published after finalisation. |
| 151 | + getObjectsManager()->stopPublishing(mHistoLuminometer.get()); |
| 152 | +} |
| 153 | + |
| 154 | +} // namespace o2::quality_control_modules::tof |
0 commit comments