Refit distro with smeared parameters

I would like to do a systematic study of the effect of fixing shape parameters in the fit by fitting the same distribution N number of times and quoting the difference as the error. At first glance it seems as if I can do this with randomizePars() method of roofitresult, however I don’t yet see how to take these new parameters to make a new shapes that I would use to refit the distribution. I’m looking right now in the class library for roofitresult and rooabspdf hoping that maybe i can pass parameters into it.

I was also wondering if you can use roomcstudy to do this? I know you can use the roorandomizeparammcsmodule to randomize parameters to generate toys which have distributions which reflect these random parameters, but this is the opposite of what I want to do. I want to fit several shapes to a single distribution rather than one shape to several distributions. Is it possible to do what I want with roomcstudy?

Thanks,
james

Hi James,

To do what you want you should write a custom module to modify the behavior of RooMCStudy. These modules inherit from RooAbsMCStudyModule and allow you to intervene in the operation before generation, between fitting and generation and after fitting.

In your case your case you can implement the following function to randomize your constant model parameters

virtual Bool_t processBetweenGenAndFit(Int_t /sampleNum/) {
// Method called after generation of toy data sample and resetting of fit parameters to initial values and before
// actual fit is performed. Any modifications to fit parameters will apply to next fit operation. Note that setConstant
// flag of fit parameters are not explicitly reset by RooMCStudy, so any changes made to these flags here will persist
return kTRUE ;
}

These modules are quite simple to write, see one of the existing modules as example (you can take RooRandomizeMCSModule as example, but as you observed you need to change its implementation to processBetweenGenAndFit)

To make RooMCStudy work with a constant dataset you can do one of two things depending if you want to fit a specific (external) dataset, or just a randomly generated one: In the first case you can pass the fixed dataset as a prototype dataset (which effectively reduces the generation phase to a simple copying of the prototype data), or in the second case you can reset the random seed to the same value for each generation in your RooMCStudy customizer module in method processBeforeGen() (the random generator instance used by RooFit is accessed through RooRandom::randomGenerator()->SetSeed() )

Wouter

Thank you for your reply Wouter. Your method seems nicer, but would take more time than I want to allocate right now. I’m hoping to just create a simple loop like:

[code]
cout << “final value of floating parameters” << endl ;
fullfitresult->floatParsFinal().Print(“s”) ;

for(Int_t i = 0;i<10;i++){

RooArgList currentArgList = fullfitresult->randomizePars();
currentArgList.Print("s");

}
[\code]

This gets me my random values, but I’ll need to take these values and put them in a similar shape with different roorealvars. I could do this brute force by getting the value from the rooarglist but could you tell me how I get the value from a rooabsarg?

james

Hi James,

If you simply want to transfer the values from randomizePars()
to the parameters of a given p.d.f. you can do that as follows

// This you do once
RooArgSet* pdfParams = pdf.getParameters(pdfObs) ;

// This part you repeat
RooArgList& ranParams = fr.randomizePars() ;
*pdfParams = ranParams ;

Wouter