Skip to content
Snippets Groups Projects
Commit 4a86e827 authored by Chao Peng's avatar Chao Peng
Browse files

add scripts

parent 6168de81
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !12. Comments created here will be created in the context of that merge request.
File moved
#!/bin/bash
if [[ ! -n "${JUGGLER_DETECTOR}" ]] ; then
export JUGGLER_DETECTOR="topside"
fi
if [[ ! -n "${JUGGLER_N_EVENTS}" ]] ; then
export JUGGLER_N_EVENTS=100
fi
if [[ ! -n "${E_start}" ]] ; then
export E_start=0.0
fi
if [[ ! -n "${E_end}" ]] ; then
export E_end=30.0
fi
export JUGGLER_FILE_NAME_TAG="emcal_uniform_electrons"
export JUGGLER_GEN_FILE="${JUGGLER_FILE_NAME_TAG}.hepmc"
export JUGGLER_SIM_FILE="sim_${JUGGLER_FILE_NAME_TAG}.root"
export JUGGLER_REC_FILE="rec_${JUGGLER_FILE_NAME_TAG}.root"
echo "JUGGLER_N_EVENTS = ${JUGGLER_N_EVENTS}"
echo "JUGGLER_DETECTOR = ${JUGGLER_DETECTOR}"
# Build the detector constructors.
git clone https://eicweb.phy.anl.gov/EIC/detectors/${JUGGLER_DETECTOR}.git
mkdir ${JUGGLER_DETECTOR}/build
pushd ${JUGGLER_DETECTOR}/build
cmake ../. -DCMAKE_INSTALL_PREFIX=/usr/local && make -j30 install
popd
# generate the input events
# note datasets is now only used to develop datasets.
#git clone https://eicweb.phy.anl.gov/EIC/datasets.git datasets
root -b -q "ecal/scripts/emcal_electrons.cxx(${JUGGLER_N_EVENTS}, ${E_start}, ${E_end}, \"${JUGGLER_FILE_NAME_TAG}.hepmc\")"
root -b -q "ecal/scripts/emcal_electrons_reader.cxx(${E_start}, ${E_end}, \"${JUGGLER_FILE_NAME_TAG}.hepmc\")"
pushd ${JUGGLER_DETECTOR}
ls -l
# run geant4 simulations
python options/ForwardRICH/simu.py \
--compact=${JUGGLER_DETECTOR}.xml \
-i ../${JUGGLER_FILE_NAME_TAG} \
-o ${JUGGLER_SIM_FILE}
-n ${JUGGLER_N_EVENTS}
# Need to figure out how to pass file name to juggler from the commandline
xenv -x /usr/local/Juggler.xenv gaudirun.py ../ecal/options/rich_reco.py
ls -l
popd
#@TODO add analysis scripts
import ROOT
import numpy as np
from ROOT import gROOT
import argparse
from matplotlib import pyplot as plt
from matplotlib.patches import Ellipse
import matplotlib.transforms as transforms
parser = argparse.ArgumentParser(description='rich reconstruction analysis')
parser.add_argument('nevents', type=int, help='number of events')
args = parser.parse_args()
gROOT.Macro('rootlogon.C')
f = ROOT.TFile("rich_test_reco.root")
events = f.events
nev = 0
while nev < args.nevents:
iev = np.random.randint(0, events.GetEntries())
events.GetEntry(iev)
if events.RICHClusters.size() == 0:
continue
nev += 1
x, y = [], []
for hit in events.RecoForwardRICHHits:
x.append(hit.position.x)
y.append(hit.position.y)
fig, ax = plt.subplots(figsize=(9, 9), dpi=120)
colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
ax.scatter(x, y, s=9, marker='s', color=colors[0])
for cluster in events.RICHClusters:
ellipse = Ellipse((cluster.position.x, cluster.position.y), width=cluster.radius * 2, height=cluster.radius * 2,
edgecolor='red', fill=False, lw=2, alpha=0.8)
ellipse.set_transform(ax.transData)
ax.add_patch(ellipse)
ax.set_xlim(-60, 60)
ax.set_ylim(-60, 60)
ax.set_xlabel('X (mm)')
ax.set_ylabel('Y (mm)')
fig.savefig('rich_cluster_{}.png'.format(iev))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment