modified: .gitignore added Ryan's autofit routine to gitignore

This commit is contained in:
Vignesh Sitaraman 2026-08-26 12:11:58 -04:00
parent 3e60105617
commit 8cd98c35e1
4 changed files with 44 additions and 33 deletions

1
.gitignore vendored
View File

@ -37,3 +37,4 @@ EventBuilder
anasen_fem/anode_to_cathode_1d_17.43.csv anasen_fem/anode_to_cathode_1d_17.43.csv
CLAUDE.md CLAUDE.md
pc_calib_raw/ pc_calib_raw/
AutoFit.C

View File

@ -4142,6 +4142,7 @@ static void reaction_ax_core(HistPlotter *plotter, const std::vector<Event> &Si_
double ebeam_kin_3498keV = invertBeamEnergyMeV(m_beam, mass_4He, m3, m4, Efix, theta * 180 / M_PI, 3.498); double ebeam_kin_3498keV = invertBeamEnergyMeV(m_beam, mass_4He, m3, m4, Efix, theta * 180 / M_PI, 3.498);
double ebeam_kin_3774keV = invertBeamEnergyMeV(m_beam, mass_4He, m3, m4, Efix, theta * 180 / M_PI, 3.774); double ebeam_kin_3774keV = invertBeamEnergyMeV(m_beam, mass_4He, m3, m4, Efix, theta * 180 / M_PI, 3.774);
double ebeam_kin_4809keV = invertBeamEnergyMeV(m_beam, mass_4He, m3, m4, Efix, theta * 180 / M_PI, 4.809); double ebeam_kin_4809keV = invertBeamEnergyMeV(m_beam, mass_4He, m3, m4, Efix, theta * 180 / M_PI, 4.809);
double ebeam_kin_5614keV = invertBeamEnergyMeV(m_beam, mass_4He, m3, m4, Efix, theta * 180 / M_PI, 5.164);
// Gated output: only fill when this hypothesis (proton "_p" / alpha "_a") agrees // Gated output: only fill when this hypothesis (proton "_p" / alpha "_a") agrees
// with which side of the proton_locus gate the event fell on, so each event // with which side of the proton_locus gate the event fell on, so each event
@ -4162,16 +4163,18 @@ static void reaction_ax_core(HistPlotter *plotter, const std::vector<Event> &Si_
beam_energy_at_vertex, ebeam_kin_MeV, pmlabel); beam_energy_at_vertex, ebeam_kin_MeV, pmlabel);
if (ejtag == "_p") if (ejtag == "_p")
{ {
plotter->Fill2D(rx + "_BeamEnergy_ETrack_vs_EKinGS" + ejtag + t + sfx, 400, 0, beamE0 * 1.5, 400, 0, beamE0 * 1.5, plotter->Fill2D(rx + "_ETrack_vs_EKinGS" + ejtag + t + sfx, 400, 0, beamE0 * 1.5, 400, 0, beamE0 * 1.5,
beam_energy_at_vertex, ebeam_kin_GS, "ETrackvsKin_assumed"); beam_energy_at_vertex, ebeam_kin_GS, "ETrackvsKin_assumed");
plotter->Fill2D(rx + "_BeamEnergy_ETrack_vs_EKin2235keV" + ejtag + t + sfx, 400, 0, beamE0 * 1.5, 400, 0, beamE0 * 1.5, plotter->Fill2D(rx + "_ETrack_vs_EKin2235keV" + ejtag + t + sfx, 400, 0, beamE0 * 1.5, 400, 0, beamE0 * 1.5,
beam_energy_at_vertex, ebeam_kin_2235keV, "ETrackvsKin_assumed"); beam_energy_at_vertex, ebeam_kin_2235keV, "ETrackvsKin_assumed");
plotter->Fill2D(rx + "_BeamEnergy_ETrack_vs_EKin3498kev" + ejtag + t + sfx, 400, 0, beamE0 * 1.5, 400, 0, beamE0 * 1.5, plotter->Fill2D(rx + "_ETrack_vs_EKin3498kev" + ejtag + t + sfx, 400, 0, beamE0 * 1.5, 400, 0, beamE0 * 1.5,
beam_energy_at_vertex, ebeam_kin_3498keV, "ETrackvsKin_assumed"); beam_energy_at_vertex, ebeam_kin_3498keV, "ETrackvsKin_assumed");
plotter->Fill2D(rx + "_BeamEnergy_ETrack_vs_EKin3774keV" + ejtag + t + sfx, 400, 0, beamE0 * 1.5, 400, 0, beamE0 * 1.5, plotter->Fill2D(rx + "_ETrack_vs_EKin3774keV" + ejtag + t + sfx, 400, 0, beamE0 * 1.5, 400, 0, beamE0 * 1.5,
beam_energy_at_vertex, ebeam_kin_3774keV, "ETrackvsKin_assumed"); beam_energy_at_vertex, ebeam_kin_3774keV, "ETrackvsKin_assumed");
plotter->Fill2D(rx + "_BeamEnergy_ETrack_vs_EKin4809keV" + ejtag + t + sfx, 400, 0, beamE0 * 1.5, 400, 0, beamE0 * 1.5, plotter->Fill2D(rx + "_ETrack_vs_EKin4809keV" + ejtag + t + sfx, 400, 0, beamE0 * 1.5, 400, 0, beamE0 * 1.5,
beam_energy_at_vertex, ebeam_kin_4809keV, "ETrackvsKin_assumed"); beam_energy_at_vertex, ebeam_kin_4809keV, "ETrackvsKin_assumed");
plotter->Fill2D(rx + "_ETrack_vs_EKin5614keV" + ejtag + t + sfx, 400, 0, beamE0 * 1.5, 400, 0, beamE0 * 1.5,
beam_energy_at_vertex, ebeam_kin_5614keV, "ETrackvsKin_assumed");
} }
}; };

