R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
testNeulandTcal.C
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2025 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
15{
16 TStopwatch timer;
17 timer.Start();
18
19 Bool_t failed = false;
20
21 Int_t i, start[2] = { 1000, 2000 }, width = 2000, end[2] = { start[0] + 1 + width, start[1] + width };
22
23 // Tacquila ------------------------------------------------------------------
24 R3BTCalPar* par = new R3BTCalPar();
25 R3BTCalEngine* engine = new R3BTCalEngine(par, 0);
26
27 for (Int_t i = 0; i < 100000; i++)
28 {
29 engine->Fill(1, 1, 1, i % width + start[0]);
30 engine->Fill(1, 1, 3, i % width + start[0]);
31 engine->Fill(1, 1, 2, i % width + start[1]);
32 engine->Fill(1, 1, 4, i % width + start[1]);
33 }
34
35 engine->CalculateParamTacquila();
36
37 for (Int_t pmt = 0; pmt < 2; pmt++)
38 {
39 R3BTCalModulePar* mpar = par->GetModuleParAt(1, 1, 1 + pmt);
40 mpar->print();
41
42 for (i = 0; i < start[pmt] - 1; i++)
43 if (mpar->GetTimeTacquila(i) != -10000)
44 {
45 failed = true;
46 cout << "Expected tac-time of channel " << i << " to be -10000 but is " << mpar->GetTimeTacquila(i)
47 << endl;
48 }
49
50 Double_t tol = 0.002;
51 const Double_t step = 25. / width;
52 for (i = 0; i <= width; i++)
53 {
54 if (mpar->GetTimeTacquila(start[pmt] + i - 1) > ((i * step) + tol) ||
55 mpar->GetTimeTacquila(start[pmt] + i - 1) < ((i * step) - tol))
56 {
57 failed = true;
58 cout << "Expected tac-time of channel " << i + start[pmt] - 1 << " to be " << i * step << " ± " << tol
59 << " but is " << mpar->GetTimeTacquila(i + start[pmt] - 1) << endl;
60 }
61 }
62
63 for (i = end[pmt] + 1; i < 5000; i++)
64 {
65 if (mpar->GetTimeTacquila(i) != -10000)
66 {
67 failed = true;
68 cout << "Expected tac-time of channel " << i << " to be -10000 but is " << mpar->GetTimeTacquila(i)
69 << endl;
70 }
71 }
72 }
73 // ---------------------------------------------------------------------------
74
75 // VFTX ----------------------------------------------------------------------
76 delete par;
77 delete engine;
78
79 par = new R3BTCalPar();
80 engine = new R3BTCalEngine(par, 0);
81
82 for (Int_t i = 0; i < 100000; i++)
83 {
84 engine->Fill(1, 1, 1, i % width + start[0]);
85 engine->Fill(1, 1, 3, i % width + start[0]);
86 engine->Fill(1, 1, 2, i % width + start[1]);
87 engine->Fill(1, 1, 4, i % width + start[1]);
88 }
89
90 engine->CalculateParamVFTX();
91
92 for (Int_t pmt = 0; pmt < 2; pmt++)
93 {
94 R3BTCalModulePar* mpar = par->GetModuleParAt(1, 1, 1 + pmt);
95 mpar->print();
96
97 for (i = 0; i < start[pmt] - 1; i++)
98 if (mpar->GetTimeVFTX(i) != -10000)
99 {
100 failed = true;
101 cout << "Expected VFTX-time of channel " << i << " to be -10000 but is " << mpar->GetTimeVFTX(i)
102 << endl;
103 }
104
105 Double_t tol = 0.002;
106 const Double_t step = 5. / width;
107 for (i = 0; i <= width; i++)
108 {
109 if (mpar->GetTimeVFTX(start[pmt] + i - 1) > ((i * step) + tol) ||
110 mpar->GetTimeVFTX(start[pmt] + i - 1) < ((i * step) - tol))
111 {
112 failed = true;
113 cout << "Expected VFTX-time of channel " << i + start[pmt] - 1 << " to be " << i * step << " ± " << tol
114 << " but is " << mpar->GetTimeVFTX(i + start[pmt] - 1) << endl;
115 }
116 }
117
118 for (i = end[pmt] + 1; i < 5000; i++)
119 {
120 if (mpar->GetTimeVFTX(i) != -10000)
121 {
122 failed = true;
123 cout << "Expected VFTX-time of channel " << i << " to be -10000 but is " << mpar->GetTimeVFTX(i)
124 << endl;
125 }
126 }
127 }
128 // ---------------------------------------------------------------------------
129
130 timer.Stop();
131 Double_t rtime = timer.RealTime();
132 Double_t ctime = timer.CpuTime();
133 cout << endl << endl;
134 cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl;
135
136 if (failed)
137 cout << endl << " Test failed! " << endl;
138 else
139 cout << endl << " Test successful! " << endl;
140}
void testNeulandTcal()