modified: TrackRecon.C changed the nA analyssis to be a little more efficient

modified:   run_17F.sh
This commit is contained in:
Vignesh Sitaraman 2026-06-03 11:46:07 -04:00
parent 254402b4cc
commit a64d45e081
2 changed files with 53 additions and 79 deletions

View File

@ -4,6 +4,7 @@
// #define VTX_GATES // #define VTX_GATES
#define AL_BEAM #define AL_BEAM
// #define F_BEAM // #define F_BEAM
#define nA_analysis
Int_t colors[40] = { Int_t colors[40] = {
kBlack, kRed, kGreen, kBlue, kYellow, kMagenta, kCyan, kOrange, kBlack, kRed, kGreen, kBlue, kYellow, kMagenta, kCyan, kOrange,
@ -39,6 +40,7 @@ bool process_alpha_proton_scattering = true;
bool doPCSX3ClusterAnalysis = true; bool doPCSX3ClusterAnalysis = true;
bool doPCQQQClusterAnalysis = true; bool doPCQQQClusterAnalysis = true;
bool do27AlapAnalysis = true; bool do27AlapAnalysis = true;
bool doOldAnalysis = false;
double source_vertex = 53; // 53 double source_vertex = 53; // 53
const double qqq_z = 100.0; const double qqq_z = 100.0;
double z_entrance = -174.3 - 9.7 - 100.0; double z_entrance = -174.3 - 9.7 - 100.0;
@ -131,6 +133,7 @@ bool qqqEcut;
void protonAlphaHistograms(HistPlotter *plotter, std::vector<Event> QQQ_Events, std::vector<Event> SX3_Events, std::vector<Event> PC_Events); void protonAlphaHistograms(HistPlotter *plotter, std::vector<Event> QQQ_Events, std::vector<Event> SX3_Events, std::vector<Event> PC_Events);
void PCSX3ClusterAnalysis(HistPlotter *plotter, std::vector<Event> QQQ_Events, std::vector<Event> SX3_Events, std::vector<Event> PC_Events); void PCSX3ClusterAnalysis(HistPlotter *plotter, std::vector<Event> QQQ_Events, std::vector<Event> SX3_Events, std::vector<Event> PC_Events);
void PCQQQClusterAnalysis(HistPlotter *plotter, std::vector<Event> QQQ_Events, std::vector<Event> SX3_Events, std::vector<Event> PC_Events); void PCQQQClusterAnalysis(HistPlotter *plotter, std::vector<Event> QQQ_Events, std::vector<Event> SX3_Events, std::vector<Event> PC_Events);
void OldAnalysis();
void TrackRecon::Begin(TTree * /*tree*/) void TrackRecon::Begin(TTree * /*tree*/)
{ {
@ -877,34 +880,35 @@ Bool_t TrackRecon::Process(Long64_t entry)
} }
///////////////////nA analysis using pseudo-wire (GetPseudoWire + getClosestWirePosAtWirePhi)/////////////////// ///////////////////nA analysis using pseudo-wire (GetPseudoWire + getClosestWirePosAtWirePhi)///////////////////
#ifdef nA_analysis
if (aClusters.size() > 0) if (aClusters.size() > 0)
{ {
// --------------------------------------------------------- std::vector<decltype(pwinstance.GetPseudoWire(aClusters[0], "ANODE"))> precomputedPW;
// PROTON LOOP (SX3 BARREL) precomputedPW.reserve(aClusters.size());
// ---------------------------------------------------------
for (auto sx3event : SX3_Events)
{
// Pick the anode cluster closest in phi to this SX3 hit
const std::vector<std::tuple<int, double, double>> *bestCluster = &aClusters[0];
double bestDphi = 9999.0;
for (const auto &acluster : aClusters) for (const auto &acluster : aClusters)
precomputedPW.push_back(pwinstance.GetPseudoWire(acluster, "ANODE"));
for (const auto &sx3event : SX3_Events)
{ {
auto [pw, sumE, maxE, tsMax] = pwinstance.GetPseudoWire(acluster, "ANODE"); double bestDphi = 9999.0;
TVector3 pos = pwinstance.getClosestWirePosAtWirePhi(pw, sx3event.pos.Phi()); 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++)
{
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())); double dphi = TMath::Abs(TVector2::Phi_mpi_pi(sx3event.pos.Phi() - pos.Phi()));
if (dphi < bestDphi) if (dphi < bestDphi)
{ {
bestDphi = dphi; bestDphi = dphi;
bestCluster = &acluster; bestIdx = j;
pcz_intersect = pos;
} }
} }
auto [apwire, apSumE, apMaxE, apTSMaxE] = precomputedPW[bestIdx];
// Extract the virtual wire specifically for the best cluster std::string nA_label = std::to_string(aClusters[bestIdx].size()) + "A";
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());
double deltaRho = sx3event.pos.Perp() - pcz_intersect.Perp(); double deltaRho = sx3event.pos.Perp() - pcz_intersect.Perp();
double deltaZ = sx3event.pos.Z() - pcz_intersect.Z(); double deltaZ = sx3event.pos.Z() - pcz_intersect.Z();
@ -972,33 +976,26 @@ Bool_t TrackRecon::Process(Long64_t entry)
// } // }
} }
// --------------------------------------------------------- for (const auto &qqqevent : QQQ_Events)
// PROTON LOOP (QQQ ENDCAP)
// ---------------------------------------------------------
for (auto qqqevent : QQQ_Events)
{ {
const std::vector<std::tuple<int, double, double>> *bestCluster = nullptr;
double bestDphi = 9999.0; 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 pos = pwinstance.getClosestWirePosAtWirePhi(std::get<0>(precomputedPW[j]), qqqevent.pos.Phi());
TVector3 pcPos = pwinstance.getClosestWirePosAtWirePhi(apw, qqqevent.pos.Phi()); double dphi = TMath::Abs(TVector2::Phi_mpi_pi(qqqevent.pos.Phi() - pos.Phi()));
double dphi = TMath::Abs(TVector2::Phi_mpi_pi(qqqevent.pos.Phi() - pcPos.Phi()));
if (dphi < bestDphi) if (dphi < bestDphi)
{ {
bestDphi = dphi; bestDphi = dphi;
bestCluster = &acluster; bestIdx = j;
pcz_intersect = pos;
} }
} }
if (!bestCluster) auto [apwire, apSumE, apMaxE, apTSMaxE] = precomputedPW[bestIdx];
continue; std::string nA_label = std::to_string(aClusters[bestIdx].size()) + "A";
// 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());
double deltaRho = qqqevent.pos.Perp() - pcz_intersect.Perp(); double deltaRho = qqqevent.pos.Perp() - pcz_intersect.Perp();
double deltaZ = qqqevent.pos.Z() - pcz_intersect.Z(); double deltaZ = qqqevent.pos.Z() - pcz_intersect.Z();

