Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "Validator.h" | ||
2 | #include "TypeDefs.h" | ||
3 | |||
4 | #include <Math/Vector3D.h> | ||
5 | #include <TStyle.h> | ||
6 | |||
7 | namespace iguana::physics { | ||
8 | |||
9 | REGISTER_IGUANA_VALIDATOR(DihadronKinematicsValidator); | ||
10 | |||
11 | 1 | void DihadronKinematicsValidator::Start(hipo::banklist& banks) | |
12 | { | ||
13 | // define the algorithm sequence | ||
14 | 2 | m_algo_seq = std::make_unique<AlgorithmSequence>(); | |
15 |
2/4✓ Branch 0 (7→8) taken 1 times.
✗ Branch 1 (7→111) not taken.
✓ Branch 2 (8→9) taken 1 times.
✗ Branch 3 (8→109) not taken.
|
2 | m_algo_seq->Add("physics::InclusiveKinematics"); |
16 |
2/4✓ Branch 0 (12→13) taken 1 times.
✗ Branch 1 (12→115) not taken.
✓ Branch 2 (13→14) taken 1 times.
✗ Branch 3 (13→113) not taken.
|
2 | m_algo_seq->Add("physics::DihadronKinematics"); |
17 |
1/2✓ Branch 0 (18→19) taken 1 times.
✗ Branch 1 (18→119) not taken.
|
2 | m_algo_seq->SetOption("physics::DihadronKinematics", "log", m_log->GetLevel()); |
18 |
4/10✓ Branch 0 (25→26) taken 1 times.
✗ Branch 1 (25→125) not taken.
✓ Branch 2 (26→27) taken 1 times.
✗ Branch 3 (26→123) not taken.
✓ Branch 4 (27→28) taken 1 times.
✗ Branch 5 (27→121) not taken.
✓ Branch 6 (30→31) taken 1 times.
✗ Branch 7 (30→33) not taken.
✗ Branch 8 (125→126) not taken.
✗ Branch 9 (125→128) not taken.
|
3 | m_algo_seq->SetOption<std::vector<int>>("physics::DihadronKinematics", "hadron_a_list", {particle::pi_plus}); |
19 |
4/10✓ Branch 0 (34→35) taken 1 times.
✗ Branch 1 (34→133) not taken.
✓ Branch 2 (35→36) taken 1 times.
✗ Branch 3 (35→131) not taken.
✓ Branch 4 (36→37) taken 1 times.
✗ Branch 5 (36→129) not taken.
✓ Branch 6 (39→40) taken 1 times.
✗ Branch 7 (39→42) not taken.
✗ Branch 8 (133→134) not taken.
✗ Branch 9 (133→136) not taken.
|
3 | m_algo_seq->SetOption<std::vector<int>>("physics::DihadronKinematics", "hadron_b_list", {particle::pi_minus}); |
20 | 1 | m_algo_seq->Start(banks); | |
21 | |||
22 | // get bank indices | ||
23 |
1/2✓ Branch 0 (44→45) taken 1 times.
✗ Branch 1 (44→137) not taken.
|
1 | b_result = GetBankIndex(banks, "physics::DihadronKinematics"); |
24 | |||
25 | // set an output file | ||
26 | 1 | auto output_dir = GetOutputDirectory(); | |
27 |
1/2✓ Branch 0 (47→48) taken 1 times.
✗ Branch 1 (47→58) not taken.
|
1 | if(output_dir) { |
28 |
3/6✓ Branch 0 (48→49) taken 1 times.
✗ Branch 1 (48→185) not taken.
✓ Branch 2 (49→50) taken 1 times.
✗ Branch 3 (49→139) not taken.
✓ Branch 4 (51→52) taken 1 times.
✗ Branch 5 (51→185) not taken.
|
2 | m_output_file_basename = output_dir.value() + "/dihadron_kinematics"; |
29 |
2/4✓ Branch 0 (52→53) taken 1 times.
✗ Branch 1 (52→143) not taken.
✓ Branch 2 (55→56) taken 1 times.
✗ Branch 3 (55→141) not taken.
|
2 | m_output_file = new TFile(m_output_file_basename + ".root", "RECREATE"); |
30 | } | ||
31 | |||
32 | // define plots | ||
33 |
1/2✓ Branch 0 (58→59) taken 1 times.
✗ Branch 1 (58→185) not taken.
|
1 | gStyle->SetOptStat(0); |
34 | const int n_bins = 100; | ||
35 |
2/4✓ Branch 0 (80→81) taken 9 times.
✓ Branch 1 (80→84) taken 1 times.
✗ Branch 2 (146→147) not taken.
✗ Branch 3 (146→150) not taken.
|
10 | plot_list = { |
36 | { | ||
37 |
1/2✓ Branch 0 (60→61) taken 1 times.
✗ Branch 1 (60→167) not taken.
|
1 | new TH1D("Mh_dist", "invariant mass M_{h} [GeV]", n_bins, 0, 4), |
38 | 12 | [](auto const& b, auto const r) { return b.getDouble("Mh", r); } | |
39 | }, | ||
40 | { | ||
41 |
1/2✓ Branch 0 (62→63) taken 1 times.
✗ Branch 1 (62→165) not taken.
|
1 | new TH1D("z_dist", "z", n_bins, 0, 1), |
42 | 12 | [](auto const& b, auto const r) { return b.getDouble("z", r); } | |
43 | }, | ||
44 | { | ||
45 |
1/2✓ Branch 0 (64→65) taken 1 times.
✗ Branch 1 (64→163) not taken.
|
1 | new TH1D("PhPerp_dist", "P_{h}^{{}^{#perp}}", n_bins, 0, 2), |
46 | 12 | [](auto const& b, auto const r) { return b.getDouble("PhPerp", r); } | |
47 | }, | ||
48 | { | ||
49 |
1/2✓ Branch 0 (66→67) taken 1 times.
✗ Branch 1 (66→161) not taken.
|
1 | new TH1D("MX_dist", "Missing mass: M_{X} [GeV];", n_bins, 0, 4), |
50 |
1/2✓ Branch 0 (3→4) taken 12 times.
✗ Branch 1 (3→5) not taken.
|
12 | [](auto const& b, auto const r) { auto MX2 = b.getDouble("MX2", r); return MX2 >= 0 ? std::sqrt(MX2) : -100; } // FIXME: handle space-like case better |
51 | }, | ||
52 | { | ||
53 |
1/2✓ Branch 0 (68→69) taken 1 times.
✗ Branch 1 (68→159) not taken.
|
1 | new TH1D("xF_dist", "Feynman-x: x_{F};", n_bins, -1, 1), |
54 | 12 | [](auto const& b, auto const r) { return b.getDouble("xF", r); } | |
55 | }, | ||
56 | { | ||
57 |
1/2✓ Branch 0 (70→71) taken 1 times.
✗ Branch 1 (70→157) not taken.
|
1 | new TH1D("yB_dist", "Breit frame rapidity: y_{B};", n_bins, -4, 4), |
58 | 12 | [](auto const& b, auto const r) { return b.getDouble("yB", r); } | |
59 | }, | ||
60 | { | ||
61 |
1/2✓ Branch 0 (72→73) taken 1 times.
✗ Branch 1 (72→155) not taken.
|
1 | new TH1D("phiH_dist", "#phi_{h};", n_bins, -M_PI, M_PI), |
62 | 12 | [](auto const& b, auto const r) { return b.getDouble("phiH", r); } | |
63 | }, | ||
64 | { | ||
65 |
1/2✓ Branch 0 (74→75) taken 1 times.
✗ Branch 1 (74→153) not taken.
|
1 | new TH1D("phiR_dist", "#phi_{R}", n_bins, -M_PI, M_PI), |
66 | 12 | [](auto const& b, auto const r) { return b.getDouble("phiR", r); } | |
67 | }, | ||
68 | { | ||
69 |
1/2✓ Branch 0 (76→77) taken 1 times.
✗ Branch 1 (76→151) not taken.
|
1 | new TH1D("theta_dist", "#theta;", n_bins, 0, M_PI), |
70 | 12 | [](auto const& b, auto const r) { return b.getDouble("theta", r); } | |
71 | } | ||
72 |
2/6✓ Branch 0 (77→78) taken 1 times.
✗ Branch 1 (77→145) not taken.
✓ Branch 2 (81→82) taken 9 times.
✗ Branch 3 (81→83) not taken.
✗ Branch 4 (147→148) not taken.
✗ Branch 5 (147→149) not taken.
|
10 | }; |
73 | |||
74 | // format plots | ||
75 |
2/2✓ Branch 0 (104→85) taken 9 times.
✓ Branch 1 (104→105) taken 1 times.
|
10 | for(auto& plot : plot_list) { |
76 |
1/2✓ Branch 0 (85→86) taken 9 times.
✗ Branch 1 (85→185) not taken.
|
9 | plot.hist->SetLineColor(kRed); |
77 |
1/2✓ Branch 0 (86→87) taken 9 times.
✗ Branch 1 (86→185) not taken.
|
9 | plot.hist->SetFillColor(kRed); |
78 |
1/2✓ Branch 0 (97→98) taken 9 times.
✗ Branch 1 (97→175) not taken.
|
9 | plot.hist->SetTitle( |
79 |
2/4✓ Branch 0 (90→91) taken 9 times.
✗ Branch 1 (90→183) not taken.
✓ Branch 2 (91→92) taken 9 times.
✗ Branch 3 (91→183) not taken.
|
18 | TString(particle::title.at(particle::pi_plus)) + |
80 |
3/6✓ Branch 0 (88→89) taken 9 times.
✗ Branch 1 (88→185) not taken.
✓ Branch 2 (89→90) taken 9 times.
✗ Branch 3 (89→185) not taken.
✓ Branch 4 (92→93) taken 9 times.
✗ Branch 5 (92→181) not taken.
|
36 | TString(particle::title.at(particle::pi_minus)) + |
81 |
3/8✓ Branch 0 (87→88) taken 9 times.
✗ Branch 1 (87→185) not taken.
✓ Branch 2 (93→94) taken 9 times.
✗ Branch 3 (93→179) not taken.
✓ Branch 4 (94→95) taken 9 times.
✗ Branch 5 (94→177) not taken.
✗ Branch 6 (185→186) not taken.
✗ Branch 7 (185→188) not taken.
|
36 | " " + plot.hist->GetTitle()); |
82 | } | ||
83 |
9/22✓ Branch 0 (61→62) taken 1 times.
✗ Branch 1 (61→169) not taken.
✓ Branch 2 (63→64) taken 1 times.
✗ Branch 3 (63→169) not taken.
✓ Branch 4 (65→66) taken 1 times.
✗ Branch 5 (65→169) not taken.
✓ Branch 6 (67→68) taken 1 times.
✗ Branch 7 (67→169) not taken.
✓ Branch 8 (69→70) taken 1 times.
✗ Branch 9 (69→169) not taken.
✓ Branch 10 (71→72) taken 1 times.
✗ Branch 11 (71→169) not taken.
✓ Branch 12 (73→74) taken 1 times.
✗ Branch 13 (73→169) not taken.
✓ Branch 14 (75→76) taken 1 times.
✗ Branch 15 (75→169) not taken.
✓ Branch 16 (77→78) taken 1 times.
✗ Branch 17 (77→145) not taken.
✗ Branch 18 (170→171) not taken.
✗ Branch 19 (170→174) not taken.
✗ Branch 20 (171→172) not taken.
✗ Branch 21 (171→173) not taken.
|
10 | } |
84 | |||
85 | |||
86 | 1000 | void DihadronKinematicsValidator::Run(hipo::banklist& banks) const | |
87 | { | ||
88 | // calculate kinematics | ||
89 | 1000 | m_algo_seq->Run(banks); | |
90 |
2/4✓ Branch 0 (3→4) taken 1000 times.
✗ Branch 1 (3→26) not taken.
✓ Branch 2 (4→5) taken 1000 times.
✗ Branch 3 (4→24) not taken.
|
1000 | auto& result_bank = GetBank(banks, b_result, "physics::DihadronKinematics"); |
91 | |||
92 | // skip events with no dihadrons | ||
93 |
2/2✓ Branch 0 (7→8) taken 993 times.
✓ Branch 1 (7→10) taken 7 times.
|
1000 | if(result_bank.getRowList().size() == 0) { |
94 | 993 | m_log->Debug("skip this event, since it has no kinematics results"); | |
95 | return; | ||
96 | } | ||
97 | |||
98 | // lock mutex and fill the plots | ||
99 | 7 | std::scoped_lock<std::mutex> lock(m_mutex); | |
100 |
3/4✓ Branch 0 (11→12) taken 7 times.
✗ Branch 1 (11→27) not taken.
✓ Branch 2 (21→13) taken 12 times.
✓ Branch 3 (21→22) taken 7 times.
|
19 | for(auto const& row : result_bank.getRowList()) { |
101 |
2/2✓ Branch 0 (19→14) taken 108 times.
✓ Branch 1 (19→20) taken 12 times.
|
120 | for(auto& plot : plot_list) |
102 |
2/4✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→16) taken 108 times.
✓ Branch 2 (17→18) taken 108 times.
✗ Branch 3 (17→27) not taken.
|
216 | plot.hist->Fill(plot.get_val(result_bank, row)); |
103 | } | ||
104 | } | ||
105 | |||
106 | |||
107 | 1 | void DihadronKinematicsValidator::Stop() | |
108 | { | ||
109 |
1/2✓ Branch 0 (6→7) taken 1 times.
✗ Branch 1 (6→29) not taken.
|
2 | if(GetOutputDirectory()) { |
110 | int const n_cols = 4; | ||
111 | 1 | int const n_rows = (plot_list.size() - 1) / n_cols + 1; | |
112 |
1/2✓ Branch 0 (8→9) taken 1 times.
✗ Branch 1 (8→30) not taken.
|
1 | auto canv = new TCanvas("canv", "canv", n_cols * 800, n_rows * 600); |
113 | 1 | canv->Divide(n_cols, n_rows); | |
114 | int pad_num = 0; | ||
115 |
2/2✓ Branch 0 (19→11) taken 9 times.
✓ Branch 1 (19→20) taken 1 times.
|
10 | for(auto& plot : plot_list) { |
116 | 9 | auto pad = canv->GetPad(++pad_num); | |
117 | 9 | pad->cd(); | |
118 | 9 | pad->SetGrid(1, 1); | |
119 | 9 | pad->SetLeftMargin(0.12); | |
120 | 9 | pad->SetRightMargin(0.12); | |
121 | 9 | pad->SetBottomMargin(0.12); | |
122 | 9 | plot.hist->Draw(); | |
123 | } | ||
124 |
1/2✓ Branch 0 (23→24) taken 1 times.
✗ Branch 1 (23→32) not taken.
|
2 | canv->SaveAs(m_output_file_basename + ".png"); |
125 | 1 | m_output_file->Write(); | |
126 | 1 | m_log->Info("Wrote output file {}", m_output_file->GetName()); | |
127 | 1 | m_output_file->Close(); | |
128 | } | ||
129 | 1 | } | |
130 | |||
131 | } | ||
132 |