Commit 6a53b574 authored by Marshall Scott's avatar Marshall Scott Committed by Jihee Kim
Browse files

Resolve "barrel ecal pi minus benchmark"

parent 5e26fad9
......@@ -26,3 +26,23 @@ imaging_ecal_pion0:
script:
- bash benchmarks/imaging_ecal/run_imcal_pion0.sh -t imcal_barrel_pion0 -p "pion0" -n 100
imaging_ecal_pion_rejection:
extends: .rec_benchmark
timeout: 48 hours
stage: run
script:
- compile_analyses.py imaging_ecal
- bash benchmarks/imaging_ecal/run_emcal_barrel_pion_rej.sh -t emcal_barrel_pion_rej_electron -p "electron" -n 100
- bash benchmarks/imaging_ecal/run_emcal_barrel_pion_rej.sh -t emcal_barrel_pion_rej_piminus -p "pion-" -n 100
imaging_ecal_pion_rejection:bench:
extends: .rec_benchmark
timeout: 1 hours
stage: benchmarks2
needs:
- ["imaging_ecal_pion_rejection"]
script:
- ls -lhtR
- compile_analyses.py imaging_ecal
- root -b -q benchmarks/imaging_ecal/analysis/emcal_barrel_pion_rejection_analysis.cxx+
#- bash run_pion_rej_analysis.sh
......@@ -19,11 +19,13 @@ from Configurables import Jug__Reco__ImagingClusterReco as ImagingClusterReco
with open('config/emcal_barrel_calibration.json') as f:
calib_data = json.load(f)['electron']
print(calib_data)
#print(calib_data)
kwargs = dict()
kwargs['img_sf'] = float(calib_data['sampling_fraction_img'])
kwargs['scfi_sf'] = float(calib_data['sampling_fraction_scfi'])
#kwargs['img_sf'] = 0.0060795
#kwargs['scfi_sf'] = 0.10343
# input arguments through environment variables
kwargs['input'] = os.environ['CB_EMCAL_SIM_FILE']
......@@ -56,14 +58,15 @@ imcaldaq = dict(
pedestalMean=400,
pedestalSigma=50) # 50/32767*3 MeV ~ 5 keV
imcaldigi = CalHitDigi('imcal_digi',
# OutputLevel=DEBUG,
OutputLevel=DEBUG,
inputHitCollection='EcalBarrelHits',
outputHitCollection='DigiEcalBarrelImagingHits',
energyResolutions=[0., 0.02, 0.],
**imcaldaq)
imcalreco = ImagingPixelReco('imcal_reco',
# OutputLevel=DEBUG,
#OutputLevel=DEBUG,
inputHitCollection=imcaldigi.outputHitCollection,
outputHitCollection='RecoEcalBarrelImagingHits',
readoutClass='EcalBarrelHits',
......@@ -72,7 +75,7 @@ imcalreco = ImagingPixelReco('imcal_reco',
**imcaldaq)
imcalcluster = ImagingTopoCluster('imcal_cluster',
# OutputLevel=DEBUG,
#OutputLevel=DEBUG,
inputHitCollection=imcalreco.outputHitCollection,
outputProtoClusterCollection='EcalBarrelImagingProtoClusters',
localDistXY=[2.*mm, 2*mm],
......@@ -80,7 +83,7 @@ imcalcluster = ImagingTopoCluster('imcal_cluster',
neighbourLayersRange=2,
sectorDist=3.*cm)
clusterreco = ImagingClusterReco('imcal_clreco',
# OutputLevel=DEBUG,
#OutputLevel=DEBUG,
inputHitCollection=imcalcluster.inputHitCollection,
inputProtoClusterCollection=imcalcluster.outputProtoClusterCollection,
outputLayerCollection='EcalBarrelImagingClustersLayers',
......@@ -112,7 +115,7 @@ scfi_barrel_reco = CalHitReco("scfi_barrel_reco",
# merge hits in different layer (projection to local x-y plane)
scfi_barrel_merger = CalHitsMerger("scfi_barrel_merger",
# OutputLevel=DEBUG,
#OutputLevel=DEBUG,
inputHitCollection=scfi_barrel_reco.outputHitCollection,
outputHitCollection="EcalBarrelScFiGridReco",
fields=["fiber"],
......@@ -120,7 +123,7 @@ scfi_barrel_merger = CalHitsMerger("scfi_barrel_merger",
readoutClass="EcalBarrelScFiHits")
scfi_barrel_cl = IslandCluster("scfi_barrel_cl",
# OutputLevel=DEBUG,
#OutputLevel=DEBUG,
inputHitCollection=scfi_barrel_merger.outputHitCollection,
outputProtoClusterCollection="EcalBarrelScFiProtoClusters",
splitCluster=False,
......
#!/bin/bash
print_env.sh
function print_the_help {
echo "USAGE: ${0} -n <nevents> -t <nametag> -p <particle> "
echo " OPTIONS: "
echo " -n,--nevents Number of events"
echo " -t,--nametag name tag"
echo " -p,--particle particle type"
echo " allowed types: pion0, pion+, pion-, kaon0, kaon+, kaon-, proton, neutron, electron, positron, photon"
exit
}
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h|--help)
shift # past argument
print_the_help
;;
-t|--nametag)
nametag="$2"
shift # past argument
shift # past value
;;
-p|--particle)
particle="$2"
shift # past argument
shift # past value
;;
-n|--nevents)
export CB_EMCAL_NUMEV="$2"
shift # past argument
shift # past value
;;
*) # unknown option
#POSITIONAL+=("$1") # save it in an array for later
echo "unknown option $1"
print_the_help
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
export CB_EMCAL_COMPACT_PATH=${DETECTOR_PATH}/${JUGGLER_DETECTOR}.xml
if [[ ! -n "${CB_EMCAL_NUMEV}" ]] ; then
export CB_EMCAL_NUMEV=1000
fi
if [[ ! -n "${CB_EMCAL_IEV}" ]] ; then
export CB_EMCAL_IEV="0, 1"
fi
if [[ ! -n "${CB_EMCAL_ENERGY}" ]] ; then
export CB_EMCAL_ENERGY=5.0
fi
if [[ ! -n "${CB_EMCAL_SAMP_FRAC}" ]] ; then
export CB_EMCAL_SAMP_FRAC=0.014
fi
export CB_EMCAL_NAME_TAG="${nametag}"
export CB_EMCAL_GEN_FILE="${CB_EMCAL_NAME_TAG}.hepmc"
export CB_EMCAL_SIM_FILE="sim_${CB_EMCAL_NAME_TAG}.root"
export CB_EMCAL_REC_FILE="rec_${CB_EMCAL_NAME_TAG}.root"
echo "CB_EMCAL_NUMEV = ${CB_EMCAL_NUMEV}"
echo "CB_EMCAL_COMPACT_PATH = ${CB_EMCAL_COMPACT_PATH}"
# Generate the input events
python benchmarks/imaging_ecal/scripts/gen_particles.py ${CB_EMCAL_GEN_FILE} -n ${CB_EMCAL_NUMEV}\
--angmin 60 --angmax 120 --pmin 0.05 --pmax 18.0 --particles="${particle}"
if [[ "$?" -ne "0" ]] ; then
echo "ERROR running script: generating input events"
exit 1
fi
ls -lh ${CB_EMCAL_GEN_FILE}
# Run geant4 simulations
npsim --runType batch \
-v WARNING \
--part.minimalKineticEnergy "0.5*MeV" \
--numberOfEvents ${CB_EMCAL_NUMEV} \
--compactFile ${CB_EMCAL_COMPACT_PATH} \
--inputFiles ${CB_EMCAL_GEN_FILE} \
--outputFile ${CB_EMCAL_SIM_FILE}
if [[ "$?" -ne "0" ]] ; then
echo "ERROR running npdet"
exit 1
fi
echo "Simulation file"
rootls -t "${CB_EMCAL_SIM_FILE}"
# Directory for plots
mkdir -p results
CB_EMCAL_OPTION_DIR=benchmarks/imaging_ecal/options
# Run Juggler
xenv -x ${JUGGLER_INSTALL_PREFIX}/Juggler.xenv \
gaudirun.py ${CB_EMCAL_OPTION_DIR}/hybrid_cluster.py
# gaudirun.py ${CB_EMCAL_OPTION_DIR}/imaging_topocluster.py
if [[ "$?" -ne "0" ]] ; then
echo "ERROR running juggler"
exit 1
fi
# Plot clusters first
FULL_CAL_SCRIPT_DIR=benchmarks/clustering/scripts
python ${FULL_CAL_SCRIPT_DIR}/cluster_plots.py ${CB_EMCAL_SIM_FILE} ${CB_EMCAL_REC_FILE} -o results \
--collections "EcalBarrelImagingClusters, EcalBarrelScFiClusters"
# check required python modules
python -m pip install -r benchmarks/imaging_ecal/requirements.txt
CB_EMCAL_SCRIPT_DIR=benchmarks/imaging_ecal/scripts
IFS=',' read -ra ADDR <<< "$CB_EMCAL_IEV"
for iev in "${ADDR[@]}"; do
if [[ $iev -ge "${CB_EMCAL_NUMEV}" ]] ; then
continue
fi
python ${CB_EMCAL_SCRIPT_DIR}/draw_cluster_layers.py \
${CB_EMCAL_REC_FILE} -e ${iev} --topo-size=1.0 --compact=${CB_EMCAL_COMPACT_PATH} -o results/${particle}
if [[ "$?" -ne "0" ]] ; then
echo "ERROR running analysis script: draw_cluster_layers"
exit 1
fi
python ${CB_EMCAL_SCRIPT_DIR}/draw_cluster.py \
${CB_EMCAL_REC_FILE} -e ${iev} --topo-size=2.0 --compact=${CB_EMCAL_COMPACT_PATH} -o results/${particle}
if [[ "$?" -ne "0" ]] ; then
echo "ERROR running analysis script: draw_cluster"
exit 1
fi
done
python ${CB_EMCAL_SCRIPT_DIR}/energy_profile.py \
${CB_EMCAL_REC_FILE} --type=EM --energy=${CB_EMCAL_ENERGY} -o results/${particle} \
--save=results/profile.csv --color=royalblue
if [[ "$?" -ne "0" ]] ; then
echo "ERROR running analysis script: energy_profile"
exit 1
fi
echo "Reconstruction File"
rootls -t "${CB_EMCAL_REC_FILE}"
root_filesize=$(stat --format=%s "${CB_EMCAL_REC_FILE}")
if [[ "${CB_EMCAL_NUMEV}" -lt "500" ]] ; then
# file must be less than 10 MB to upload
if [[ "${root_filesize}" -lt "10000000" ]] ; then
cp ${CB_EMCAL_REC_FILE} results/.
fi
fi
pwd
echo "Current directory"
ls
#echo "Results directory"
#ls benchmarks/imaging_ecal/results/
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment