@@ -58,7 +58,7 @@ class StepTHn : public TNamed
5858 virtual Long64_t Merge (TCollection* list) = 0;
5959
6060 TAxis* GetAxis (int i) { return mPrototype ->GetAxis (i); }
61- void Sumw2 (){}; // TODO: added for compatibiltiy with registry, but maybe it would be useful also in StepTHn as toggle for error weights
61+ void Sumw2 () {}; // TODO: added for compatibiltiy with registry, but maybe it would be useful also in StepTHn as toggle for error weights
6262
6363 protected:
6464 void init ();
@@ -67,6 +67,7 @@ class StepTHn : public TNamed
6767 void deleteContainers ();
6868
6969 Long64_t getGlobalBinIndex (const Int_t* binIdx);
70+ virtual void updateBin (int iStep, Long64_t bin, double weight) = 0;
7071
7172 Long64_t mNBins ; // number of total bins
7273 Int_t mNVars ; // number of variables
@@ -107,6 +108,28 @@ class StepTHnT : public StepTHn
107108 }
108109 }
109110
111+ void updateBin (int iStep, Long64_t bin, double weight) override
112+ {
113+ if (!mValues [iStep]) {
114+ mValues [iStep] = createArray ();
115+ LOGF (info, " Created values container for step %d" , iStep);
116+ }
117+
118+ if (weight != 1 .) {
119+ if (!mSumw2 [iStep]) {
120+ mSumw2 [iStep] = createArray (mValues [iStep]);
121+ LOGF (info, " Created sumw2 container for step %d" , iStep);
122+ }
123+ }
124+
125+ auto * arr = static_cast <TemplateArray*>(mValues [iStep])->GetArray ();
126+ arr[bin] += weight;
127+ if (mSumw2 [iStep]) {
128+ auto * sw2 = static_cast <TemplateArray*>(mSumw2 [iStep])->GetArray ();
129+ sw2[bin] += weight * weight;
130+ }
131+ }
132+
110133 ClassDef (StepTHnT, 1 ) // THn like container
111134};
112135
0 commit comments