-
Notifications
You must be signed in to change notification settings - Fork 257
/
AliTRDcreateLUT.C
77 lines (60 loc) · 2.64 KB
/
AliTRDcreateLUT.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*--------------------------------------------------------------------------------------------------*\
| |
| Macro that translates an arbitrary function and sacle factor into a look-up table (LUT) |
| |
| Author: 10/2016, Benjamin Brudnyj, Jochen Klein |
\*--------------------------------------------------------------------------------------------------*/
Int_t GetPID(Int_t q)
{
const Float_t a1 = 0.100251; //0.0889764;
const Float_t a2 = 0.0193284; //0.0193284;
const Float_t b1 = -108.571; //-101.892;
const Float_t b2 = 113.847; //1.06657899999999998e+02;
const Int_t thr = 2750; //2988;
TF1 elLUT("elLUT","pol1",0,thr);
TF1 nuclLUT("nuclLUT","pol1",thr,20005);
elLUT.SetParameters(b1, a1);
nuclLUT.SetParameters(b2, a2);
Int_t result;
if (q < thr) {
result = ((Int_t) (a1 * q + b1));
if (TMath::Abs(result - elLUT.Eval(q)) >= 1)
printf("error: %i <-> %i\n", result, elLUT.Eval(q));
}
else {
result = ((Int_t) (a2 * q + b2));
if (TMath::Abs(result - nuclLUT.Eval(q)) >= 1)
printf("error: %i <-> %i\n", result, nuclLUT.Eval(q));
}
if (result < 0)
result = 0;
else if (result > 255)
result = 255;
return result;
}
void AliTRDcreateLUT()
{
const Int_t Bins = 2008;
const char *LUT_file_name = "lhc11dv3en";
const char *file_type = "tcs";
ULong64_t scaleq0 = 429496730;
ULong64_t scaleq1 = 0;
Int_t addrPID[Bins] = {0};
for(Int_t i = 0; i < Bins; i++) {
Int_t q = ((1ull << 32) * (i + .5)) / scaleq0;
if (i != (((q * scaleq0)>> 16)>>16))
printf("error: bin %i -> %i \n", i, (((q * scaleq0)>> 16)>>16));
addrPID[i/4] |= (GetPID(q) & 0xff) << ((i % 4) * 8);
}
ofstream LUTfile;
LUTfile.open(Form("%s.%s",LUT_file_name,file_type));
LUTfile << setw(8) << "tracklet" << setw(8) << "scaleq0" << setw(14) << Form("%u;\n",scaleq0);
LUTfile << setw(8) << "tracklet" << setw(8) << "scaleq1" << setw(14) << Form("%u;\n",scaleq1);
LUTfile << setw(8) << "write " << setw(8) << "127, " << setw(14) << "0xc029, " << setw(13) << "2008;\n";
LUTfile << setw(8) << "write " << setw(8) << "127, " << setw(14) << "0xc02b, " << setw(13) << "2008;\n";
for(Int_t i = 0; i < Bins/4; i++)
LUTfile << setw(8) << "write " << setw(8) << "127, "
<< setw(14) << Form("0x%x, ",0xc100 + i)
<< setw(13) << Form("%i;\n", addrPID[i]);
LUTfile.close();
}