Skip to content

Commit

Permalink
Merge pull request cms-sw#19 from gpetruc/fix-non-uniform-binned-gene…
Browse files Browse the repository at this point in the history
…ration

Fix weight issue
  • Loading branch information
gpetruc committed Aug 6, 2013
2 parents 97ad68e + d6a7221 commit c4c934e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ToyMCSamplerOpt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ toymcoptutils::SinglePdfGenInfo::generateWithHisto(RooRealVar *&weightVar, bool
for (int i = 1, n = histoSpec_->GetNbinsX(); i <= n; ++i) {
x->setVal(histoSpec_->GetXaxis()->GetBinCenter(i));
double w = histoSpec_->GetXaxis()->GetBinWidth(i);
data->add(observables_, w*weightScale*(asimov ? histoSpec_->GetBinContent(i) : RooRandom::randomGenerator()->Poisson(histoSpec_->GetBinContent(i))) );
data->add(observables_, weightScale*(asimov ? w*histoSpec_->GetBinContent(i) : RooRandom::randomGenerator()->Poisson(w*histoSpec_->GetBinContent(i))) );
}
break;
case 2:
Expand All @@ -218,7 +218,7 @@ toymcoptutils::SinglePdfGenInfo::generateWithHisto(RooRealVar *&weightVar, bool
x->setVal(h2.GetXaxis()->GetBinCenter(ix));
y->setVal(h2.GetYaxis()->GetBinCenter(iy));
double w = h2.GetXaxis()->GetBinWidth(ix) * h2.GetYaxis()->GetBinWidth(iy);
data->add(observables_, w*weightScale*(asimov ? h2.GetBinContent(ix,iy) : RooRandom::randomGenerator()->Poisson(h2.GetBinContent(ix,iy))) );
data->add(observables_, weightScale*(asimov ? w*h2.GetBinContent(ix,iy) : RooRandom::randomGenerator()->Poisson(w*h2.GetBinContent(ix,iy))) );
} }
}
break;
Expand All @@ -232,7 +232,7 @@ toymcoptutils::SinglePdfGenInfo::generateWithHisto(RooRealVar *&weightVar, bool
y->setVal(h3.GetYaxis()->GetBinCenter(iy));
z->setVal(h3.GetZaxis()->GetBinCenter(iz));
double w = h3.GetXaxis()->GetBinWidth(ix) * h3.GetYaxis()->GetBinWidth(iy) * h3.GetZaxis()->GetBinWidth(iz);
data->add(observables_, w*weightScale*(asimov ? h3.GetBinContent(ix,iy,iz) : RooRandom::randomGenerator()->Poisson(h3.GetBinContent(ix,iy,iz))) );
data->add(observables_, weightScale*(asimov ? w*h3.GetBinContent(ix,iy,iz) : RooRandom::randomGenerator()->Poisson(w*h3.GetBinContent(ix,iy,iz))) );
} } }
}
}
Expand Down

0 comments on commit c4c934e

Please sign in to comment.