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

Fix the radiation length check macro + add CI to main and mCBM sim chains

- Replace the squares by explicite multiplications to avoid version dependent awk error
- Filter out the `vacuum` material defined with e-18 Z
- Fix tab printout
parent 48c3a9e6
No related branches found
No related tags found
1 merge request!691Fix the radiation length check macro + add CI to main and mCBM sim chains
../include/.rootrc
\ No newline at end of file
......@@ -4,7 +4,13 @@
echo "Scanning the geometry" $1
root -l -q '$VMCWORKDIR/macro/geometry/scan_geometry.C("'$1'")' 1>tmp
root -l -b -q '$VMCWORKDIR/macro/geometry/scan_geometry.C("'$1'")' 1>tmp
ROOT_EXIT=$?;
if [ 0 -ne $ROOT_EXIT ]; then
echo "root command failed, nothing more done";
exit ${ROOT_EXIT};
fi;
grep '^M\(at\|ix\)' tmp | \
sort | \
......@@ -26,13 +32,14 @@ variables=`echo "$line" | sed -e 's/eff//g' | sed -e 's/index/jndex/g' | sed -e
-v TOL=0.1 \
$variables \
'BEGIN{\
if(Z==0){
if(Z<1){
printf "SKIP"; \
exit 3;
};
cal_rad_len=(716.4*A/(Z*(Z+1)*log(287/sqrt(Z)))/rho);\
#print cal_rad_len;
if(((cal_rad_len - radlen)/radlen)**2 <= TOL**2 ){\
diff=(cal_rad_len - radlen);\
if(diff*diff <= TOL*TOL*radlen*radlen ){\
printf "OKAY"; exit 1;
}else{\
printf "FAIL"; exit 2;
......@@ -46,7 +53,7 @@ variables=`echo "$line" | sed -e 's/eff//g' | sed -e 's/index/jndex/g' | sed -e
COUNT=$((COUNT+1));
echo " \t $line"
echo -e " \t $line"
done < MATERIALS
......
......@@ -10,81 +10,72 @@
#include "TCanvas.h"
#include "TStopwatch.h"
#endif
#endif // !defined(__CLING__)
#include <cstdlib>
#include <fstream>
#include <iostream>
#define NODE_DEPTH 25
TGeoNode* node[NODE_DEPTH];
TGeoMedium* med;
TGeoManager* gman;
TGeoVolume* top;
//const char* seekstr1 = "cable";
const char* seekstr2 = "cable";
void scan_geometry(const char* fileName = "test.geo.root")
void scan_geometry(std::string fileName = "test.geo.root", uint32_t uMaxNodeDepth = 25)
{
TString myName = "scan_and_graph";
TFile file(fileName, "READ");
std::vector<TGeoNode*> node(uMaxNodeDepth, nullptr);
TGeoMedium* med = nullptr;
TGeoVolume* top = nullptr;
TFile file(fileName.c_str(), "READ");
if (!file.IsOpen()) {
std::cerr << "Was a root geo file supplied?" << endl;
std::cerr << "Was a root geo file supplied?" << std::endl;
exit(1);
};
gROOT->cd();
file.GetListOfKeys()->Print();
file.GetSize();
char geo_tag[100];
strcpy(geo_tag, basename(fileName));
char* ptr = strstr(geo_tag, ".geo.root");
*(ptr) = '\0';
std::string geo_tag = fileName.substr(fileName.find_last_of('/') + 1);
geo_tag = geo_tag.substr(0, geo_tag.find_first_of('.'));
std::cout << "geo tag extracted from file name is: " << geo_tag << std::endl;
file.GetObject("FAIRGeom", gGeoManager);
if (gGeoManager != nullptr) { top = gGeoManager->GetTopVolume(); };
gROOT->cd();
gman = (TGeoManager*) file.Get("FAIRGeom");
if (gman != NULL) { top = gman->GetTopVolume(); };
if (top == nullptr) file.GetObject(geo_tag.c_str(), top);
if (top == nullptr) file.GetObject("FAIRGeom", top);
if (top == nullptr) file.GetObject("top", top);
if (top == nullptr) file.GetObject("TOP", top);
if (top == nullptr) file.GetObject("Top", top);
if (top == nullptr) file.GetObject("geometryFromGDML", top);
if (top == NULL) top = (TGeoVolume*) file.Get(geo_tag);
if (top == NULL) top = (TGeoVolume*) file.Get("FAIRGeom");
if (top == NULL) top = (TGeoVolume*) file.Get("top");
if (top == NULL) top = (TGeoVolume*) file.Get("TOP");
if (top == NULL) top = (TGeoVolume*) file.Get("Top");
if (top == NULL) top = (TGeoVolume*) file.Get("geometryFromGDML");
gROOT->cd();
if (top == NULL) {
std::cerr << "No Top Volume found. Is the TGeoManager or Top Volume unusally named" << endl;
if (top == nullptr) {
std::cerr << "No Top Volume found. Is the TGeoManager or Top Volume unusally named" << std::endl;
exit(1);
}
FILE* graph = fopen("geo.gv", "w+");
fprintf(graph, "digraph D {\n");
TObjArray* nodes = top->GetNodes();
if (nodes == nullptr) {
std::cerr << "Could not get the Nodes." << std::endl;
exit(1);
}
nodes->Print();
gROOT->cd();
int i_array[NODE_DEPTH], num_array[NODE_DEPTH], j;
for (int i = 0; i < NODE_DEPTH; i++)
i_array[i] = 0;
for (int i = 0; i < NODE_DEPTH; i++)
num_array[i] = 0;
//TGeoNode* node[NODE_DEPTH];
//TGeoMedium* med;
j = 0;
i_array[0] = 0;
std::vector<int32_t> i_array(uMaxNodeDepth, 0);
std::vector<int32_t> num_array(uMaxNodeDepth + 2, 0);
int32_t j = 0;
num_array[0] = nodes->GetEntries();
std::cout << "\n" << endl;
FILE* graph = fopen("geo.gv", "w+");
fprintf(graph, "digraph D {\n");
int k = 0;
while (num_array[0] != 0) {
while (num_array[0] != 0 && 0 <= j) {
k++; // Only used for stop.
//if(k==3)break;
......@@ -96,7 +87,7 @@ void scan_geometry(const char* fileName = "test.geo.root")
i_array[j]++; // Update number.
std::cout << "Node: \t";
for (int i = 0; i < j + 1; i++)
for (int i = 0; i < j + 1 && i < uMaxNodeDepth; i++)
printf("%d/%d \t", i_array[i], num_array[i]);
printf("\n");
......@@ -118,27 +109,32 @@ void scan_geometry(const char* fileName = "test.geo.root")
std::cout << "Number of daughters: " << num_array[j + 1];
std::cout << endl << endl << endl;
if (num_array[j + 1] > 0) {
if (j + 1 < uMaxNodeDepth && num_array[j + 1] > 0) {
j++;
num_array[j + 2] = 0;
};
while (i_array[j] == num_array[j]) {
while (0 <= j && i_array[j] == num_array[j]) {
num_array[j] = 0;
i_array[j] = 0; // Reset the counter before falling back.
j--;
};
if (j >= NODE_DEPTH) {
std::cerr << "Maximum depth of " << NODE_DEPTH << " exceeded. Increase NODE_DEPTH in header of macro," << endl;
exit(NODE_DEPTH);
if (0 <= j && j >= uMaxNodeDepth) {
std::cerr << "Maximum depth of " << uMaxNodeDepth << " exceeded (" << j
<< "). Increase uMaxNodeDepth which is the second parameter of the macro" << std::endl;
exit(uMaxNodeDepth);
};
};
fprintf(graph, "}\n");
fclose(graph);
gROOT->cd();
file.Close();
RemoveGeoManager();
printf("Processed %d nodes.\n", k);
std::cout << "Program Ends" << endl;
std::cout << "Program Ends" << std::endl;
} // End of macro
......@@ -11,6 +11,10 @@ GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/mcbm/mcbm_qa.C)
Set(MACRO_DIR ${CMAKE_CURRENT_BINARY_DIR})
GENERATE_CBM_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/geometry/check_media.C ${MACRO_DIR})
GENERATE_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/geometry/check_radlen.sh ${MACRO_DIR})
# ============================================================================
# disable dev tests - GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/mcbm/mcbm_mc_dev.C)
# disable dev tests - GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/mcbm/mcbm_reco_dev.C)
......@@ -141,13 +145,23 @@ ForEach(setup IN LISTS cbm_setup)
FIXTURES_SETUP ${fixture_mcbm_overlap}
)
# --- Test check_radlen.sh
set(testname mcbm_radlen_${setup})
add_test(${testname} ${MACRO_DIR}/check_radlen.sh data/${setup}_test.geo.root )
Set(fixture_mcbm_radlen fixture_radlen_${setup})
set_tests_properties(${testname} PROPERTIES
TIMEOUT 100
FIXTURES_REQUIRED ${fixture_mcbm_overlap}
FIXTURES_SETUP ${fixture_mcbm_radlen}
)
If(NOT ${CBM_TEST_MODEL} MATCHES Experimental)
Set(testname mcbm_check_media_${setup})
Add_Test(${testname} ${CBMROOT_BINARY_DIR}/macro/mcbm/check_media.sh \"data/${setup}_test\")
Set_Tests_Properties(${testname} PROPERTIES
TIMEOUT "60"
PASS_REGULAR_EXPRESSION "Test Passed;All ok"
FIXTURES_REQUIRED ${fixture_mcbm_overlap}
FIXTURES_REQUIRED ${fixture_mcbm_radlen}
)
EndIf()
......
......@@ -6,6 +6,9 @@ GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/run/run_tra_beam.C)
GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/run/run_digi.C)
GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/run/run_reco.C)
GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/run/run_qa.C)
Set(MACRO_DIR ${CMAKE_CURRENT_BINARY_DIR})
GENERATE_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/geometry/check_radlen.sh ${MACRO_DIR})
# ============================================================================
......@@ -173,6 +176,18 @@ foreach(setup IN LISTS cbm_setup)
RESOURCE_LOCK collParDb_${setup}
)
# --- Test check_radlen.sh
# --- Transport run with collision events, using run_tra_file.C
set(testname check_${sname}_radlen)
add_test(${testname} ${MACRO_DIR}/check_radlen.sh
data/${sname}_coll.geo.root )
set_tests_properties(${testname} PROPERTIES
TIMEOUT ${timeOutTime}
FIXTURES_REQUIRED "fixt_digi_ev_${setup};fixt_digi_ts_${setup}"
# FIXTURES_SETUP fixt_tra_coll_${setup}
RESOURCE_LOCK collParDb_${setup}
)
# --- Test run_reco_ev_ideal
# --- Event-by-event reconstruction from event-based simulation
# --- Ideal raw event builder
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment