Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:44

0001 /// \file ROOT/RHistUtils.hxx
0002 /// \ingroup HistV7
0003 /// \author Axel Naumann <axel@cern.ch>
0004 /// \date 2016-06-01
0005 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
0006 
0007 /*************************************************************************
0008  * Copyright (C) 1995-2016, Rene Brun and Fons Rademakers.               *
0009  * All rights reserved.                                                  *
0010  *                                                                       *
0011  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0012  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0013  *************************************************************************/
0014 
0015 #ifndef ROOT7_RHistUtils
0016 #define ROOT7_RHistUtils
0017 
0018 #include <array>
0019 #include <type_traits>
0020 
0021 namespace ROOT {
0022 namespace Experimental {
0023 
0024 class RLogChannel;
0025 /// Log channel for Hist diagnostics.
0026 RLogChannel &HistLog(); // implemented in RAxis.cxx
0027 
0028 namespace Hist {
0029 
0030 template <int DIMENSIONS>
0031 struct RCoordArray: std::array<double, DIMENSIONS> {
0032    using Base_t = std::array<double, DIMENSIONS>;
0033 
0034    /// Default construction.
0035    RCoordArray() = default;
0036 
0037    /// Construction with one `double` per `DIMENSION`.
0038    template<class...ELEMENTS, class = typename std::enable_if<sizeof...(ELEMENTS) + 1 == DIMENSIONS>::type>
0039    RCoordArray(double x, ELEMENTS...el): Base_t{{x, el...}} {}
0040 
0041    /// Fallback constructor, invoked if the one above fails because of the wrong number of
0042    /// arguments / coordinates.
0043    template<class T, class...ELEMENTS, class = typename std::enable_if<sizeof...(ELEMENTS) + 1 != DIMENSIONS>::type>
0044    RCoordArray(T, ELEMENTS...) {
0045       static_assert(sizeof...(ELEMENTS) + 1 == DIMENSIONS, "Number of coordinates does not match DIMENSIONS");
0046    }
0047 
0048    /// Construction from a C-style array.
0049    RCoordArray(double (&arr)[DIMENSIONS]): Base_t(arr) {}
0050 
0051    /// Copy-construction from a C++-style array.
0052    /// (No need for a move-constructor, it isn't any better for doubles)
0053    RCoordArray(const std::array<double, DIMENSIONS>& arr): Base_t(arr) {}
0054 };
0055 
0056 template <int DIMENSIONS>
0057 //using CoordArray_t = std::array<double, DIMENSIONS>;
0058 using CoordArray_t = RCoordArray<DIMENSIONS>;
0059 
0060 
0061 } // namespace Hist
0062 } // namespace Experimental
0063 } // namespace ROOT
0064 
0065 #endif //ROOT7_THistUtils_h