This code does Geometric Reconstruction (GR) in npsim simulations of the ePIC hpDIRC. It is a standalone code that compiles and runs outside the eic-shell, after you've produced simulation root files inside the shell. The code opens the two TTrees written by npsim and loops through them, keeping them in sync, to calculate thetaC (mrad) for every charged fast particle incident on the hpDIRC. This code was developed to explore the hpDIRC PID performance and to inform about viable approaches for doing this same reconstruction inside eicrecon soon.
Once you have a working eic-shell, first install ddDircAction, the stepping action plugin that writes the "incidence tree." To compile ddDircAction:
cd eic
git clone git@github.com:eic/ddDircAction.git
cd ddDircAction
mkdir build install
#---- !!! inside eic-shell !!!
cmake -B build -S . -DCMAKE_INSTALL_PREFIX=install -DCMAKE_C_COMPILER=/usr/bin/cc -DCMAKE_CXX_COMPILER=/usr/bin/g++
cmake --build build -- install
cd ..
Make sure that the ddDircAction location is added to LD_LIBRARY_PATH (update the path used to match your case):
export LD_LIBRARY_PATH=/Users/wjllope/eic/ddDircAction/install/lib:${LD_LIBRARY_PATH}
This line should be added to your local mysetup script.
To install dircGR:
cd ~/eic
git clone git@github.com:eic/dircGR.git
cd build
#---- !!! outside eic-shell !!!
cmake ..
cmake --build .
This will install the folder "dircGR" inside your "eic" subdirectory, and build the application "ddircGR_app" which will be found in ~/eic/dircGR/run/ when cmake completes.
Once the app is built, change directories to ../run/
You will notice the subdirectory named "LUT" there! Inside it are the ten look-up tables for the ten bars in each bar box. There is thus no need for you to generate LUTs. If you would like to do this anyway though, some helper files are also in dircGR/run, feel free to contact me for additional details.
Simulations are done inside the eic-shell, and we will run dircGR on the output of those outside the shell. One mode to run npsim is the "gun", where single particles with specific momenta and direction can be fired from the vertex.
You either need to install and build the epic geometry locally or you need to just set up the defaults. For the defaults:
#---- !!! inside eic-shell !!!
source /opt/detector/epic-main/bin/thisepic.sh
or, to clone and build the geometries locally:
cd eic
git clone git@github.com:eic/epic.git
cd epic
mkdir build install
#---- !!! inside eic-shell !!!
cmake -B build -S . -DCMAKE_INSTALL_PREFIX=install
cmake --build build -- install
cd ..
source install/bin/thisepic.sh
Let's throw 3 GeV pions at a polar angle of 70 degrees. The azimuthal angle is chosen for this polar angle and momentum so that the particles strike the center (in azimuth) of bar "5", one of the "middle" bars in each bar box. For convenience in the subsequent steps, i am running npsim from within the dircGR/run/ directory:
cd dircGR/run
#---- !!! inside eic-shell !!!
npsim.py --runType batch \
--printLevel WARNING \
--action.step '{"name":"ddDIRCactionStep","parameter":{"OutputBase":"sim_epic_500evt_pi+3GeV70deg.incidence", "fileNumber":1, "DetailLevel":1}}' \
--compactFile $DETECTOR_PATH/epic.xml -G -N 500 --gun.particle "pi+" \
--gun.momentumMin 3*GeV --gun.momentumMax 3*GeV --gun.phiMin 354.73*deg --gun.phiMax 354.73*deg \
--gun.thetaMin 70*deg --gun.thetaMax 70*deg --gun.distribution uniform --gun.position 0*cm,0*cm,0*cm \
--outputFile sim_epic_500evt_pi+3GeV70deg.edm4hep.root
This will take a few minutes to complete. When it does, you should see these files in this same directory:
24351777 Aug 7 14:57 sim_epic_500evt_pi+3GeV70deg.edm4hep.root
529160 Aug 7 14:57 sim_epic_500evt_pi+3GeV70deg.incidence.root
Note these files have the same basename, and the extensions 'edm4hep.root' for the standard npsim output (large file) and 'incidence.root' for the charged particle incidence information (small file).
To do the PID, you then run the *.edm4hep.root file through dircGR.
#---- !!! outside eic-shell !!!
./dircGR_app sim_epic_500evt_pi+3GeV70deg.edm4hep.root epic
The dircGR application uses the edm4hep filename given as a command line parameter to get the path to the incidence tree. Both trees are required.
After the dircGR app completes, you will now see two new files in this same directory:
sim_epic_500evt_pi+3GeV70deg.gr.pdf
sim_epic_500evt_pi+3GeV70deg.gr.root
Note the basename is the same, and the extensions are ".gr.(pdf/root)".
Pick any existing event file (these have the extension hepmc3.tree.root), and put it into eic/dircGR/run. Run npsim using this file as input, and remove all the gun commands, for example:
#---- !!! inside eic-shell !!!
time npsim -N 5000 --runType batch --printLevel WARNING \
--action.step '{"name":"ddDIRCactionStep","parameter":{"OutputBase":"dis_eicBeam_hiDiv_18x275_1to10.incidence", "fileNumber":1, "DetailLevel":1}}' \
--inputFiles dis_eicBeam_hiDiv_18x275_1to10.hepmc3.tree.root \
--compactFile $DETECTOR_PATH/epic.xml \
--outputFile dis_eicBeam_hiDiv_18x275_1to10.edm4hep.root
and this will create two files:
dis_eicBeam_hiDiv_18x275_1to10.edm4hep.root
dis_eicBeam_hiDiv_18x275_1to10.incidence.root
and you can then run these through dircGR via:
#---- !!! outside eic-shell !!!
./dircGR_app dis_eicBeam_hiDiv_18x275_1to10.edm4hep.root epic
which will create:
dis_eicBeam_hiDiv_18x275_1to10.gr.pdf
dis_eicBeam_hiDiv_18x275_1to10.gr.root
The TH2D histogram hthetaC_ptot provides a decent overview of the PID performance by plotting the Cherenkov angle (in mrad) versus the track momentum, for all particles striking any hpDIRC bar anywhere along its length. The appropriate LUT is used for each bar-incident particle; 20M OPs were used to calculate each LUT. Tight timing cuts (~1ns wide) are implemented as a function of the Z-position of the particle incidence. The OP polar angles of allowable prism paths are also required to be consistent with the known range of polar angles for hit-producing OPs created at this incidence Z-position. Chromatic corrections are applied. The thetaC resolution in the present code is approximately 4-6 mrad, which is close to expectations. Some additional improvements to the chromatic corrections are likely possible.