From a64d45e081910a5b7092aacfbe8817b46798551d Mon Sep 17 00:00:00 2001 From: vsitaraman Date: Wed, 3 Jun 2026 11:46:07 -0400 Subject: [PATCH] modified: TrackRecon.C changed the nA analyssis to be a little more efficient modified: run_17F.sh --- TrackRecon.C | 69 +++++++++++++++++++++++++--------------------------- run_17F.sh | 63 +++++++++++++++-------------------------------- 2 files changed, 53 insertions(+), 79 deletions(-) diff --git a/TrackRecon.C b/TrackRecon.C index 0a5e757..a7fd31c 100644 --- a/TrackRecon.C +++ b/TrackRecon.C @@ -4,6 +4,7 @@ // #define VTX_GATES #define AL_BEAM // #define F_BEAM +#define nA_analysis Int_t colors[40] = { kBlack, kRed, kGreen, kBlue, kYellow, kMagenta, kCyan, kOrange, @@ -39,6 +40,7 @@ bool process_alpha_proton_scattering = true; bool doPCSX3ClusterAnalysis = true; bool doPCQQQClusterAnalysis = true; bool do27AlapAnalysis = true; +bool doOldAnalysis = false; double source_vertex = 53; // 53 const double qqq_z = 100.0; double z_entrance = -174.3 - 9.7 - 100.0; @@ -131,6 +133,7 @@ bool qqqEcut; void protonAlphaHistograms(HistPlotter *plotter, std::vector QQQ_Events, std::vector SX3_Events, std::vector PC_Events); void PCSX3ClusterAnalysis(HistPlotter *plotter, std::vector QQQ_Events, std::vector SX3_Events, std::vector PC_Events); void PCQQQClusterAnalysis(HistPlotter *plotter, std::vector QQQ_Events, std::vector SX3_Events, std::vector PC_Events); +void OldAnalysis(); void TrackRecon::Begin(TTree * /*tree*/) { @@ -877,34 +880,35 @@ Bool_t TrackRecon::Process(Long64_t entry) } ///////////////////nA analysis using pseudo-wire (GetPseudoWire + getClosestWirePosAtWirePhi)/////////////////// + +#ifdef nA_analysis if (aClusters.size() > 0) { - // --------------------------------------------------------- - // PROTON LOOP (SX3 BARREL) - // --------------------------------------------------------- - for (auto sx3event : SX3_Events) - { - // Pick the anode cluster closest in phi to this SX3 hit - const std::vector> *bestCluster = &aClusters[0]; - double bestDphi = 9999.0; + std::vector precomputedPW; + precomputedPW.reserve(aClusters.size()); + for (const auto &acluster : aClusters) + precomputedPW.push_back(pwinstance.GetPseudoWire(acluster, "ANODE")); - for (const auto &acluster : aClusters) + for (const auto &sx3event : SX3_Events) + { + double bestDphi = 9999.0; + size_t bestIdx = 0; + auto bestPW = precomputedPW[0]; + TVector3 pcz_intersect = pwinstance.getClosestWirePosAtWirePhi(std::get<0>(bestPW), sx3event.pos.Phi()); + + for (size_t j = 0; j < aClusters.size(); j++) { - auto [pw, sumE, maxE, tsMax] = pwinstance.GetPseudoWire(acluster, "ANODE"); - TVector3 pos = pwinstance.getClosestWirePosAtWirePhi(pw, sx3event.pos.Phi()); + TVector3 pos = pwinstance.getClosestWirePosAtWirePhi(std::get<0>(precomputedPW[j]), sx3event.pos.Phi()); double dphi = TMath::Abs(TVector2::Phi_mpi_pi(sx3event.pos.Phi() - pos.Phi())); if (dphi < bestDphi) { bestDphi = dphi; - bestCluster = &acluster; + bestIdx = j; + pcz_intersect = pos; } } - - // Extract the virtual wire specifically for the best cluster - auto [apwire, apSumE, apMaxE, apTSMaxE] = pwinstance.GetPseudoWire(*bestCluster, "ANODE"); - std::string nA_label = std::to_string(bestCluster->size()) + "A"; - - TVector3 pcz_intersect = pwinstance.getClosestWirePosAtWirePhi(apwire, sx3event.pos.Phi()); + auto [apwire, apSumE, apMaxE, apTSMaxE] = precomputedPW[bestIdx]; + std::string nA_label = std::to_string(aClusters[bestIdx].size()) + "A"; double deltaRho = sx3event.pos.Perp() - pcz_intersect.Perp(); double deltaZ = sx3event.pos.Z() - pcz_intersect.Z(); @@ -972,33 +976,26 @@ Bool_t TrackRecon::Process(Long64_t entry) // } } - // --------------------------------------------------------- - // PROTON LOOP (QQQ ENDCAP) - // --------------------------------------------------------- - for (auto qqqevent : QQQ_Events) + for (const auto &qqqevent : QQQ_Events) { - const std::vector> *bestCluster = nullptr; double bestDphi = 9999.0; + size_t bestIdx = 0; + auto bestPW = precomputedPW[0]; + TVector3 pcz_intersect; - for (const auto &acluster : aClusters) + for (size_t j = 0; j < aClusters.size(); j++) { - auto [apw, sumE, maxE, tsMax] = pwinstance.GetPseudoWire(acluster, "ANODE"); - TVector3 pcPos = pwinstance.getClosestWirePosAtWirePhi(apw, qqqevent.pos.Phi()); - double dphi = TMath::Abs(TVector2::Phi_mpi_pi(qqqevent.pos.Phi() - pcPos.Phi())); + TVector3 pos = pwinstance.getClosestWirePosAtWirePhi(std::get<0>(precomputedPW[j]), qqqevent.pos.Phi()); + double dphi = TMath::Abs(TVector2::Phi_mpi_pi(qqqevent.pos.Phi() - pos.Phi())); if (dphi < bestDphi) { bestDphi = dphi; - bestCluster = &acluster; + bestIdx = j; + pcz_intersect = pos; } } - if (!bestCluster) - continue; - - // Extract the virtual wire specifically for the best cluster - auto [apwire, apSumE, apMaxE, apTSMaxE] = pwinstance.GetPseudoWire(*bestCluster, "ANODE"); - std::string nA_label = std::to_string(bestCluster->size()) + "A"; - - TVector3 pcz_intersect = pwinstance.getClosestWirePosAtWirePhi(apwire, qqqevent.pos.Phi()); + auto [apwire, apSumE, apMaxE, apTSMaxE] = precomputedPW[bestIdx]; + std::string nA_label = std::to_string(aClusters[bestIdx].size()) + "A"; double deltaRho = qqqevent.pos.Perp() - pcz_intersect.Perp(); double deltaZ = qqqevent.pos.Z() - pcz_intersect.Z(); diff --git a/run_17F.sh b/run_17F.sh index 85f75b7..8f77f9f 100644 --- a/run_17F.sh +++ b/run_17F.sh @@ -1,57 +1,34 @@ rm results_run*.root export DATASET="17F" -export flip180="0" -export flipa=0 -export anode_offset=2 -export cathode_offset=0 -export productionrun=1 -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/Source_005_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run05.root; -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/Source_006_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run06.root; -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/Source_007_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run07.root; -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/Source_008_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run08.root; -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/Source_009_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run09.root; -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/Source_010_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run10.root; -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/Source_011_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run11.root; -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/Source_012_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run12.root; -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/Source_013_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run13.root; -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/Source_014_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run14.root; - -#17F pulser runs -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/PulserRun_015_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run15.root; -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/PulserRun_016_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run16.root; -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/PulserRun_017_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run17.root; - -#17F alpha run with gas -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/SourceRun_018_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run18.root; -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/SourceRun_019_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run19.root; -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/SourceRun_020_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run20.root; -#root -q -l -b -x ../ANASEN_analysis/data/17F_Data/SourceRun_021_mapped.root -e 'tree->Process("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run21.root; +export reactiondata=1 #17F reaction data -# export flip180="0" -declare -i run=322 #49 -# while [[ $run -lt 399 ]]; do #392 -# wrun=$(printf "%03d" $run) -# 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("MakeVertex.C+O","Analyzer_17F.root")'; mv Analyzer_17F.root 17F_output/results_run$wrun.root; -# run=run+1 -# done +#declare -i run=231 #49 +#while [[ $run -lt 258 ]]; do #392 +# wrun=$(printf "%03d" $run) +# 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("MakeVertex.C+O")'; mv Analyzer_SX3.root results_run$wrun.root; +# run=run+1 +#done -while [[ $run -lt 323 ]]; do #392 - wrun=$(printf "%03d" $run) +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("VertexRecon.C+O","Analyzer_17F.root")'; mv Analyzer_17F.root 17F_output/results_run$wrun.root; - run=run+1 -done + 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; + mv analyzed_run$wrun.root results_run$wrun.root; +} -rm output.root -hadd -k -j 4 output.root 17F_output/results_run*.root -mv output.root output_17F.root +export -f run_once +run_once 351 +# parallel -j 6 --ctag run_once {1} ::: {350..400} +rm output_17F.root +hadd -j 4 -k output_17F.root results_run3*.root unset souce_vertex unset DATASET unset flip180 unset flipa unset anode_offset +unset reactiondata