Skip to content

Commit

Permalink
update material map script for acts v35.2 (#826)
Browse files Browse the repository at this point in the history
### Briefly, what does this PR introduce?
Update the material map script to acts 35.2 to allow saving map in cbor
format. Tested with jug_xl nightly, 02042025

### What kind of change does this PR introduce?
- [ ] Bug fix (issue #__)
- [ x] New feature (issue #__)
- [ ] Documentation update
- [ ] Other: __

### Please check if this PR fulfills the following:
- [ ] Tests for the changes have been added
- [ ] Documentation has been added / updated
- [x ] Changes have been communicated to collaborators

### Does this PR introduce breaking changes? What changes might users
need to make to their code?
N/A
### Does this PR change default behavior?
N/A

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Barak Schmookler <bschmookler1@gmail.com>
Co-authored-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
  • Loading branch information
4 people authored Feb 9, 2025
1 parent 363442f commit 891ceb5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 11 deletions.
14 changes: 14 additions & 0 deletions configurations/craterlake_material_map.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# This contains all geometry to be used in the material map
ebeam: 5
pbeam: 41
features:
beampipe:
tracking:
Expand All @@ -13,5 +15,17 @@ features:
silicon_disks:
tof_barrel:
tof_endcap:
pid:
dirc:
pfrich:
drich:
ecal:
forward_homogeneous:
forward_insert_homogeneous:
hcal:
lfhcal_with_space_for_insert:
forward_insert:
far_forward:
default:
far_backward:
default:
9 changes: 9 additions & 0 deletions scripts/material_map/material_mapping_epic.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,18 @@
args = p.parse_args()

mapName = args.matFile.split('.')[0]
if '.json' in args.matFile:
mapFormat = JsonFormat.Json
elif '.cbor' in args.matFile:
mapFormat = JsonFormat.Cbor
else:
print('ERROR(material_mapping_epic.py): please provide a material map file in .json or .cbor format')
exit()

detector, trackingGeometry, decorators = epic.getDetector(
args.xmlFile, args.geoFile)


runMaterialMapping(
trackingGeometry,
decorators,
Expand All @@ -48,4 +56,5 @@
readCachedSurfaceInformation=False,
mapVolume= False,
mapName = mapName,
mapFormat = mapFormat,
).run()
13 changes: 10 additions & 3 deletions scripts/material_map/material_validation_epic.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"--matFile",
type=str,
default="material-map.json",
help="input material map file, can be either Json or Cbor",
help="input material map file with extension, can be either xx.json or xx.cbor",
)
p.add_argument(
"--outputName",
Expand All @@ -38,16 +38,23 @@
p.add_argument(
"-n","--nevents",
type=int,
default=100,
default=1000,
help="number of events to run",
)

p.add_argument(
"-t","--ntracks",
type=int,
default=1000,
help="number of tracks per event")

args = p.parse_args()

detector, trackingGeometry, decorators = epic.getDetector(args.xmlFile, args.matFile)

field = acts.ConstantBField(acts.Vector3(0, 0, 0))

runMaterialValidation(
runMaterialValidation(args.nevents, args.ntracks,
trackingGeometry, decorators, field,
outputDir=os.getcwd(), outputName=args.outputName,
s=Sequencer(events=args.nevents, numThreads=-1)
Expand Down
22 changes: 14 additions & 8 deletions scripts/material_map/run_material_map_validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ set -e
# script for material map validation with ACTS python bindings
# run as : ./run_material_map_validation.sh --nevents 1000
# Shujie Li, 03. 2024 (https://github.com/eic/snippets/pull/3)

# Check if DETECTOR_PATH and DETECTOR_CONFIG are set
if [[ -z ${DETECTOR_PATH} || -z ${DETECTOR_CONFIG} ]] ; then
echo "You must set \$DETECTOR_PATH and \$DETECTOR_CONFIG before running this script."
DETECTOR_CONFIG="epic_craterlake_material_map"
# Check if DETECTOR_PATH are set
if [[ -z ${DETECTOR_PATH} ]] ; then
echo "You must set \$DETECTOR_PATH before running this script."
exit -1
fi

# Download required Acts files
ACTS_VERSION="8e1b7a659d912cd98db9d700906ff59e708da574" # v34.1.0
ACTS_VERSION="b3b09f46d064c43050dd3d21cdf51d7a412134fc" #v35.2.0
ACTS_URL="https://github.com/acts-project/acts/raw/"
ACTS_FILES=(
"Examples/Scripts/Python/geometry.py"
Expand All @@ -20,6 +20,7 @@ ACTS_FILES=(
"Examples/Scripts/Python/material_validation.py"
"Examples/Scripts/MaterialMapping/writeMapConfig.py"
"Examples/Scripts/MaterialMapping/configureMap.py"
"Examples/Scripts/MaterialMapping/GeometryVisualisationAndMaterialHandling.py"
"Examples/Scripts/MaterialMapping/Mat_map.C"
"Examples/Scripts/MaterialMapping/Mat_map_surface_plot.C"
"Examples/Scripts/MaterialMapping/Mat_map_surface_plot_ratio.C"
Expand Down Expand Up @@ -78,7 +79,7 @@ set -- "${POSITIONAL[@]}" # restore positional parameters

recordingFile=geant4_material_tracks.root
geoFile=geometry-map.json
matFile=material-map.json
matFile=material-map.cbor
trackFile=material-map_tracks.root
propFile=propagation_material

Expand All @@ -101,6 +102,11 @@ python materialmap_config.py -i config-map.json -o config-map_new.json

# turn config-map.json into modified geometry-map.json
python Examples/Scripts/MaterialMapping/configureMap.py ${geoFile} config-map_new.json

# generate figures to display tracking layers and volumes as seen by ACTS
rm -rf plots
mkdir -p plots
python Examples/Scripts/MaterialMapping/GeometryVisualisationAndMaterialHandling.py --geometry ${geoFile}
echo "::endgroup::"

echo "::group::----MAPPING------------"
Expand All @@ -112,8 +118,8 @@ echo "::endgroup::"

echo "::group::----Prepare validation rootfile--------"
# output propagation-material.root
python material_validation_epic.py --xmlFile ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml --outputName ${propFile}_new --matFile ${matFile} -n ${nevents}
python material_validation_epic.py --xmlFile ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml --outputName ${propFile}_old --matFile "calibrations/materials-map.cbor" -n ${nevents}
python material_validation_epic.py --xmlFile ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml --outputName ${propFile}_new --matFile ${matFile} -n ${nevents} -t ${nparticles}
python material_validation_epic.py --xmlFile ${DETECTOR_PATH}/${DETECTOR_CONFIG}.xml --outputName ${propFile}_old --matFile "calibrations/materials-map.cbor" -n ${nevents} -t ${nparticles}
echo "::endgroup::"

echo "::group::-------Comparison plots---------"
Expand Down

0 comments on commit 891ceb5

Please sign in to comment.