Update Setup authored by Jeppe Schultz Nielsen's avatar Jeppe Schultz Nielsen
......@@ -44,14 +44,18 @@ The following shows an example of a setup json file.
"CHARGE",
"ACCEPTED",
"TOTAL"
],
"function" : [
"clovers/fullEfficiency.json"
]
}
```
It consists of three things:
It consists of four things:
1. `detectors` an array of detector objects.
2. `signals` an array of names of scaler values.
3. `name` optional value. Just nice to keep track of things.
4. `functions` is functions that parametrize the setup, such as an efficiency curve.
Detectors
---------
......@@ -127,6 +131,70 @@ __Pad__
* `upLength` Size in mm along orientation vector
* `transverseLength` Size in mm along n x orientation vector.
Functions file
------------------
The function must contain a name, a formula string (written in a way that can be interpreted by a TF1), the function parameters and a covariance matrix for the parameters. An example of how to write such a file can be seen here:
```
TF1 *effFit = new TF1("effFit", "[p3] * exp([p0]*log(x/1000) + [p1]*pow(log(x/1000), 2) - [p2]/pow(x,3))", 100, 1500);
effFit->SetNpx(1000);
effFit->SetLineColor(kRed);
effFit->SetParameters(-6.38681e-01, 1.05816e-01, 8.41966e+05, 1.65417e-04);
auto ptr = totalEfficiency->Fit(effFit, "QR NS");
auto covar = ptr->GetCovarianceMatrix();
auto par = ptr->GetParams();
vector<double> parVector = {par[0], par[1], par[2], par[3]};
AUSATF1 *ausaTF1 = new AUSATF1("fullEfficiency",(string)effFit->GetExpFormula(), covar, parVector);
auto json = buildAUSATF1JSON(*ausaTF1);
ofstream outfile("calout/fullEfficiency.json");
rapidjson::StringBuffer buffer;
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
writer.SetIndent(' ', 4);
json.Accept(writer);
outfile << buffer.GetString() << endl;
```
And the output json file looks like this:
```json
{
"name": "fullEfficiency",
"formula": "[p3]*exp([p0]*log(x/1000)+[p1]*pow(log(x/1000),2)-[p2]/pow(x,3))",
"parameters": [
-0.7694757487972153,
0.06299888821949205,
558694.190596955,
0.03145986764934158
],
"covariance": [
[
0.0013829417252703846,
0.001324725837104106,
5288.965527781921,
-0.0000014514547654257206
],
[
0.001324725837104106,
0.001544332430566392,
7163.282818239304,
-0.000004619537976793716
],
[
5288.965527781921,
7163.282818239304,
38425470370.68322,
-25.306620182992537
],
[
-0.0000014514547654257206,
-0.000004619537976793716,
-25.306620182992537,
1.1066298354253414e-7
]
]
}
```
Loading setup
==============
This small example shows how to load setup file
......
......