RooArgSet::readFromFile weirdness

I’ve run into a bit of a mystery with the readFromFile function [ROOT 5.26/00 with RooFit v3.12]:

I have two standalone programs, the first fits a fairly complex pdf to a simulated spectrum and outputs the complete set of pdf parameters to a file using writeToFile. The second is supposed to generate toy MC using the same pdf and with parameters extracted from the file using readFromFile. Simple enough.

What’s happening is that readFromFile is only successfully reading 10 of my 17 parameters [and always the same 10, though not the first 10]. Despite extreme scrutiny I can’t discern any pattern with which parameters are successfully read and which parameters are not. In fact, there are “pairs” of parameters defined in exactly the same way with essentially the same function and yet one of the pair is read in successfully and the other isn’t.

I can’t post the whole code, but here’s part of it, using the continuum background part of the pdf:

// Program 1: Fit to MC

RooRealVar bestSigGamSoftE("bestSigGamSoftE","bestSigGamSoftE", 0.04, 0.24, "GeV");

RooRealVar     lambda("#lambda", "lambda", -61.6, -100., -1.);
RooRealVar     a1("a_{1}", "a_1", 0.00, -1.0, 0.0);
RooExponential expo("expo", "expo", bestSigGamSoftE, lambda);
RooChebychev   line("line","bkg",bestSigGamSoftE, a1); 

RooRealVar    nBkg("N_{bkg}", "nBkg", 100, 100, 1000);
RooRealVar    frac("frac","frac",0.5, 0.0, 1.0);

RooAddPdf     bkgModel("bkgModel","bkgModel", RooArgList(expo, line), RooArgList(frac));

// Ignore for now where DblCB_<X> and nSig<X> came from  
RooAddPdf    *model = new RooAddPdf("model", "model", RooArgList(DblCB_0, DblCB_1, DblCB_2, bkgModel), RooArgList(nSig0, nSig1, nSig2, nBkg));

// *dataSoft is a RooDataSet
RooFitResult* res = model.fitTo(*dataSoft, Save(), Extended(kTRUE), SumW2Error(kFALSE));

model.getVariables()->writeToFile("fits/toys/Y2S_rep_vars.dat");

The parameters file looks fine:

// Y2S_rep_vars.dat [some parameters removed]
#lambda = -60.1515 +/- 19.708 L(-100 - -1) 
N_{bkg} =  758.14 +/- 64.609 L(100 - 1000) 
a_{1} = -0.703826 +/- 0.13407 L(-1 - 0) 
frac =  0.25098 +/- 0.099563 L(0 - 1) 

The second program defines the parameters and pdf’s exactly as the first, then in place of .fitTo():

// ... last part of the second program
  RooArgSet *params = model->getVariables();
  params->readFromFile("fits/toys/Y2S_rep_vars.dat","READ");

// Print current param values then values that failed the readFromFile
  params->Print("v");
  cout << endl << "These params failed: " << endl;
  params->selectByAttrib("READ",kFALSE)->Print("v");

The output is [without extra params]:

  4) 0x9cf7208 RooRealVar::         #lambda = -61.6  L(-100 - -1)  "lambda"
  9) 0x9d16b70 RooRealVar::         N_{bkg} = 758.14 +/- 64.609  L(100 - 1000)  "nBkg"
 10) 0x9cf7a70 RooRealVar::           a_{1} = -0.703826 +/- 0.13407  L(-1 - 0)  "a_1"
 12) 0x9d16fa0 RooRealVar::            frac = 0.25098 +/- 0.099563  L(0 - 1)  "frac"

These params failed:
   3) 0x9cf7208 RooRealVar::    #lambda = -61.6  L(-100 - -1)  "lambda"

In this case #lambda fails but the rest do not. And it’s not a problem with the LaTex formatting of the parameter names, since in the full fit I have several successful parameters with names like #alpha_{1}, etc.

Ideas? I of course could hard-code the parameter values but that could get very old very fast…