| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "Validator.h" | ||
| 2 | |||
| 3 | #include <TCanvas.h> | ||
| 4 | #include <TLegend.h> | ||
| 5 | |||
| 6 | namespace iguana::clas12 { | ||
| 7 | |||
| 8 | REGISTER_IGUANA_VALIDATOR(ZVertexFilterValidator); | ||
| 9 | |||
| 10 | 1 | void ZVertexFilterValidator::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 → 125 not taken.
✓ Branch 8 → 9 taken 1 time.
✗ Branch 8 → 119 not taken.
✓ Branch 14 → 15 taken 1 time.
✗ Branch 14 → 17 not taken.
✗ Branch 125 → 126 not taken.
✗ Branch 125 → 128 not taken.
|
2 | m_algo_seq->Add("clas12::ZVertexFilter"); |
| 15 |
5/14✓ Branch 20 → 21 taken 1 time.
✗ Branch 20 → 143 not taken.
✓ Branch 21 → 22 taken 1 time.
✗ Branch 21 → 137 not taken.
✓ Branch 22 → 23 taken 1 time.
✗ Branch 22 → 131 not taken.
✓ Branch 28 → 29 taken 1 time.
✗ Branch 28 → 31 not taken.
✓ Branch 33 → 34 taken 1 time.
✗ Branch 33 → 36 not taken.
✗ Branch 137 → 138 not taken.
✗ Branch 137 → 140 not taken.
✗ Branch 143 → 144 not taken.
✗ Branch 143 → 146 not taken.
|
4 | m_algo_seq->SetOption<std::vector<int>>("clas12::ZVertexFilter", "pids", u_pdgtocut_list); |
| 16 |
5/14✓ Branch 37 → 38 taken 1 time.
✗ Branch 37 → 159 not taken.
✓ Branch 38 → 39 taken 1 time.
✗ Branch 38 → 153 not taken.
✓ Branch 39 → 40 taken 1 time.
✗ Branch 39 → 147 not taken.
✓ Branch 45 → 46 taken 1 time.
✗ Branch 45 → 48 not taken.
✓ Branch 50 → 51 taken 1 time.
✗ Branch 50 → 53 not taken.
✗ Branch 153 → 154 not taken.
✗ Branch 153 → 156 not taken.
✗ Branch 159 → 160 not taken.
✗ Branch 159 → 162 not taken.
|
4 | m_algo_seq->SetOption<std::vector<double>>("clas12::ZVertexFilter", "cuts", u_cuts_list); |
| 17 | 1 | m_algo_seq->Start(banks); | |
| 18 | |||
| 19 | // get bank indices | ||
| 20 |
2/4✓ Branch 55 → 56 taken 1 time.
✗ Branch 55 → 163 not taken.
✓ Branch 56 → 57 taken 1 time.
✗ Branch 56 → 59 not taken.
|
1 | b_particle = GetBankIndex(banks, "REC::Particle"); |
| 21 | |||
| 22 | // set an output file | ||
| 23 | 1 | auto output_dir = GetOutputDirectory(); | |
| 24 |
1/2✓ Branch 62 → 63 taken 1 time.
✗ Branch 62 → 77 not taken.
|
1 | if(output_dir) { |
| 25 |
3/6✓ Branch 63 → 64 taken 1 time.
✗ Branch 63 → 204 not taken.
✓ Branch 64 → 65 taken 1 time.
✗ Branch 64 → 169 not taken.
✓ Branch 70 → 71 taken 1 time.
✗ Branch 70 → 204 not taken.
|
2 | m_output_file_basename = output_dir.value() + "/zvertex_filter"; |
| 26 |
2/4✓ Branch 71 → 72 taken 1 time.
✗ Branch 71 → 177 not taken.
✓ Branch 74 → 75 taken 1 time.
✗ Branch 74 → 175 not taken.
|
2 | m_output_file = new TFile(m_output_file_basename + ".root", "RECREATE"); |
| 27 | } | ||
| 28 | |||
| 29 | // define plots | ||
| 30 |
2/2✓ Branch 116 → 78 taken 5 times.
✓ Branch 116 → 117 taken 1 time.
|
6 | for(auto const& pdg : u_pdg_list) { |
| 31 | std::vector<TH1D*> zvertexplots; | ||
| 32 |
2/6✓ Branch 78 → 79 taken 5 times.
✗ Branch 78 → 200 not taken.
✓ Branch 79 → 80 taken 5 times.
✗ Branch 79 → 200 not taken.
✗ Branch 200 → 201 not taken.
✗ Branch 200 → 203 not taken.
|
5 | TString particle_name = particle::name.at(particle::PDG(pdg)); |
| 33 |
2/4✓ Branch 80 → 81 taken 5 times.
✗ Branch 80 → 198 not taken.
✓ Branch 81 → 82 taken 5 times.
✗ Branch 81 → 198 not taken.
|
5 | TString particle_title = particle::title.at(particle::PDG(pdg)); |
| 34 |
2/2✓ Branch 103 → 83 taken 10 times.
✓ Branch 103 → 104 taken 5 times.
|
15 | for(int i = 0; i < 2; i++) { |
| 35 |
1/2✓ Branch 83 → 84 taken 10 times.
✗ Branch 83 → 196 not taken.
|
10 | TString beforeafter_name = "before"; |
| 36 |
2/2✓ Branch 84 → 85 taken 5 times.
✓ Branch 84 → 86 taken 5 times.
|
10 | if(i == 1) { |
| 37 |
1/2✓ Branch 85 → 86 taken 5 times.
✗ Branch 85 → 190 not taken.
|
5 | beforeafter_name = "after"; |
| 38 | } | ||
| 39 | |||
| 40 |
1/2✓ Branch 96 → 97 taken 10 times.
✗ Branch 96 → 179 not taken.
|
10 | zvertexplots.push_back(new TH1D( |
| 41 |
3/6✓ Branch 90 → 91 taken 10 times.
✗ Branch 90 → 185 not taken.
✓ Branch 91 → 92 taken 10 times.
✗ Branch 91 → 183 not taken.
✓ Branch 92 → 93 taken 10 times.
✗ Branch 92 → 181 not taken.
|
20 | "zvertexplots_" + particle_name + "_" + beforeafter_name, |
| 42 |
1/4✓ Branch 87 → 88 taken 10 times.
✗ Branch 87 → 187 not taken.
✗ Branch 187 → 188 not taken.
✗ Branch 187 → 189 not taken.
|
20 | particle_title + " Z Vertex ; Z Vertex [cm]", |
| 43 |
1/2✓ Branch 95 → 96 taken 10 times.
✗ Branch 95 → 179 not taken.
|
10 | 200, -40, 40)); |
| 44 | |||
| 45 | // std::cout<<"Adding plots for "<<pdg<<" "<<beforeafter_name<<std::endl; | ||
| 46 | 10 | } | |
| 47 | 5 | u_zvertexplots.insert({pdg, zvertexplots}); | |
| 48 | 5 | } | |
| 49 | 1 | } | |
| 50 | |||
| 51 | |||
| 52 | 1000 | bool ZVertexFilterValidator::Run(hipo::banklist& banks) const | |
| 53 | { | ||
| 54 |
1/2✓ Branch 3 → 4 taken 1000 times.
✗ Branch 3 → 41 not taken.
|
1000 | auto& particle_bank = GetBank(banks, b_particle, "REC::Particle"); |
| 55 | |||
| 56 | // lock the mutex, so we can mutate plots | ||
| 57 | 1000 | std::scoped_lock<std::mutex> lock(m_mutex); | |
| 58 | |||
| 59 | // fill the plots before | ||
| 60 |
3/4✓ Branch 10 → 11 taken 1000 times.
✗ Branch 10 → 47 not taken.
✓ Branch 23 → 12 taken 6993 times.
✓ Branch 23 → 24 taken 1000 times.
|
7993 | for(auto const& row : particle_bank.getRowList()) { |
| 61 | 6993 | double vz = particle_bank.getFloat("vz", row); | |
| 62 | 6993 | int pdg = particle_bank.getInt("pid", row); | |
| 63 | 6993 | int status = particle_bank.getShort("status", row); | |
| 64 | auto it = u_zvertexplots.find(pdg); | ||
| 65 | // check if pdg is amongs those that we want to plot | ||
| 66 |
4/4✓ Branch 17 → 18 taken 4077 times.
✓ Branch 17 → 22 taken 2916 times.
✓ Branch 18 → 19 taken 3583 times.
✓ Branch 18 → 22 taken 494 times.
|
6993 | if(it != u_zvertexplots.end() && abs(status) >= 2000) { |
| 67 |
2/4✓ Branch 20 → 21 taken 3583 times.
✗ Branch 20 → 47 not taken.
✓ Branch 21 → 22 taken 3583 times.
✗ Branch 21 → 47 not taken.
|
3583 | u_zvertexplots.at(pdg).at(0)->Fill(vz); |
| 68 | } | ||
| 69 | } | ||
| 70 | |||
| 71 | // run the momentum corrections | ||
| 72 |
1/2✓ Branch 24 → 25 taken 1000 times.
✗ Branch 24 → 47 not taken.
|
1000 | m_algo_seq->Run(banks); |
| 73 | |||
| 74 | // fill the plots after | ||
| 75 |
3/4✓ Branch 25 → 26 taken 1000 times.
✗ Branch 25 → 47 not taken.
✓ Branch 38 → 27 taken 6972 times.
✓ Branch 38 → 39 taken 1000 times.
|
7972 | for(auto const& row : particle_bank.getRowList()) { |
| 76 | 6972 | double vz = particle_bank.getFloat("vz", row); | |
| 77 | 6972 | int pdg = particle_bank.getInt("pid", row); | |
| 78 | 6972 | int status = particle_bank.getShort("status", row); | |
| 79 | auto it = u_zvertexplots.find(pdg); | ||
| 80 | // check if pdg is amongs those that we want to plot | ||
| 81 |
4/4✓ Branch 32 → 33 taken 4056 times.
✓ Branch 32 → 37 taken 2916 times.
✓ Branch 33 → 34 taken 3562 times.
✓ Branch 33 → 37 taken 494 times.
|
6972 | if(it != u_zvertexplots.end() && abs(status) >= 2000) { |
| 82 |
2/4✓ Branch 35 → 36 taken 3562 times.
✗ Branch 35 → 47 not taken.
✓ Branch 36 → 37 taken 3562 times.
✗ Branch 36 → 47 not taken.
|
3562 | u_zvertexplots.at(pdg).at(1)->Fill(vz); |
| 83 | } | ||
| 84 | } | ||
| 85 | 1000 | return true; | |
| 86 | } | ||
| 87 | |||
| 88 | 1 | void ZVertexFilterValidator::Stop() | |
| 89 | { | ||
| 90 |
1/2✓ Branch 4 → 5 taken 1 time.
✗ Branch 4 → 49 not taken.
|
2 | if(GetOutputDirectory()) { |
| 91 |
2/2✓ Branch 44 → 6 taken 5 times.
✓ Branch 44 → 45 taken 1 time.
|
6 | for(auto const& [pdg, plots] : u_zvertexplots) { |
| 92 | 5 | TString canv_name = Form("canv%d", pdg); | |
| 93 |
1/2✓ Branch 11 → 12 taken 5 times.
✗ Branch 11 → 50 not taken.
|
5 | auto canv = new TCanvas(canv_name, canv_name, 800, 600); |
| 94 | |||
| 95 |
2/4✓ Branch 12 → 13 taken 5 times.
✗ Branch 12 → 66 not taken.
✓ Branch 13 → 14 taken 5 times.
✗ Branch 13 → 66 not taken.
|
5 | plots.at(0)->SetLineColor(kBlue); |
| 96 |
2/4✓ Branch 14 → 15 taken 5 times.
✗ Branch 14 → 66 not taken.
✓ Branch 15 → 16 taken 5 times.
✗ Branch 15 → 66 not taken.
|
5 | plots.at(0)->SetLineWidth(2); |
| 97 |
2/4✓ Branch 16 → 17 taken 5 times.
✗ Branch 16 → 66 not taken.
✓ Branch 17 → 18 taken 5 times.
✗ Branch 17 → 66 not taken.
|
5 | plots.at(0)->Draw(""); |
| 98 | |||
| 99 |
2/4✓ Branch 18 → 19 taken 5 times.
✗ Branch 18 → 66 not taken.
✓ Branch 19 → 20 taken 5 times.
✗ Branch 19 → 66 not taken.
|
5 | plots.at(1)->SetLineColor(kRed); |
| 100 |
2/4✓ Branch 20 → 21 taken 5 times.
✗ Branch 20 → 66 not taken.
✓ Branch 21 → 22 taken 5 times.
✗ Branch 21 → 66 not taken.
|
5 | plots.at(1)->SetLineWidth(2); |
| 101 |
2/4✓ Branch 22 → 23 taken 5 times.
✗ Branch 22 → 66 not taken.
✓ Branch 23 → 24 taken 5 times.
✗ Branch 23 → 66 not taken.
|
5 | plots.at(1)->Draw("same"); |
| 102 | |||
| 103 |
1/2✓ Branch 24 → 25 taken 5 times.
✗ Branch 24 → 66 not taken.
|
5 | canv->Draw(); |
| 104 |
5/10✓ Branch 26 → 27 taken 5 times.
✗ Branch 26 → 60 not taken.
✓ Branch 27 → 28 taken 5 times.
✗ Branch 27 → 58 not taken.
✓ Branch 28 → 29 taken 5 times.
✗ Branch 28 → 56 not taken.
✓ Branch 29 → 30 taken 5 times.
✗ Branch 29 → 54 not taken.
✓ Branch 32 → 33 taken 5 times.
✗ Branch 32 → 52 not taken.
|
10 | canv->SaveAs(m_output_file_basename + "_" + std::to_string(pdg) + ".png"); |
| 105 | 5 | } | |
| 106 | 1 | m_output_file->Write(); | |
| 107 | 1 | m_log->Info("Wrote output file {}", m_output_file->GetName()); | |
| 108 | 1 | m_output_file->Close(); | |
| 109 | } | ||
| 110 | 1 | } | |
| 111 | |||
| 112 | } | ||
| 113 |