View File

@ -1,57 +1,34 @@
rm results_run*.root rm results_run*.root
export DATASET="17F" export DATASET="17F"
export flip180="0" export reactiondata=1
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;
#17F reaction data #17F reaction data
# export flip180="0" #declare -i run=231 #49
declare -i run=322 #49 #while [[ $run -lt 258 ]]; do #392
# while [[ $run -lt 399 ]]; do #392
# wrun=$(printf "%03d" $run) # wrun=$(printf "%03d" $run)
# file_exists=$(test -f ../ANASEN_analysis/data/17F_Data/Run_"$wrun"_mapped.root) # file_exists=$(test -f ../ANASEN_analysis/data/17F_Data/Run_"$wrun"_mapped.root)
# if [[ $file_exists -ne 0 ]]; then continue; fi # 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; # 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 # run=run+1
#done #done
while [[ $run -lt 323 ]]; do #392 function run_once() {
wrun=$(printf "%03d" $run) wrun=$(printf "%03d" $1)
file_exists=$(test -f ../ANASEN_analysis/data/17F_Data/Run_"$wrun"_mapped.root) file_exists=$(test -f ../ANASEN_analysis/data/17F_Data/Run_"$wrun"_mapped.root)
if [[ $file_exists -ne 0 ]]; then continue; fi 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; 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;
run=run+1 mv analyzed_run$wrun.root results_run$wrun.root;
done }
rm output.root export -f run_once
hadd -k -j 4 output.root 17F_output/results_run*.root run_once 351
mv output.root output_17F.root # 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 souce_vertex
unset DATASET unset DATASET
unset flip180 unset flip180
unset flipa unset flipa
unset anode_offset unset anode_offset
unset reactiondata