Skip to content
Snippets Groups Projects
Commit 4ba38b23 authored by Wouter Deconinck's avatar Wouter Deconinck
Browse files

Fix clustering benchmarks for missing ID.value

parent 16efa6e7
No related branches found
No related tags found
1 merge request!250Fix clustering benchmarks for missing ID.value
...@@ -158,10 +158,14 @@ if __name__ == '__main__': ...@@ -158,10 +158,14 @@ if __name__ == '__main__':
print('{} do not have valid entries, skip it'.format(coll)) print('{} do not have valid entries, skip it'.format(coll))
continue continue
df.rename(columns={c: c.replace(coll + '.', '') for c in df.columns}, inplace=True) df.rename(columns={c: c.replace(coll + '.', '') for c in df.columns}, inplace=True)
# print(df[['eta', 'polar.theta', 'position.x', 'position.y', 'position.z']]) df['r'] = np.sqrt(df['position.x'].values**2 + df['position.y'].values**2 + df['position.z'].values**2)
df['phi'] = np.arctan2(df['position.y'].values, df['position.x'].values)
df['theta'] = np.arccos(df['position.z'].values/df['r'].values)
df['eta'] = -np.log(np.tan(df['theta'].values/2.))
# print(df[['eta', 'theta', 'position.x', 'position.y', 'position.z']])
fig, axs = plt.subplots(2, 2, figsize=(12, 8), dpi=160) fig, axs = plt.subplots(2, 2, figsize=(12, 8), dpi=160)
ncl = df.groupby('event')['ID.value'].nunique().values ncl = df.groupby('event')['event'].count()
axs[0][0].hist(ncl, weights=np.repeat(1./float(ncl.shape[0]), ncl.shape[0]), axs[0][0].hist(ncl, weights=np.repeat(1./float(ncl.count()), ncl.count()),
bins=np.arange(0, 10), align='mid', ec='k') bins=np.arange(0, 10), align='mid', ec='k')
axs[0][0].set_xlabel('Number of Clusters', fontsize=16) axs[0][0].set_xlabel('Number of Clusters', fontsize=16)
......
...@@ -4,7 +4,6 @@ imaging_ecal_electrons: ...@@ -4,7 +4,6 @@ imaging_ecal_electrons:
stage: run stage: run
script: script:
- bash benchmarks/imaging_ecal/run_emcal_barrel.sh -t emcal_barrel_electrons -p "electron" -n 100 - bash benchmarks/imaging_ecal/run_emcal_barrel.sh -t emcal_barrel_electrons -p "electron" -n 100
allow_failure: true
imaging_ecal_photons: imaging_ecal_photons:
extends: .rec_benchmark extends: .rec_benchmark
...@@ -12,7 +11,6 @@ imaging_ecal_photons: ...@@ -12,7 +11,6 @@ imaging_ecal_photons:
stage: run stage: run
script: script:
- bash benchmarks/imaging_ecal/run_emcal_barrel.sh -t emcal_barrel_photons -p "photon" -n 100 - bash benchmarks/imaging_ecal/run_emcal_barrel.sh -t emcal_barrel_photons -p "photon" -n 100
allow_failure: true
imaging_ecal_pions: imaging_ecal_pions:
extends: .rec_benchmark extends: .rec_benchmark
...@@ -20,7 +18,6 @@ imaging_ecal_pions: ...@@ -20,7 +18,6 @@ imaging_ecal_pions:
stage: run stage: run
script: script:
- bash benchmarks/imaging_ecal/run_emcal_barrel.sh -t emcal_barrel_pions -p "pion-" -n 100 - bash benchmarks/imaging_ecal/run_emcal_barrel.sh -t emcal_barrel_pions -p "pion-" -n 100
allow_failure: true
imaging_ecal_pion0: imaging_ecal_pion0:
extends: .rec_benchmark extends: .rec_benchmark
...@@ -28,7 +25,6 @@ imaging_ecal_pion0: ...@@ -28,7 +25,6 @@ imaging_ecal_pion0:
stage: run stage: run
script: script:
- bash benchmarks/imaging_ecal/run_imcal_pion0.sh -t imcal_barrel_pion0 -p "pion0" -n 100 - bash benchmarks/imaging_ecal/run_imcal_pion0.sh -t imcal_barrel_pion0 -p "pion0" -n 100
allow_failure: true
imaging_ecal_pion_rejection: imaging_ecal_pion_rejection:
extends: .rec_benchmark extends: .rec_benchmark
...@@ -38,7 +34,6 @@ imaging_ecal_pion_rejection: ...@@ -38,7 +34,6 @@ imaging_ecal_pion_rejection:
- compile_analyses.py imaging_ecal - 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_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 - bash benchmarks/imaging_ecal/run_emcal_barrel_pion_rej.sh -t emcal_barrel_pion_rej_piminus -p "pion-" -n 100
allow_failure: true
imaging_ecal_pion_rejection:bench: imaging_ecal_pion_rejection:bench:
extends: .rec_benchmark extends: .rec_benchmark
...@@ -51,4 +46,3 @@ imaging_ecal_pion_rejection:bench: ...@@ -51,4 +46,3 @@ imaging_ecal_pion_rejection:bench:
- compile_analyses.py imaging_ecal - compile_analyses.py imaging_ecal
- root -b -q benchmarks/imaging_ecal/analysis/emcal_barrel_pion_rejection_analysis.cxx+ - root -b -q benchmarks/imaging_ecal/analysis/emcal_barrel_pion_rejection_analysis.cxx+
#- bash run_pion_rej_analysis.sh #- bash run_pion_rej_analysis.sh
allow_failure: true
...@@ -80,7 +80,6 @@ imcal_barrel_clreco = RecoCoG('imcal_barrel_clreco', ...@@ -80,7 +80,6 @@ imcal_barrel_clreco = RecoCoG('imcal_barrel_clreco',
# OutputLevel=DEBUG, # OutputLevel=DEBUG,
inputProtoClusterCollection = imcal_barrel_cl.outputProtoClusterCollection, inputProtoClusterCollection = imcal_barrel_cl.outputProtoClusterCollection,
outputClusterCollection='EcalBarrelImagingClusters', outputClusterCollection='EcalBarrelImagingClusters',
mcHits="EcalBarrelHits",
logWeightBase=6.2, logWeightBase=6.2,
samplingFraction=kwargs['img_sf']) samplingFraction=kwargs['img_sf'])
......
...@@ -142,13 +142,14 @@ for iev in "${ADDR[@]}"; do ...@@ -142,13 +142,14 @@ for iev in "${ADDR[@]}"; do
fi fi
done done
python ${CB_EMCAL_SCRIPT_DIR}/energy_profile.py \ # FIXME energy_profile disabled due to change in layer encoding, needs work
${CB_EMCAL_REC_FILE} --type=EM --energy=${CB_EMCAL_ENERGY} -o results/${particle} \ #python ${CB_EMCAL_SCRIPT_DIR}/energy_profile.py \
--save=results/profile.csv --color=royalblue # ${CB_EMCAL_REC_FILE} --type=EM --energy=${CB_EMCAL_ENERGY} -o results/${particle} \
if [[ "$?" -ne "0" ]] ; then # --save=results/profile.csv --color=royalblue
echo "ERROR running analysis script: energy_profile" #if [[ "$?" -ne "0" ]] ; then
exit 1 # echo "ERROR running analysis script: energy_profile"
fi # exit 1
#fi
root_filesize=$(stat --format=%s "${CB_EMCAL_REC_FILE}") root_filesize=$(stat --format=%s "${CB_EMCAL_REC_FILE}")
if [[ "${CB_EMCAL_NUMEV}" -lt "500" ]] ; then if [[ "${CB_EMCAL_NUMEV}" -lt "500" ]] ; then
......
...@@ -143,13 +143,14 @@ for iev in "${ADDR[@]}"; do ...@@ -143,13 +143,14 @@ for iev in "${ADDR[@]}"; do
fi fi
done done
python ${CB_EMCAL_SCRIPT_DIR}/energy_profile.py \ # FIXME energy_profile disabled due to change in layer encoding, needs work
${CB_EMCAL_REC_FILE} --type=EM --energy=${CB_EMCAL_ENERGY} -o results/${particle} \ #python ${CB_EMCAL_SCRIPT_DIR}/energy_profile.py \
--save=results/profile.csv --color=royalblue # ${CB_EMCAL_REC_FILE} --type=EM --energy=${CB_EMCAL_ENERGY} -o results/${particle} \
if [[ "$?" -ne "0" ]] ; then # --save=results/profile.csv --color=royalblue
echo "ERROR running analysis script: energy_profile" #if [[ "$?" -ne "0" ]] ; then
exit 1 # echo "ERROR running analysis script: energy_profile"
fi # exit 1
#fi
echo "Reconstruction File" echo "Reconstruction File"
rootls -t "${CB_EMCAL_REC_FILE}" rootls -t "${CB_EMCAL_REC_FILE}"
......
...@@ -167,7 +167,7 @@ if __name__ == '__main__': ...@@ -167,7 +167,7 @@ if __name__ == '__main__':
# Calculate geometric variables of decaying particles # Calculate geometric variables of decaying particles
dfdecaymcp['r'] = np.sqrt(dfdecaymcp['vex'].values**2 + dfdecaymcp['vey'].values**2 + dfdecaymcp['vez'].values**2) dfdecaymcp['r'] = np.sqrt(dfdecaymcp['vex'].values**2 + dfdecaymcp['vey'].values**2 + dfdecaymcp['vez'].values**2)
dfdecaymcp['phi'] = np.arctan2(dfdecaymcp['vey'].values, dfdecaymcp['vex'].values)*1000. dfdecaymcp['phi'] = np.arctan2(dfdecaymcp['vey'].values, dfdecaymcp['vex'].values)*1000.
dfdecaymcp['theta'] = np.arccos(dfdecaymcp['vez'].values/dfdecaymcp['r'].values)*1000. dfdecaymcp['theta'] = np.arctan2(dfdecaymcp['vez'].values, dfdecaymcp['r'].values)*1000.
dfdecaymcp['eta'] = -np.log(np.tan(dfdecaymcp['theta'].values/1000./2.)) dfdecaymcp['eta'] = -np.log(np.tan(dfdecaymcp['theta'].values/1000./2.))
# truth # truth
......
...@@ -153,7 +153,7 @@ if __name__ == '__main__': ...@@ -153,7 +153,7 @@ if __name__ == '__main__':
# gif frames # gif frames
fig.savefig('ltmp.png') fig.savefig('ltmp.png')
plt.close(fig) plt.close(fig)
frames.append(imageio.imread('ltmp.png')) frames.append(imageio.v2.imread('ltmp.png'))
pdf.close() pdf.close()
os.remove('ltmp.png') os.remove('ltmp.png')
...@@ -191,7 +191,7 @@ if __name__ == '__main__': ...@@ -191,7 +191,7 @@ if __name__ == '__main__':
# gif frames # gif frames
fig.savefig('ltmp.png') fig.savefig('ltmp.png')
plt.close(fig) plt.close(fig)
frames.append(imageio.imread('ltmp.png')) frames.append(imageio.v2.imread('ltmp.png'))
pdf.close() pdf.close()
os.remove('ltmp.png') os.remove('ltmp.png')
......
...@@ -126,8 +126,8 @@ def get_hits_data(path, evnums=None, branch='RecoEcalBarreImaginglHits'): ...@@ -126,8 +126,8 @@ def get_hits_data(path, evnums=None, branch='RecoEcalBarreImaginglHits'):
continue continue
events.GetEntry(iev) events.GetEntry(iev)
for hit in getattr(events, branch): for ihit, hit in enumerate(getattr(events, branch)):
dbuf[idb] = (iev, hit.ID.value, hit.layer, hit.position.x, hit.position.y, dbuf[idb] = (iev, ihit, hit.layer, hit.position.x, hit.position.y,
hit.position.z, hit.energy*1000.) hit.position.z, hit.energy*1000.)
idb += 1 idb += 1
...@@ -152,8 +152,8 @@ def get_layers_data(path, evnums=None, branch="EcalBarrelImagingClustersLayers") ...@@ -152,8 +152,8 @@ def get_layers_data(path, evnums=None, branch="EcalBarrelImagingClustersLayers")
continue continue
events.GetEntry(iev) events.GetEntry(iev)
for layer in getattr(events, branch): for icl, layer in enumerate(getattr(events, branch)):
dbuf[idb] = (iev, layer.clusterID.value, layer.layer, dbuf[idb] = (iev, icl, layer.layer,
layer.position.x, layer.position.y, layer.position.z, layer.position.x, layer.position.y, layer.position.z,
layer.energy*1000.) layer.energy*1000.)
idb += 1 idb += 1
......
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