diff --git a/distributions.cc b/distributions.cc index e3016a5..f7f94f2 100644 --- a/distributions.cc +++ b/distributions.cc @@ -89,8 +89,8 @@ void WriteCutPlot(TH2D *h, double a, double c, double si, const string &label) h->Draw("colz"); - double x_min = -20.; - double x_max = +20.; + double x_min = -30.; + double x_max = +30.; TGraph *g_up = new TGraph(); g_up->SetName("g_up"); @@ -134,28 +134,43 @@ int main() TFile *f_out = new TFile("distributions.root", "recreate"); // book histograms - TH2D *h2_y_vs_x_L_2_F_no_sel = new TH2D("h2_y_vs_x_L_2_F_no_sel", ";x;y", 400, 40., 60., 300, -15., +15.); - TH2D *h2_y_vs_x_L_1_F_no_sel = new TH2D("h2_y_vs_x_L_1_F_no_sel", ";x;y", 400, 0., 20., 300, -15., +15.); - TH2D *h2_y_vs_x_R_1_F_no_sel = new TH2D("h2_y_vs_x_R_1_F_no_sel", ";x;y", 400, 0., 20., 300, -15., +15.); - TH2D *h2_y_vs_x_R_2_F_no_sel = new TH2D("h2_y_vs_x_R_2_F_no_sel", ";x;y", 400, 40., 60., 300, -15., +15.); + const double bin_size_x = 142.3314E-3; // mm + const unsigned int n_bins_x = 210; - TH2D *h2_x_L_2_F_vs_x_L_1_F = new TH2D("h2_x_L_2_F_vs_x_L_1_F", ";x_L_1_F;x_L_2_F", 100, 0., 20., 100, 40., 60.); - TProfile *p_x_L_2_F_vs_x_L_1_F = new TProfile("p_x_L_2_F_vs_x_L_1_F", ";x_L_1_F;x_L_2_F", 100, 0., 20.); + const double pixel_x_offset = (cfg.aligned) ? 0. : 40.; + + const double x_min_pix = pixel_x_offset, x_max_pix = pixel_x_offset + n_bins_x * bin_size_x; + const double x_min_str = 0., x_max_str = n_bins_x * bin_size_x; + + const unsigned int n_bins_y = 400; + const double y_min = -20., y_max = +20.; + + TH2D *h2_y_vs_x_L_2_F_no_sel = new TH2D("h2_y_vs_x_L_2_F_no_sel", ";x;y", n_bins_x, x_min_pix, x_max_pix, n_bins_y, y_min, y_max); + TH2D *h2_y_vs_x_L_1_F_no_sel = new TH2D("h2_y_vs_x_L_1_F_no_sel", ";x;y", n_bins_x, x_min_str, x_max_str, n_bins_y, y_min, y_max); + TH2D *h2_y_vs_x_R_1_F_no_sel = new TH2D("h2_y_vs_x_R_1_F_no_sel", ";x;y", n_bins_x, x_min_str, x_max_str, n_bins_y, y_min, y_max); + TH2D *h2_y_vs_x_R_2_F_no_sel = new TH2D("h2_y_vs_x_R_2_F_no_sel", ";x;y", n_bins_x, x_min_pix, x_max_pix, n_bins_y, y_min, y_max); + + TH2D *h2_x_L_2_F_vs_x_L_1_F_before = new TH2D("h2_x_L_2_F_vs_x_L_1_F_before", ";x_L_1_F;x_L_2_F", n_bins_x, x_min_str, x_max_str, n_bins_x, x_min_pix, x_max_pix); + TH2D *h2_x_L_2_F_vs_x_L_1_F_after = new TH2D("h2_x_L_2_F_vs_x_L_1_F_after", ";x_L_1_F;x_L_2_F", n_bins_x, x_min_str, x_max_str, n_bins_x, x_min_pix, x_max_pix); + TProfile *p_x_L_2_F_vs_x_L_1_F_after = new TProfile("p_x_L_2_F_vs_x_L_1_F_after", ";x_L_1_F;x_L_2_F", n_bins_x, x_min_str, x_max_str); TH1D *h_q_cut1_before = new TH1D("h_q_cut1_before", ";cq1", 400, -2., 2.); h_q_cut1_before->SetLineColor(2); TH1D *h_q_cut1_after = new TH1D("h_q_cut1_after", ";cq1", 400, -2., 2.); h_q_cut1_after->SetLineColor(4); - TH2D *h2_x_R_2_F_vs_x_R_1_F = new TH2D("h2_x_R_2_F_vs_x_R_1_F", ";x_R_1_F;x_R_2_F", 100, 0., 20., 100, 40., 60.); - TProfile *p_x_R_2_F_vs_x_R_1_F = new TProfile("p_x_R_2_F_vs_x_R_1_F", ";x_R_1_F;x_R_2_F", 100, 0., 20.); + TH2D *h2_x_R_2_F_vs_x_R_1_F_before = new TH2D("h2_x_R_2_F_vs_x_R_1_F_before", ";x_R_1_F;x_R_2_F", n_bins_x, x_min_str, x_max_str, n_bins_x, x_min_pix, x_max_pix); + TH2D *h2_x_R_2_F_vs_x_R_1_F_after = new TH2D("h2_x_R_2_F_vs_x_R_1_F_after", ";x_R_1_F;x_R_2_F", n_bins_x, x_min_str, x_max_str, n_bins_x, x_min_pix, x_max_pix); + TProfile *p_x_R_2_F_vs_x_R_1_F_after = new TProfile("p_x_R_2_F_vs_x_R_1_F_after", ";x_R_1_F;x_R_2_F", n_bins_x, x_min_str, x_max_str); TH1D *h_q_cut2_before = new TH1D("h_q_cut2_before", ";cq2", 400, -2., 2.); h_q_cut2_before->SetLineColor(2); TH1D *h_q_cut2_after = new TH1D("h_q_cut2_after", ";cq2", 400, -2., 2.); h_q_cut2_after->SetLineColor(4); - TH2D *h2_y_L_2_F_vs_y_L_1_F = new TH2D("h2_y_L_2_F_vs_y_L_1_F", ";y_L_1_F;y_L_2_F", 100, -10., +10., 100, -10., +10.); - TProfile *p_y_L_2_F_vs_y_L_1_F = new TProfile("p_y_L_2_F_vs_y_L_1_F", ";y_L_1_F;y_L_2_F", 100, -10., +10.); + TH2D *h2_y_L_2_F_vs_y_L_1_F_before = new TH2D("h2_y_L_2_F_vs_y_L_1_F_before", ";y_L_1_F;y_L_2_F", 100, -10., +10., 100, -10., +10.); + TH2D *h2_y_L_2_F_vs_y_L_1_F_after = new TH2D("h2_y_L_2_F_vs_y_L_1_F_after", ";y_L_1_F;y_L_2_F", 100, -10., +10., 100, -10., +10.); + TProfile *p_y_L_2_F_vs_y_L_1_F_after = new TProfile("p_y_L_2_F_vs_y_L_1_F_after", ";y_L_1_F;y_L_2_F", 100, -10., +10.); TH1D *h_q_cut3_before = new TH1D("h_q_cut3_before", ";cq3", 400, -2., 2.); h_q_cut3_before->SetLineColor(2); TH1D *h_q_cut3_after = new TH1D("h_q_cut3_after", ";cq3", 400, -2., 2.); h_q_cut3_after->SetLineColor(4); - TH2D *h2_y_R_2_F_vs_y_R_1_F = new TH2D("h2_y_R_2_F_vs_y_R_1_F", ";y_R_1_F;y_R_2_F", 100, -10., +10., 100, -10., +10.); - TProfile *p_y_R_2_F_vs_y_R_1_F = new TProfile("p_y_R_2_F_vs_y_R_1_F", ";y_R_1_F;y_R_2_F", 100, -10., +10.); + TH2D *h2_y_R_2_F_vs_y_R_1_F_before = new TH2D("h2_y_R_2_F_vs_y_R_1_F_before", ";y_R_1_F;y_R_2_F", 100, -10., +10., 100, -10., +10.); + TH2D *h2_y_R_2_F_vs_y_R_1_F_after = new TH2D("h2_y_R_2_F_vs_y_R_1_F_after", ";y_R_1_F;y_R_2_F", 100, -10., +10., 100, -10., +10.); + TProfile *p_y_R_2_F_vs_y_R_1_F_after = new TProfile("p_y_R_2_F_vs_y_R_1_F_after", ";y_R_1_F;y_R_2_F", 100, -10., +10.); TH1D *h_q_cut4_before = new TH1D("h_q_cut4_before", ";cq4", 400, -2., 2.); h_q_cut4_before->SetLineColor(2); TH1D *h_q_cut4_after = new TH1D("h_q_cut4_after", ";cq4", 400, -2., 2.); h_q_cut4_after->SetLineColor(4); @@ -164,10 +179,10 @@ int main() TGraph *g_y_vs_x_R_1_F_sel = new TGraph(); g_y_vs_x_R_1_F_sel->SetName("g_y_vs_x_R_1_F_sel"); g_y_vs_x_R_1_F_sel->SetTitle(";x;y"); TGraph *g_y_vs_x_R_2_F_sel = new TGraph(); g_y_vs_x_R_2_F_sel->SetName("g_y_vs_x_R_2_F_sel"); g_y_vs_x_R_2_F_sel->SetTitle(";x;y"); - TH2D *h2_y_vs_x_L_2_F_sel = new TH2D("h2_y_vs_x_L_2_F_sel", ";x;y", 200, 0., 20., 100, -15., +15.); - TH2D *h2_y_vs_x_L_1_F_sel = new TH2D("h2_y_vs_x_L_1_F_sel", ";x;y", 200, 0., 20., 100, -15., +15.); - TH2D *h2_y_vs_x_R_1_F_sel = new TH2D("h2_y_vs_x_R_1_F_sel", ";x;y", 200, 0., 20., 100, -15., +15.); - TH2D *h2_y_vs_x_R_2_F_sel = new TH2D("h2_y_vs_x_R_2_F_sel", ";x;y", 200, 0., 20., 100, -15., +15.); + TH2D *h2_y_vs_x_L_2_F_sel = new TH2D(*h2_y_vs_x_L_2_F_no_sel); h2_y_vs_x_L_2_F_sel->SetName("h2_y_vs_x_L_2_F_sel"); + TH2D *h2_y_vs_x_L_1_F_sel = new TH2D(*h2_y_vs_x_L_1_F_no_sel); h2_y_vs_x_L_1_F_sel->SetName("h2_y_vs_x_L_1_F_sel"); + TH2D *h2_y_vs_x_R_1_F_sel = new TH2D(*h2_y_vs_x_R_1_F_no_sel); h2_y_vs_x_R_1_F_sel->SetName("h2_y_vs_x_R_1_F_sel"); + TH2D *h2_y_vs_x_R_2_F_sel = new TH2D(*h2_y_vs_x_R_2_F_no_sel); h2_y_vs_x_R_2_F_sel->SetName("h2_y_vs_x_R_2_F_sel"); Profile p_y_vs_x_L_2_F_sel("L_2_F", h2_y_vs_x_L_2_F_sel); Profile p_y_vs_x_L_1_F_sel("L_1_F", h2_y_vs_x_L_1_F_sel); @@ -179,16 +194,10 @@ int main() unsigned long int tr_sel_count = 0; for (ev.toBegin(); ! ev.atEnd(); ++ev) { - /* - // TODO: comment out - if (ev_count > 1000000) - break; - */ - ev_count++; // TODO: comment out - if (tr_sel_count > 10000) + if (tr_sel_count > 1000000) break; // default track data @@ -232,11 +241,8 @@ int main() if (tr_L_1_F_valid && tr_L_2_F_valid) { - h2_x_L_2_F_vs_x_L_1_F->Fill(tr_L_1_F.getX(), tr_L_2_F.getX()); - p_x_L_2_F_vs_x_L_1_F->Fill(tr_L_1_F.getX(), tr_L_2_F.getX()); - - h2_y_L_2_F_vs_y_L_1_F->Fill(tr_L_1_F.getY(), tr_L_2_F.getY()); - p_y_L_2_F_vs_y_L_1_F->Fill(tr_L_1_F.getY(), tr_L_2_F.getY()); + h2_x_L_2_F_vs_x_L_1_F_before->Fill(tr_L_1_F.getX(), tr_L_2_F.getX()); + h2_y_L_2_F_vs_y_L_1_F_before->Fill(tr_L_1_F.getY(), tr_L_2_F.getY()); double cq1 = tr_L_2_F.getX() + cfg.cut1_a * tr_L_1_F.getX() + cfg.cut1_c; h_q_cut1_before->Fill(cq1); @@ -256,6 +262,12 @@ int main() { tr_sel_count++; + h2_x_L_2_F_vs_x_L_1_F_after->Fill(tr_L_1_F.getX(), tr_L_2_F.getX()); + h2_y_L_2_F_vs_y_L_1_F_after->Fill(tr_L_1_F.getY(), tr_L_2_F.getY()); + + p_x_L_2_F_vs_x_L_1_F_after->Fill(tr_L_1_F.getX(), tr_L_2_F.getX()); + p_y_L_2_F_vs_y_L_1_F_after->Fill(tr_L_1_F.getY(), tr_L_2_F.getY()); + h_q_cut1_after->Fill(cq1); h_q_cut3_after->Fill(cq3); @@ -271,33 +283,35 @@ int main() } } - /* if (tr_R_1_F_valid && tr_R_2_F_valid) { - h2_x_R_2_F_vs_x_R_1_F->Fill(tr_R_1_F.getX(), tr_R_2_F.getX()); - p_x_R_2_F_vs_x_R_1_F->Fill(tr_R_1_F.getX(), tr_R_2_F.getX()); - - h2_y_R_2_F_vs_y_R_1_F->Fill(tr_R_1_F.getY(), tr_R_2_F.getY()); - p_y_R_2_F_vs_y_R_1_F->Fill(tr_R_1_F.getY(), tr_R_2_F.getY()); + h2_x_R_2_F_vs_x_R_1_F_before->Fill(tr_R_1_F.getX(), tr_R_2_F.getX()); + h2_y_R_2_F_vs_y_R_1_F_before->Fill(tr_R_1_F.getY(), tr_R_2_F.getY()); - double cq2 = tr_R_2_F.getX() + cut2_a * tr_R_1_F.getX() + cut2_c; + double cq2 = tr_R_2_F.getX() + cfg.cut2_a * tr_R_1_F.getX() + cfg.cut2_c; h_q_cut2_before->Fill(cq2); - bool cut2_val = (fabs(cq2) < n_si * cut2_si); + bool cut2_val = (fabs(cq2) < cfg.n_si * cfg.cut2_si); - double cq4 = tr_R_2_F.getY() + cut4_a * tr_R_1_F.getY() + cut4_c; + double cq4 = tr_R_2_F.getY() + cfg.cut4_a * tr_R_1_F.getY() + cfg.cut4_c; h_q_cut4_before->Fill(cq4); - bool cut4_val = (fabs(cq4) < n_si * cut4_si); + bool cut4_val = (fabs(cq4) < cfg.n_si * cfg.cut4_si); bool cuts_passed = true; - if (cut2_apply) + if (cfg.cut2_apply) cuts_passed &= cut2_val; - if (cut4_apply) + if (cfg.cut4_apply) cuts_passed &= cut4_val; if (cuts_passed) { tr_sel_count++; + h2_x_R_2_F_vs_x_R_1_F_after->Fill(tr_R_1_F.getX(), tr_R_2_F.getX()); + h2_y_R_2_F_vs_y_R_1_F_after->Fill(tr_R_1_F.getY(), tr_R_2_F.getY()); + + p_x_R_2_F_vs_x_R_1_F_after->Fill(tr_R_1_F.getX(), tr_R_2_F.getX()); + p_y_R_2_F_vs_y_R_1_F_after->Fill(tr_R_1_F.getY(), tr_R_2_F.getY()); + h_q_cut2_after->Fill(cq2); h_q_cut4_after->Fill(cq4); @@ -312,7 +326,6 @@ int main() p_y_vs_x_R_2_F_sel.Fill(tr_R_2_F.getX(), tr_R_2_F.getY()); } } - */ } printf("* events processed: %lu\n", ev_count); @@ -324,33 +337,28 @@ int main() // make fits TF1 *ff_pol1 = new TF1("ff_pol1", "[0] + [1]*x"); - // TODO - bool alignment_run = false; - double fx_min, fx_max; - fx_min = (alignment_run) ? 4. : 7.; - fx_max = (alignment_run) ? 13. : 14.; - p_x_L_2_F_vs_x_L_1_F->Fit(ff_pol1, "Q", "", fx_min, fx_max); + ff_pol1->FixParameter(1, 1.); + + fx_min = (cfg.aligned) ? 3. : 7.; + fx_max = (cfg.aligned) ? 7.5 : 14.; + p_x_L_2_F_vs_x_L_1_F_after->Fit(ff_pol1, "Q", "", fx_min, fx_max); printf("\tcut1_a = %+.3f; cut1_c = %+.3f; cut1_si = 0.20;\n", -ff_pol1->GetParameter(1), -ff_pol1->GetParameter(0)); - /* - fx_min = (alignment_run) ? 2. : 7.; - fx_max = (alignment_run) ? 13. : 16.; - p_x_R_2_F_vs_x_R_1_F->Fit(ff_pol1, "Q", "", fx_min, fx_max); + fx_min = (cfg.aligned) ? 2. : 7.; + fx_max = (cfg.aligned) ? 6. : 16.; + p_x_R_2_F_vs_x_R_1_F_after->Fit(ff_pol1, "Q", "", fx_min, fx_max); printf("\tcut2_a = %+.3f; cut2_c = %+.3f; cut2_si = 0.20;\n", -ff_pol1->GetParameter(1), -ff_pol1->GetParameter(0)); - */ - fx_min = (alignment_run) ? -4.5 : -4.5; - fx_max = (alignment_run) ? +4.5 : +4.5; - - p_y_L_2_F_vs_y_L_1_F->Fit(ff_pol1, "Q", "", fx_min, fx_max); + fx_min = (cfg.aligned) ? -2.5 : -6.5; + fx_max = (cfg.aligned) ? -2.5 : +6.5; + + p_y_L_2_F_vs_y_L_1_F_after->Fit(ff_pol1, "Q", "", fx_min, fx_max); printf("\tcut3_a = %+.3f; cut3_c = %+.3f; cut3_si = 0.15;\n", -ff_pol1->GetParameter(1), -ff_pol1->GetParameter(0)); - /* - p_y_R_2_F_vs_y_R_1_F->Fit(ff_pol1, "Q", "", fx_min, fx_max); + p_y_R_2_F_vs_y_R_1_F_after->Fit(ff_pol1, "Q", "", fx_min, fx_max); printf("\tcut4_a = %+.3f; cut4_c = %+.3f; cut4_si = 0.15;\n", -ff_pol1->GetParameter(1), -ff_pol1->GetParameter(0)); - */ // save histograms gDirectory = f_out->mkdir("before selection"); @@ -360,32 +368,32 @@ int main() h2_y_vs_x_R_2_F_no_sel->Write(); TDirectory *d_cuts = f_out->mkdir("cuts"); - + gDirectory = d_cuts->mkdir("cut 1"); - h2_x_L_2_F_vs_x_L_1_F->Write(); - WriteCutPlot(h2_x_L_2_F_vs_x_L_1_F, cfg.cut1_a, cfg.cut1_c, cfg.cut1_si, "canvas_before"); - p_x_L_2_F_vs_x_L_1_F->Write(); + WriteCutPlot(h2_x_L_2_F_vs_x_L_1_F_before, cfg.cut1_a, cfg.cut1_c, cfg.cut1_si, "canvas_before"); + WriteCutPlot(h2_x_L_2_F_vs_x_L_1_F_after, cfg.cut1_a, cfg.cut1_c, cfg.cut1_si, "canvas_after"); + p_x_L_2_F_vs_x_L_1_F_after->Write(); h_q_cut1_before->Write(); h_q_cut1_after->Write(); gDirectory = d_cuts->mkdir("cut 2"); - h2_x_R_2_F_vs_x_R_1_F->Write(); - WriteCutPlot(h2_x_R_2_F_vs_x_R_1_F, cfg.cut2_a, cfg.cut2_c, cfg.cut2_si, "canvas_before"); - p_x_R_2_F_vs_x_R_1_F->Write(); + WriteCutPlot(h2_x_R_2_F_vs_x_R_1_F_before, cfg.cut2_a, cfg.cut2_c, cfg.cut2_si, "canvas_before"); + WriteCutPlot(h2_x_R_2_F_vs_x_R_1_F_after, cfg.cut2_a, cfg.cut2_c, cfg.cut2_si, "canvas_after"); + p_x_R_2_F_vs_x_R_1_F_after->Write(); h_q_cut2_before->Write(); h_q_cut2_after->Write(); - + gDirectory = d_cuts->mkdir("cut 3"); - h2_y_L_2_F_vs_y_L_1_F->Write(); - WriteCutPlot(h2_y_L_2_F_vs_y_L_1_F, cfg.cut3_a, cfg.cut3_c, cfg.cut3_si, "canvas_before"); - p_y_L_2_F_vs_y_L_1_F->Write(); + WriteCutPlot(h2_y_L_2_F_vs_y_L_1_F_before, cfg.cut3_a, cfg.cut3_c, cfg.cut3_si, "canvas_before"); + WriteCutPlot(h2_y_L_2_F_vs_y_L_1_F_after, cfg.cut3_a, cfg.cut3_c, cfg.cut3_si, "canvas_after"); + p_y_L_2_F_vs_y_L_1_F_after->Write(); h_q_cut3_before->Write(); h_q_cut3_after->Write(); gDirectory = d_cuts->mkdir("cut 4"); - h2_y_R_2_F_vs_y_R_1_F->Write(); - WriteCutPlot(h2_y_R_2_F_vs_y_R_1_F, cfg.cut4_a, cfg.cut4_c, cfg.cut4_si, "canvas_before"); - p_y_R_2_F_vs_y_R_1_F->Write(); + WriteCutPlot(h2_y_R_2_F_vs_y_R_1_F_before, cfg.cut4_a, cfg.cut4_c, cfg.cut4_si, "canvas_before"); + WriteCutPlot(h2_y_R_2_F_vs_y_R_1_F_after, cfg.cut4_a, cfg.cut4_c, cfg.cut4_si, "canvas_after"); + p_y_R_2_F_vs_y_R_1_F_after->Write(); h_q_cut4_before->Write(); h_q_cut4_after->Write();