Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:18:33

0001 #!/bin/bash
0002 # script for material mapping with ACTS python bindings
0003 # please run it in eic-shell, whith DETECTOR_PATH and ACTS_PATH set up 
0004 # run as : ./run_matmap_py.sh 0 --nev 1000 --tag _test
0005 #           use option 0,1,2 step by step to generate the material map (or option -1 to run it at once). option 4 and 5 to produce comparison plots.
0006 # Shujie Li, 03. 2024
0007 
0008 
0009 echo "=========FOR EPIC Craterlake, 03.2024========="
0010 source detector_setup.sh
0011 ACTS_PATH="" #path to the ACTS source code. see https://github.com/acts-project/acts/tree/main
0012 XML_NAME="epic_craterlake_matmap.xml" #the detector configuration contains all detectors and materials within the volume you want to create the map for
0013 XML_PATH=${PWD}
0014 XML_FILE=${XML_PATH}/${XML_NAME}
0015 
0016 nev=1000  #1000
0017 nparticles=1000 #5000 #5000
0018 tag=""
0019 kopt=$1
0020 while [[ $# -gt 1 ]]
0021 do
0022   key="$2"
0023 
0024   case $key in
0025     --nev)
0026       nev=$3
0027       shift # past value
0028       shift
0029       ;;
0030     --nparticles)
0031       nparticles=$3
0032       shift # past value
0033       shift
0034       ;;
0035     --tag)
0036                         tag=$3
0037                         shift
0038                         shift
0039                         ;;
0040     *)    # unknown option
0041       #POSITIONAL+=("$1") # save it in an array for later
0042       echo "unknown option $2"
0043       print_the_help
0044       shift # past argument
0045       ;;
0046   esac
0047 done
0048 set -- "${POSITIONAL[@]}" # restore positional parameters
0049 
0050 recordingFile=geant4_material_tracks${tag}.root
0051 geoFile=geometry-map${tag}.json
0052 matFile=material-map${tag}.json
0053 trackFile=material-map${tag}_tracks.root
0054 propFile=propagation-material${tag}.root
0055 
0056         # ----GEANTINO SCAN------
0057 if  [ "$kopt" == 0 ] || [ "$kopt" -lt 0 ]; then
0058         # output geant4_material_tracks.root
0059         # The result of the geantino scan will be a root file containing material tracks. Those contain the direction and production vertex of the geantino, the total material accumulated and all the interaction points in the detector.
0060 
0061 python material_recording_ePIC.py -i ${XML_FILE} -n ${nev} -t ${nparticles} -o ${recordingFile}
0062 
0063 fi
0064 
0065         #-----MAPPING Configuration-----
0066 
0067 if  [ "$kopt" == 1 ]|| [ "$kopt" -lt 0 ]; then
0068 
0069 
0070         # map gemoery to geometry-map.json
0071         python geometry_ePIC.py -i ${XML_FILE} -o ${geoFile}
0072 
0073         # take geometry-map.json and read out config-map.json
0074         python3 ${ACTS_PATH}/Examples/Scripts/MaterialMapping/writeMapConfig.py ${geoFile} config-map${tag}.json
0075 
0076         # turn on approaches and beampipe surfaces for material mapping
0077         # you can always manually adjust the mapmaterial flag and binnings in config-map.json
0078         python3 materialmap_config.py -i config-map${tag}.json -o config-map_new${tag}.json
0079 
0080 fi
0081 
0082 if  [ "$kopt" == 2 ]|| [ "$kopt" -lt 0 ]; then
0083         # turn config-map.json into modified geometry-map.json
0084         python3 ${ACTS_PATH}/Examples/Scripts/MaterialMapping/configureMap.py ${geoFile} config-map_new${tag}.json
0085 
0086 
0087         #----MAPPING------------
0088         # input: geant4_material_tracks.root, geometry-map.json
0089         # output: material-maps.json or cbor. This is the material map that you want to provide to EICrecon, i.e.  -Pacts:MaterialMap=XXX  .Please --matFile to specify the name and type 
0090         #         material-maps_tracks.root(recorded steps from geantino, for validation purpose)
0091 
0092         python material_mapping_ePIC.py --xmlFile $XML_FILE --stepFile ${recordingFile} --geoFile ${geoFile} --matFile ${matFile}
0093 
0094 fi
0095 
0096 ## steps below are for validation/debugging
0097 if  [ "$kopt" == 3 ]|| [ "$kopt" -lt 0 ]; then
0098         #----Prepare validation rootfile--------
0099         # output propagation-material.root
0100         python material_validation_ePIC.py --xmlFile $XML_FILE --outputName ${propFile} --matFile ${matFile} -n ${nev} -t ${nparticles}
0101         # you may see a couple of the error msg below. Should not matter as long as it's not for every event.
0102         # PropagationA   ERROR     Propagation reached the step count limit of 1000 (did 1000 steps)
0103         #  PropagationA   ERROR     Step failed with EigenStepperError:3: Step size adjustment exceeds maximum trials
0104 
0105 fi
0106 
0107 ## -------Comparison plots---------
0108 if  [ "$kopt" == 4 ]; then
0109         rm -rf Validation
0110         mkdir Validation
0111         root -l -b -q ${ACTS_PATH}/Examples/Scripts/MaterialMapping/Mat_map.C'("'$propFile'","'$trackFile'","Validation")'
0112         root -l -b -q mat_map_local.C'("'$propFile'","'$trackFile'","Validation")'      # 
0113 
0114 # fi
0115 # if  [ "$kopt" == 5 ]; then
0116 rm -rf Surfaces
0117 mkdir Surfaces
0118 cd Surfaces
0119 mkdir prop_plot
0120 mkdir map_plot
0121 mkdir ratio_plot
0122 mkdir dist_plot
0123 mkdir 1D_plot
0124 cd ..
0125 root -l -b -q ${ACTS_PATH}/Examples/Scripts/MaterialMapping/Mat_map_surface_plot_ratio.C'("'$propFile'","'$trackFile'",-1,"Surfaces/ratio_plot","Surfaces/prop_plot","Surfaces/map_plot")'
0126 root -l -b -q ${ACTS_PATH}/Examples/Scripts/MaterialMapping/Mat_map_surface_plot_dist.C'("'$trackFile'",-1,"Surfaces/dist_plot")'
0127 root -l -b -q ${ACTS_PATH}/Examples/Scripts/MaterialMapping/Mat_map_surface_plot_1D.C'("'$trackFile'",-1,"Surfaces/1D_plot")'
0128 fi