Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "Validator.h" | ||
2 | #include "Algorithm.h" | ||
3 | |||
4 | #include <TProfile.h> | ||
5 | #include <TStyle.h> | ||
6 | |||
7 | namespace iguana::clas12 { | ||
8 | |||
9 | REGISTER_IGUANA_VALIDATOR(FiducialFilterValidator); | ||
10 | |||
11 | 1 | void FiducialFilterValidator::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→126) not taken.
✓ Branch 2 (8→9) taken 1 times.
✗ Branch 3 (8→124) not taken.
|
2 | m_algo_seq->Add("clas12::EventBuilderFilter"); |
16 |
2/4✓ Branch 0 (12→13) taken 1 times.
✗ Branch 1 (12→130) not taken.
✓ Branch 2 (13→14) taken 1 times.
✗ Branch 3 (13→128) not taken.
|
2 | m_algo_seq->Add("clas12::FiducialFilter"); |
17 |
4/10✓ Branch 0 (17→18) taken 1 times.
✗ Branch 1 (17→136) not taken.
✓ Branch 2 (18→19) taken 1 times.
✗ Branch 3 (18→134) not taken.
✓ Branch 4 (19→20) taken 1 times.
✗ Branch 5 (19→132) not taken.
✓ Branch 6 (22→23) taken 1 times.
✗ Branch 7 (22→25) not taken.
✗ Branch 8 (136→137) not taken.
✗ Branch 9 (136→139) not taken.
|
3 | m_algo_seq->SetOption<std::vector<int>>("clas12::EventBuilderFilter", "pids", u_pdg_list); |
18 | 1 | m_algo_seq->Start(banks); | |
19 | |||
20 | // get bank indices | ||
21 |
1/2✓ Branch 0 (27→28) taken 1 times.
✗ Branch 1 (27→140) not taken.
|
1 | b_particle = GetBankIndex(banks, "REC::Particle"); |
22 |
1/2✓ Branch 0 (30→31) taken 1 times.
✗ Branch 1 (30→142) not taken.
|
1 | b_traj = GetBankIndex(banks, "REC::Traj"); |
23 | |||
24 | // set an output file | ||
25 | 1 | auto output_dir = GetOutputDirectory(); | |
26 |
1/2✓ Branch 0 (33→34) taken 1 times.
✗ Branch 1 (33→44) not taken.
|
1 | if(output_dir) { |
27 |
3/6✓ Branch 0 (34→35) taken 1 times.
✗ Branch 1 (34→190) not taken.
✓ Branch 2 (35→36) taken 1 times.
✗ Branch 3 (35→144) not taken.
✓ Branch 4 (37→38) taken 1 times.
✗ Branch 5 (37→190) not taken.
|
2 | m_output_file_basename = output_dir.value() + "/fiducial"; |
28 |
2/4✓ Branch 0 (38→39) taken 1 times.
✗ Branch 1 (38→148) not taken.
✓ Branch 2 (41→42) taken 1 times.
✗ Branch 3 (41→146) not taken.
|
2 | m_output_file = new TFile(m_output_file_basename + ".root", "RECREATE"); |
29 | } | ||
30 | |||
31 | // define plots | ||
32 |
1/2✓ Branch 0 (44→45) taken 1 times.
✗ Branch 1 (44→190) not taken.
|
1 | gStyle->SetOptStat(0); |
33 |
2/2✓ Branch 0 (119→46) taken 4 times.
✓ Branch 1 (119→120) taken 1 times.
|
5 | for(auto const& pdg : u_pdg_list) { |
34 |
2/6✓ Branch 0 (46→47) taken 4 times.
✗ Branch 1 (46→190) not taken.
✓ Branch 2 (47→48) taken 4 times.
✗ Branch 3 (47→190) not taken.
✗ Branch 4 (190→191) not taken.
✗ Branch 5 (190→193) not taken.
|
4 | TString particle_name = particle::name.at(particle::PDG(pdg)); |
35 |
3/6✓ Branch 0 (48→49) taken 4 times.
✗ Branch 1 (48→188) not taken.
✓ Branch 2 (49→50) taken 4 times.
✗ Branch 3 (49→188) not taken.
✓ Branch 4 (50→51) taken 4 times.
✗ Branch 5 (50→186) not taken.
|
4 | TString particle_title = particle::title.at(particle::PDG(pdg)); |
36 | |||
37 | TH2D *DC1_before = new TH2D( | ||
38 |
1/2✓ Branch 0 (54→55) taken 4 times.
✗ Branch 1 (54→152) not taken.
|
8 | "DC1_before_"+particle_name, |
39 |
1/2✓ Branch 0 (60→61) taken 4 times.
✗ Branch 1 (60→186) not taken.
|
4 | particle_title + " DC1 w/o fiducial cuts; x [cm]; y [cm]", |
40 | 4 | 100, DC1xleft, DC1xright, | |
41 |
1/2✓ Branch 0 (51→52) taken 4 times.
✗ Branch 1 (51→154) not taken.
|
4 | 100, DC1ybottom, DC1ytop |
42 |
1/2✓ Branch 0 (57→58) taken 4 times.
✗ Branch 1 (57→150) not taken.
|
4 | ); |
43 | TH2D *DC1_after = new TH2D( | ||
44 |
1/2✓ Branch 0 (64→65) taken 4 times.
✗ Branch 1 (64→158) not taken.
|
8 | "DC1_after_"+particle_name, |
45 |
1/2✓ Branch 0 (70→71) taken 4 times.
✗ Branch 1 (70→186) not taken.
|
4 | particle_title + " DC1 w fiducial cuts; x [cm]; y [cm]", |
46 | 4 | 100, DC1xleft, DC1xright, | |
47 |
1/2✓ Branch 0 (61→62) taken 4 times.
✗ Branch 1 (61→160) not taken.
|
4 | 100, DC1ybottom, DC1ytop |
48 |
1/2✓ Branch 0 (67→68) taken 4 times.
✗ Branch 1 (67→156) not taken.
|
4 | ); |
49 | |||
50 | TH2D *DC2_before = new TH2D( | ||
51 |
1/2✓ Branch 0 (74→75) taken 4 times.
✗ Branch 1 (74→164) not taken.
|
8 | "DC2_before_" + particle_name, |
52 |
1/2✓ Branch 0 (80→81) taken 4 times.
✗ Branch 1 (80→186) not taken.
|
4 | particle_title + " DC2 w/o fiducial cuts; x [cm]; y [cm]", |
53 | 4 | 100, DC2xleft, DC2xright, | |
54 |
1/2✓ Branch 0 (71→72) taken 4 times.
✗ Branch 1 (71→166) not taken.
|
4 | 100, DC2ybottom, DC2ytop |
55 |
1/2✓ Branch 0 (77→78) taken 4 times.
✗ Branch 1 (77→162) not taken.
|
4 | ); |
56 | TH2D *DC2_after = new TH2D( | ||
57 |
1/2✓ Branch 0 (84→85) taken 4 times.
✗ Branch 1 (84→170) not taken.
|
8 | "DC2_after_" + particle_name, |
58 |
1/2✓ Branch 0 (90→91) taken 4 times.
✗ Branch 1 (90→186) not taken.
|
4 | particle_title + " DC2 w fiducial cuts; x [cm]; y [cm]", |
59 | 4 | 100, DC2xleft, DC2xright, | |
60 |
1/2✓ Branch 0 (81→82) taken 4 times.
✗ Branch 1 (81→172) not taken.
|
4 | 100, DC2ybottom, DC2ytop |
61 |
1/2✓ Branch 0 (87→88) taken 4 times.
✗ Branch 1 (87→168) not taken.
|
4 | ); |
62 | |||
63 | TH2D *DC3_before = new TH2D( | ||
64 |
1/2✓ Branch 0 (94→95) taken 4 times.
✗ Branch 1 (94→176) not taken.
|
8 | "DC3_before_" + particle_name, |
65 |
1/2✓ Branch 0 (100→101) taken 4 times.
✗ Branch 1 (100→186) not taken.
|
4 | particle_title + " DC3 w/o fiducial cuts; x [cm]; y [cm]", |
66 | 4 | 100, DC3xleft, DC3xright, | |
67 |
1/2✓ Branch 0 (91→92) taken 4 times.
✗ Branch 1 (91→178) not taken.
|
4 | 100, DC3ybottom, DC3ytop |
68 |
1/2✓ Branch 0 (97→98) taken 4 times.
✗ Branch 1 (97→174) not taken.
|
4 | ); |
69 | TH2D *DC3_after = new TH2D( | ||
70 |
1/2✓ Branch 0 (104→105) taken 4 times.
✗ Branch 1 (104→182) not taken.
|
8 | "DC3_after_" + particle_name, |
71 |
1/2✓ Branch 0 (110→111) taken 4 times.
✗ Branch 1 (110→186) not taken.
|
4 | particle_title + " DC3 w fiducial cuts; x [cm]; y [cm]", |
72 | 4 | 100, DC3xleft, DC3xright, | |
73 |
1/2✓ Branch 0 (101→102) taken 4 times.
✗ Branch 1 (101→184) not taken.
|
4 | 100, DC3ybottom, DC3ytop |
74 |
1/2✓ Branch 0 (107→108) taken 4 times.
✗ Branch 1 (107→180) not taken.
|
4 | ); |
75 | |||
76 |
1/2✓ Branch 0 (111→112) taken 4 times.
✗ Branch 1 (111→186) not taken.
|
4 | u_DC1_before.insert({pdg, DC1_before}); |
77 |
1/2✓ Branch 0 (112→113) taken 4 times.
✗ Branch 1 (112→186) not taken.
|
4 | u_DC1_after.insert({pdg, DC1_after}); |
78 |
1/2✓ Branch 0 (113→114) taken 4 times.
✗ Branch 1 (113→186) not taken.
|
4 | u_DC2_before.insert({pdg, DC2_before}); |
79 |
1/2✓ Branch 0 (114→115) taken 4 times.
✗ Branch 1 (114→186) not taken.
|
4 | u_DC2_after.insert({pdg, DC2_after}); |
80 |
1/2✓ Branch 0 (115→116) taken 4 times.
✗ Branch 1 (115→186) not taken.
|
4 | u_DC3_before.insert({pdg, DC3_before}); |
81 | 4 | u_DC3_after.insert({pdg, DC3_after}); | |
82 | 4 | } | |
83 | 1 | } | |
84 | |||
85 | |||
86 | 1000 | void FiducialFilterValidator::Run(hipo::banklist& banks) const | |
87 | { | ||
88 | // get the momenta before | ||
89 |
1/2✓ Branch 0 (3→4) taken 1000 times.
✗ Branch 1 (3→70) not taken.
|
1000 | auto& particle_bank = GetBank(banks, b_particle, "REC::Particle"); |
90 |
1/2✓ Branch 0 (6→7) taken 1000 times.
✗ Branch 1 (6→72) not taken.
|
1000 | auto& trajBank = GetBank(banks, b_traj, "REC::Traj"); |
91 | // get a pindex'd map of the REC::Traj data | ||
92 | 1000 | auto traj_map = FiducialFilter::GetTrajMap(trajBank); | |
93 | |||
94 |
3/4✓ Branch 0 (9→10) taken 1000 times.
✗ Branch 1 (9→74) not taken.
✓ Branch 2 (37→11) taken 7143 times.
✓ Branch 3 (37→38) taken 1000 times.
|
8143 | for(auto const& row : particle_bank.getRowList()){ |
95 | 7143 | auto pid = particle_bank.getInt("pid", row); | |
96 |
6/6✓ Branch 0 (12→13) taken 5513 times.
✓ Branch 1 (12→16) taken 1630 times.
✓ Branch 2 (13→14) taken 5052 times.
✓ Branch 3 (13→16) taken 461 times.
✓ Branch 4 (14→15) taken 4795 times.
✓ Branch 5 (14→16) taken 257 times.
|
7672 | if(pid!=11&&pid!=211&&pid!=-211&&pid!=2212) continue; |
97 |
2/2✓ Branch 0 (25→26) taken 529 times.
✓ Branch 1 (25→27) taken 1819 times.
|
2348 | if (traj_map.find(row) == traj_map.end()) { |
98 | 529 | continue; | |
99 | } | ||
100 |
2/4✓ Branch 0 (27→28) taken 1819 times.
✗ Branch 1 (27→74) not taken.
✓ Branch 2 (28→29) taken 1819 times.
✗ Branch 3 (28→74) not taken.
|
1819 | auto traj_row = traj_map.at(row); |
101 |
1/2✓ Branch 0 (29→30) taken 1819 times.
✗ Branch 1 (29→74) not taken.
|
1819 | u_DC1_before.at(pid)->Fill(traj_row.x1,traj_row.y1); |
102 |
1/2✓ Branch 0 (31→32) taken 1819 times.
✗ Branch 1 (31→74) not taken.
|
1819 | u_DC2_before.at(pid)->Fill(traj_row.x2,traj_row.y2); |
103 |
1/2✓ Branch 0 (33→34) taken 1819 times.
✗ Branch 1 (33→74) not taken.
|
1819 | u_DC3_before.at(pid)->Fill(traj_row.x3,traj_row.y3); |
104 | } | ||
105 | |||
106 | // run the fiducial cuts | ||
107 |
1/2✓ Branch 0 (38→39) taken 1000 times.
✗ Branch 1 (38→74) not taken.
|
1000 | m_algo_seq->Run(banks); |
108 | |||
109 | // fill the plots | ||
110 |
3/4✓ Branch 0 (39→40) taken 1000 times.
✗ Branch 1 (39→74) not taken.
✓ Branch 2 (67→41) taken 1442 times.
✓ Branch 3 (67→68) taken 1000 times.
|
2442 | for(auto const& row : particle_bank.getRowList()) { |
111 | |||
112 | 1442 | auto pid = particle_bank.getInt("pid", row); | |
113 |
5/6✓ Branch 0 (42→43) taken 485 times.
✓ Branch 1 (42→46) taken 957 times.
✓ Branch 2 (43→44) taken 150 times.
✓ Branch 3 (43→46) taken 335 times.
✗ Branch 4 (44→45) not taken.
✓ Branch 5 (44→46) taken 150 times.
|
1442 | if(pid!=11&&pid!=211&&pid!=-211&&pid!=2212) continue; |
114 |
1/2✗ Branch 0 (55→56) not taken.
✓ Branch 1 (55→57) taken 1442 times.
|
1442 | if (traj_map.find(row) == traj_map.end()) { |
115 | ✗ | continue; | |
116 | } | ||
117 |
2/4✓ Branch 0 (57→58) taken 1442 times.
✗ Branch 1 (57→74) not taken.
✓ Branch 2 (58→59) taken 1442 times.
✗ Branch 3 (58→74) not taken.
|
1442 | auto traj_row = traj_map.at(row); |
118 |
1/2✓ Branch 0 (59→60) taken 1442 times.
✗ Branch 1 (59→74) not taken.
|
1442 | u_DC1_after.at(pid)->Fill(traj_row.x1,traj_row.y1); |
119 |
1/2✓ Branch 0 (61→62) taken 1442 times.
✗ Branch 1 (61→74) not taken.
|
1442 | u_DC2_after.at(pid)->Fill(traj_row.x2,traj_row.y2); |
120 |
1/2✓ Branch 0 (63→64) taken 1442 times.
✗ Branch 1 (63→74) not taken.
|
1442 | u_DC3_after.at(pid)->Fill(traj_row.x3,traj_row.y3); |
121 | } | ||
122 | 1000 | } | |
123 | |||
124 | |||
125 | 1 | void FiducialFilterValidator::Stop() | |
126 | { | ||
127 |
1/2✓ Branch 0 (6→7) taken 1 times.
✗ Branch 1 (6→95) not taken.
|
2 | if(GetOutputDirectory()) { |
128 | int n_cols = 2; | ||
129 | int n_rows = 2; | ||
130 |
2/2✓ Branch 0 (48→8) taken 3 times.
✓ Branch 1 (48→49) taken 1 times.
|
4 | for(int r=0;r<3;r++){ |
131 | 3 | TString canv_name = Form("beforecanv%d", r); | |
132 |
1/2✓ Branch 0 (13→14) taken 3 times.
✗ Branch 1 (13→96) not taken.
|
3 | auto canv = new TCanvas(canv_name, canv_name, n_cols * 800, n_rows * 600); |
133 |
1/2✓ Branch 0 (14→15) taken 3 times.
✗ Branch 1 (14→108) not taken.
|
3 | canv->Divide(n_cols, n_rows); |
134 | int pad_num = 0; | ||
135 |
2/2✓ Branch 0 (32→16) taken 12 times.
✓ Branch 1 (32→33) taken 3 times.
|
15 | for(auto const& pdg : u_pdg_list){ |
136 |
1/2✓ Branch 0 (16→17) taken 12 times.
✗ Branch 1 (16→108) not taken.
|
12 | auto pad = canv->GetPad(++pad_num); |
137 |
1/2✓ Branch 0 (17→18) taken 12 times.
✗ Branch 1 (17→108) not taken.
|
12 | pad->cd(); |
138 |
1/2✓ Branch 0 (18→19) taken 12 times.
✗ Branch 1 (18→108) not taken.
|
12 | pad->SetGrid(1, 1); |
139 |
1/2✓ Branch 0 (19→20) taken 12 times.
✗ Branch 1 (19→108) not taken.
|
12 | pad->SetLogz(); |
140 |
1/2✓ Branch 0 (20→21) taken 12 times.
✗ Branch 1 (20→108) not taken.
|
12 | pad->SetLeftMargin(0.12); |
141 |
1/2✓ Branch 0 (21→22) taken 12 times.
✗ Branch 1 (21→108) not taken.
|
12 | pad->SetRightMargin(0.12); |
142 |
1/2✓ Branch 0 (22→23) taken 12 times.
✗ Branch 1 (22→108) not taken.
|
12 | pad->SetBottomMargin(0.12); |
143 |
2/2✓ Branch 0 (23→24) taken 4 times.
✓ Branch 1 (23→26) taken 8 times.
|
12 | if(r==0){ |
144 |
1/2✓ Branch 0 (25→31) taken 4 times.
✗ Branch 1 (25→108) not taken.
|
4 | u_DC1_before.at(pdg)->Draw("colz"); |
145 |
2/2✓ Branch 0 (26→27) taken 4 times.
✓ Branch 1 (26→29) taken 4 times.
|
8 | }else if(r==1){ |
146 |
1/2✓ Branch 0 (28→31) taken 4 times.
✗ Branch 1 (28→108) not taken.
|
4 | u_DC2_before.at(pdg)->Draw("colz"); |
147 | }else{ | ||
148 |
1/2✓ Branch 0 (30→31) taken 4 times.
✗ Branch 1 (30→108) not taken.
|
4 | u_DC3_before.at(pdg)->Draw("colz"); |
149 | } | ||
150 | } | ||
151 |
5/10✓ Branch 0 (34→35) taken 3 times.
✗ Branch 1 (34→106) not taken.
✓ Branch 2 (35→36) taken 3 times.
✗ Branch 3 (35→104) not taken.
✓ Branch 4 (36→37) taken 3 times.
✗ Branch 5 (36→102) not taken.
✓ Branch 6 (37→38) taken 3 times.
✗ Branch 7 (37→100) not taken.
✓ Branch 8 (40→41) taken 3 times.
✗ Branch 9 (40→98) not taken.
|
6 | canv->SaveAs(m_output_file_basename + "_before_DC" + std::to_string(r+1) + ".png"); |
152 | 3 | } | |
153 | |||
154 |
2/2✓ Branch 0 (90→50) taken 3 times.
✓ Branch 1 (90→91) taken 1 times.
|
4 | for(int r=0;r<3;r++){ |
155 | 3 | TString canv_name = Form("aftercanv%d", r); | |
156 |
1/2✓ Branch 0 (55→56) taken 3 times.
✗ Branch 1 (55→110) not taken.
|
3 | auto canv = new TCanvas(canv_name, canv_name, n_cols * 800, n_rows * 600); |
157 |
1/2✓ Branch 0 (56→57) taken 3 times.
✗ Branch 1 (56→122) not taken.
|
3 | canv->Divide(n_cols, n_rows); |
158 | int pad_num = 0; | ||
159 |
2/2✓ Branch 0 (74→58) taken 12 times.
✓ Branch 1 (74→75) taken 3 times.
|
15 | for(auto const& pdg : u_pdg_list){ |
160 |
1/2✓ Branch 0 (58→59) taken 12 times.
✗ Branch 1 (58→122) not taken.
|
12 | auto pad = canv->GetPad(++pad_num); |
161 |
1/2✓ Branch 0 (59→60) taken 12 times.
✗ Branch 1 (59→122) not taken.
|
12 | pad->cd(); |
162 |
1/2✓ Branch 0 (60→61) taken 12 times.
✗ Branch 1 (60→122) not taken.
|
12 | pad->SetGrid(1, 1); |
163 |
1/2✓ Branch 0 (61→62) taken 12 times.
✗ Branch 1 (61→122) not taken.
|
12 | pad->SetLogz(); |
164 |
1/2✓ Branch 0 (62→63) taken 12 times.
✗ Branch 1 (62→122) not taken.
|
12 | pad->SetLeftMargin(0.12); |
165 |
1/2✓ Branch 0 (63→64) taken 12 times.
✗ Branch 1 (63→122) not taken.
|
12 | pad->SetRightMargin(0.12); |
166 |
1/2✓ Branch 0 (64→65) taken 12 times.
✗ Branch 1 (64→122) not taken.
|
12 | pad->SetBottomMargin(0.12); |
167 |
2/2✓ Branch 0 (65→66) taken 4 times.
✓ Branch 1 (65→68) taken 8 times.
|
12 | if(r==0){ |
168 |
1/2✓ Branch 0 (67→73) taken 4 times.
✗ Branch 1 (67→122) not taken.
|
4 | u_DC1_after.at(pdg)->Draw("colz"); |
169 |
2/2✓ Branch 0 (68→69) taken 4 times.
✓ Branch 1 (68→71) taken 4 times.
|
8 | }else if(r==1){ |
170 |
1/2✓ Branch 0 (70→73) taken 4 times.
✗ Branch 1 (70→122) not taken.
|
4 | u_DC2_after.at(pdg)->Draw("colz"); |
171 | }else{ | ||
172 |
1/2✓ Branch 0 (72→73) taken 4 times.
✗ Branch 1 (72→122) not taken.
|
4 | u_DC3_after.at(pdg)->Draw("colz"); |
173 | } | ||
174 | } | ||
175 |
5/10✓ Branch 0 (76→77) taken 3 times.
✗ Branch 1 (76→120) not taken.
✓ Branch 2 (77→78) taken 3 times.
✗ Branch 3 (77→118) not taken.
✓ Branch 4 (78→79) taken 3 times.
✗ Branch 5 (78→116) not taken.
✓ Branch 6 (79→80) taken 3 times.
✗ Branch 7 (79→114) not taken.
✓ Branch 8 (82→83) taken 3 times.
✗ Branch 9 (82→112) not taken.
|
6 | canv->SaveAs(m_output_file_basename + "_after_DC" + std::to_string(r+1) + ".png"); |
176 | 3 | } | |
177 | 1 | m_output_file->Write(); | |
178 | 1 | m_log->Info("Wrote output file {}", m_output_file->GetName()); | |
179 | 1 | m_output_file->Close(); | |
180 | } | ||
181 | 1 | } | |
182 | } | ||
183 |