REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Loading...
Searching...
No Matches
test/src/TRestRawSignalRangeReductionProcess.cxx
1
2#include <TRestRawSignalRangeReductionProcess.h>
3#include <gtest/gtest.h>
4
5#include <filesystem>
6
7namespace fs = std::filesystem;
8
9using namespace std;
10
11const auto filesPath = fs::path(__FILE__).parent_path().parent_path() / "files";
12const auto restRawSignalShapingProcessRml = filesPath / "TRestRawSignalRangeReductionProcess.rml";
13
15 cout << "Test files path: " << filesPath << endl;
16
17 // Check dir exists and is a directory
18 EXPECT_TRUE(fs::is_directory(filesPath));
19 // Check it's not empty
20 EXPECT_TRUE(!fs::is_empty(filesPath));
21 EXPECT_TRUE(fs::exists(restRawSignalShapingProcessRml));
22}
23
26 EXPECT_TRUE(process.GetProcessName() == (std::string) "rawSignalRangeReductionProcess");
27
28 EXPECT_TRUE(process.GetResolutionInNumberOfBits() == 12);
29
30 EXPECT_TRUE(process.GetDigitizationInputRange().X() == numeric_limits<Short_t>::min());
31 EXPECT_TRUE(process.GetDigitizationInputRange().Y() == numeric_limits<Short_t>::max());
32}
33
35 TRestRawSignalRangeReductionProcess process(restRawSignalShapingProcessRml.c_str());
36
37 process.PrintMetadata();
38
39 EXPECT_TRUE(process.GetResolutionInNumberOfBits() == 10);
40
41 EXPECT_TRUE(process.GetDigitizationInputRange().X() == -1000);
42 EXPECT_TRUE(process.GetDigitizationInputRange().Y() == 10000);
43}
44
47 process.SetResolutionInNumberOfBits(12);
48 process.SetDigitizationInputRange({-2000, 12000});
49
51 TRestRawSignal signal;
52 for (int i = 0; i < 512; i++) {
53 if (i == 100) {
54 signal.AddPoint(process.GetDigitizationInputRange().Y());
55 } else {
56 signal.AddPoint(process.GetDigitizationInputRange().X());
57 }
58 }
59 event.AddSignal(signal);
60
61 process.Initialize();
62 process.InitProcess();
63 const auto output = (TRestRawSignalEvent*)process.ProcessEvent(&event);
64
65 const auto outputSignal = output->GetSignal(0);
66
67 output->PrintEvent();
68 EXPECT_TRUE(outputSignal->GetMinValue() == 0);
69 EXPECT_TRUE(outputSignal->GetMaxValue() == 4095);
70}
virtual void PrintEvent() const
An event container for time rawdata signals with fixed length.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
void InitProcess() override
To be executed at the beginning of the run (outside event loop).
It defines a Short_t array with a physical parameter that evolves in time using a fixed time bin.
void AddPoint(Short_t)
Adds a new point to the end of the signal data array.