Make roovarialbe optional as argument in function

Hi all,

I have this function in a script, and I would like for RooPolynomial& pol and RooDoubleCBFast& cb to be optional arguments. I can’t seem to set pol and cb to values in the arguments themselves (like doing int i = 0 for example), and using std::optional hasn’t worked either. If anyone has any ideas on how to achieve this, please let me know :slight_smile: Thanks!

void printYields(std::string sample, std::string channel, RooRealVar& mass, RooRealVar& norm, RooPolynomial& pol, RooDoubleCBFast& cb){
  std::ofstream txtFile;"_"+model+"_yields.txt");
  txtFile<<"norm: "<<norm.getVal()<<std::endl;
  for(int binIndex=0;binIndex<numberOfBins-1;binIndex++){
    std::string bin_str = "bin"+std::to_string(binIndex);
    const char* bin_char = bin_str.c_str();
    txtFile<< pol.createIntegral(mass, RooFit::NormSet(mass), RooFit::Range(bin_char))->getVal() * norm.getVal()<<std::endl;      

ROOT Version: 6.20.06
Platform: centos7
Compiler: gcc8

You could pass them as pointers, defaulting to nullptr?

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