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 (7→8) taken 1 times.
✗ Branch 1 (7→92) not taken.
✓ Branch 2 (8→9) taken 1 times.
✗ Branch 3 (8→90) not taken.
|
2 | m_algo_seq->Add("clas12::ZVertexFilter"); |
16 |
4/10✓ Branch 0 (12→13) taken 1 times.
✗ Branch 1 (12→98) not taken.
✓ Branch 2 (13→14) taken 1 times.
✗ Branch 3 (13→96) not taken.
✓ Branch 4 (14→15) taken 1 times.
✗ Branch 5 (14→94) not taken.
✓ Branch 6 (17→18) taken 1 times.
✗ Branch 7 (17→20) not taken.
✗ Branch 8 (98→99) not taken.
✗ Branch 9 (98→101) not taken.
|
3 | m_algo_seq->SetOption<std::vector<int>>("clas12::ZVertexFilter", "pids", u_pdgtocut_list); |
17 |
4/10✓ Branch 0 (21→22) taken 1 times.
✗ Branch 1 (21→106) not taken.
✓ Branch 2 (22→23) taken 1 times.
✗ Branch 3 (22→104) not taken.
✓ Branch 4 (23→24) taken 1 times.
✗ Branch 5 (23→102) not taken.
✓ Branch 6 (26→27) taken 1 times.
✗ Branch 7 (26→29) not taken.
✗ Branch 8 (106→107) not taken.
✗ Branch 9 (106→109) 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 (31→32) taken 1 times.
✗ Branch 1 (31→110) 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 (34→35) taken 1 times.
✗ Branch 1 (34→45) not taken.
|
1 | if(output_dir) { |
26 |
3/8✓ Branch 0 (35→36) taken 1 times.
✗ Branch 1 (35→143) not taken.
✓ Branch 2 (36→37) taken 1 times.
✗ Branch 3 (36→112) not taken.
✓ Branch 4 (38→39) taken 1 times.
✗ Branch 5 (38→143) not taken.
✗ Branch 6 (143→144) not taken.
✗ Branch 7 (143→146) not taken.
|
2 | m_output_file_basename = output_dir.value() + "/zvertex_filter"; |
27 |
2/4✓ Branch 0 (39→40) taken 1 times.
✗ Branch 1 (39→116) not taken.
✓ Branch 2 (42→43) taken 1 times.
✗ Branch 3 (42→114) not taken.
|
2 | m_output_file = new TFile(m_output_file_basename + ".root", "RECREATE"); |
28 | } | ||
29 | |||
30 | // define plots | ||
31 |
1/2✓ Branch 0 (45→46) taken 1 times.
✗ Branch 1 (45→143) not taken.
|
1 | gStyle->SetOptStat(0); |
32 |
2/2✓ Branch 0 (85→47) taken 5 times.
✓ Branch 1 (85→86) taken 1 times.
|
6 | for(auto const& pdg : u_pdg_list) { |
33 | std::vector<TH1D*> zvertexplots; | ||
34 |
2/6✓ Branch 0 (47→48) taken 5 times.
✗ Branch 1 (47→139) not taken.
✓ Branch 2 (48→49) taken 5 times.
✗ Branch 3 (48→139) not taken.
✗ Branch 4 (139→140) not taken.
✗ Branch 5 (139→142) not taken.
|
5 | TString particle_name = particle::name.at(particle::PDG(pdg)); |
35 |
2/4✓ Branch 0 (49→50) taken 5 times.
✗ Branch 1 (49→137) not taken.
✓ Branch 2 (50→51) taken 5 times.
✗ Branch 3 (50→137) not taken.
|
5 | TString particle_title = particle::title.at(particle::PDG(pdg)); |
36 |
2/2✓ Branch 0 (72→52) taken 10 times.
✓ Branch 1 (72→73) taken 5 times.
|
15 | for(int i = 0; i < 2; i++) { |
37 |
1/2✓ Branch 0 (52→53) taken 10 times.
✗ Branch 1 (52→135) not taken.
|
10 | TString beforeafter_name = "before"; |
38 |
3/4✓ Branch 0 (53→54) taken 5 times.
✓ Branch 1 (53→55) taken 5 times.
✓ Branch 2 (54→55) taken 5 times.
✗ Branch 3 (54→129) not taken.
|
10 | if (i == 1){ beforeafter_name = "after";} |
39 | |||
40 |
1/2✓ Branch 0 (65→66) taken 10 times.
✗ Branch 1 (65→118) not taken.
|
10 | zvertexplots.push_back(new TH1D( |
41 |
3/6✓ Branch 0 (59→60) taken 10 times.
✗ Branch 1 (59→124) not taken.
✓ Branch 2 (60→61) taken 10 times.
✗ Branch 3 (60→122) not taken.
✓ Branch 4 (61→62) taken 10 times.
✗ Branch 5 (61→120) not taken.
|
20 | "zvertexplots_" + particle_name + "_" + beforeafter_name, |
42 |
1/4✓ Branch 0 (56→57) taken 10 times.
✗ Branch 1 (56→126) not taken.
✗ Branch 2 (126→127) not taken.
✗ Branch 3 (126→128) not taken.
|
20 | particle_title + " Z Vertex ; Z Vertex [cm]", |
43 |
1/2✓ Branch 0 (64→65) taken 10 times.
✗ Branch 1 (64→118) 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 (3→4) taken 1000 times.
✗ Branch 1 (3→33) 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 (6→7) taken 1000 times.
✗ Branch 1 (6→35) not taken.
✓ Branch 2 (17→8) taken 7143 times.
✓ Branch 3 (17→18) 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 (11→12) taken 4174 times.
✓ Branch 1 (11→16) taken 2969 times.
✓ Branch 2 (12→13) taken 3645 times.
✓ Branch 3 (12→16) taken 529 times.
|
7143 | if (it != u_zvertexplots.end() && abs(status)>=2000) { |
67 |
2/4✓ Branch 0 (14→15) taken 3645 times.
✗ Branch 1 (14→35) not taken.
✓ Branch 2 (15→16) taken 3645 times.
✗ Branch 3 (15→35) not taken.
|
3645 | u_zvertexplots.at(pdg).at(0)->Fill(vz); |
68 | } | ||
69 | } | ||
70 | |||
71 | // run the momentum corrections | ||
72 |
1/2✓ Branch 0 (18→19) taken 1000 times.
✗ Branch 1 (18→35) not taken.
|
1000 | m_algo_seq->Run(banks); |
73 | |||
74 | // fill the plots after | ||
75 |
3/4✓ Branch 0 (19→20) taken 1000 times.
✗ Branch 1 (19→35) not taken.
✓ Branch 2 (30→21) taken 7141 times.
✓ Branch 3 (30→31) 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 (24→25) taken 4172 times.
✓ Branch 1 (24→29) taken 2969 times.
✓ Branch 2 (25→26) taken 3643 times.
✓ Branch 3 (25→29) taken 529 times.
|
7141 | if (it != u_zvertexplots.end() && abs(status)>=2000) { |
82 |
2/4✓ Branch 0 (27→28) taken 3643 times.
✗ Branch 1 (27→35) not taken.
✓ Branch 2 (28→29) taken 3643 times.
✗ Branch 3 (28→35) 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 (6→7) taken 1 times.
✗ Branch 1 (6→47) not taken.
|
2 | if(GetOutputDirectory()) { |
90 |
2/2✓ Branch 0 (42→8) taken 5 times.
✓ Branch 1 (42→43) 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 (13→14) taken 5 times.
✗ Branch 1 (13→48) not taken.
|
5 | auto canv = new TCanvas(canv_name, canv_name, 800, 600); |
93 | |||
94 |
2/4✓ Branch 0 (14→15) taken 5 times.
✗ Branch 1 (14→60) not taken.
✓ Branch 2 (15→16) taken 5 times.
✗ Branch 3 (15→60) not taken.
|
5 | plots.at(0)->SetLineColor(kBlue); |
95 |
2/4✓ Branch 0 (16→17) taken 5 times.
✗ Branch 1 (16→60) not taken.
✓ Branch 2 (17→18) taken 5 times.
✗ Branch 3 (17→60) not taken.
|
5 | plots.at(0)->SetLineWidth(2); |
96 |
2/4✓ Branch 0 (18→19) taken 5 times.
✗ Branch 1 (18→60) not taken.
✓ Branch 2 (19→20) taken 5 times.
✗ Branch 3 (19→60) not taken.
|
5 | plots.at(0)->Draw(""); |
97 | |||
98 |
2/4✓ Branch 0 (20→21) taken 5 times.
✗ Branch 1 (20→60) not taken.
✓ Branch 2 (21→22) taken 5 times.
✗ Branch 3 (21→60) not taken.
|
5 | plots.at(1)->SetLineColor(kRed); |
99 |
2/4✓ Branch 0 (22→23) taken 5 times.
✗ Branch 1 (22→60) not taken.
✓ Branch 2 (23→24) taken 5 times.
✗ Branch 3 (23→60) not taken.
|
5 | plots.at(1)->SetLineWidth(2); |
100 |
2/4✓ Branch 0 (24→25) taken 5 times.
✗ Branch 1 (24→60) not taken.
✓ Branch 2 (25→26) taken 5 times.
✗ Branch 3 (25→60) not taken.
|
5 | plots.at(1)->Draw("same"); |
101 | |||
102 |
1/2✓ Branch 0 (26→27) taken 5 times.
✗ Branch 1 (26→60) not taken.
|
5 | canv->Draw(); |
103 |
5/10✓ Branch 0 (28→29) taken 5 times.
✗ Branch 1 (28→58) not taken.
✓ Branch 2 (29→30) taken 5 times.
✗ Branch 3 (29→56) not taken.
✓ Branch 4 (30→31) taken 5 times.
✗ Branch 5 (30→54) not taken.
✓ Branch 6 (31→32) taken 5 times.
✗ Branch 7 (31→52) not taken.
✓ Branch 8 (34→35) taken 5 times.
✗ Branch 9 (34→50) 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 |