Skip to content
Snippets Groups Projects
Commit 2028b971 authored by Pierre-Alain Loizeau's avatar Pierre-Alain Loizeau
Browse files

Add CI test to check setups materials + related small fixes

parent 6d4334cd
Branches
Tags
1 merge request!1195Fix media check macros for MVD compat + re-enable check_media CI-CDASH test
......@@ -34,3 +34,6 @@ file(GLOB _dumpfiles
foreach(file IN LISTS _dumpfiles)
file(REMOVE ${file})
endforeach()
# Extra file created by transport/Geant
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/gphysi.dat)
......@@ -7,6 +7,7 @@ add_subdirectory(mvd)
add_subdirectory(much)
add_subdirectory(include)
add_subdirectory (reco)
add_subdirectory (geometry)
#--- Additional tests for nightly builds
If(NOT ${CBM_TEST_MODEL} MATCHES Experimental)
......
......
geo.gv
gphysi.dat
# ===== Generate the needed shell scripts ================================
GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/geometry/examine_materials.C)
Set(MACRO_DIR ${CMAKE_CURRENT_BINARY_DIR})
# ============================================================================
# ===== Copy the .rootrc file into the directory from which root is executed
# --- Otherwise the rootalias file is not loaded
file(COPY ${CBMROOT_SOURCE_DIR}/macro/include/.rootrc
DESTINATION ${CBMROOT_BINARY_DIR}/macro/run
)
# ============================================================================
Set(timeOutTime 100)
# ===== Cleanup the data and execution directories =======================
add_test(geo_cleanup ${CMAKE_COMMAND}
-P ${CMAKE_SOURCE_DIR}/cmake/scripts/cleanmacrodir.cmake)
set_tests_properties(geo_cleanup PROPERTIES
TIMEOUT ${timeOutTime}
FIXTURES_SETUP geo_cleanup
)
# ============================================================================
# ===== Define tests for each setup ======================================
file(GLOB setup_files
LIST_DIRECTORIES false
${CBMROOT_SOURCE_DIR}/geometry/setup/setup_*.C
)
foreach(setup IN LISTS setup_files)
string(REPLACE ${CBMROOT_SOURCE_DIR}/geometry/setup/setup_ "" setup ${setup})
string(REPLACE .C "" setup ${setup})
# Message("Test: found setup tag ${setup}")
# --- Test setup materials
# --- Check that materials in a loaded geometry (1 evt tra run) match corresponding single det geo files,
# using check_materials.C
set(testname geo_check_mats_${setup})
add_test(${testname} ${MACRO_DIR}/examine_materials.sh \"${setup}\")
set_tests_properties(${testname} PROPERTIES
TIMEOUT ${timeOutTime}
FAIL_REGULAR_EXPRESSION "FAILED;issues with materials were detected"
PASS_REGULAR_EXPRESSION "SUCCESS;Excluding air and dummy materials, no material errors were detected"
FIXTURES_REQUIRED geo_cleanup
FIXTURES_SETUP fixt_check_mats_${setup}
)
endforeach(setup IN LISTS setup_files)
# ============================================================================
*.root
......@@ -20,21 +20,6 @@
original standard, the two TGeoManager and the material in the subsystem match, otherwise there is a material
mismatch detected. Output to the screen will help diagonsis. */
char* padd(char* source_string, unsigned int size)
{
char* padded_string = (char*) malloc(sizeof(char) * (size + 1));
strncpy(padded_string, source_string, size + 1);
unsigned int i = strlen(source_string);
if (i < size)
for (; i < size; i++)
padded_string[i] = ' ';
padded_string[size] = '\0';
return padded_string;
};
typedef struct MAT_VOL mat_vol_t;
struct MAT_VOL {
......@@ -98,7 +83,7 @@ int extract_mat_vol(char* fileName, mat_vol_t* material_array)
exit(1);
};
TObjArray* nodes = top->GetNodes();
TObjArray* nodes = (TObjArray*) (top->GetNodes());
int i_array[NODE_DEPTH], num_array[NODE_DEPTH], j;
for (int i = 0; i < NODE_DEPTH; i++)
......@@ -142,19 +127,21 @@ int extract_mat_vol(char* fileName, mat_vol_t* material_array)
return 0;
}
int examine_material(const char* setup = "sis100_electron")
int examine_materials(const char* setup = "sis100_electron")
{
TString srcDir = gSystem->Getenv("VMCWORKDIR");
ECbmEngine engine = kGeant3;
CbmTransport run;
run.SetEngine(engine);
run.AddInput(srcDir + "/input/urqmd.auau.10gev.centr.root", kUnigen);
run.SetOutFileName("examine.tra.root", kTRUE);
run.SetParFileName("examaine.par.root");
run.SetGeoFileName("examine.geo.root");
run.SetOutFileName(Form("data/examine_%s.tra.root", setup), kTRUE);
run.SetParFileName(Form("data/examine_%s.par.root", setup));
run.SetGeoFileName(Form("data/examine_%s.geo.root", setup));
run.LoadSetup(setup);
run.SetField(new CbmFieldConst()); // Avoid crash for setups without field as not real simu (COSY, mCBM, ...)
// Shoot single 10 GeV proton straight through the pipe to minimize transport
run.SetBeamPosition(0, 0, 0.1, 0.1);
run.AddInput(new CbmBeamGenerator(1, 1, 1, 10., 0));
run.SetRandomSeed(1234); // I fix this number so everything is deterministic
run.Run(1);
......@@ -164,7 +151,7 @@ int examine_material(const char* setup = "sis100_electron")
strcpy(transport_materials[i].name, "");
};
extract_mat_vol("examine.geo.root", transport_materials);
extract_mat_vol(Form("data/examine_%s.geo.root", setup), transport_materials);
// Detector and passive subsystems
for (int i = 0; i < 120; i++)
......@@ -240,19 +227,19 @@ int examine_material(const char* setup = "sis100_electron")
};
(void) printf("TOTAL NUMBER OF VOLUMES\tTRANSPORTED: %d\t DETECTORS: %d\n", SUMT, SUMD);
printf("%s\t\tTransported\t\tSubsystems\t\tDifference \n", padd("Material", 25));
printf("%-25s\t\tTransported\t\tSubsystems\t\tDifference \n", "Material");
int FAIL = 0; // Success
int DIFF = 0;
for (int i = 0; i < MAX_MATERIALS; i++) {
if (0 < (transport_materials + i)->count) {
printf("%s\t\t%d", padd((transport_materials + i)->name, 25), (transport_materials + i)->count);
printf("%-25s\t\t%9d", (transport_materials + i)->name, (transport_materials + i)->count);
for (int j = 0; j < MAX_MATERIALS; j++) {
if (!strcmp((transport_materials[i].name), (detector_materials[j].name)))
printf("\t\t%d", (detector_materials + i)->count);
printf("\t\t%9d", (detector_materials + i)->count);
};
DIFF = ((transport_materials + i)->count) - ((detector_materials + i)->count);
printf("\t\t%d\n", DIFF);
printf("\t\t%9d\n", DIFF);
};
if ((strcmp(transport_materials[i].name, "dummy") != 0) && (strcmp(transport_materials[i].name, "air") != 0))
FAIL += abs(DIFF);
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment