Skip to content

Commit 3c7df5a

Browse files
fuhlig1dennisklein
authored andcommitted
Add new test
Add a test which checks if the correct unit system is set in FairRun. The test is done on the actual value of the radiation length of the material aluminum. If the value is not the expected one the test fails.
1 parent 99491c2 commit 3c7df5a

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ if(BUILD_UNITTESTS)
345345
message(STATUS "Building the unit tests.")
346346
add_subdirectory(test)
347347
endif()
348+
add_subdirectory(test/tgeo)
349+
348350

349351
if(BUILD_EXAMPLES)
350352
install(DIRECTORY

test/tgeo/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
################################################################################
2+
# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
3+
# #
4+
# This software is distributed under the terms of the #
5+
# GNU Lesser General Public Licence (LGPL) version 3, #
6+
# copied verbatim in the file "LICENSE" #
7+
################################################################################
8+
GENERATE_ROOT_TEST_SCRIPT(${CMAKE_CURRENT_SOURCE_DIR}/test_tgeo_units.C)
9+
10+
set(maxTestTime 20)
11+
12+
add_test(NAME test_tgeo_units
13+
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_tgeo_units.sh
14+
)
15+
set_tests_properties(test_tgeo_units PROPERTIES
16+
TIMEOUT ${maxTestTime}
17+
)

test/tgeo/test_tgeo_units.C

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
int test_tgeo_units()
2+
{
3+
// Between root version v6.18.02 and v6.25.01 a differnt unit
4+
// system (from Geant4) was used which results in problems.
5+
// To work around the problem in the main steering class FairRunAna
6+
// the ROOT unit system is set as default.
7+
// When using tye wrong unit system the radiation length and the
8+
// interaction lenght has a value which is a factor 10 smaller than
9+
// when using the correct unit system.
10+
// This tests checks if the proper unit system is used.
11+
12+
Int_t root_version = gROOT->GetVersionInt();
13+
cout << "Root Version: " << root_version << endl;
14+
15+
FairRunSim* run = new FairRunSim();
16+
17+
// Define the values for the correct unit system
18+
Double_t correctRadLengthAl{8.87561};
19+
Double_t correctIntLengthAl{38.8622};
20+
21+
TGeoManager* geom = new TGeoManager("test_tgeo_units", "Test if the radiation lengtyh is the expected one");
22+
cout << endl;
23+
24+
// Create a new material with the propertoes of aluminum
25+
// and get the radiation and interaction length values from it
26+
TGeoMaterial* matAl = new TGeoMaterial("BP_aluminium", 26.9815386, 13, 2.7, 24.01);
27+
Double_t radLength = matAl->GetRadLen();
28+
Double_t intLength = matAl->GetIntLen();
29+
30+
// Compare the expected values with the actual ones and fail the test
31+
// if they are not equal
32+
if (((correctRadLengthAl - radLength) < 0.001) && ((correctIntLengthAl - intLength) < 0.001)) {
33+
return 0;
34+
} else {
35+
cout << "Radiation or interaction length differnt from expectation" << endl;
36+
cout << "Expected radiation length : " << correctRadLengthAl << endl;
37+
cout << "Radiation length : " << radLength << endl;
38+
cout << "Expected Interaction length : " << correctIntLengthAl << endl;
39+
cout << "Interaction length : " << intLength << endl;
40+
return 1;
41+
}
42+
}

0 commit comments

Comments
 (0)