src/iguana/algorithms/clas12/ZVertexFilter/Validator.cc
| 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::StartHook(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 → 91 not taken.
✓ Branch 8 → 9 taken 1 time.
✗ Branch 8 → 85 not taken.
✓ Branch 14 → 15 taken 1 time.
✗ Branch 14 → 17 not taken.
✗ Branch 91 → 92 not taken.
✗ Branch 91 → 94 not taken.
|
2 | m_algo_seq->Add("clas12::ZVertexFilter"); |
| 15 | 1 | m_algo_seq->Start(banks); | |
| 16 | |||
| 17 | // get bank indices | ||
| 18 |
2/4✓ Branch 21 → 22 taken 1 time.
✗ Branch 21 → 97 not taken.
✓ Branch 22 → 23 taken 1 time.
✗ Branch 22 → 25 not taken.
|
1 | b_particle = GetBankIndex(banks, "REC::Particle"); |
| 19 | |||
| 20 | // set an output file | ||
| 21 | 1 | auto output_dir = GetOutputDirectory(); | |
| 22 |
1/2✓ Branch 28 → 29 taken 1 time.
✗ Branch 28 → 43 not taken.
|
1 | if(output_dir) { |
| 23 |
3/6✓ Branch 29 → 30 taken 1 time.
✗ Branch 29 → 138 not taken.
✓ Branch 30 → 31 taken 1 time.
✗ Branch 30 → 103 not taken.
✓ Branch 36 → 37 taken 1 time.
✗ Branch 36 → 138 not taken.
|
2 | m_output_file_basename = output_dir.value() + "/zvertex_filter"; |
| 24 |
2/4✓ Branch 37 → 38 taken 1 time.
✗ Branch 37 → 111 not taken.
✓ Branch 40 → 41 taken 1 time.
✗ Branch 40 → 109 not taken.
|
2 | m_output_file = new TFile(m_output_file_basename + ".root", "RECREATE"); |
| 25 | } | ||
| 26 | |||
| 27 | // define plots | ||
| 28 |
2/2✓ Branch 82 → 44 taken 5 times.
✓ Branch 82 → 83 taken 1 time.
|
6 | for(auto const& pdg : u_pdg_list) { |
| 29 | std::vector<TH1D*> zvertexplots; | ||
| 30 |
2/6✓ Branch 44 → 45 taken 5 times.
✗ Branch 44 → 134 not taken.
✓ Branch 45 → 46 taken 5 times.
✗ Branch 45 → 134 not taken.
✗ Branch 134 → 135 not taken.
✗ Branch 134 → 137 not taken.
|
5 | TString particle_name = particle::name.at(particle::PDG(pdg)); |
| 31 |
2/4✓ Branch 46 → 47 taken 5 times.
✗ Branch 46 → 132 not taken.
✓ Branch 47 → 48 taken 5 times.
✗ Branch 47 → 132 not taken.
|
5 | TString particle_title = particle::title.at(particle::PDG(pdg)); |
| 32 |
2/2✓ Branch 69 → 49 taken 10 times.
✓ Branch 69 → 70 taken 5 times.
|
15 | for(int i = 0; i < 2; i++) { |
| 33 |
1/2✓ Branch 49 → 50 taken 10 times.
✗ Branch 49 → 130 not taken.
|
10 | TString beforeafter_name = "before"; |
| 34 |
2/2✓ Branch 50 → 51 taken 5 times.
✓ Branch 50 → 52 taken 5 times.
|
10 | if(i == 1) { |
| 35 |
1/2✓ Branch 51 → 52 taken 5 times.
✗ Branch 51 → 124 not taken.
|
5 | beforeafter_name = "after"; |
| 36 | } | ||
| 37 | |||
| 38 |
1/2✓ Branch 62 → 63 taken 10 times.
✗ Branch 62 → 113 not taken.
|
10 | zvertexplots.push_back(new TH1D( |
| 39 |
3/6✓ Branch 56 → 57 taken 10 times.
✗ Branch 56 → 119 not taken.
✓ Branch 57 → 58 taken 10 times.
✗ Branch 57 → 117 not taken.
✓ Branch 58 → 59 taken 10 times.
✗ Branch 58 → 115 not taken.
|
20 | "zvertexplots_" + particle_name + "_" + beforeafter_name, |
| 40 |
1/4✓ Branch 53 → 54 taken 10 times.
✗ Branch 53 → 121 not taken.
✗ Branch 121 → 122 not taken.
✗ Branch 121 → 123 not taken.
|
20 | particle_title + " Z Vertex ; Z Vertex [cm]", |
| 41 |
1/2✓ Branch 61 → 62 taken 10 times.
✗ Branch 61 → 113 not taken.
|
10 | 200, -40, 40)); |
| 42 | |||
| 43 | // std::cout<<"Adding plots for "<<pdg<<" "<<beforeafter_name<<std::endl; | ||
| 44 | 10 | } | |
| 45 | 5 | u_zvertexplots.insert({pdg, zvertexplots}); | |
| 46 | 5 | } | |
| 47 | 1 | } | |
| 48 | |||
| 49 | |||
| 50 | 1000 | bool ZVertexFilterValidator::RunHook(hipo::banklist& banks) const | |
| 51 | { | ||
| 52 |
1/2✓ Branch 3 → 4 taken 1000 times.
✗ Branch 3 → 41 not taken.
|
1000 | auto& particle_bank = GetBank(banks, b_particle, "REC::Particle"); |
| 53 | |||
| 54 | // lock the mutex, so we can mutate plots | ||
| 55 | 1000 | std::scoped_lock<std::mutex> lock(m_mutex); | |
| 56 | |||
| 57 | // fill the plots before | ||
| 58 |
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()) { |
| 59 | 6993 | double vz = particle_bank.getFloat("vz", row); | |
| 60 | 6993 | int pdg = particle_bank.getInt("pid", row); | |
| 61 | 6993 | int status = particle_bank.getShort("status", row); | |
| 62 | auto it = u_zvertexplots.find(pdg); | ||
| 63 | // check if pdg is amongs those that we want to plot | ||
| 64 |
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) { |
| 65 |
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); |
| 66 | } | ||
| 67 | } | ||
| 68 | |||
| 69 | // run the momentum corrections | ||
| 70 |
1/2✓ Branch 24 → 25 taken 1000 times.
✗ Branch 24 → 47 not taken.
|
1000 | m_algo_seq->Run(banks); |
| 71 | |||
| 72 | // fill the plots after | ||
| 73 |
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()) { |
| 74 | 6972 | double vz = particle_bank.getFloat("vz", row); | |
| 75 | 6972 | int pdg = particle_bank.getInt("pid", row); | |
| 76 | 6972 | int status = particle_bank.getShort("status", row); | |
| 77 | auto it = u_zvertexplots.find(pdg); | ||
| 78 | // check if pdg is amongs those that we want to plot | ||
| 79 |
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) { |
| 80 |
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); |
| 81 | } | ||
| 82 | } | ||
| 83 | 1000 | return true; | |
| 84 | } | ||
| 85 | |||
| 86 | 1 | void ZVertexFilterValidator::StopHook() | |
| 87 | { | ||
| 88 |
1/2✓ Branch 4 → 5 taken 1 time.
✗ Branch 4 → 49 not taken.
|
2 | if(GetOutputDirectory()) { |
| 89 |
2/2✓ Branch 44 → 6 taken 5 times.
✓ Branch 44 → 45 taken 1 time.
|
6 | for(auto const& [pdg, plots] : u_zvertexplots) { |
| 90 | 5 | TString canv_name = Form("canv%d", pdg); | |
| 91 |
1/2✓ Branch 11 → 12 taken 5 times.
✗ Branch 11 → 50 not taken.
|
5 | auto canv = new TCanvas(canv_name, canv_name, 800, 600); |
| 92 | |||
| 93 |
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); |
| 94 |
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); |
| 95 |
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(""); |
| 96 | |||
| 97 |
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); |
| 98 |
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); |
| 99 |
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"); |
| 100 | |||
| 101 |
1/2✓ Branch 24 → 25 taken 5 times.
✗ Branch 24 → 66 not taken.
|
5 | canv->Draw(); |
| 102 |
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"); |
| 103 | 5 | } | |
| 104 | 1 | m_output_file->Write(); | |
| 105 | 1 | m_log->Info("Wrote output file {}", m_output_file->GetName()); | |
| 106 | 1 | m_output_file->Close(); | |
| 107 | } | ||
| 108 | 1 | } | |
| 109 | |||
| 110 | } | ||
| 111 |