From 5824fa7148029a8d8a0690c23848bd10050d6196 Mon Sep 17 00:00:00 2001 From: vsitaraman Date: Mon, 8 Jun 2026 11:32:39 -0400 Subject: [PATCH] modified: TrackRecon.C made variables to account for variable energy loss in 27Al and 17F runs due to beamline components modified: run_17F.sh made all outputs direct to specific folders for clarity and to avoid overwriting results from different datasets modified: run_27Al.sh made output folder format consitent across datasets modified: run_tr.sh made output folder format consitent across datasets --- TrackRecon.C | 50 ++++++++++++++++++++++++------------------ run_17F.sh | 4 ++-- run_27Al.sh | 4 ++-- run_tr.sh | 61 ++++++++++++++++++++++++++-------------------------- 4 files changed, 64 insertions(+), 55 deletions(-) diff --git a/TrackRecon.C b/TrackRecon.C index 657e314..0c0491e 100644 --- a/TrackRecon.C +++ b/TrackRecon.C @@ -49,6 +49,7 @@ const double qqq_z = 100.0; double z_entrance = -174.3 - 9.7 - 100.0; const double anode_gain = 1.5146e-5; // channels --> MeV std::string dataset; +int CO2percent; bool reactiondata = false; TF1 pcfix_func("func", model_invert, -200, 200); @@ -166,7 +167,7 @@ void TrackRecon::Begin(TTree * /*tree*/) dataset = std::string(getenv("DATASET")); if (getenv("source_vertex")) source_vertex = (double)std::atof(std::string(getenv("source_vertex")).c_str()); - + if (getenv("CO2percent")) CO2percent = (double)std::atof((getenv("CO2percent"))); std::cout << "CO2 percent set to " << CO2percent << std::endl; @@ -264,25 +265,25 @@ void TrackRecon::Begin(TTree * /*tree*/) } // ------------- ELOSS Correction read in from tables ------------- -if (CO2percent == 3.0) { - MeV_to_cm = new TGraph("eloss_calculations/alpha_lookup_20MeV_3pc.dat", "%lf %*lf %lf"); - MeV_to_cm_p = new TGraph("eloss_calculations/proton_lookup_20MeV_3pc.dat", "%lf %*lf %lf"); - MeV_to_cm_27Al = new TGraph("eloss_calculations/aluminum_lookup_80MeV_3pc.dat", "%lf %*lf %lf"); - MeV_to_cm_17F = new TGraph("eloss_calculations/fluorine_lookup_70MeV_3pc.dat", "%lf %*lf %lf"); -} - -if (CO2percent == 4.0) { - MeV_to_cm = new TGraph("eloss_calculations/alpha_lookup_20MeV_4pc.dat", "%lf %*lf %lf"); - MeV_to_cm_p = new TGraph("eloss_calculations/proton_lookup_20MeV_4pc.dat", "%lf %*lf %lf"); - MeV_to_cm_27Al = new TGraph("eloss_calculations/aluminum_lookup_80MeV_4pc.dat", "%lf %*lf %lf"); - MeV_to_cm_17F = new TGraph("eloss_calculations/fluorine_lookup_70MeV_4pc.dat", "%lf %*lf %lf"); -} + if (CO2percent == 4) + { + MeV_to_cm = new TGraph("eloss_calculations/alpha_lookup_20MeV_4pc.dat", "%lf %*lf %lf"); + MeV_to_cm_p = new TGraph("eloss_calculations/proton_lookup_20MeV_4pc.dat", "%lf %*lf %lf"); + MeV_to_cm_27Al = new TGraph("eloss_calculations/aluminum_lookup_80MeV_4pc.dat", "%lf %*lf %lf"); + MeV_to_cm_17F = new TGraph("eloss_calculations/fluorine_lookup_70MeV_4pc.dat", "%lf %*lf %lf"); + } + else + { + MeV_to_cm = new TGraph("eloss_calculations/alpha_lookup_20MeV_3pc.dat", "%lf %*lf %lf"); + MeV_to_cm_p = new TGraph("eloss_calculations/proton_lookup_20MeV_3pc.dat", "%lf %*lf %lf"); + MeV_to_cm_27Al = new TGraph("eloss_calculations/aluminum_lookup_80MeV_3pc.dat", "%lf %*lf %lf"); + MeV_to_cm_17F = new TGraph("eloss_calculations/fluorine_lookup_70MeV_3pc.dat", "%lf %*lf %lf"); + } cm_to_MeV = new TGraph(MeV_to_cm->GetN(), MeV_to_cm->GetY(), MeV_to_cm->GetX()); cm_to_MeVp = new TGraph(MeV_to_cm_p->GetN(), MeV_to_cm_p->GetY(), MeV_to_cm_p->GetX()); cm_to_MeV_27Al = new TGraph(MeV_to_cm_27Al->GetN(), MeV_to_cm_27Al->GetY(), MeV_to_cm_27Al->GetX()); cm_to_MeV_17F = new TGraph(MeV_to_cm_17F->GetN(), MeV_to_cm_17F->GetY(), MeV_to_cm_17F->GetX()); - } Bool_t TrackRecon::Process(Long64_t entry) @@ -2033,9 +2034,9 @@ void miscHistograms_oneWire(HistPlotter *plotter, std::vector QQQ_Events, { // consider the 'proton-like' QQQ branch seen in a,p data TRandom3 rand; - rand.SetSeed(); // random seed set - Kinematics apkin_a(1.008664916, 4.002603254, 4.002603254, 1.008664916, 6.34); // m3 is alpha, 6.411 MeV is 7.0 MeV proton energy after havar+kapton+100mm 4He gas (molar mass 5.2, 250 torr) - // Kinematics apkin_a(1.008664916, 4.002603254, 4.002603254, 1.008664916, 6.79); // m3 is alpha, 6.79 MeV is 7.0 MeV proton energy after kapton+100mm 4He gas (molar mass 5.2, 250 torr) + rand.SetSeed(); // random seed set + // Kinematics apkin_a(1.008664916, 4.002603254, 4.002603254, 1.008664916, 6.34); // m3 is alpha, 6.411 MeV is 7.0 MeV proton energy after havar+mylar+kapton+100mm 4He gas (molar mass 5.3, 250 torr) + Kinematics apkin_a(1.008664916, 4.002603254, 4.002603254, 1.008664916, 6.79); // m3 is alpha, 6.79 MeV is 7.0 MeV proton energy after kapton+100mm 4He gas (molar mass 5.2, 250 torr) for (auto qqqevent : QQQ_Events) { if (qqqevent.Energy1 < 0.6) @@ -2120,9 +2121,16 @@ void protonMiscHistograms(HistPlotter *plotter, std::vector QQQ_Events, s { // consider the 'proton-like' QQQ branch seen in a,p data TRandom3 rand; - rand.SetSeed(); // random seed set - Kinematics apkin_a(1.008664916, 4.002603254, 4.002603254, 1.008664916, 6.34); // m3 is alpha, 6.411 MeV is 7.0 MeV proton energy after Havar+kapton+100mm 4He gas (molar mass 5.2, 250 torr) - // Kinematics apkin_a(1.008664916, 4.002603254, 4.002603254, 1.008664916, 6.79); // m3 is alpha, 6.79 MeV is 7.0 MeV proton energy after kapton+100mm 4He gas (molar mass 5.2, 250 torr) + rand.SetSeed(); // random seed set + double initial_energy = 7.0; + if (dataset == "27Al") + initial_energy = 6.79; // m3 is alpha, 6.79 MeV is 7.0 MeV proton energy after kapton+100mm 4He gas (molar mass 5.2, 250 torr) + if (dataset == "17F") + initial_energy = 6.34; // m3 is alpha, 6.411 MeV is 7.0 MeV proton energy after Havar+kapton+100mm 4He gas (molar mass 5.2, 250 torr) + + Kinematics apkin_a(1.008664916, 4.002603254, 4.002603254, 1.008664916, initial_energy); // m3 is alpha + + TF1 pcfix_func("pcfix_func", "pol2", -200, 200); for (auto qqqevent : QQQ_Events) { if (qqqevent.Energy1 < 0.6) diff --git a/run_17F.sh b/run_17F.sh index 347a84b..7e62469 100644 --- a/run_17F.sh +++ b/run_17F.sh @@ -16,7 +16,7 @@ function run_once() { wrun=$(printf "%03d" $1) file_exists=$(test -f ../ANASEN_analysis/data/17F_Data/Run_"$wrun"_mapped.root) if [[ $file_exists -ne 0 ]]; then continue; fi - root -q -l -b -x ../ANASEN_analysis/data/17F_Data/Run_"$wrun"_mapped.root -e 'tree->Process("TrackRecon.C+O","Analyzer_17F.root")'; mv Analyzer_17F.root 17F_output/results_run$wrun.root; + root -q -l -b -x ../ANASEN_analysis/data/17F_Data/Run_"$wrun"_mapped.root -e 'tree->Process("TrackRecon.C+O","Analyzer_17F.root")'; mv Analyzer_17F.root Output_17F/results_run$wrun.root; } export -f run_once @@ -24,7 +24,7 @@ export -f run_once # parallel -j 6 --ctag run_once {1} ::: {325..400} parallel -j 6 --ctag run_once {1} ::: {351,353,355,358,359,360,362,367} rm output_17F.root -hadd -j 4 -k output_17F.root 17F_output/results_run3*.root +hadd -j 4 -k output_17F.root Output_17F/results_run3*.root unset souce_vertex unset DATASET diff --git a/run_27Al.sh b/run_27Al.sh index cf084a6..5d7178c 100644 --- a/run_27Al.sh +++ b/run_27Al.sh @@ -10,7 +10,7 @@ root -q -l -b -e '.L TrackRecon.C++O' process_run() { local wrun=$(printf "%03d" $1) - local out="27Al_output/results_run${wrun}.root" + local out="Output_27Al/results_run${wrun}.root" root -q -l -b -x "../ANASEN_analysis/data/27Al_Data/Run_${wrun}_mapped.root" \ -e "tree->Process(\"TrackRecon.C+\", \"${out}\")" > /dev/null 2>&1 @@ -28,6 +28,6 @@ echo "Starting parallel processing..." parallel --bar -j 4 process_run ::: {50..52} echo "Merging files..." -hadd -k -j 4 output_27Al.root 27Al_output/results_run*.root +hadd -k -j 4 output_27Al.root Output_27Al/results_run*.root unset DATASET \ No newline at end of file diff --git a/run_tr.sh b/run_tr.sh index a386b31..76db628 100644 --- a/run_tr.sh +++ b/run_tr.sh @@ -10,27 +10,31 @@ root -q -l -b -e '.L TrackRecon.C++O' # Function to process a single run process_run() { local wrun=$(printf "%03d" "$1") - # Use PREFIX if set, otherwise default to "Run_" local prefix="${PREFIX:-Run_}" - local out="source_run${wrun}.root" + local outdir="${OUT_DIR:-output}" # Defaults to 'output' if OUT_DIR is not set + local out="$Output_{outdir}/results_run${wrun}.root" - root -q -l -b -x "../ANASEN_analysis/data/${DATASET}/${prefix}${wrun}_mapped.root" \ + # Ensure the directory exists so ROOT doesn't fail silently + mkdir -p "$outdir" + + root -q -l -b -x "../ANASEN_analysis/data/${DATASET}_Data/${prefix}${wrun}_mapped.root" \ -e "tree->Process(\"TrackRecon.C+\", \"${out}\")" > /dev/null 2>&1 if [ -f "$out" ]; then - echo "Run $wrun completed successfully." + echo "Run $wrun completed successfully in $outdir." else echo "ERROR: Run $wrun failed to generate $out" fi } export -f process_run +export -f process_run +export CO2percent=3 # --- Block 1: 27Al Source Runs No Gas (1-8) --- if [[ 1 -eq 0 ]]; then - export DATASET="27Al_Data" + export DATASET="27Al" export PREFIX="Run_" - export CO2percent=3.0 - + export OUT_DIR="av" echo "Starting parallel processing for 27Al runs..." rm -f p_output/all.root @@ -39,12 +43,11 @@ fi # --- Block 2: 27Al Alpha+Gas Runs (9, 12) --- if [[ 1 -eq 0 ]]; then - export DATASET="27Al_Data" + export DATASET="27Al" export PREFIX="Run_" export timecut_low=400.0 export source_vertex=53.44 - export CO2percent=3.0 - + export OUT_DIR="a" echo "Processing 27Al alpha+gas runs..." parallel --bar -j 6 process_run ::: 9 12 @@ -52,36 +55,34 @@ if [[ 1 -eq 0 ]]; then fi # --- Block 3: 27Al Protons+Gas Runs (15, 17-22) --- -if [[ 1 -eq 0 ]]; then - export DATASET="27Al_Data" +if [[ 1 -eq 1 ]]; then + export DATASET="27Al" export PREFIX="Run_" + export OUT_DIR="p" export source_vertex=-200.0 # Source on the entrance window - export CO2percent=3.0 echo "Starting parallel processing for 27Al proton runs..." - rm -f p_output/all.root - + # rm -f p_output/all.root + parallel --bar -j 6 process_run ::: 15 {17..22} - - # Uncomment to merge via hadd when ready - # hadd -j 4 -k p_output/all.root p_output/results_run*.root - exit + hadd -j 4 -k p_output/Al_protons.root p_output/results_run0{17..22}.root fi # --- Block 4: 17F Source Runs (5-14) --- if [[ 1 -eq 0 ]]; then - export DATASET="17F_Data" + export DATASET="17F" export PREFIX="Source_" + export OUT_DIR="av" echo "Starting parallel processing for 17F source runs..." - rm -f p_output/all.root + # rm -f p_output/all.root parallel --bar -j 6 process_run ::: {5..13} fi # --- Block 5: 17F Alpha Run with Gas (18-21) --- if [[ 1 -eq 0 ]]; then - export DATASET="17F_Data" + export DATASET="17F" export PREFIX="SourceRun_" - export CO2percent=3.0 + export OUT_DIR="a" echo "Processing 17F alpha runs with dynamic source vertices..." # Running sequentially since the source_vertex variable changes per run @@ -93,17 +94,16 @@ fi # --- Block 6: 17F Proton Data --- if [[ 1 -eq 1 ]]; then - export DATASET="17F_Data" + export DATASET="17F" export PREFIX="ProtonRun_" - + export OUT_DIR="p" export source_vertex=-57.28 - export CO2percent=4.0 - # parallel --bar -j 6 process_run ::: {38..42} #4% CO2 - export CO2percent=3.0 parallel --bar -j 6 process_run ::: {44..48} #3CO2 - # hadd -j 4 -k p_output/all.root p_output/results_run*.root + hadd -j 4 -k p_output/3pc.root p_output/results_run0{44..48}.root + export CO2percent=4 + parallel --bar -j 6 process_run ::: {38..42} #4% CO2 + hadd -j 4 -k p_output/4pc.root p_output/results_run0{38..42}.root exit - fi # ========================================== @@ -115,6 +115,7 @@ unset anode_offset unset cathode_offset unset source_vertex # Fixed typo here unset DATASET +unset OUT_DIR unset PREFIX unset flip180 unset timecut_low