REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Loading...
Searching...
No Matches
test/src/TRestDetectorGas.cxx
1
2#include <TRestDetectorGas.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 gasDefaultRml = filesPath / "TRestDetectorGasExample.rml";
13
14TEST(TRestDetectorGas, TestFiles) {
15 cout << "FrameworkCore 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
22 // All used files in this tests
23 EXPECT_TRUE(fs::exists(gasDefaultRml));
24}
25
26TEST(TRestDetectorGas, Default) {
28
29 gas.PrintGasInfo();
30
31 // Default parameters
32 EXPECT_TRUE(gas.GetPressure() == 1);
33 EXPECT_TRUE(gas.GetTemperature() == 300);
34 EXPECT_TRUE(gas.GetElectricField() == 0);
35}
36
37TEST(TRestDetectorGas, FromRml) {
38 TRestDetectorGas gas(gasDefaultRml.c_str(), // config file
39 "Xenon 10-10E3Vcm", // name
40 false, // generation
41 false // test
42 );
43
44 EXPECT_TRUE(gas.GetW() == 21.9);
45 EXPECT_TRUE(gas.GetTemperature() == 293.15);
46
47 EXPECT_TRUE(gas.GetNofGases() == 1);
48 EXPECT_TRUE(gas.GetGasComponentName(0) == "xe");
49 EXPECT_TRUE(gas.GetGasComponentFraction(0) == 1.0);
50
51 EXPECT_TRUE(!gas.GetError());
52}
53
54/*
55TEST(TRestDetectorGas, FromServer) {
56 GTEST_SKIP_("Not working on test but works on `restRoot` prompt");
57
58 TRestDetectorGas gas("server", // use gas server
59 "Xenon 10-10E3Vcm", // name
60 false, // generation
61 true // test
62 );
63 gas.PrintGasInfo();
64
65 EXPECT_TRUE(!gas.GetError());
66
67 EXPECT_TRUE(gas.GetW() == 21.9);
68 EXPECT_TRUE(gas.GetTemperature() == 293.15);
69
70 EXPECT_TRUE(gas.GetNofGases() == 1);
71 EXPECT_TRUE(gas.GetGasComponentName(0) == "xe");
72 EXPECT_TRUE(gas.GetGasComponentFraction(0) == 1.0);
73}
74*/
virtual Double_t GetElectricField() const
Returns the electric field in V/mm.
TString GetGasComponentName(Int_t n)
Returns the gas component n.
Int_t GetNofGases() const
Returns the number of gas elements/compounds present in the gas mixture.
void PrintGasInfo()
Prints the metadata information from the gas.
Double_t GetGasComponentFraction(Int_t n)
Returns the gas fraction in volume for component n.
Bool_t GetError() const
It returns true if an error was identified by a derived metadata class.