Hi all,
I am having difficulty filling a 2D vector (matrix) of RooForumulaVar*.
I keep getting formula evaluation errors back at run time when I try to feed a vector into RooForumulaVar. I appear to be missing some syntax or making some rookie error!
I have pasted a short code snippet (with the appropriate lines) below and the error I am seeing.
Thanks in advance
S
RooRealVar gamma("gamma","gamma",1.4,0.9,1.9);
std::vector<RooRealVar *> attack_parameters (num_teams);
std::vector<RooRealVar *> defence_parameters (num_teams);
std::vector<std::vector<RooFormulaVar *>> H_RATES;
std::vector<std::vector<RooFormulaVar *>> A_RATES;
std::vector<std::vector<RooDataSet *>> DATA_SETS;
H_RATES.resize(num_teams, std::vector<RooFormulaVar *>(num_teams, 0));
A_RATES.resize(num_teams, std::vector<RooFormulaVar *>(num_teams, 0));
DATA_SETS.resize(num_teams, std::vector<RooDataSet *>(num_teams, 0));
for (int i = 0; i < num_teams; i++) {
for (int j = 0; j < num_teams; j++) {
// Cut the subdataset for i,j
DATA_SETS[i][j] = (RooDataSet*)data->reduce(game_cut);
int dataset_entries = DATA_SETS[i][j]->numEntries();
cout << "Number of sub-dataset entries = " << dataset_entries << endl;
cout << "DATA_SETS[i][j] exists = " << DATA_SETS[i][j] << endl;
// Define the RooFormulaVars required
H_RATES[i][j] = new RooFormulaVar(hratename,"attack_parameters[i]*defence_parameters[j]*gamma", RooArgList(*attack_parameters[i],*defence_parameters[j],gamma));
cout << "H_RATES[i][j] exists = " << H_RATES[i][j] << endl;
A_RATES[i][j] = new RooFormulaVar(aratename, "attack_parameters[j]*defence_parameters[i]", RooArgList(*attack_parameters[j],*defence_parameters[i]));
cout << "A_RATES[i][j] exists = " << A_RATES[i][j] << endl;
}
}
Number of sub-dataset entries = 9
DATA_SETS[i][j] exists = 0x5055f74
i=2, j=0
hratename = h_rate_2_0
H_RATES[i][j] exists = 0x586dbc0
Error in <RooFormula::Compile>: Bad numerical expression : "attack_parameters[j]"
[#0] ERROR:InputArguments -- RooFormula::RooFormula(a_rate_2_0): compile error
[#0] ERROR:Eval -- RooFormula::eval(a_rate_2_0): Formula doesn't compile: attack_parameters[j]*defence_parameters[i]
A_RATES[i][j] exists = 0x586d260