Update Setup authored by Jeppe Schultz Nielsen's avatar Jeppe Schultz Nielsen
This page is about specifying a detector setup for use within AUSALIB. This page is about specifying a detector setup for use within AUSALIB.
The details of the experimental setup should be specified within a json file. This file should contain an entry for each detector specifying how that detector will appear within an unpacked data file. Additionally, details of the detector position and orientation can be provided. Additional files containing energy calibrations and detector specific properties, such as dead layer thickness and strip numbers, can also be provided. The details of the experimental setup should be specified within a json file. This file should contain an entry for each detector specifying how that detector will appear within an unpacked data file. Additionally, details of the detector position and orientation can be provided. Additional files containing energy calibrations and detector specific properties, such as dead layer thickness and strip numbers, can also be provided.
This approach permits these parameters to be stored in an easy to read, plain text format. Furthermore, adjusting these parameters does not require any code recompilation. In cases where the detector geometry changes between runs, the exact same analysis code may be applied by simply providing different setup files as arguments. This approach permits these parameters to be stored in an easy to read, plain text format. Furthermore, adjusting these parameters does not require any code recompilation. In cases where the detector geometry changes between runs, the exact same analysis code may be applied by simply providing different setup files as arguments.
The setup files are intended to be used both at the sorting and analysis stages. The setup files are intended to be used both at the sorting and analysis stages.
__Please note: All lengths should be given as mm__ __Please note: All lengths should be given as mm__
Example Example
========================= =========================
The following shows an example of a setup json file. The following shows an example of a setup json file.
```json ```json
{ {
"name" : "IFA003", "name" : "IFA003",
"detectors" : [ "detectors" : [
{ {
"name" : "SU", "name" : "SU",
"file" : "S3_332um.json", "file" : "S3_332um.json",
"calibration" : "S3_332um.cal", "calibration" : "S3_332um.cal",
"position" : {"x":"0mm", "y":"0mm", "z":"-43mm"}, "position" : {"x":"0mm", "y":"0mm", "z":"-43mm"},
"normal" : {"x":"0mm", "y":"0mm", "z":"-1mm"}, "normal" : {"x":"0mm", "y":"0mm", "z":"-1mm"},
"orientation" : {"x":"0mm", "y":"1mm", "z":"0mm"}, "orientation" : {"x":"0mm", "y":"1mm", "z":"0mm"},
"frontMapping" : { "frontMapping" : {
"prefix" : "SU_S", "prefix" : "SU_S",
"multiplicity" : "", "multiplicity" : "",
"segment" : "I", "segment" : "I",
"adc" : "_E", "adc" : "_E",
"tdc" : "-DEAD-" "tdc" : "-DEAD-"
}, },
"backMapping" : { "backMapping" : {
"prefix" : "SU_R", "prefix" : "SU_R",
"multiplicity" : "", "multiplicity" : "",
"segment" : "I", "segment" : "I",
"adc" : "_E", "adc" : "_E",
"tdc" : "_T" "tdc" : "_T"
} }
} }
], ],
"signals" : [ "signals" : [
"CLOCK", "CLOCK",
"CHARGE", "CHARGE",
"ACCEPTED", "ACCEPTED",
"TOTAL" "TOTAL"
] ],
} "function" : [
``` "clovers/fullEfficiency.json"
]
It consists of three 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. It consists of four things:
1. `detectors` an array of detector objects.
Detectors 2. `signals` an array of names of scaler values.
--------- 3. `name` optional value. Just nice to keep track of things.
Each detector must have the following properties 4. `functions` is functions that parametrize the setup, such as an efficiency curve.
* `name` The detector name
* `position` The central position of the detector. Detectors
* `normal` The normal vector to the detector surface. ---------
* `orientation` A vector describing the orientation of the detector. The interpretation of this is detector specific. Each detector must have the following properties
* `file` A file containing detector specific information such a strip numbers, dead layer thickness etc. * `name` The detector name
* (optional) `calibration` A file containing calibration as two column separated by space, offset first. * `position` The central position of the detector.
* (optional) `frontmapping/backmapping/mapping` Json object describing mapping from ROOT file to detector. Front/back is for dssd. * `normal` The normal vector to the detector surface.
* `orientation` A vector describing the orientation of the detector. The interpretation of this is detector specific.
`position`, `direction`, `orientation` can be specified in three different coordinate systems * `file` A file containing detector specific information such a strip numbers, dead layer thickness etc.
* Cartesian: `{"x":"40mm", "y":"0mm", "z":"-40mm"}` * (optional) `calibration` A file containing calibration as two column separated by space, offset first.
* Cylindrical: `{"r":"40mm", "z":"-43mm", "phi":"45deg"}` * (optional) `frontmapping/backmapping/mapping` Json object describing mapping from ROOT file to detector. Front/back is for dssd.
* Spherical: `{"r":"40mm", "theta":"20deg", "phi":"1.57rad"}`
`position`, `direction`, `orientation` can be specified in three different coordinate systems
__Mapping__ * Cartesian: `{"x":"40mm", "y":"0mm", "z":"-40mm"}`
Name of the branches in the ROOT tree which contains the following information: * Cylindrical: `{"r":"40mm", "z":"-43mm", "phi":"45deg"}`
* `multiplicity` How many entries are the for this detector side. * Spherical: `{"r":"40mm", "theta":"20deg", "phi":"1.57rad"}`
* `segment` Which strip/detector segment have been hit
* `adc` ADC values __Mapping__
* `tdc` TDC values Name of the branches in the ROOT tree which contains the following information:
* (optional) `prefix` This value is appended to the others. * `multiplicity` How many entries are the for this detector side.
* `segment` Which strip/detector segment have been hit
The special value `-DEAD-` signal that this information is _not_ available. * `adc` ADC values
* `tdc` TDC values
Detector file * (optional) `prefix` This value is appended to the others.
------------------
The following information is expected to be present in the detector file. The special value `-DEAD-` signal that this information is _not_ available.
__All detectors__ Detector file
* `type` What type of detector this is: Valid values are ------------------
* SquareDSSD The following information is expected to be present in the detector file.
* RoundDSSD
* Clover __All detectors__
* SquareSSSD * `type` What type of detector this is: Valid values are
* Pad * SquareDSSD
* RoundDSSD
__All DSSD__ * Clover
* `nFrontStrips` Number of front strips. * SquareSSSD
* `nBackStrips` Number of back strips. * Pad
* `reverseFront` true/false if the strip ordering should be reversed.
* `reverseBack` true/false if the strip ordering should be reversed. __All DSSD__
* (optional) `solidAngle` path to csv file with solid angle for each pixel. If not provided approximate values is calculated. * `nFrontStrips` Number of front strips.
* `nBackStrips` Number of back strips.
![both](uploads/3a11f75b24274dae3f7eccf70a90c5bc/both.png) * `reverseFront` true/false if the strip ordering should be reversed.
* `reverseBack` true/false if the strip ordering should be reversed.
__All silicon__ * (optional) `solidAngle` path to csv file with solid angle for each pixel. If not provided approximate values is calculated.
* `thickness` Thickness of detector (optional default = 0)
* `deadLayer` Thickness of deadlayer on front side of detector (optional default = 0) ![both](uploads/3a11f75b24274dae3f7eccf70a90c5bc/both.png)
* `deadLayer_back` Thickness of deadlayer on back side of detector (optional default = 0)
__All silicon__
__RoundDSSD (S3)__ * `thickness` Thickness of detector (optional default = 0)
* `ringWidth` Width of a single ring. * `deadLayer` Thickness of deadlayer on front side of detector (optional default = 0)
* `ringPitch` Width of ring + ring gap. * `deadLayer_back` Thickness of deadlayer on back side of detector (optional default = 0)
* `innerRadius` Inner radius of active area.
__RoundDSSD (S3)__
__SquareDSSD (W1)__ * `ringWidth` Width of a single ring.
* `stripWidth` Width of a single strip. * `ringPitch` Width of ring + ring gap.
* `stripPitch` Width of single strip + strip gap. * `innerRadius` Inner radius of active area.
* `gridThickness` Thickness of W1 grid specified as string. Default : "0.5um"
* `gridWidth` Width of W1 grid on a single pixel specified as string. Default : "90um" __SquareDSSD (W1)__
* `backContactThickness` Thickness of contact on back of W1 specified as string. Default : "0.2um" * `stripWidth` Width of a single strip.
* `stripPitch` Width of single strip + strip gap.
__Clover__ * `gridThickness` Thickness of W1 grid specified as string. Default : "0.5um"
* `nSegments` Number of segments the clover have. * `gridWidth` Width of W1 grid on a single pixel specified as string. Default : "90um"
* `backContactThickness` Thickness of contact on back of W1 specified as string. Default : "0.2um"
__SquareSSSD__
* `nSegments` Number of segments the single sided detector have. __Clover__
* `nSegments` Number of segments the clover have.
__Pad__
* `upLength` Size in mm along orientation vector __SquareSSSD__
* `transverseLength` Size in mm along n x orientation vector. * `nSegments` Number of segments the single sided detector have.
Loading setup __Pad__
============== * `upLength` Size in mm along orientation vector
This small example shows how to load setup file * `transverseLength` Size in mm along n x orientation vector.
```c++
#include <ausa/json/IO.cpp> Functions file
------------------
using namespace AUSA; 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:
```
int main() { TF1 *effFit = new TF1("effFit", "[p3] * exp([p0]*log(x/1000) + [p1]*pow(log(x/1000), 2) - [p2]/pow(x,3))", 100, 1500);
std::shared_ptr<Setup> s = JSON::readSetupFromJSON("setup/setup.json"); 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();
If in doubt vector<double> parVector = {par[0], par[1], par[2], par[3]};
============== AUSATF1 *ausaTF1 = new AUSATF1("fullEfficiency",(string)effFit->GetExpFormula(), covar, parVector);
[json/IO.cpp](https://gitlab.au.dk/ausa/ausalib/blob/master/source/json/IO.cpp) contains the implementation. 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
```c++
#include <ausa/json/IO.cpp>
using namespace AUSA;
int main() {
std::shared_ptr<Setup> s = JSON::readSetupFromJSON("setup/setup.json");
}
```
If in doubt
==============
[json/IO.cpp](https://gitlab.au.dk/ausa/ausalib/blob/master/source/json/IO.cpp) contains the implementation.