diff --git a/core/base/CbmHistManager.h b/core/base/CbmHistManager.h old mode 100755 new mode 100644 index 037b2208c77bf3a233f86d67963d73da61c58879..d0eaeb39453f1f0b9cb77c6e39a8f42e99828cf9 --- a/core/base/CbmHistManager.h +++ b/core/base/CbmHistManager.h @@ -28,12 +28,14 @@ #include <TProfile.h> // for TProfile #include <TProfile2D.h> // for TProfile2D -#include <cassert> // for assert -#include <map> // for map, __map_const_iterator, operator!= -#include <ostream> // for string, operator<<, ostream -#include <string> // for operator< -#include <utility> // for pair, make_pair -#include <vector> // for vector +#include <array> // for array +#include <cassert> // for assert +#include <map> // for map, __map_const_iterator, operator!= +#include <ostream> // for string, operator<<, ostream +#include <string> // for operator< +#include <type_traits> // for is_base_of +#include <utility> // for pair, make_pair +#include <vector> // for vector class TFile; @@ -169,20 +171,21 @@ public: /** * \brief Helper function for creation of THnSparse objects. - * Template argument is a real object type that has to be created, for example, - * CreateSparse<THnSparseD>("name", "title", nDim, nBins, minVals, maxVals); + * \tparam <T> { real object type that has to be created, for example THnSparseD } + * \tparam <nDim> { Array dimensions for nBins, minVals and maxVals } + * CreateSparse<THnSparseD, 3>("name", "title", nDim, nBins, minVals, maxVals); * \param[in] name Object name. * \param[in] title Object title. - * \param[in] nDim Number of dimensions. - * \param[in] nBins Array with number of bins for each dimension. - * \param[in] minVals Array with minimum values for each dimension. - * \param[in] maxVals Array with maximum values for each dimension. + * \param[in] nBins Array of size nDim with number of bins for each dimension. + * \param[in] minVals Array of size nDim with minimum values for each dimension. + * \param[in] maxVals Array of size nDim with maximum values for each dimension. */ - template<class T> - void CreateSparse(const std::string& name, const std::string& title, Int_t nDim, const Int_t* nBins, - const Double_t* minVals, const Double_t* maxVals) + template<class T, int nDim> + void CreateSparse(const std::string& name, const std::string& title, const std::array<Int_t, nDim>& nBins, + const std::array<Double_t, nDim>& minVals, const std::array<Double_t, nDim>& maxVals) { - T* h = new T(name.c_str(), title.c_str(), nDim, nBins, minVals, maxVals); + static_assert(std::is_base_of<THnSparse, T>::value, "Class must be derrived from THnSparse"); + T* h = new T(name.c_str(), title.c_str(), nDim, nBins.data(), minVals.data(), maxVals.data()); Add(name, h); } @@ -195,6 +198,7 @@ public: return fMap.find(name)->second; } + /** * \brief Return pointer to TH1 histogram. * \param[in] name Name of TH1 histogram.