56 RooAbsMCStudyModule(
"RooRandomizeParamMCSModule",
"RooRandomizeParamMCSModule"), _data(nullptr)
67 _unifParams(other._unifParams),
68 _gausParams(other._gausParams),
98 oocoutW(
nullptr,InputArguments) <<
"RooRandomizeParamMCSModule::initializeInstance: variable " << param.
GetName() <<
" is not a parameter of RooMCStudy model and is ignored!" << endl ;
119 oocoutW(
nullptr,InputArguments) <<
"RooRandomizeParamMCSModule::initializeInstance: variable " << param.
GetName() <<
" is not a parameter of RooMCStudy model and is ignored!" << endl ;
145 oocoutW(
nullptr,InputArguments) <<
"RooRandomizeParamMCSModule::sampleSumUniform() ERROR: input parameter " << arg->
GetName() <<
" is not a RooRealVar and is ignored" << endl ;
158 oocoutW(
nullptr,InputArguments) <<
"RooRandomizeParamMCSModule::sampleSumUniform: variable " << arg2->
GetName() <<
" is not a parameter of RooMCStudy model and is ignored!" << endl ;
160 okset2.
add(*actualVar) ;
194 oocoutW(
nullptr,InputArguments) <<
"RooRandomizeParamMCSModule::sampleSumGauss() ERROR: input parameter " << arg->
GetName() <<
" is not a RooRealVar and is ignored" << endl ;
207 oocoutW(
nullptr,InputArguments) <<
"RooRandomizeParamMCSModule::sampleSumUniform: variable " << arg2->
GetName() <<
" is not a parameter of RooMCStudy model and is ignored!" << endl ;
209 okset2.
add(*actualVar) ;
232 std::list<UniParam>::iterator uiter ;
238 oocoutW(
nullptr,InputArguments) <<
"RooRandomizeParamMCSModule::initializeInstance: variable " << uiter->_param->
GetName() <<
" is not a parameter of RooMCStudy model and is ignored!" << endl ;
242 uiter->_param = actualPar ;
245 std::string parName = std::string(uiter->_param->GetName()) +
"_gen";
246 std::string parTitle = std::string(uiter->_param->GetTitle()) +
" as generated";
247 _genParSet.
addOwned(std::make_unique<RooRealVar>(parName.c_str(),parTitle.c_str(),0));
251 std::list<GausParam>::iterator giter ;
257 oocoutW(
nullptr,InputArguments) <<
"RooRandomizeParamMCSModule::initializeInstance: variable " << giter->_param->
GetName() <<
" is not a parameter of RooMCStudy model and is ignored!" << endl ;
261 giter->_param = actualPar ;
264 std::string parName = std::string(giter->_param->GetName()) +
"_gen";
265 std::string parTitle = std::string(giter->_param->GetTitle()) +
" as generated";
266 _genParSet.
addOwned(std::make_unique<RooRealVar>(parName.c_str(),parTitle.c_str(),0));
271 std::list<UniParamSet>::iterator usiter ;
279 oocoutW(
nullptr,InputArguments) <<
"RooRandomizeParamMCSModule::initializeInstance: variable " << arg->
GetName() <<
" is not a parameter of RooMCStudy model and is ignored!" << endl ;
281 actualPSet.
add(*actualVar) ;
284 usiter->_pset.removeAll() ;
285 usiter->_pset.add(actualPSet) ;
288 for(
auto * param : static_range_cast<RooRealVar*>(usiter->_pset)) {
289 std::string parName = std::string(param->GetName()) +
"_gen";
290 std::string parTitle = std::string(param->GetTitle()) +
" as generated";
291 _genParSet.
addOwned(std::make_unique<RooRealVar>(parName.c_str(),parTitle.c_str(),0));
296 std::list<GausParamSet>::iterator ugiter ;
304 oocoutW(
nullptr,InputArguments) <<
"RooRandomizeParamMCSModule::initializeInstance: variable " << arg->
GetName() <<
" is not a parameter of RooMCStudy model and is ignored!" << endl ;
306 actualPSet.
add(*actualVar) ;
310 ugiter->_pset.removeAll() ;
311 ugiter->_pset.add(actualPSet) ;
314 for(
auto * param : static_range_cast<RooRealVar*>(ugiter->_pset)) {
315 std::string parName = std::string(param->GetName()) +
"_gen";
316 std::string parTitle = std::string(param->GetTitle()) +
" as generated";
317 _genParSet.
addOwned(std::make_unique<RooRealVar>(parName.c_str(),parTitle.c_str(),0));
347 std::list<UniParam>::iterator uiter ;
350 oocoutE(
nullptr,Generation) <<
"RooRandomizeParamMCSModule::processBeforeGen: applying uniform smearing to generator parameter "
351 << uiter->_param->GetName() <<
" in range [" << uiter->_lo <<
"," << uiter->_hi <<
"], chosen value for this sample is " << newVal << endl ;
352 uiter->_param->setVal(newVal) ;
359 std::list<GausParam>::iterator giter ;
362 oocoutI(
nullptr,Generation) <<
"RooRandomizeParamMCSModule::processBeforeGen: applying gaussian smearing to generator parameter "
363 << giter->_param->GetName() <<
" with a mean of " << giter->_mean <<
" and a width of " << giter->_sigma <<
", chosen value for this sample is " << newVal << endl ;
364 giter->_param->setVal(newVal) ;
371 std::list<UniParamSet>::iterator usiter ;
376 oocoutI(
nullptr,Generation) <<
"RooRandomizeParamMCSModule::processBeforeGen: applying uniform smearing to sum of set of generator parameters "
378 <<
" in range [" << usiter->_lo <<
"," << usiter->_hi <<
"], chosen sum value for this sample is " << newVal << endl ;
381 RooAddition sumVal(
"sumVal",
"sumVal",usiter->_pset) ;
382 double compScaleFactor = newVal/sumVal.
getVal() ;
385 for(
auto * param : static_range_cast<RooRealVar*>(usiter->_pset)) {
386 param->setVal(param->getVal()*compScaleFactor) ;
388 genpar->
setVal(param->getVal()) ;
393 std::list<GausParamSet>::iterator gsiter ;
398 oocoutI(
nullptr,Generation) <<
"RooRandomizeParamMCSModule::processBeforeGen: applying gaussian smearing to sum of set of generator parameters "
400 <<
" with a mean of " << gsiter->_mean <<
" and a width of " << gsiter->_sigma
401 <<
", chosen value for this sample is " << newVal << endl ;
404 RooAddition sumVal(
"sumVal",
"sumVal",gsiter->_pset) ;
405 double compScaleFactor = newVal/sumVal.
getVal() ;
408 for(
auto * param : static_range_cast<RooRealVar*>(gsiter->_pset)) {
409 param->setVal(param->getVal()*compScaleFactor) ;
411 genpar->
setVal(param->getVal()) ;
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Common abstract base class for objects that represent a value and a "shape" in RooFit.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
virtual bool addOwned(RooAbsArg &var, bool silent=false)
Add an argument and transfer the ownership to the collection.
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsMCStudyModule is a base class for add-on modules to RooMCStudy that can perform additional calc...
RooArgSet * genParams()
Return current value of generator model parameters.
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooAddition calculates the sum of a set of RooAbsReal terms, or when constructed with two sets,...
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooDataSet is a container class to hold unbinned data.
void add(const RooArgSet &row, double weight, double weightError)
Add one ore more rows of data.
static TRandom * randomGenerator()
Return a pointer to a singleton random-number generator implementation.
Add-on module to RooMCStudy that allows you to randomize input generation parameters.
void sampleSumGauss(const RooArgSet ¶mSet, double lo, double hi)
Request gaussian smearing of sum of parameters in paramSet uniform smearing with mean 'mean' and widt...
bool initializeRun(Int_t) override
Initialize module at beginning of RooCMStudy run.
std::list< GausParam > _gausParams
!
void sampleSumUniform(const RooArgSet ¶mSet, double lo, double hi)
Request uniform smearing of sum of parameters in paramSet uniform smearing in range [lo,...
std::list< UniParamSet > _unifParamSets
!
void sampleGaussian(RooRealVar ¶m, double mean, double sigma)
Request Gaussian smearing of param in with mean 'mean' and width 'sigma' in RooMCStudy generation cyc...
bool processBeforeGen(Int_t) override
Apply all smearings to generator parameters.
~RooRandomizeParamMCSModule() override
Destructor.
RooRandomizeParamMCSModule()
Constructor.
RooDataSet * finalizeRun() override
Return auxiliary data of this module so that it is merged with RooMCStudy::fitParDataSet()
bool initializeInstance() override
Initialize module after attachment to RooMCStudy object.
void sampleUniform(RooRealVar ¶m, double lo, double hi)
Request uniform smearing of param in range [lo,hi] in RooMCStudy generation cycle.
std::list< GausParamSet > _gausParamSets
!
std::list< UniParam > _unifParams
!
RooRealVar represents a variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
const char * GetName() const override
Returns name of object.
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).