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