Skip to content
Snippets Groups Projects
Commit 3ce8863e authored by Pierre-Alain Loizeau's avatar Pierre-Alain Loizeau Committed by Florian Uhlig
Browse files

Add script to check rad length values in geo files set

- If git argument given or none, script check all new geo files introduced by an eventual hash change compared to upstream/master
- if all argument given, check all geo file in local copy
- if main argument given, check all geo file in local copy except mcbm ones
- If other argument, use it as a tag to restrict the list of checked geo from local copy (e.g. using mcbm checks only all mCBM geometries)
- Also add gitignore for macro geometry folder
- Add instructions on new script in README file
parent 43a46597
No related branches found
No related tags found
1 merge request!1038Add script to check rad length in various geo file sets + remove radlen CI
geo.gv
......@@ -6,6 +6,8 @@ files which contain a TGeoManager.
## Scan Geometry (scan_geometry.C)
Now moved to the `geometry/ci_scripts` folder.
Scan geometry travels through the root geometry hierarchy of a typical root geometry binary and outputs standard information regarding the node to the screen. There are several options, some of which are commented out in the file, which allows the easy comparison of root binaries. A GRAPHVIZ file named geo.gv is also output to the working directory.
### Examining Text
......@@ -127,13 +129,13 @@ output file example.txt
## costum_setup.sh
Intended for inspection of geometry setups. At the user risk, it may also work for simulation.
Generates a costum-setup file for the CBM experiemnt. User is prompted which subsystem and its configuration to include.
The scripts only works for default geometries and is not intended to switch between geometry versions.
Intended for inspection of geometry setups. At the user risk, it may also work for simulation.
Generates a costum-setup file for the CBM experiemnt. User is prompted which subsystem and its configuration to include.
The scripts only works for default geometries and is not intended to switch between geometry versions.
For detectors which are placed on railsystems the user will be prompted as to specify its distance to the target.
Specifying a variable like PSD_INCLUDE=1 will skip question relating to including the PSD, allowing a user to predefine a configuration skip.
Suggested command to create costum setup file:
Suggested command to create costum setup file:
sh costum-setup.sh
......@@ -161,18 +163,20 @@ include
## check_radlen.sh
Checks for a common issue whereby the radiaiton length is miscalculated by root.
Now moved to the `geometry/ci_scripts` folder.
Checks for a common issue whereby the radiaiton length is miscalculated by root.
The script calculates the radiation length from the stated atomic number, mass and density of the material
and compares this to the stated radlen in the material. If the difference is more than a tolerance (currently
5%) then failure is declared. It is up to the use to assess information. Dummy and vacuum materials may be safely
and compares this to the stated radlen in the material. If the difference is more than a tolerance (currently
5%) then failure is declared. It is up to the use to assess information. Dummy and vacuum materials may be safely
ignored.
Sugggested command
sh check_radlen.sh much_v20b_mcbm.geo.root
This will check the materials rad length within a certain tolerance (5%). Recommended checking
This will check the materials rad length within a certain tolerance (5%). Recommended checking
the transported geometry file in simulations to check whether target definition and all geometries
are correct.
......@@ -181,4 +185,21 @@ sh check_radlen.sh test.geo.root
---
## check_radlen_bulk.sh
Allows to run the `check_radlen` script on sets of geometries present in the subfolders of the local `geometry` folder.
**Usage of the script:**
- `./macro/geometry/check_radlen_bulk.sh` or `./macro/geometry/check_radlen_bulk.sh git` \
=> check new geometries introduced by a hash change relative to the current upstream tip
- `./macro/geometry/check_radlen_bulk.sh all` \
=> check all geometries in the local geometry folder (including mCBM ones)
- `./macro/geometry/check_radlen_bulk.sh main` \
=> check all geometries without mcbm in their name in the local geometry folder
- `./macro/geometry/check_radlen_bulk.sh <tag>` \
=> check all geometries with a given tag (detector, version, ...) in their name in the local geometry folder \
Example for mCBM: `./macro/geometry/check_radlen_bulk.sh mcbm` \
Example for sts: `./macro/geometry/check_radlen_bulk.sh sts` \
Example for a version: `./macro/geometry/check_radlen_bulk.sh v22a` \
Special tags which cannot be used in this way: `git`, `all`, `main`
#!/bin/bash
# Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
# SPDX-License-Identifier: GPL-3.0-only
# First commited by Pierre-Alain Loizeau
TAG="git"
if [[ $# -eq 1 ]]; then
TAG=$1
fi
FAILED=0
FAILED_LIST=""
CHECK_LIST=""
if [[ $TAG == "git" ]]; then
if [ -z $UPSTREAM ]; then
UPSTREAM=$(git remote -v | grep git.cbm.gsi.de[:/]computing/cbmroot | cut -f1 | uniq)
if [ -z $UPSTREAM ]; then
echo "Error: Name of upstream repository not provided and not found by automatic means"
echo 'Please provide if by checking your remotes with "git remote -v" and exporting UPSTREAM'
return -1 2>/dev/null || exit -1
fi
fi
echo "Upstream name is :" $UPSTREAM
BASE_COMMIT=$UPSTREAM/master
GEO_BASE=`git diff ${BASE_COMMIT} ${VMCWORKDIR}/external/InstallGeometry.cmake | grep '-' | grep GEOMETRY_VERSION`
if [[ 1 -eq `echo "$GEO_BASE" | wc -l` ]]; then
GEO_BASE=`echo ${GEO_BASE} | cut -f2 -d ' ' | rev | cut -c2- | rev`
printf "Geo Base commit is ${GEO_BASE}\n"
cd ${VMCWORKDIR}/geometry/
# Get only name of changed files and filter out deleted files
CHECK_LIST=$(git diff --name-only --diff-filter=d ${GEO_BASE} | grep -E '.*\.geo.root$')
cd -
else
echo "No change to GEO hash"
return 0 2>/dev/null ||exit 0
fi
elif [[ $TAG == "all" || $TAG == "main" ]]; then
cd ${VMCWORKDIR}/geometry/
CHECK_LIST=`ls */*.geo.root`
if [[ $TAG == "main" ]]; then
CHECK_LIST=`printf "${CHECK_LIST}" | grep -v mcbm`
fi
cd -
else
cd ${VMCWORKDIR}/geometry/
CHECK_LIST=`ls */*${TAG}*.geo.root`
cd -
fi
printf "Files to be checked: \n${CHECK_LIST}\n"
cd ${VMCWORKDIR}/geometry/
echo "---------------------------------"
for geo in ${CHECK_LIST}; do
echo $geo;
./ci_scripts/check_radlen.sh ${VMCWORKDIR}/geometry/$geo;
if [[ $? -gt 0 ]]; then
FAILED=$((FAILED+1));
FAILED_LIST=${FAILED_LIST}" \n "${geo}
fi
echo "---------------------------------"
done
cd -
if [[ ${FAILED} -gt 0 ]]; then
printf "${FAILED} geometries have wrong radiation length or are incompatible with the macro\n"
printf "These geometries are: \n ${FAILED_LIST} \n"
else
echo "All checked geometries have valid radiation length values"
fi
return ${FAILED} 2>/dev/null || exit ${FAILED}
......@@ -41,9 +41,23 @@ void scan_geometry(std::string fileName = "test.geo.root", uint32_t uMaxNodeDept
if (top == nullptr) {
std::string geo_tag = fileName.substr(fileName.find_last_of('/') + 1);
geo_tag = geo_tag.substr(0, geo_tag.find_first_of('.'));
geo_tag = geo_tag.substr(0, geo_tag.find(".geo.root"));
std::cout << "geo tag extracted from file name is: " << geo_tag << std::endl;
file.GetObject(geo_tag.c_str(), top);
file.GetObject(geo_tag.data(), top);
// If still not there, may be an mCBM geometry not following the filename = tag convention
if (top == nullptr) {
std::string geo_tag_mcbm = geo_tag.substr(0, geo_tag.find("_mcbm"));
std::cout << "mcbm geo tag extracted from file name is: " << geo_tag_mcbm << std::endl;
file.GetObject(geo_tag_mcbm.data(), top);
}
// If still not there, may be a SIS18 geometry not following the filename = tag convention
if (top == nullptr) {
std::string geo_tag_sis18 = geo_tag.substr(0, geo_tag.find("_sis18"));
std::cout << "sis18 geo tag extracted from file name is: " << geo_tag_sis18 << std::endl;
file.GetObject(geo_tag_sis18.data(), top);
}
}
if (top == nullptr) file.GetObject("FAIRGeom", top);
if (top == nullptr) file.GetObject("top", top);
......@@ -51,6 +65,8 @@ void scan_geometry(std::string fileName = "test.geo.root", uint32_t uMaxNodeDept
if (top == nullptr) file.GetObject("Top", top);
if (top == nullptr) file.GetObject("geometryFromGDML", top);
if (top == nullptr) top = dynamic_cast<TGeoVolume*>(file.Get(file.GetListOfKeys()->First()->GetName()));
gROOT->cd();
if (top == nullptr) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment