From 580056768b0f793d4ae6ba69d27ce5dcef199684 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Fri, 29 Nov 2024 17:01:37 -0500 Subject: [PATCH 1/2] test: impact on M_X from boost patch --- draw_mx.C | 15 +++++++++++ src/clas-stringspinner.cpp | 54 ++++++++++++++++++++++++++++++++++++++ src/config/clas12.h | 2 +- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 draw_mx.C diff --git a/draw_mx.C b/draw_mx.C new file mode 100644 index 0000000..4a233ab --- /dev/null +++ b/draw_mx.C @@ -0,0 +1,15 @@ +// ninja && clas-stringspinner --seed 29877 --trig 10000 --cut-inclusive 11,211,-211|grep M_X| awk '{print $2}' > output.dat +void draw_mx(TString file_name = "output.dat") { + auto tr = new TTree(); + tr->ReadFile(file_name, "mx/D"); + // new TCanvas(); + // tr->Draw("mx"); + auto c = new TCanvas("c", "c", 800, 600); + auto mx_dist = new TH1D("mx_dist","m_x",100,0.9,1.5); + tr->Project("mx_dist", "mx"); + mx_dist->Draw(); + auto peak = mx_dist->GetBinCenter(mx_dist->GetMaximumBin()); + auto dev = 0.03; + mx_dist->Fit("gaus","","",peak-dev,peak+dev); + c->SaveAs(file_name+".png"); +} diff --git a/src/clas-stringspinner.cpp b/src/clas-stringspinner.cpp index 8a380f5..082d2b2 100644 --- a/src/clas-stringspinner.cpp +++ b/src/clas-stringspinner.cpp @@ -694,6 +694,60 @@ int main(int argc, char** argv) lund_particle.vz ); + // make sure we have a delta + bool delta_found = false; + for(auto const& par : *evt.particles()) { + if(par.id() == 2214) { + delta_found = true; + break; + } + } + if(!delta_found) continue; + + // find the scattered electron + int ele_idx = -1; + double ele_p = -10000; + for(int idx = 0; idx < evt.size(); ++idx) { + auto const& par = evt[idx]; + if(par.isFinal() && par.id() == 11) { + auto this_p = std::hypot(par.px(), par.py(), par.pz()); + if(this_p > ele_p) { + ele_p = par.e(); + ele_idx = idx; + } + } + } + // fmt::print("ele_idx = {}\n", ele_idx); + if(ele_idx < 0) continue; + + // loop over pi+ pi- dihadrons + for(int idxA = 0; idxA < evt.size(); ++idxA) { + auto const& parA = evt[idxA]; + if(parA.isFinal() && parA.id() == 211) { + for(int idxB = 0; idxB < evt.size(); ++idxB) { + auto const& parB = evt[idxB]; + if(parB.isFinal() && parB.id() == -211) { + + Pythia8::Vec4 p_beam(0.0, 0.0, 10.6040999877, 10.6041); + Pythia8::Vec4 p_target(0.0, 0.0, 0.0, 0.93827); + + auto p_ele = evt[ele_idx].p(); + auto p_pip = parA.p(); + auto p_pim = parB.p(); + + // calculate missing mass + auto vecW = p_beam + p_target - p_ele; + auto vecPh = p_pip + p_pim; + auto M_X = (vecW - vecPh).mCalc(); + fmt::print("M_X {}\n", M_X); + } + } + } + } + + // if(evnum < 1000) + // evt.list(false, false, 10); + // finalize if(!enable_count_before_cuts) { if(++evnum >= num_events) diff --git a/src/config/clas12.h b/src/config/clas12.h index aaa594c..46b8f92 100644 --- a/src/config/clas12.h +++ b/src/config/clas12.h @@ -70,6 +70,6 @@ inline void config_clas12(Pythia8::Pythia& pyth) { // handle event printouts set_config(pyth, "Next:numberShowInfo = 0"); set_config(pyth, "Next:numberShowProcess = 0"); - set_config(pyth, "Next:numberShowEvent = 1"); + set_config(pyth, "Next:numberShowEvent = 0"); } From b674111a994cdcb94d1f037d371d81d9f6ae27f8 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Mon, 16 Dec 2024 16:04:17 -0500 Subject: [PATCH 2/2] feat: plot in same --- draw_mx.C | 10 +++++++--- draw_mx_2.C | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 draw_mx_2.C diff --git a/draw_mx.C b/draw_mx.C index 4a233ab..df7d69d 100644 --- a/draw_mx.C +++ b/draw_mx.C @@ -1,15 +1,19 @@ // ninja && clas-stringspinner --seed 29877 --trig 10000 --cut-inclusive 11,211,-211|grep M_X| awk '{print $2}' > output.dat -void draw_mx(TString file_name = "output.dat") { +void draw_mx(TString file_name = "output.dat", TString title = "m_x") { auto tr = new TTree(); tr->ReadFile(file_name, "mx/D"); // new TCanvas(); // tr->Draw("mx"); auto c = new TCanvas("c", "c", 800, 600); - auto mx_dist = new TH1D("mx_dist","m_x",100,0.9,1.5); + auto mx_dist = new TH1D("mx_dist",title,100,0.9,1.5); tr->Project("mx_dist", "mx"); mx_dist->Draw(); auto peak = mx_dist->GetBinCenter(mx_dist->GetMaximumBin()); auto dev = 0.03; - mx_dist->Fit("gaus","","",peak-dev,peak+dev); + // mx_dist->Fit("gaus","","",peak-dev,peak+dev); + auto delta = new TLine(1.232, 0, 1.232, mx_dist->GetMaximum()); + delta->SetLineColor(kRed); + delta->SetLineWidth(3); + delta->Draw(); c->SaveAs(file_name+".png"); } diff --git a/draw_mx_2.C b/draw_mx_2.C new file mode 100644 index 0000000..6283e53 --- /dev/null +++ b/draw_mx_2.C @@ -0,0 +1,25 @@ +// ninja && clas-stringspinner --seed 29877 --trig 10000 --cut-inclusive 11,211,-211|grep M_X| awk '{print $2}' > output.dat +void draw_mx_2(TString file_name = "output.both.dat") { + gStyle->SetOptStat(0); + auto tr = new TTree(); + tr->ReadFile(file_name, "mx_before/D:mx_after/D"); + // new TCanvas(); + // tr->Draw("mx"); + auto c = new TCanvas("c", "c", 800, 600); + auto mx_dist_before = new TH1D("mx_dist_before", "M_{X} distribution", 60, 1.0, 1.35); + auto mx_dist_after = new TH1D("mx_dist_after", "M_{X} distribution", 60, 1.0, 1.35); + tr->Project("mx_dist_before", "mx_before"); + tr->Project("mx_dist_after", "mx_after"); + mx_dist_before->SetLineColor(kBlue); + mx_dist_after->SetLineColor(kRed); + mx_dist_after->SetLineStyle(kDashed); + mx_dist_after->SetLineWidth(2); + mx_dist_before->SetLineWidth(2); + mx_dist_before->Draw(); + mx_dist_after->Draw("same"); + auto delta = new TLine(1.232, 0, 1.232, mx_dist_before->GetMaximum()); + delta->SetLineColor(kGreen+1); + delta->SetLineWidth(3); + delta->Draw(); + c->SaveAs(file_name+".png"); +}