|
| 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 BCVisualization.h |
| 14 | +/// \author Markus Fasel |
| 15 | +/// |
| 16 | + |
| 17 | +#ifndef QUALITYCONTROL_BCVISUALIZATION_H |
| 18 | +#define QUALITYCONTROL_BCVISUALIZATION_H |
| 19 | + |
| 20 | +// QC includes |
| 21 | +#include "QualityControl/PostProcessingInterface.h" |
| 22 | +#include <map> |
| 23 | +#include <memory> |
| 24 | +#include <vector> |
| 25 | +#include <string> |
| 26 | +#include <tuple> |
| 27 | +#include <cfloat> |
| 28 | + |
| 29 | +class TCanvas; |
| 30 | +class TH1; |
| 31 | + |
| 32 | +namespace o2::quality_control_modules::emcal |
| 33 | +{ |
| 34 | + |
| 35 | +/// \brief Visualization of BC distributions and determination of Shift between EMCAL and CTP |
| 36 | +class BCVisualization final : public quality_control::postprocessing::PostProcessingInterface |
| 37 | +{ |
| 38 | + public: |
| 39 | + enum class MethodBCShift_t { |
| 40 | + LEADING_BC, |
| 41 | + ISOLATED_BC, |
| 42 | + UNKNOWN |
| 43 | + }; |
| 44 | + /// \brief Constructor |
| 45 | + BCVisualization() = default; |
| 46 | + /// \brief Destructor |
| 47 | + ~BCVisualization() = default; |
| 48 | + |
| 49 | + /// \brief Configuration of a post-processing task. |
| 50 | + /// Configuration of a post-processing task. Can be overridden if user wants to retrieve the configuration of the task. |
| 51 | + /// \param config ConfigurationInterface with prefix set to "" |
| 52 | + void configure(const boost::property_tree::ptree& config) override; |
| 53 | + /// \brief Initialization of a post-processing task. |
| 54 | + /// Initialization of a post-processing task. User receives a Trigger which caused the initialization and a service |
| 55 | + /// registry with singleton interfaces. |
| 56 | + /// \param trigger Trigger which caused the initialization, for example Trigger::SOR |
| 57 | + /// \param services Interface containing optional interfaces, for example DatabaseInterface |
| 58 | + void initialize(quality_control::postprocessing::Trigger, framework::ServiceRegistryRef) override; |
| 59 | + /// \brief Update of a post-processing task. |
| 60 | + /// Update of a post-processing task. User receives a Trigger which caused the update and a service |
| 61 | + /// registry with singleton interfaces. |
| 62 | + /// \param trigger Trigger which caused the initialization, for example Trigger::Period |
| 63 | + /// \param services Interface containing optional interfaces, for example DatabaseInterface |
| 64 | + void update(quality_control::postprocessing::Trigger, framework::ServiceRegistryRef services) override; |
| 65 | + /// \brief Finalization of a post-processing task. |
| 66 | + /// Finalization of a post-processing task. User receives a Trigger which caused the finalization and a service |
| 67 | + /// registry with singleton interfaces. |
| 68 | + /// \param trigger Trigger which caused the initialization, for example Trigger::EOR |
| 69 | + /// \param services Interface containing optional interfaces, for example DatabaseInterface |
| 70 | + void finalize(quality_control::postprocessing::Trigger, framework::ServiceRegistryRef) override; |
| 71 | + |
| 72 | + void reset(); |
| 73 | + |
| 74 | + private: |
| 75 | + std::tuple<bool, int> determineBCShift(const TH1* emchist, const TH1* ctphist, MethodBCShift_t method) const; |
| 76 | + std::tuple<bool, int> determineBCShiftIsolated(const TH1* emchist, const TH1* ctphist) const; |
| 77 | + std::tuple<bool, int> determineBCShiftLeading(const TH1* emchist, const TH1* ctphist) const; |
| 78 | + std::vector<int> getIsolatedBCs(const TH1* bchist) const; |
| 79 | + std::vector<int> getShifted(const std::vector<int>& bcEMC, int shift) const; |
| 80 | + int getNMatching(const std::vector<int>& bcShiftedEMC, const std::vector<int>& bcCTP) const; |
| 81 | + int getLeadingBC(const TH1* histogram) const; |
| 82 | + MethodBCShift_t getMethod(const std::string_view methodstring) const; |
| 83 | + std::string getMethodString(MethodBCShift_t method) const; |
| 84 | + TCanvas* mOutputCanvas = nullptr; ///< output plot |
| 85 | + TH1* mFrame = nullptr; ///< Frame for output canvas |
| 86 | + std::string mDataPath; ///< Path in QCDB with histos |
| 87 | + MethodBCShift_t mShiftEvaluation = MethodBCShift_t::ISOLATED_BC; ///< Method used to determine the BC shift |
| 88 | + int mMinNumberOfEntriesBCShift = 100; ///< Min. number of entries for BC shift calculation |
| 89 | +}; |
| 90 | + |
| 91 | +} // namespace o2::quality_control_modules::emcal |
| 92 | + |
| 93 | +#endif // QUALITYCONTROL_BCVISUALIZATION_H |
0 commit comments