Skip to content

Commit bbc7397

Browse files
authored
StepTHn: use AddAt rather than Get+Set (#5897)
1 parent 161a3b5 commit bbc7397

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Framework/Core/include/Framework/StepTHn.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class StepTHn : public TNamed
4343
}
4444
return mTarget[step];
4545
}
46+
47+
virtual void AddAt(TArray* array, Double_t c, Int_t i) = 0;
48+
4649
Int_t getNSteps() { return mNSteps; }
4750
Int_t getNVar() { return mNVars; }
4851

@@ -93,6 +96,11 @@ class StepTHnT : public StepTHn
9396
StepTHnT(const char* name, const char* title, const int nSteps, const int nAxes, const int* nBins, const double* xmin, const double* xmax);
9497
~StepTHnT() override = default;
9598

99+
void AddAt(TArray* a, double c, int bin) final
100+
{
101+
static_cast<TemplateArray*>(a)->AddAt(c, bin);
102+
}
103+
96104
protected:
97105
TArray* createArray(const TArray* src = nullptr) const override
98106
{
@@ -186,10 +194,9 @@ void StepTHn::Fill(Int_t istep, const Ts&... valuesAndWeight)
186194
}
187195
}
188196

189-
// TODO probably slow; add StepTHnT::add ?
190-
mValues[istep]->SetAt(mValues[istep]->GetAt(bin) + weight, bin);
197+
this->AddAt(mValues[istep], weight, bin);
191198
if (mSumw2[istep]) {
192-
mSumw2[istep]->SetAt(mSumw2[istep]->GetAt(bin) + weight, bin);
199+
this->AddAt(mSumw2[istep], weight, bin);
193200
}
194201
}
195202

0 commit comments

Comments
 (0)