View File

@ -8,14 +8,9 @@ export CO2percent=3
export pressure_in_torr=250 export pressure_in_torr=250
export CATHODE_GAIN=3.0 export CATHODE_GAIN=3.0
export source_vertex=-200.0 export source_vertex=-200.0
export DEDX_SCALE=0.80 export DEDX_SCALE=0.89
# export BEAM_AXIS_X=-15
# export BEAM_AXIS_Y=-5
export CUTLIST=cuts_list.txt export CUTLIST=cuts_list.txt
# Clean up previous runs
echo "Pre-compiling TrackRecon.C safely on a single core..." echo "Pre-compiling TrackRecon.C safely on a single core..."
root -q -l -b -e '.L TrackRecon.C++O' root -q -l -b -e '.L TrackRecon.C++O'
@ -23,15 +18,16 @@ process_run() {
local wrun=$(printf "%03d" "$1") local wrun=$(printf "%03d" "$1")
local prefix="${PREFIX:-Run_}" local prefix="${PREFIX:-Run_}"
local infile="../ANASEN_analysis/data/${DATASET}_Data/${prefix}${wrun}_mapped.root" local infile="../ANASEN_analysis/data/${DATASET}_Data/${prefix}${wrun}_mapped.root"
local out="Output_27Al_$DEDX_SCALE/results_run${wrun}.root"
mkdir -p Output_27Al_$DEDX_SCALE # Dynamically point to the correct output directory for this X/Y iteration
local current_out_dir="Output_27Al_X${BEAM_AXIS_X}_Y${BEAM_AXIS_Y}"
local out="${current_out_dir}/results_run${wrun}.root"
root -q -l -b -x "$infile" \ root -q -l -b -x "$infile" \
-e "tree->Process(\"TrackRecon.C+\", \"${out}\")" > /dev/null 2>&1 -e "tree->Process(\"TrackRecon.C+\", \"${out}\")" > /dev/null 2>&1
if [ -f "$out" ]; then if [ -f "$out" ]; then
echo "Run $wrun completed successfully in Output_27Al." echo "Run $wrun completed successfully in ${current_out_dir}."
else else
echo "ERROR: Run $wrun failed to generate $out" echo "ERROR: Run $wrun failed to generate $out"
fi fi
@ -39,30 +35,37 @@ process_run() {
export -f process_run export -f process_run
for i in 0.75 0.80 0.85 0.87 0.88 0.89 0.90 0.91 0.92 0.95 1.00 1.05 1.10 1.15 for x in -5 5
do do
DEDX_SCALE=$i export BEAM_AXIS_X=$x
rm -f Output_27Al_$DEDX_SCALE/*.root for y in -5 5
do
export BEAM_AXIS_Y=$y
echo "Running Eloss.py with a scaling parameter of $DEDX_SCALE" # Define and create a clean directory name BEFORE running parallel tasks
python3 eloss_calculations/Eloss.py CURRENT_OUT_DIR="Output_27Al_X${BEAM_AXIS_X}_Y${BEAM_AXIS_Y}"
echo "Starting parallel processing..." mkdir -p "$CURRENT_OUT_DIR"
time parallel --bar -j 10 process_run ::: {24..41} echo "Running Eloss.py with a scaling parameter of $DEDX_SCALE"
time parallel --bar -j 3 process_run ::: 44 45 46 echo "running with a beam offset of $BEAM_AXIS_X $BEAM_AXIS_Y"
time parallel --bar -j 8 process_run ::: {50..59} python3 eloss_calculations/Eloss.py
echo "Starting parallel processing..."
time parallel --bar -j 10 process_run ::: {24..41}
time parallel --bar -j 3 process_run ::: 44 45 46
time parallel --bar -j 8 process_run ::: {50..59}
# time parallel --bar -j 4 process_run ::: 62 63 66 67 68 # time parallel --bar -j 4 process_run ::: 62 63 66 67 68
# time parallel --bar -j 1 process_run ::: 73 # time parallel --bar -j 1 process_run ::: 73
# time parallel --bar -j 1 process_run ::: 74 # time parallel --bar -j 1 process_run ::: 74
# time parallel --bar -j 4 process_run ::: {78..89} # time parallel --bar -j 4 process_run ::: {78..89}
echo "Merging files..." echo "Merging files..."
hadd -k -j 4 Output_27Al_$DEDX_SCALE/output_27Al.root Output_27Al_$DEDX_SCALE/results_run*.root # Fixed: Safely merge using the clean directory variable (added -f to overwrite if re-running)
hadd -k -f -j 4 "${CURRENT_OUT_DIR}/output_27Al.root" "${CURRENT_OUT_DIR}/results_run"*.root
done
done done
# rootbrowse Output_27Al/output_27Al.root # Cleanup
unset DATASET unset DATASET
unset PREFIX unset PREFIX
unset OUT_DIR unset OUT_DIR
@ -79,4 +82,5 @@ unset BEAM_AXIS_X
unset BEAM_AXIS_Y unset BEAM_AXIS_Y
unset CUTLIST unset CUTLIST
unset DEDX_SCALE unset DEDX_SCALE
unset CURRENT_OUT_DIR
echo "Script execution finished." echo "Script execution finished."

View File

@ -194,7 +194,10 @@ void make_prettyplots(const char *rootFile,
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Multi-File Overlay Function // Multi-File Overlay Function
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void make_prettyplots(TString filesCSV, TString labelsCSV, TString histName, TString xAxisLabel="", TString yAxisLabel="", double yMin=-9999, double yMax=-9999, double xMin=-9999, double xMax=-9999) // NOTE: canvasW/canvasH added as trailing optional args (default = old
// hardcoded values, so every existing call site keeps working unchanged).
// Pass larger values for a bigger/higher-resolution output image.
void make_prettyplots(TString filesCSV, TString labelsCSV, TString histName, TString xAxisLabel="", TString yAxisLabel="", double yMin=-9999, double yMax=-9999, double xMin=-9999, double xMax=-9999, int canvasW=2100, int canvasH=1575)
{ {
SetStyle(); SetStyle();
@ -259,7 +262,7 @@ void make_prettyplots(TString filesCSV, TString labelsCSV, TString histName, TSt
} }
// --- Draw --- // --- Draw ---
TCanvas c("c", "", 0, 0, 2100, 1575); TCanvas c("c", "", 0, 0, canvasW, canvasH);
c.cd(); c.cd();
// Create Legend (Positioned top right) // Create Legend (Positioned top right)