23#include "TCollection.h"
71template <
class TemplateArray>
79 LOGF(warning,
"StepTHn: Requesting more than 250M bins (%lld). This will need extensive memory.",
mNBins);
81 mPrototype =
new THnSparseT<TemplateArray>(Form(
"%s_sparse",
name), title, nAxes, nBins, xmin, xmax);
84template <
class TemplateArray>
86 Int_t* nBins, std::vector<Double_t> binEdges[],
const char** axisTitles) :
StepTHn(
name, title, nSteps, nAxes)
93 LOGF(warning,
"StepTHn: Requesting more than 250M bins (%lld). This will need extensive memory.",
mNBins);
95 mPrototype =
new THnSparseT<TemplateArray>(Form(
"%s_sparse",
name), title, nAxes, nBins);
98 if (nBins[
i] + 1 == binEdges[
i].
size()) {
100 }
else if (binEdges[
i].
size() == 2) {
101 mPrototype->GetAxis(
i)->Set(nBins[
i], binEdges[
i][0], binEdges[
i][1]);
103 LOGF(fatal,
"Invalid binning information for axis %d with %d bins and %d entries for bin edges",
i, nBins[
i], binEdges[
i].
size());
105 LOGF(
debug,
"Histogram %s Axis %d created with %d bins and %d edges",
name,
i, nBins[
i], binEdges[
i].
size());
126 mValues(new TArray*[
c.mNSteps]),
127 mSumw2(new TArray*[
c.mNSteps]),
130 mNbinsCache(nullptr),
224template <
class TemplateArray>
234 if (
list->IsEmpty()) {
238 TIterator* iter =
list->MakeIterator();
242 while ((obj = iter->Next())) {
245 if (
entry ==
nullptr) {
249 for (Int_t
i = 0;
i < mNSteps;
i++) {
252 mValues[
i] = createArray();
255 auto source =
dynamic_cast<TemplateArray*
>(
entry->mValues[
i])->GetArray();
256 auto target =
dynamic_cast<TemplateArray*
>(mValues[
i])->GetArray();
257 for (Long64_t l = 0; l < mNBins; l++) {
264 mSumw2[
i] = createArray();
267 auto source =
dynamic_cast<TemplateArray*
>(
entry->mSumw2[
i])->GetArray();
268 auto target =
dynamic_cast<TemplateArray*
>(mSumw2[
i])->GetArray();
269 for (Long64_t l = 0; l < mNBins; l++) {
290 bin += binIdx[
i] - 1;
301 LOGF(fatal,
"Histogram request for step %d which is empty.", step);
318 TArray* sourceSumw2 =
source;
320 sourceSumw2 =
mSumw2[step];
324 mTarget[step] = THnSparse::CreateSparse(Form(
"%s_%d", GetName(), step), Form(
"%s_%d", GetTitle(), step),
mPrototype);
326 mTarget[step] = THn::CreateHn(Form(
"%s_%d", GetName(), step), Form(
"%s_%d", GetTitle(), step),
mPrototype);
331 Int_t* binIdx =
new Int_t[
mNVars];
332 Int_t* nBins =
new Int_t[
mNVars];
335 nBins[
j] =
target->GetAxis(
j)->GetNbins();
351 target->SetBinError(binIdx, TMath::Sqrt(sourceSumw2->GetAt(globalBin)));
359 if (binIdx[
j] > nBins[
j]) {
365 if (binIdx[0] > nBins[0]) {
382 LOGF(fatal,
"Selected step for filling is not in range of StepTHn.");
386 if (nParams ==
mNVars + 1) {
388 }
else if (nParams !=
mNVars) {
389 LOGF(fatal,
"Fill called with invalid number of parameters (%d vs %d)",
mNVars, nParams);
438 LOGF(info,
"Created values container for step %d", iStep);
445 LOGF(info,
"Created sumw2 container for step %d", iStep);
templateClassImp(StepTHnT)
Long64_t Merge(TCollection *list) override
Double_t * mLastVars
cache Nbins per axis
Int_t * mLastBins
caching of last used bins (in many loops some vars are the same for a while)
void Fill(int iStep, const Ts &... valuesAndWeight)
TAxis ** mAxisCache
target histogram
Long64_t getGlobalBinIndex(const Int_t *binIdx)
StepTHn & operator=(const StepTHn &corr)
virtual TArray * createArray(const TArray *src=nullptr) const =0
Int_t * mNbinsCache
cache axis pointers (about 50% of the time in Fill is spent in GetAxis otherwise)
void createTarget(Int_t step, Bool_t sparse)
THnSparse * mPrototype
caching of last used bins (in many loops some vars are the same for a while)
void Copy(TObject &c) const override
GLuint const GLchar * name
GLuint GLuint GLfloat weight
GLsizei GLsizei GLchar * source
GLsizei const GLfloat * value