11.2.3.1. Construction with a TRun

This constructor uses the Relauncher architecture. This approach provides a simple way to change the evaluator (e.g., switching from a C++ function to a Python function or another code). It also allows the use of either a sequential approach (for single-thread execution) or a threaded approach (to distribute estimates locally). This approach is partly discussed in The Relauncher module.

In this case, the constructor has the following form:

// Constructor with a runner
TCalClass(TDataServer *tds, TRun *runner, Int_t ns=1, Option_t *option="")

It takes up to four arguments, two of which are optional:

  1. tds: a TDataServer object containing one attribute for each parameter to be calibrated. This is the TDataServer object called tdsPar, defined in General introduction to data and model definition.

  2. runner: a TRun-inheriting instance that contains all the model information and whose type determines how the estimates are distributed: it can either be a TSequentialRun instance or TThreadedRun for distributed computations.

  3. ns (optional): the number of samples to be produced. This parameter is only relevant for methods that return multiple configurations (either multiple solutions to the minimisation problem or samples from the posterior distribution). It is not used in local minimisation with single-point initialisation, nor in linear Bayesian analysis (see Analytical linear Bayesian estimation). The default value is 1.

  4. option (optional): the options that can be applied to the method. Options common to all calibration classes (those defined in the TCalibration class) are discussed in Running the estimate.

A crucial step in this constructor is the creation of the instance that inherits from TRun. As mentioned earlier, its type determines how the estimates are distributed. To construct such an object, one needs to provide an evaluator (the available evaluators are described in detail in TEval).

Using the formalism introduced in Recommended distance and likelihood functions, construction method, a model instance based on the code Foo, initialised with TCIntEval, can be created as shown below. This example assumes the model takes three inputs (“ref_var1”, “par1”, “ref_var2”) and it produces a single output, which is compared with the reference output “ref_out1” via the distance or likelihood function (see Recommended distance and likelihood functions, construction method).

// Define the dataservers
TDataServer *tdsRef = new TDataServer("reference","myReferenceData");
// Load the data, both inputs (ref_var1 and ref_var2) and a single output (ref_out1).
tdsRef->fileDataRead("myInputData.dat");
...
TDataServer *tdsPar = new TDataServer("parameters","myParameters");
tdsPar->addAttribute( new TNormalDistribution("par1",0,1) ); // the parameter to calibrate
...
// Define the model if a function Foo(double *x, double *y)  is defined above
// where x[0]=ref_var1, x[1]=par1 and x[2]=ref_var2 and y[0] is the model prediction
TCIntEval *model = new TCIntEval("Foo");
// Add inputs in the correct order
model->addInput(tdsRef->getAttribute("ref_var1"));
model->addInput(tdsPar->getAttribute("par1"));
model->addInput(tdsRef->getAttribute("ref_var2"));
// Define the output attribute
TAttribute *out = new TAttribute("out");
model->addOutput(out);
// Define a sequential runner to be used
TSequentialRun *runner = new TSequentialRun(model);
...
// Create the instance of TCalClass
int ns=1;
TCalClass *cal = new TCalClass(tdsPar, runner, ns, "");