Skip to content

Commit

Permalink
[RF] Don't use batch mode in rf611_weightedfits.C tutorial
Browse files Browse the repository at this point in the history
This is done so we don't have to adopt this tutorial to the new batch
mode yet.
  • Loading branch information
guitargeek committed Oct 24, 2021
1 parent 729ee2e commit 977be07
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tutorials/roofit/rf611_weightedfits.C
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
#include "RooDataSet.h"
#include "RooPolynomial.h"

#include "rbc.h"

using namespace RooFit;


Expand Down Expand Up @@ -107,7 +109,7 @@ int rf611_weightedfits(int acceptancemodel=2) {
TH1D* hc1pull3 = new TH1D("hc1pull3", "Asymptotically correct approach [Asymptotic(true)];Pull (c_{1}^{fit}-c_{1}^{gen})/#sigma(c_{1});", 20, -5.0, 5.0);

//number of pseudoexperiments (toys) and number of events per pseudoexperiment
constexpr unsigned int ntoys = 500;
constexpr unsigned int ntoys = 20;
constexpr unsigned int nstats = 5000;
//parameters used in the generation
constexpr double c0gen = 0.0;
Expand All @@ -123,6 +125,8 @@ int rf611_weightedfits(int acceptancemodel=2) {
// M a i n l o o p : r u n p s e u d o e x p e r i m e n t s
//----------------------------------------------------------------
for (unsigned int i=0; i<ntoys; i++) {
std::cout << i << std::endl;

//S e t u p p a r a m e t e r s a n d P D F
//-----------------------------------------------
//angle theta and the weight to account for the acceptance effect
Expand Down Expand Up @@ -165,18 +169,21 @@ int rf611_weightedfits(int acceptancemodel=2) {

//F i t t o y u s i n g t h e t h r e e d i f f e r e n t a p p r o a c h e s t o u n c e r t a i n t y d e t e r m i n a t i o n
//-------------------------------------------------------------------------------------------------------------------------------------------------

auto batchMode = rbc::Off;

//this uses the inverse weighted Hessian matrix
RooFitResult* result = pol.fitTo(data, Save(true), SumW2Error(false), PrintLevel(-1), BatchMode(true));
RooFitResult* result = pol.fitTo(data, Save(true), SumW2Error(false), PrintLevel(-1), BatchMode(batchMode));
hc0pull1->Fill((c0.getVal()-c0gen)/c0.getError());
hc1pull1->Fill((c1.getVal()-c1gen)/c1.getError());

//this uses the correction with the Hesse matrix with squared weights
result = pol.fitTo(data, Save(true), SumW2Error(true), PrintLevel(-1), BatchMode(true));
result = pol.fitTo(data, Save(true), SumW2Error(true), PrintLevel(-1), BatchMode(batchMode));
hc0pull2->Fill((c0.getVal()-c0gen)/c0.getError());
hc1pull2->Fill((c1.getVal()-c1gen)/c1.getError());

//this uses the asymptotically correct approach
result = pol.fitTo(data, Save(true), AsymptoticError(true), PrintLevel(-1), BatchMode(true));
result = pol.fitTo(data, Save(true), AsymptoticError(true), PrintLevel(-1), BatchMode(batchMode));
hc0pull3->Fill((c0.getVal()-c0gen)/c0.getError());
hc1pull3->Fill((c1.getVal()-c1gen)/c1.getError());
}
Expand Down

0 comments on commit 977be07

Please sign in to comment.