Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "Validator.h" | ||
2 | |||
3 | #include <TStyle.h> | ||
4 | #include <TCanvas.h> | ||
5 | #include <TLegend.h> | ||
6 | |||
7 | namespace iguana::clas12 { | ||
8 | |||
9 | REGISTER_IGUANA_VALIDATOR(ZVertexFilterValidator); | ||
10 | |||
11 | 1 | void ZVertexFilterValidator::Start(hipo::banklist& banks) | |
12 | { | ||
13 | // define the algorithm sequence | ||
14 | 2 | m_algo_seq = std::make_unique<AlgorithmSequence>(); | |
15 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | m_algo_seq->Add("clas12::ZVertexFilter"); |
16 |
4/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
3 | m_algo_seq->SetOption<std::vector<int>>("clas12::ZVertexFilter", "pids", u_pdgtocut_list); |
17 |
4/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
3 | m_algo_seq->SetOption<std::vector<double>>("clas12::ZVertexFilter", "cuts", u_cuts_list); |
18 | 1 | m_algo_seq->Start(banks); | |
19 | |||
20 | // get bank indices | ||
21 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | b_particle = GetBankIndex(banks, "REC::Particle"); |
22 | |||
23 | // set an output file | ||
24 | 1 | auto output_dir = GetOutputDirectory(); | |
25 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(output_dir) { |
26 |
3/8✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
2 | m_output_file_basename = output_dir.value() + "/zvertex_filter"; |
27 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | m_output_file = new TFile(m_output_file_basename + ".root", "RECREATE"); |
28 | } | ||
29 | |||
30 | // define plots | ||
31 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | gStyle->SetOptStat(0); |
32 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
|
6 | for(auto const& pdg : u_pdg_list) { |
33 | std::vector<TH1D*> zvertexplots; | ||
34 |
2/6✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
5 | TString particle_name = particle::name.at(particle::PDG(pdg)); |
35 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | TString particle_title = particle::title.at(particle::PDG(pdg)); |
36 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 5 times.
|
15 | for(int i = 0; i < 2; i++) { |
37 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | TString beforeafter_name = "before"; |
38 |
3/4✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
10 | if (i == 1){ beforeafter_name = "after";} |
39 | |||
40 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | zvertexplots.push_back(new TH1D( |
41 |
3/6✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
|
20 | "zvertexplots_" + particle_name + "_" + beforeafter_name, |
42 |
1/4✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
20 | particle_title + " Z Vertex ; Z Vertex [cm]", |
43 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 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 | void ZVertexFilterValidator::Run(hipo::banklist& banks) const | |
53 | { | ||
54 |
1/2✓ Branch 0 taken 1000 times.
✗ Branch 1 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 0 taken 1000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7143 times.
✓ Branch 3 taken 1000 times.
|
8143 | for(auto const& row : particle_bank.getRowList()) { |
61 | 7143 | double vz = particle_bank.getFloat("vz", row); | |
62 | 7143 | int pdg = particle_bank.getInt("pid", row); | |
63 | 7143 | 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 0 taken 4174 times.
✓ Branch 1 taken 2969 times.
✓ Branch 2 taken 3645 times.
✓ Branch 3 taken 529 times.
|
7143 | if (it != u_zvertexplots.end() && abs(status)>=2000) { |
67 |
2/4✓ Branch 0 taken 3645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3645 times.
✗ Branch 3 not taken.
|
3645 | u_zvertexplots.at(pdg).at(0)->Fill(vz); |
68 | } | ||
69 | } | ||
70 | |||
71 | // run the momentum corrections | ||
72 |
1/2✓ Branch 0 taken 1000 times.
✗ Branch 1 not taken.
|
1000 | m_algo_seq->Run(banks); |
73 | |||
74 | // fill the plots after | ||
75 |
3/4✓ Branch 0 taken 1000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7141 times.
✓ Branch 3 taken 1000 times.
|
8141 | for(auto const& row : particle_bank.getRowList()) { |
76 | 7141 | double vz = particle_bank.getFloat("vz", row); | |
77 | 7141 | int pdg = particle_bank.getInt("pid", row); | |
78 | 7141 | 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 0 taken 4172 times.
✓ Branch 1 taken 2969 times.
✓ Branch 2 taken 3643 times.
✓ Branch 3 taken 529 times.
|
7141 | if (it != u_zvertexplots.end() && abs(status)>=2000) { |
82 |
2/4✓ Branch 0 taken 3643 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3643 times.
✗ Branch 3 not taken.
|
3643 | u_zvertexplots.at(pdg).at(1)->Fill(vz); |
83 | } | ||
84 | } | ||
85 | 1000 | } | |
86 | |||
87 | 1 | void ZVertexFilterValidator::Stop() | |
88 | { | ||
89 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | if(GetOutputDirectory()) { |
90 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
|
6 | for(auto const& [pdg, plots] : u_zvertexplots) { |
91 | 5 | TString canv_name = Form("canv%d", pdg); | |
92 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | auto canv = new TCanvas(canv_name, canv_name, 800, 600); |
93 | |||
94 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | plots.at(0)->SetLineColor(kBlue); |
95 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | plots.at(0)->SetLineWidth(2); |
96 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | plots.at(0)->Draw(""); |
97 | |||
98 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | plots.at(1)->SetLineColor(kRed); |
99 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | plots.at(1)->SetLineWidth(2); |
100 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | plots.at(1)->Draw("same"); |
101 | |||
102 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | canv->Draw(); |
103 |
5/10✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
|
10 | canv->SaveAs(m_output_file_basename + "_" + std::to_string(pdg) + ".png"); |
104 | 5 | } | |
105 | 1 | m_output_file->Write(); | |
106 | 1 | m_log->Info("Wrote output file {}", m_output_file->GetName()); | |
107 | 1 | m_output_file->Close(); | |
108 | } | ||
109 | 1 | } | |
110 | |||
111 | } | ||
112 |