Scale data during a fit

Hello Roofiters,

I’m trying to do a fit of my data by using Monte-Carlo. My main issue is that my data need to be recalibrated and I wanted to do the re-calibration while I’m fitting the amplitudes of the Monte-Carlo components.

Here is how I’m setting up the re-scaling of the data:

RooRealVar Eraw("Raw_Energy_keV","Raw_Energy_keV",0, 0, 2500) ;
Eraw.setBins(100);
RooDataSet data("ds","ds",RooArgSet(Eraw));
//....... Fill data by looping over TTree

RooRealVar scalingFactor("scalingFactor","scalingFactor",1, 0, 5000);
RooFormulaVar EcorrFormula("Ecorr","Corrected energy","  (Raw_Energy_keV*scalingFactor)",RooArgSet(Eraw, scalingFactor));
  
RooRealVar* Ecorr = (RooRealVar*) data.addColumn(EcorrFormula) ;  

Then, I create my MC PDFs by using RooHistPdf and the variable Ecorr . I combine those PDF into one model by using workspace factory.

My main questions is: during the fit, is the fitter going to use scalingFactor as a free parameter ?
Is doing that enough ?

// Create likelihood function
RooAbsReal* nllE = modelEcorr->createNLL(data, NumCPU(2), Extended(true), Range(fit_range_min, fit_range_max));``` 
RooMinuit* minimizerEnergy = new RooMinuit(*nllE);
auto fit = minimizerEnergy->fit("m");

I would like to know that before modifying my full fitter.

Thanks,
Quentin

Hi Quentin,

the data are fixed, and they are not changed during fits. But you can apply the scaling as input to the PDF.
Make modelEcorr take EcorrFormula as input, and EcorrFormula takes Ecorr directly from the dataset.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.