Skip to content

Commit c4c934e

Browse files
committed
Merge pull request #19 from gpetruc/fix-non-uniform-binned-generation
Fix weight issue
2 parents 97ad68e + d6a7221 commit c4c934e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/ToyMCSamplerOpt.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ toymcoptutils::SinglePdfGenInfo::generateWithHisto(RooRealVar *&weightVar, bool
207207
for (int i = 1, n = histoSpec_->GetNbinsX(); i <= n; ++i) {
208208
x->setVal(histoSpec_->GetXaxis()->GetBinCenter(i));
209209
double w = histoSpec_->GetXaxis()->GetBinWidth(i);
210-
data->add(observables_, w*weightScale*(asimov ? histoSpec_->GetBinContent(i) : RooRandom::randomGenerator()->Poisson(histoSpec_->GetBinContent(i))) );
210+
data->add(observables_, weightScale*(asimov ? w*histoSpec_->GetBinContent(i) : RooRandom::randomGenerator()->Poisson(w*histoSpec_->GetBinContent(i))) );
211211
}
212212
break;
213213
case 2:
@@ -218,7 +218,7 @@ toymcoptutils::SinglePdfGenInfo::generateWithHisto(RooRealVar *&weightVar, bool
218218
x->setVal(h2.GetXaxis()->GetBinCenter(ix));
219219
y->setVal(h2.GetYaxis()->GetBinCenter(iy));
220220
double w = h2.GetXaxis()->GetBinWidth(ix) * h2.GetYaxis()->GetBinWidth(iy);
221-
data->add(observables_, w*weightScale*(asimov ? h2.GetBinContent(ix,iy) : RooRandom::randomGenerator()->Poisson(h2.GetBinContent(ix,iy))) );
221+
data->add(observables_, weightScale*(asimov ? w*h2.GetBinContent(ix,iy) : RooRandom::randomGenerator()->Poisson(w*h2.GetBinContent(ix,iy))) );
222222
} }
223223
}
224224
break;
@@ -232,7 +232,7 @@ toymcoptutils::SinglePdfGenInfo::generateWithHisto(RooRealVar *&weightVar, bool
232232
y->setVal(h3.GetYaxis()->GetBinCenter(iy));
233233
z->setVal(h3.GetZaxis()->GetBinCenter(iz));
234234
double w = h3.GetXaxis()->GetBinWidth(ix) * h3.GetYaxis()->GetBinWidth(iy) * h3.GetZaxis()->GetBinWidth(iz);
235-
data->add(observables_, w*weightScale*(asimov ? h3.GetBinContent(ix,iy,iz) : RooRandom::randomGenerator()->Poisson(h3.GetBinContent(ix,iy,iz))) );
235+
data->add(observables_, weightScale*(asimov ? w*h3.GetBinContent(ix,iy,iz) : RooRandom::randomGenerator()->Poisson(w*h3.GetBinContent(ix,iy,iz))) );
236236
} } }
237237
}
238238
}

0 commit comments

Comments
 (0)