REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Loading...
Searching...
No Matches
test/src/TRestGeant4Metadata.cxx
1
2#include <TRestGeant4Metadata.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 geant4MetadataRml = filesPath / "TRestGeant4Example.rml";
13
14TEST(TRestGeant4Metadata, TestFiles) {
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
22 // All used files in this tests
23 EXPECT_TRUE(fs::exists(geant4MetadataRml));
24}
25
26TEST(TRestGeant4Metadata, Default) {
27 TRestGeant4Metadata restGeant4Metadata;
28
29 restGeant4Metadata.PrintMetadata();
30
31 EXPECT_TRUE(restGeant4Metadata.GetSeed() == 0);
32}
33
34TEST(TRestGeant4Metadata, FromRml) {
35 cout << "Path: " << geant4MetadataRml << endl;
36
37 TRestGeant4Metadata restGeant4Metadata(geant4MetadataRml.c_str());
38
39 GTEST_SKIP_("TODO: fix this");
40
41 restGeant4Metadata.PrintMetadata();
42
43 EXPECT_TRUE(restGeant4Metadata.GetSensitiveVolume() == "sensitiveVolume");
44 EXPECT_TRUE(restGeant4Metadata.GetSeed() == 17021981);
45
46 // primary generator
47 EXPECT_TRUE(restGeant4Metadata.GetNumberOfSources() == 1);
48 const auto particleSource = restGeant4Metadata.GetParticleSource(0);
49 EXPECT_TRUE(particleSource->GetParticleName() == "geantino");
50 EXPECT_TRUE(particleSource->GetEnergyDistributionType() == "mono");
51}
The main class to store the Geant4 simulation conditions that will be used by restG4.
Long_t GetSeed() const
// Used for faster lookup
TString GetSensitiveVolume(int n=0) const
Returns a std::string with the name of the sensitive volume.
void PrintMetadata() override
Prints on screen the details about the Geant4 simulation conditions, stored in TRestGeant4Metadata.
Int_t GetNumberOfSources() const
Returns the number of primary event sources defined in the generator.
TRestGeant4ParticleSource * GetParticleSource(size_t n=0) const
Returns the name of the particle source with index n (Geant4 based names).