Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions Analysis/Core/src/CorrelationContainer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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<StepTHnF>({"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<StepTHnF>({"mTriggerHist", "d^{2}N_{ch}/d#varphid#eta", {HistType::kStepTHnF, {axisList[2], axisList[3], axisList[5]}, fgkCFSteps}})->Clone();
mTrackHistEfficiency = (StepTHnD*)HistFactory::createHist<StepTHnD>({"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<TH2F>({"mEventCount", ";step;centrality;count", {HistType::kTH2F, {{fgkCFSteps + 2, -2.5, -0.5 + fgkCFSteps, "step"}, axisList[3]}}})->Clone());
mPairHist = HistFactory::createHist<StepTHnF>({"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<StepTHnF>({"mTriggerHist", "d^{2}N_{ch}/d#varphid#eta", {HistType::kStepTHnF, {axisList[2], axisList[3], axisList[5]}, fgkCFSteps}}).release();
mTrackHistEfficiency = HistFactory::createHist<StepTHnD>({"mTrackHistEfficiency", "Tracking efficiency", {HistType::kStepTHnD, {axisList[6], axisList[7], {4, -0.5, 3.5, "species"}, axisList[3], axisList[8]}, fgkCFSteps}}).release();
mEventCount = HistFactory::createHist<TH2F>({"mEventCount", ";step;centrality;count", {HistType::kTH2F, {{fgkCFSteps + 2, -2.5, -0.5 + fgkCFSteps, "step"}, axisList[3]}}}).release();
}

//_____________________________________________________________________________
Expand Down
10 changes: 5 additions & 5 deletions Framework/Core/include/Framework/HistogramRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -36,7 +36,7 @@ struct HistFactory {

// create histogram of type T with the axes defined in HistogramSpec
template <typename T>
static std::shared_ptr<T> createHist(const HistogramSpec& histSpec)
static std::unique_ptr<T> createHist(const HistogramSpec& histSpec)
{
constexpr std::size_t MAX_DIM{10};
const std::size_t nAxes{histSpec.config.axes.size()};
Expand All @@ -57,15 +57,15 @@ struct HistFactory {
}

// create histogram
std::shared_ptr<T> hist{generateHist<T>(histSpec.name, histSpec.title, nAxes, nBins, lowerBounds, upperBounds, histSpec.config.nSteps)};
std::unique_ptr<T> hist{generateHist<T>(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;
}

// 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());
Expand Down Expand Up @@ -117,7 +117,7 @@ struct HistFactory {

// helper function to get the axis via index for any type of root histogram
template <typename T>
static TAxis* getAxis(const int i, std::shared_ptr<T>& hist)
static TAxis* getAxis(const int i, T* hist)
{
if constexpr (std::is_base_of_v<THnBase, T> || std::is_base_of_v<StepTHn, T>) {
return hist->GetAxis(i);
Expand Down
9 changes: 5 additions & 4 deletions Framework/Core/include/Framework/HistogramSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#ifndef FRAMEWORK_HISTOGRAMSPEC_H_
#define FRAMEWORK_HISTOGRAMSPEC_H_

#include <string>
#include <variant>
#include <deque>

#include <TH1.h>
#include <TH2.h>
#include <TH3.h>
Expand All @@ -23,13 +27,10 @@
#include <TDataMember.h>
#include <TDataType.h>

#include <string>
#include <variant>
#include <deque>

#include "Framework/StepTHn.h"
#include "Framework/Configurable.h"
#include "Framework/StringHelpers.h"
#include "Framework/RuntimeError.h"

namespace o2::framework
{
Expand Down
2 changes: 1 addition & 1 deletion Framework/Core/src/HistogramRegistry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down