| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "Validator.h" | ||
| 2 | #include "TypeDefs.h" | ||
| 3 | |||
| 4 | #include <Math/Vector3D.h> | ||
| 5 | |||
| 6 | namespace iguana::physics { | ||
| 7 | |||
| 8 | REGISTER_IGUANA_VALIDATOR(DihadronKinematicsValidator); | ||
| 9 | |||
| 10 | 1 | void DihadronKinematicsValidator::Start(hipo::banklist& banks) | |
| 11 | { | ||
| 12 | // define the algorithm sequence | ||
| 13 | 2 | m_algo_seq = std::make_unique<AlgorithmSequence>(); | |
| 14 |
3/8✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 159 not taken.
✓ Branch 8 → 9 taken 1 time.
✗ Branch 8 → 153 not taken.
✓ Branch 14 → 15 taken 1 time.
✗ Branch 14 → 17 not taken.
✗ Branch 159 → 160 not taken.
✗ Branch 159 → 162 not taken.
|
2 | m_algo_seq->Add("physics::InclusiveKinematics"); |
| 15 |
3/8✓ Branch 20 → 21 taken 1 time.
✗ Branch 20 → 171 not taken.
✓ Branch 21 → 22 taken 1 time.
✗ Branch 21 → 165 not taken.
✓ Branch 27 → 28 taken 1 time.
✗ Branch 27 → 30 not taken.
✗ Branch 171 → 172 not taken.
✗ Branch 171 → 174 not taken.
|
2 | m_algo_seq->Add("physics::DihadronKinematics"); |
| 16 |
2/6✓ Branch 34 → 35 taken 1 time.
✗ Branch 34 → 183 not taken.
✓ Branch 43 → 44 taken 1 time.
✗ Branch 43 → 46 not taken.
✗ Branch 183 → 184 not taken.
✗ Branch 183 → 186 not taken.
|
3 | m_algo_seq->SetOption("physics::DihadronKinematics", "log", m_log->GetLevel()); |
| 17 |
5/14✓ Branch 49 → 50 taken 1 time.
✗ Branch 49 → 201 not taken.
✓ Branch 50 → 51 taken 1 time.
✗ Branch 50 → 195 not taken.
✓ Branch 51 → 52 taken 1 time.
✗ Branch 51 → 189 not taken.
✓ Branch 57 → 58 taken 1 time.
✗ Branch 57 → 60 not taken.
✓ Branch 62 → 63 taken 1 time.
✗ Branch 62 → 65 not taken.
✗ Branch 195 → 196 not taken.
✗ Branch 195 → 198 not taken.
✗ Branch 201 → 202 not taken.
✗ Branch 201 → 204 not taken.
|
4 | m_algo_seq->SetOption<std::vector<int>>("physics::DihadronKinematics", "hadron_a_list", {particle::pi_plus}); |
| 18 |
5/14✓ Branch 66 → 67 taken 1 time.
✗ Branch 66 → 217 not taken.
✓ Branch 67 → 68 taken 1 time.
✗ Branch 67 → 211 not taken.
✓ Branch 68 → 69 taken 1 time.
✗ Branch 68 → 205 not taken.
✓ Branch 74 → 75 taken 1 time.
✗ Branch 74 → 77 not taken.
✓ Branch 79 → 80 taken 1 time.
✗ Branch 79 → 82 not taken.
✗ Branch 211 → 212 not taken.
✗ Branch 211 → 214 not taken.
✗ Branch 217 → 218 not taken.
✗ Branch 217 → 220 not taken.
|
4 | m_algo_seq->SetOption<std::vector<int>>("physics::DihadronKinematics", "hadron_b_list", {particle::pi_minus}); |
| 19 | 1 | m_algo_seq->Start(banks); | |
| 20 | |||
| 21 | // get bank indices | ||
| 22 |
2/4✓ Branch 84 → 85 taken 1 time.
✗ Branch 84 → 221 not taken.
✗ Branch 85 → 86 not taken.
✓ Branch 85 → 88 taken 1 time.
|
1 | b_result = GetBankIndex(banks, "physics::DihadronKinematics"); |
| 23 | |||
| 24 | // set an output file | ||
| 25 | 1 | auto output_dir = GetOutputDirectory(); | |
| 26 |
1/2✓ Branch 91 → 92 taken 1 time.
✗ Branch 91 → 106 not taken.
|
1 | if(output_dir) { |
| 27 |
3/6✓ Branch 92 → 93 taken 1 time.
✗ Branch 92 → 277 not taken.
✓ Branch 93 → 94 taken 1 time.
✗ Branch 93 → 227 not taken.
✓ Branch 99 → 100 taken 1 time.
✗ Branch 99 → 277 not taken.
|
2 | m_output_file_basename = output_dir.value() + "/dihadron_kinematics"; |
| 28 |
2/4✓ Branch 100 → 101 taken 1 time.
✗ Branch 100 → 235 not taken.
✓ Branch 103 → 104 taken 1 time.
✗ Branch 103 → 233 not taken.
|
2 | m_output_file = new TFile(m_output_file_basename + ".root", "RECREATE"); |
| 29 | } | ||
| 30 | |||
| 31 | // define plots | ||
| 32 | int const n_bins = 100; | ||
| 33 | plot_list = { | ||
| 34 |
1/2✓ Branch 107 → 108 taken 1 time.
✗ Branch 107 → 259 not taken.
|
1 | {new TH1D("Mh_dist", "invariant mass M_{h} [GeV]", n_bins, 0, 4), |
| 35 | 13 | [](auto const& b, auto const r) { return b.getDouble("Mh", r); }}, | |
| 36 |
1/2✓ Branch 109 → 110 taken 1 time.
✗ Branch 109 → 257 not taken.
|
1 | {new TH1D("z_dist", "z", n_bins, 0, 1), |
| 37 | 13 | [](auto const& b, auto const r) { return b.getDouble("z", r); }}, | |
| 38 |
1/2✓ Branch 111 → 112 taken 1 time.
✗ Branch 111 → 255 not taken.
|
1 | {new TH1D("PhPerp_dist", "P_{h}^{{}^{#perp}}", n_bins, 0, 2), |
| 39 | 13 | [](auto const& b, auto const r) { return b.getDouble("PhPerp", r); }}, | |
| 40 | { | ||
| 41 |
1/2✓ Branch 113 → 114 taken 1 time.
✗ Branch 113 → 253 not taken.
|
1 | new TH1D("MX_dist", "Missing mass: M_{X} [GeV];", n_bins, 0, 4), |
| 42 |
1/2✓ Branch 3 → 4 taken 13 times.
✗ Branch 3 → 5 not taken.
|
13 | [](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 |
| 43 | }, | ||
| 44 |
1/2✓ Branch 115 → 116 taken 1 time.
✗ Branch 115 → 251 not taken.
|
1 | {new TH1D("xF_dist", "Feynman-x: x_{F};", n_bins, -1, 1), |
| 45 | 13 | [](auto const& b, auto const r) { return b.getDouble("xF", r); }}, | |
| 46 |
1/2✓ Branch 117 → 118 taken 1 time.
✗ Branch 117 → 249 not taken.
|
1 | {new TH1D("yB_dist", "Breit frame rapidity: y_{B};", n_bins, -4, 4), |
| 47 | 13 | [](auto const& b, auto const r) { return b.getDouble("yB", r); }}, | |
| 48 |
1/2✓ Branch 119 → 120 taken 1 time.
✗ Branch 119 → 247 not taken.
|
1 | {new TH1D("phiH_dist", "#phi_{h};", n_bins, -M_PI, M_PI), |
| 49 | 13 | [](auto const& b, auto const r) { return b.getDouble("phiH", r); }}, | |
| 50 |
1/2✓ Branch 121 → 122 taken 1 time.
✗ Branch 121 → 245 not taken.
|
1 | {new TH1D("phiR_dist", "#phi_{R}", n_bins, -M_PI, M_PI), |
| 51 | 13 | [](auto const& b, auto const r) { return b.getDouble("phiR", r); }}, | |
| 52 |
1/2✓ Branch 123 → 124 taken 1 time.
✗ Branch 123 → 243 not taken.
|
1 | {new TH1D("theta_dist", "#theta;", n_bins, 0, M_PI), |
| 53 |
4/10✓ Branch 124 → 125 taken 1 time.
✗ Branch 124 → 237 not taken.
✓ Branch 126 → 127 taken 9 times.
✓ Branch 126 → 130 taken 1 time.
✓ Branch 127 → 128 taken 9 times.
✗ Branch 127 → 129 not taken.
✗ Branch 238 → 239 not taken.
✗ Branch 238 → 242 not taken.
✗ Branch 239 → 240 not taken.
✗ Branch 239 → 241 not taken.
|
24 | [](auto const& b, auto const r) { return b.getDouble("theta", r); }}}; |
| 54 | |||
| 55 | // format plots | ||
| 56 |
2/2✓ Branch 150 → 131 taken 9 times.
✓ Branch 150 → 151 taken 1 time.
|
10 | for(auto& plot : plot_list) { |
| 57 |
1/2✓ Branch 131 → 132 taken 9 times.
✗ Branch 131 → 277 not taken.
|
9 | plot.hist->SetLineColor(kRed); |
| 58 |
1/2✓ Branch 132 → 133 taken 9 times.
✗ Branch 132 → 277 not taken.
|
9 | plot.hist->SetFillColor(kRed); |
| 59 |
1/2✓ Branch 143 → 144 taken 9 times.
✗ Branch 143 → 267 not taken.
|
9 | plot.hist->SetTitle( |
| 60 |
2/4✓ Branch 136 → 137 taken 9 times.
✗ Branch 136 → 275 not taken.
✓ Branch 137 → 138 taken 9 times.
✗ Branch 137 → 275 not taken.
|
18 | TString(particle::title.at(particle::pi_plus)) + |
| 61 |
3/6✓ Branch 134 → 135 taken 9 times.
✗ Branch 134 → 277 not taken.
✓ Branch 135 → 136 taken 9 times.
✗ Branch 135 → 277 not taken.
✓ Branch 138 → 139 taken 9 times.
✗ Branch 138 → 273 not taken.
|
36 | TString(particle::title.at(particle::pi_minus)) + |
| 62 |
3/6✓ Branch 133 → 134 taken 9 times.
✗ Branch 133 → 277 not taken.
✓ Branch 139 → 140 taken 9 times.
✗ Branch 139 → 271 not taken.
✓ Branch 140 → 141 taken 9 times.
✗ Branch 140 → 269 not taken.
|
36 | " " + plot.hist->GetTitle()); |
| 63 | } | ||
| 64 |
9/22✓ Branch 108 → 109 taken 1 time.
✗ Branch 108 → 261 not taken.
✓ Branch 110 → 111 taken 1 time.
✗ Branch 110 → 261 not taken.
✓ Branch 112 → 113 taken 1 time.
✗ Branch 112 → 261 not taken.
✓ Branch 114 → 115 taken 1 time.
✗ Branch 114 → 261 not taken.
✓ Branch 116 → 117 taken 1 time.
✗ Branch 116 → 261 not taken.
✓ Branch 118 → 119 taken 1 time.
✗ Branch 118 → 261 not taken.
✓ Branch 120 → 121 taken 1 time.
✗ Branch 120 → 261 not taken.
✓ Branch 122 → 123 taken 1 time.
✗ Branch 122 → 261 not taken.
✓ Branch 124 → 125 taken 1 time.
✗ Branch 124 → 237 not taken.
✗ Branch 262 → 263 not taken.
✗ Branch 262 → 266 not taken.
✗ Branch 263 → 264 not taken.
✗ Branch 263 → 265 not taken.
|
10 | } |
| 65 | |||
| 66 | |||
| 67 | 1000 | bool DihadronKinematicsValidator::Run(hipo::banklist& banks) const | |
| 68 | { | ||
| 69 | // calculate kinematics | ||
| 70 | 1000 | m_algo_seq->Run(banks); | |
| 71 |
2/4✓ Branch 3 → 4 taken 1000 times.
✗ Branch 3 → 37 not taken.
✓ Branch 4 → 5 taken 1000 times.
✗ Branch 4 → 31 not taken.
|
1000 | auto& result_bank = GetBank(banks, b_result, "physics::DihadronKinematics"); |
| 72 | |||
| 73 | // skip events with no dihadrons | ||
| 74 |
2/2✓ Branch 13 → 14 taken 991 times.
✓ Branch 13 → 16 taken 9 times.
|
2000 | if(result_bank.getRowList().size() == 0) { |
| 75 | 991 | m_log->Debug("skip this event, since it has no kinematics results"); | |
| 76 | 991 | return false; | |
| 77 | } | ||
| 78 | |||
| 79 | // lock mutex and fill the plots | ||
| 80 | 9 | std::scoped_lock<std::mutex> lock(m_mutex); | |
| 81 |
3/4✓ Branch 17 → 18 taken 9 times.
✗ Branch 17 → 38 not taken.
✓ Branch 27 → 19 taken 13 times.
✓ Branch 27 → 28 taken 9 times.
|
22 | for(auto const& row : result_bank.getRowList()) { |
| 82 |
2/2✓ Branch 25 → 20 taken 117 times.
✓ Branch 25 → 26 taken 13 times.
|
130 | for(auto& plot : plot_list) |
| 83 |
2/4✗ Branch 20 → 21 not taken.
✓ Branch 20 → 22 taken 117 times.
✓ Branch 23 → 24 taken 117 times.
✗ Branch 23 → 38 not taken.
|
234 | plot.hist->Fill(plot.get_val(result_bank, row)); |
| 84 | } | ||
| 85 | return true; | ||
| 86 | } | ||
| 87 | |||
| 88 | |||
| 89 | 1 | void DihadronKinematicsValidator::Stop() | |
| 90 | { | ||
| 91 |
1/2✓ Branch 4 → 5 taken 1 time.
✗ Branch 4 → 29 not taken.
|
2 | if(GetOutputDirectory()) { |
| 92 | int const n_cols = 4; | ||
| 93 | 1 | int const n_rows = (plot_list.size() - 1) / n_cols + 1; | |
| 94 |
1/2✓ Branch 8 → 9 taken 1 time.
✗ Branch 8 → 30 not taken.
|
1 | auto canv = new TCanvas("canv", "canv", n_cols * 800, n_rows * 600); |
| 95 | 1 | canv->Divide(n_cols, n_rows); | |
| 96 | int pad_num = 0; | ||
| 97 |
2/2✓ Branch 19 → 11 taken 9 times.
✓ Branch 19 → 20 taken 1 time.
|
10 | for(auto& plot : plot_list) { |
| 98 | 9 | auto pad = canv->GetPad(++pad_num); | |
| 99 | 9 | pad->cd(); | |
| 100 | 9 | pad->SetGrid(1, 1); | |
| 101 | 9 | pad->SetLeftMargin(0.12); | |
| 102 | 9 | pad->SetRightMargin(0.12); | |
| 103 | 9 | pad->SetBottomMargin(0.12); | |
| 104 | 9 | plot.hist->Draw(); | |
| 105 | } | ||
| 106 |
1/2✓ Branch 23 → 24 taken 1 time.
✗ Branch 23 → 32 not taken.
|
2 | canv->SaveAs(m_output_file_basename + ".png"); |
| 107 | 1 | m_output_file->Write(); | |
| 108 | 1 | m_log->Info("Wrote output file {}", m_output_file->GetName()); | |
| 109 | 1 | m_output_file->Close(); | |
| 110 | } | ||
| 111 | 1 | } | |
| 112 | |||
| 113 | } | ||
| 114 |