| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "Validator.h" | ||
| 2 | |||
| 3 | #include <Math/Vector3D.h> | ||
| 4 | |||
| 5 | namespace iguana::physics { | ||
| 6 | |||
| 7 | REGISTER_IGUANA_VALIDATOR(InclusiveKinematicsValidator); | ||
| 8 | |||
| 9 | 1 | void InclusiveKinematicsValidator::Start(hipo::banklist& banks) | |
| 10 | { | ||
| 11 | // define the algorithm sequence | ||
| 12 | 2 | m_algo_seq = std::make_unique<AlgorithmSequence>(); | |
| 13 |
3/8✓ Branch 7 → 8 taken 1 time.
✗ Branch 7 → 100 not taken.
✓ Branch 8 → 9 taken 1 time.
✗ Branch 8 → 94 not taken.
✓ Branch 14 → 15 taken 1 time.
✗ Branch 14 → 17 not taken.
✗ Branch 100 → 101 not taken.
✗ Branch 100 → 103 not taken.
|
2 | m_algo_seq->Add("physics::InclusiveKinematics"); |
| 14 |
2/6✓ Branch 21 → 22 taken 1 time.
✗ Branch 21 → 112 not taken.
✓ Branch 30 → 31 taken 1 time.
✗ Branch 30 → 33 not taken.
✗ Branch 112 → 113 not taken.
✗ Branch 112 → 115 not taken.
|
3 | m_algo_seq->SetOption("physics::InclusiveKinematics", "log", m_log->GetLevel()); |
| 15 | 1 | m_algo_seq->Start(banks); | |
| 16 | |||
| 17 | // get bank indices | ||
| 18 |
2/4✓ Branch 37 → 38 taken 1 time.
✗ Branch 37 → 118 not taken.
✓ Branch 38 → 39 taken 1 time.
✗ Branch 38 → 41 not taken.
|
1 | b_particle = GetBankIndex(banks, "REC::Particle"); |
| 19 |
2/4✓ Branch 44 → 45 taken 1 time.
✗ Branch 44 → 124 not taken.
✗ Branch 45 → 46 not taken.
✓ Branch 45 → 48 taken 1 time.
|
1 | b_result = GetBankIndex(banks, "physics::InclusiveKinematics"); |
| 20 | |||
| 21 | // set an output file | ||
| 22 | 1 | auto output_dir = GetOutputDirectory(); | |
| 23 |
1/2✓ Branch 51 → 52 taken 1 time.
✗ Branch 51 → 66 not taken.
|
1 | if(output_dir) { |
| 24 |
3/6✓ Branch 52 → 53 taken 1 time.
✗ Branch 52 → 156 not taken.
✓ Branch 53 → 54 taken 1 time.
✗ Branch 53 → 130 not taken.
✓ Branch 59 → 60 taken 1 time.
✗ Branch 59 → 156 not taken.
|
2 | m_output_file_basename = output_dir.value() + "/inclusive_kinematics"; |
| 25 |
2/4✓ Branch 60 → 61 taken 1 time.
✗ Branch 60 → 138 not taken.
✓ Branch 63 → 64 taken 1 time.
✗ Branch 63 → 136 not taken.
|
2 | m_output_file = new TFile(m_output_file_basename + ".root", "RECREATE"); |
| 26 | } | ||
| 27 | |||
| 28 | // define plots | ||
| 29 | // clang-format off | ||
| 30 | const int n_bins = 100; | ||
| 31 |
2/4✓ Branch 67 → 68 taken 1 time.
✗ Branch 67 → 140 not taken.
✓ Branch 68 → 69 taken 1 time.
✗ Branch 68 → 156 not taken.
|
1 | lepton_p_dist = new TH1D("lepton_p_dist", "lepton p;p [GeV]", n_bins, 0, 12); |
| 32 |
2/4✓ Branch 69 → 70 taken 1 time.
✗ Branch 69 → 142 not taken.
✓ Branch 70 → 71 taken 1 time.
✗ Branch 70 → 156 not taken.
|
1 | lepton_theta_dist = new TH1D("lepton_theta_dist", "lepton #theta;#theta [deg]", n_bins, 0, 60); |
| 33 |
2/4✓ Branch 71 → 72 taken 1 time.
✗ Branch 71 → 144 not taken.
✓ Branch 72 → 73 taken 1 time.
✗ Branch 72 → 156 not taken.
|
1 | lepton_phi_dist = new TH1D("lepton_phi_dist", "lepton #phi;#phi [deg]", n_bins, -180, 180); |
| 34 |
2/4✓ Branch 73 → 74 taken 1 time.
✗ Branch 73 → 146 not taken.
✓ Branch 74 → 75 taken 1 time.
✗ Branch 74 → 156 not taken.
|
1 | lepton_vz_dist = new TH1D("lepton_vz_dist", "lepton v_{z};v_{z} [cm]", n_bins, -30, 30); |
| 35 |
2/4✓ Branch 75 → 76 taken 1 time.
✗ Branch 75 → 148 not taken.
✓ Branch 76 → 77 taken 1 time.
✗ Branch 76 → 156 not taken.
|
1 | Q2_vs_x = new TH2D("Q2_vs_x", "Q^{2} vs. x;x;Q^{2} [GeV^{2}]", n_bins, 0, 1, n_bins, 0, 12); |
| 36 |
2/4✓ Branch 77 → 78 taken 1 time.
✗ Branch 77 → 150 not taken.
✓ Branch 78 → 79 taken 1 time.
✗ Branch 78 → 156 not taken.
|
1 | Q2_vs_W = new TH2D("Q2_vs_W", "Q^{2} vs. W;W [GeV];Q^{2} [GeV^{2}]", n_bins, 0, 5, n_bins, 0, 12); |
| 37 |
2/4✓ Branch 79 → 80 taken 1 time.
✗ Branch 79 → 152 not taken.
✓ Branch 80 → 81 taken 1 time.
✗ Branch 80 → 156 not taken.
|
1 | y_dist = new TH1D("y_dist", "y distribution;y", n_bins, 0, 1); |
| 38 |
1/2✓ Branch 81 → 82 taken 1 time.
✗ Branch 81 → 154 not taken.
|
1 | nu_dist = new TH1D("nu_dist", "#nu distribution;#nu", n_bins, 0, 12); |
| 39 | // clang-format on | ||
| 40 | |||
| 41 | // format plots | ||
| 42 |
2/2✓ Branch 86 → 83 taken 4 times.
✓ Branch 86 → 87 taken 1 time.
|
5 | for(auto hist : {lepton_p_dist, lepton_theta_dist, lepton_phi_dist, lepton_vz_dist}) { |
| 43 |
1/2✓ Branch 83 → 84 taken 4 times.
✗ Branch 83 → 156 not taken.
|
4 | hist->SetLineColor(kYellow + 2); |
| 44 |
1/2✓ Branch 84 → 85 taken 4 times.
✗ Branch 84 → 156 not taken.
|
4 | hist->SetFillColor(kYellow + 2); |
| 45 | } | ||
| 46 |
2/2✓ Branch 91 → 88 taken 2 times.
✓ Branch 91 → 92 taken 1 time.
|
3 | for(auto hist : {y_dist, nu_dist}) { |
| 47 |
1/2✓ Branch 88 → 89 taken 2 times.
✗ Branch 88 → 156 not taken.
|
2 | hist->SetLineColor(kBlue); |
| 48 |
1/2✓ Branch 89 → 90 taken 2 times.
✗ Branch 89 → 156 not taken.
|
2 | hist->SetFillColor(kBlue); |
| 49 | } | ||
| 50 | 1 | } | |
| 51 | |||
| 52 | |||
| 53 | 1000 | bool InclusiveKinematicsValidator::Run(hipo::banklist& banks) const | |
| 54 | { | ||
| 55 | // calculate kinematics | ||
| 56 | 1000 | m_algo_seq->Run(banks); | |
| 57 |
1/2✓ Branch 4 → 5 taken 1000 times.
✗ Branch 4 → 57 not taken.
|
1000 | auto& particle_bank = GetBank(banks, b_particle, "REC::Particle"); |
| 58 |
1/2✓ Branch 11 → 12 taken 1000 times.
✗ Branch 11 → 63 not taken.
|
1000 | auto& result_bank = GetBank(banks, b_result, "physics::InclusiveKinematics"); |
| 59 | |||
| 60 |
2/2✓ Branch 20 → 21 taken 857 times.
✓ Branch 20 → 23 taken 143 times.
|
2000 | if(result_bank.getRowList().size() == 0) { |
| 61 | 857 | m_log->Debug("skip this event, since it has no inclusive kinematics results"); | |
| 62 | 857 | return false; | |
| 63 | } | ||
| 64 |
1/2✗ Branch 26 → 27 not taken.
✓ Branch 26 → 29 taken 143 times.
|
286 | if(result_bank.getRowList().size() > 1) { |
| 65 | ✗ | m_log->Warn("found event with more than 1 inclusive kinematics bank rows; only the first row will be used"); | |
| 66 | } | ||
| 67 | |||
| 68 | 143 | auto pindex = result_bank.getShort("pindex", 0); | |
| 69 | 143 | auto Q2 = result_bank.getDouble("Q2", 0); | |
| 70 | 143 | auto x = result_bank.getDouble("x", 0); | |
| 71 | 143 | auto W = result_bank.getDouble("W", 0); | |
| 72 | 143 | auto y = result_bank.getDouble("y", 0); | |
| 73 | 143 | auto nu = result_bank.getDouble("nu", 0); | |
| 74 | |||
| 75 | ROOT::Math::XYZVector vec_lepton( | ||
| 76 | 143 | particle_bank.getFloat("px", pindex), | |
| 77 | 143 | particle_bank.getFloat("py", pindex), | |
| 78 | 143 | particle_bank.getFloat("pz", pindex)); | |
| 79 | 143 | auto lepton_p = std::sqrt(vec_lepton.Mag2()); | |
| 80 | 143 | auto lepton_theta = vec_lepton.Theta() * 180.0 / M_PI; | |
| 81 | 143 | auto lepton_phi = vec_lepton.Phi() * 180.0 / M_PI; | |
| 82 | 143 | auto lepton_vz = particle_bank.getFloat("vz", pindex); | |
| 83 |
1/2✗ Branch 42 → 41 not taken.
✓ Branch 42 → 44 taken 143 times.
|
143 | while(lepton_phi > 180) |
| 84 | ✗ | lepton_phi -= 360; | |
| 85 |
1/2✗ Branch 44 → 43 not taken.
✓ Branch 44 → 45 taken 143 times.
|
143 | while(lepton_phi < -180) |
| 86 | ✗ | lepton_phi += 360; | |
| 87 | |||
| 88 | // lock mutex and fill the plots | ||
| 89 | 143 | std::scoped_lock<std::mutex> lock(m_mutex); | |
| 90 |
1/2✓ Branch 46 → 47 taken 143 times.
✗ Branch 46 → 69 not taken.
|
143 | lepton_p_dist->Fill(lepton_p); |
| 91 |
1/2✓ Branch 47 → 48 taken 143 times.
✗ Branch 47 → 69 not taken.
|
143 | lepton_theta_dist->Fill(lepton_theta); |
| 92 |
1/2✓ Branch 48 → 49 taken 143 times.
✗ Branch 48 → 69 not taken.
|
143 | lepton_phi_dist->Fill(lepton_phi); |
| 93 |
1/2✓ Branch 49 → 50 taken 143 times.
✗ Branch 49 → 69 not taken.
|
143 | lepton_vz_dist->Fill(lepton_vz); |
| 94 |
1/2✓ Branch 50 → 51 taken 143 times.
✗ Branch 50 → 69 not taken.
|
143 | Q2_vs_x->Fill(x, Q2); |
| 95 |
1/2✓ Branch 51 → 52 taken 143 times.
✗ Branch 51 → 69 not taken.
|
143 | Q2_vs_W->Fill(W, Q2); |
| 96 |
1/2✓ Branch 52 → 53 taken 143 times.
✗ Branch 52 → 69 not taken.
|
143 | y_dist->Fill(y); |
| 97 |
1/2✓ Branch 53 → 54 taken 143 times.
✗ Branch 53 → 69 not taken.
|
143 | nu_dist->Fill(nu); |
| 98 | return true; | ||
| 99 | } | ||
| 100 | |||
| 101 | |||
| 102 | 1 | void InclusiveKinematicsValidator::Stop() | |
| 103 | { | ||
| 104 |
1/2✓ Branch 4 → 5 taken 1 time.
✗ Branch 4 → 45 not taken.
|
2 | if(GetOutputDirectory()) { |
| 105 | int n_rows = 2; | ||
| 106 | int n_cols = 4; | ||
| 107 |
1/2✓ Branch 6 → 7 taken 1 time.
✗ Branch 6 → 46 not taken.
|
1 | auto canv = new TCanvas("canv", "canv", n_cols * 800, n_rows * 600); |
| 108 | 1 | canv->Divide(n_cols, n_rows); | |
| 109 |
2/2✓ Branch 35 → 9 taken 8 times.
✓ Branch 35 → 36 taken 1 time.
|
9 | for(int pad_num = 1; pad_num <= n_rows * n_cols; pad_num++) { |
| 110 | 8 | auto pad = canv->GetPad(pad_num); | |
| 111 | 8 | pad->cd(); | |
| 112 | 8 | pad->SetGrid(1, 1); | |
| 113 | 8 | pad->SetLeftMargin(0.12); | |
| 114 | 8 | pad->SetRightMargin(0.12); | |
| 115 | 8 | pad->SetBottomMargin(0.12); | |
| 116 |
8/8✓ Branch 15 → 16 taken 1 time.
✓ Branch 15 → 18 taken 1 time.
✓ Branch 15 → 20 taken 1 time.
✓ Branch 15 → 22 taken 1 time.
✓ Branch 15 → 24 taken 1 time.
✓ Branch 15 → 27 taken 1 time.
✓ Branch 15 → 30 taken 1 time.
✓ Branch 15 → 32 taken 1 time.
|
8 | switch(pad_num) { |
| 117 | 1 | case 1: | |
| 118 | 1 | lepton_p_dist->Draw(); | |
| 119 | 1 | break; | |
| 120 | 1 | case 2: | |
| 121 | 1 | lepton_theta_dist->Draw(); | |
| 122 | 1 | break; | |
| 123 | 1 | case 3: | |
| 124 | 1 | lepton_phi_dist->Draw(); | |
| 125 | 1 | break; | |
| 126 | 1 | case 4: | |
| 127 | 1 | lepton_vz_dist->Draw(); | |
| 128 | 1 | break; | |
| 129 | 1 | case 5: | |
| 130 | 1 | pad->SetLogz(); | |
| 131 | 1 | Q2_vs_x->Draw("colz"); | |
| 132 | 1 | break; | |
| 133 | 1 | case 6: | |
| 134 | 1 | pad->SetLogz(); | |
| 135 | 1 | Q2_vs_W->Draw("colz"); | |
| 136 | 1 | break; | |
| 137 | 1 | case 7: | |
| 138 | 1 | y_dist->Draw(); | |
| 139 | 1 | break; | |
| 140 | 1 | case 8: | |
| 141 | 1 | nu_dist->Draw(); | |
| 142 | 1 | break; | |
| 143 | } | ||
| 144 | } | ||
| 145 |
1/2✓ Branch 39 → 40 taken 1 time.
✗ Branch 39 → 48 not taken.
|
2 | canv->SaveAs(m_output_file_basename + ".png"); |
| 146 | 1 | m_output_file->Write(); | |
| 147 | 1 | m_log->Info("Wrote output file {}", m_output_file->GetName()); | |
| 148 | 1 | m_output_file->Close(); | |
| 149 | } | ||
| 150 | 1 | } | |
| 151 | |||
| 152 | } | ||
| 153 |