diff --git a/Analysis/Core/src/CorrelationContainer.cxx b/Analysis/Core/src/CorrelationContainer.cxx index 96eaaa7187819..ff28029d6ff9c 100644 --- a/Analysis/Core/src/CorrelationContainer.cxx +++ b/Analysis/Core/src/CorrelationContainer.cxx @@ -30,9 +30,9 @@ using namespace o2::framework; -ClassImp(CorrelationContainer) +ClassImp(CorrelationContainer); - const Int_t CorrelationContainer::fgkCFSteps = 11; +const Int_t CorrelationContainer::fgkCFSteps = 11; CorrelationContainer::CorrelationContainer() : TNamed(), mPairHist(nullptr), @@ -94,11 +94,10 @@ CorrelationContainer::CorrelationContainer(const char* name, const char* objTitl LOGF(info, "Creating CorrelationContainer"); - // TODO Remove Clone() pending change in HistogramRegistry - mPairHist = (StepTHnF*)HistFactory::createHist({"mPairHist", "d^{2}N_{ch}/d#varphid#eta", {HistType::kStepTHnF, {axisList[0], axisList[1], axisList[2], axisList[3], axisList[4], axisList[5]}, fgkCFSteps}})->Clone(); - mTriggerHist = (StepTHnF*)HistFactory::createHist({"mTriggerHist", "d^{2}N_{ch}/d#varphid#eta", {HistType::kStepTHnF, {axisList[2], axisList[3], axisList[5]}, fgkCFSteps}})->Clone(); - mTrackHistEfficiency = (StepTHnD*)HistFactory::createHist({"mTrackHistEfficiency", "Tracking efficiency", {HistType::kStepTHnD, {axisList[6], axisList[7], {4, -0.5, 3.5, "species"}, axisList[3], axisList[8]}, fgkCFSteps}})->Clone(); - mEventCount = (TH2F*)(HistFactory::createHist({"mEventCount", ";step;centrality;count", {HistType::kTH2F, {{fgkCFSteps + 2, -2.5, -0.5 + fgkCFSteps, "step"}, axisList[3]}}})->Clone()); + mPairHist = HistFactory::createHist({"mPairHist", "d^{2}N_{ch}/d#varphid#eta", {HistType::kStepTHnF, {axisList[0], axisList[1], axisList[2], axisList[3], axisList[4], axisList[5]}, fgkCFSteps}}).release(); + mTriggerHist = HistFactory::createHist({"mTriggerHist", "d^{2}N_{ch}/d#varphid#eta", {HistType::kStepTHnF, {axisList[2], axisList[3], axisList[5]}, fgkCFSteps}}).release(); + mTrackHistEfficiency = HistFactory::createHist({"mTrackHistEfficiency", "Tracking efficiency", {HistType::kStepTHnD, {axisList[6], axisList[7], {4, -0.5, 3.5, "species"}, axisList[3], axisList[8]}, fgkCFSteps}}).release(); + mEventCount = HistFactory::createHist({"mEventCount", ";step;centrality;count", {HistType::kTH2F, {{fgkCFSteps + 2, -2.5, -0.5 + fgkCFSteps, "step"}, axisList[3]}}}).release(); } //_____________________________________________________________________________ diff --git a/Framework/Core/include/Framework/HistogramRegistry.h b/Framework/Core/include/Framework/HistogramRegistry.h index b7ec8f4d189f8..0e84387777d1c 100644 --- a/Framework/Core/include/Framework/HistogramRegistry.h +++ b/Framework/Core/include/Framework/HistogramRegistry.h @@ -20,12 +20,12 @@ #include "Framework/OutputSpec.h" #include "Framework/SerializationMethods.h" #include "Framework/TableBuilder.h" -#include "Framework/RuntimeError.h" #define HIST(name) CONST_STR(name) namespace o2::framework { + //************************************************************************************************** /** * Static helper class to generate histograms from the specifications. @@ -36,7 +36,7 @@ struct HistFactory { // create histogram of type T with the axes defined in HistogramSpec template - static std::shared_ptr createHist(const HistogramSpec& histSpec) + static std::unique_ptr createHist(const HistogramSpec& histSpec) { constexpr std::size_t MAX_DIM{10}; const std::size_t nAxes{histSpec.config.axes.size()}; @@ -57,7 +57,7 @@ struct HistFactory { } // create histogram - std::shared_ptr hist{generateHist(histSpec.name, histSpec.title, nAxes, nBins, lowerBounds, upperBounds, histSpec.config.nSteps)}; + std::unique_ptr hist{generateHist(histSpec.name, histSpec.title, nAxes, nBins, lowerBounds, upperBounds, histSpec.config.nSteps)}; if (!hist) { LOGF(FATAL, "The number of dimensions specified for histogram %s does not match the type.", histSpec.name); return nullptr; @@ -65,7 +65,7 @@ struct HistFactory { // set axis properties for (std::size_t i = 0; i < nAxes; i++) { - TAxis* axis{getAxis(i, hist)}; + TAxis* axis{getAxis(i, hist.get())}; if (axis) { if (histSpec.config.axes[i].title) { axis->SetTitle((*histSpec.config.axes[i].title).data()); @@ -117,7 +117,7 @@ struct HistFactory { // helper function to get the axis via index for any type of root histogram template - static TAxis* getAxis(const int i, std::shared_ptr& hist) + static TAxis* getAxis(const int i, T* hist) { if constexpr (std::is_base_of_v || std::is_base_of_v) { return hist->GetAxis(i); diff --git a/Framework/Core/include/Framework/HistogramSpec.h b/Framework/Core/include/Framework/HistogramSpec.h index b391dc8b91802..c6af69a2e42fe 100644 --- a/Framework/Core/include/Framework/HistogramSpec.h +++ b/Framework/Core/include/Framework/HistogramSpec.h @@ -11,6 +11,10 @@ #ifndef FRAMEWORK_HISTOGRAMSPEC_H_ #define FRAMEWORK_HISTOGRAMSPEC_H_ +#include +#include +#include + #include #include #include @@ -23,13 +27,10 @@ #include #include -#include -#include -#include - #include "Framework/StepTHn.h" #include "Framework/Configurable.h" #include "Framework/StringHelpers.h" +#include "Framework/RuntimeError.h" namespace o2::framework { diff --git a/Framework/Core/src/HistogramRegistry.cxx b/Framework/Core/src/HistogramRegistry.cxx index f833f2ec8f9ce..88ca417bc9084 100644 --- a/Framework/Core/src/HistogramRegistry.cxx +++ b/Framework/Core/src/HistogramRegistry.cxx @@ -194,7 +194,7 @@ void HistogramRegistry::print(bool showAxisDetails) nDim = hist->GetDimension(); } for (int d = 0; d < nDim; ++d) { - TAxis* axis = HistFactory::getAxis(d, hist); + TAxis* axis = HistFactory::getAxis(d, hist.get()); LOGF(INFO, "- Axis %d: %-20s (%d bins)", d, axis->GetTitle(), axis->GetNbins()); } }