Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "Validator.h" | ||
2 | |||
3 | #include <TProfile.h> | ||
4 | #include <TStyle.h> | ||
5 | |||
6 | namespace iguana::clas12 { | ||
7 | |||
8 | REGISTER_IGUANA_VALIDATOR(SectorFinderValidator); | ||
9 | |||
10 | 1 | void SectorFinderValidator::Start(hipo::banklist& banks) | |
11 | { | ||
12 | // define the algorithm sequence | ||
13 | 2 | m_algo_seq = std::make_unique<AlgorithmSequence>(); | |
14 |
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::EventBuilderFilter"); |
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::SectorFinder"); |
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::EventBuilderFilter", "pids", u_pdg_list); |
17 |
3/6✓ 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.
|
2 | m_algo_seq->SetOption<std::string>("clas12::SectorFinder", "bank_charged", "REC::Track"); |
18 |
3/6✓ 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.
|
2 | m_algo_seq->SetOption<std::string>("clas12::SectorFinder", "bank_uncharged", "default"); |
19 | 1 | m_algo_seq->Start(banks); | |
20 | |||
21 | |||
22 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | b_particle = GetBankIndex(banks, "REC::Particle"); |
23 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | b_cal = GetBankIndex(banks, "REC::Calorimeter"); |
24 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | b_sector = GetBankIndex(banks, "REC::Particle::Sector"); |
25 | |||
26 | // set an output file | ||
27 | 1 | auto output_dir = GetOutputDirectory(); | |
28 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(output_dir) { |
29 |
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() + "/sector_finder"; |
30 |
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"); |
31 | } | ||
32 | |||
33 | // define plots | ||
34 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | gStyle->SetOptStat(0); |
35 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for(auto const& pdg : u_pdg_list) { |
36 | std::vector<TH2D*> YvsX; | ||
37 |
2/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
2 | TString particle_name = particle::name.at(particle::PDG(pdg)); |
38 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | TString particle_title = particle::title.at(particle::PDG(pdg)); |
39 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2 times.
|
14 | for(int sec = 1; sec <= 6; sec++) { |
40 |
2/4✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
|
12 | TString sector_name = Form("sec%d", sec); |
41 |
2/4✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
|
12 | TString sector_title = Form("sector %d", sec); |
42 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | YvsX.push_back(new TH2D( |
43 |
3/6✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
|
24 | "YvsX_" + particle_name + "_" + sector_name, |
44 |
3/8✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
24 | particle_title + " Calorimeter Hit Position, " + sector_title + ";X [cm];Y [cm]", |
45 | 50, -500, 500, | ||
46 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | 50, -500, 500)); |
47 | 12 | } | |
48 | 2 | u_YvsX.insert({pdg, YvsX}); | |
49 | 2 | } | |
50 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | u_IsInFD = new TH1D( |
51 | "IsInFD", | ||
52 | "e^{-} with #theta>6.5^{o} Sector; e^{-} Sector", | ||
53 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | 7, -0.5, 6.5); |
54 | |||
55 | 1 | } | |
56 | |||
57 | 1000 | void SectorFinderValidator::Run(hipo::banklist& banks) const | |
58 | { | ||
59 | |||
60 |
1/2✓ Branch 0 taken 1000 times.
✗ Branch 1 not taken.
|
1000 | auto& particle_bank = GetBank(banks, b_particle, "REC::Particle"); |
61 |
2/4✓ Branch 0 taken 1000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1000 times.
✗ Branch 3 not taken.
|
1000 | auto& sector_bank = GetBank(banks, b_sector, "REC::Particle::Sector"); |
62 |
2/4✓ Branch 0 taken 1000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1000 times.
✗ Branch 3 not taken.
|
2000 | auto& cal_bank = GetBank(banks, b_cal, "REC::Calorimeter"); |
63 | |||
64 | |||
65 | 1000 | m_algo_seq->Run(banks); | |
66 | |||
67 | // lock the mutex, so we can mutate plots | ||
68 | 1000 | std::scoped_lock<std::mutex> lock(m_mutex); | |
69 | // fill the plots | ||
70 |
3/4✓ Branch 0 taken 1000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2516 times.
✓ Branch 3 taken 1000 times.
|
3516 | for(auto const& row : particle_bank.getRowList()) { |
71 | |||
72 | 2516 | auto pdg = particle_bank.getInt("pid", row); | |
73 | 2516 | auto sector = sector_bank.getInt("sector", row); | |
74 | |||
75 | double x=0,y=0; | ||
76 |
3/4✓ Branch 0 taken 2516 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18708 times.
✓ Branch 3 taken 2516 times.
|
21224 | for(auto const& rowcal : cal_bank.getRowList()){ |
77 |
2/2✓ Branch 0 taken 2533 times.
✓ Branch 1 taken 16175 times.
|
18708 | if(cal_bank.getShort("pindex", rowcal)==row){ |
78 | 2533 | x=cal_bank.getFloat("x", rowcal); | |
79 | 2533 | y=cal_bank.getFloat("y", rowcal); | |
80 | } | ||
81 | } | ||
82 | |||
83 |
2/2✓ Branch 0 taken 651 times.
✓ Branch 1 taken 1865 times.
|
2516 | if(pdg==11){ |
84 | 651 | double Px=particle_bank.getFloat("px", row); | |
85 | 651 | double Py=particle_bank.getFloat("py", row); | |
86 | 651 | double Pz=particle_bank.getFloat("pz", row); | |
87 | 651 | double P=sqrt(Px*Px+Py*Py+Pz*Pz); | |
88 | 651 | double Theta=acos(Pz/P) * 180./M_PI ; | |
89 | //electrons are in FT or FD | ||
90 | //sector should always be 1 if theta is larger than 5.5 degrees | ||
91 |
2/2✓ Branch 0 taken 125 times.
✓ Branch 1 taken 526 times.
|
651 | if (Theta>6.5){ |
92 |
1/2✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
|
125 | u_IsInFD->Fill(sector); |
93 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 122 times.
|
125 | if(sector==0){ |
94 | 3 | m_log->Trace("e' with theta={} and sector==0, this should not happen", Theta); | |
95 | } | ||
96 | } | ||
97 | } | ||
98 | |||
99 | // skip central particle, or unknown sector | ||
100 |
2/2✓ Branch 0 taken 851 times.
✓ Branch 1 taken 1543 times.
|
2394 | if(sector == 0) |
101 | 851 | continue; | |
102 |
2/4✓ Branch 0 taken 1665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1665 times.
✗ Branch 3 not taken.
|
1665 | m_log->Trace("Filling SectorFinder Validator, pdg {} sector {} pindex {}", pdg, sector, row); |
103 |
2/4✓ Branch 0 taken 1665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1665 times.
✗ Branch 3 not taken.
|
1665 | u_YvsX.at(pdg).at(sector - 1)->Fill(x, y); |
104 | } | ||
105 | |||
106 | 1000 | } | |
107 | |||
108 | |||
109 | 1 | void SectorFinderValidator::Stop() | |
110 | { | ||
111 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | if(GetOutputDirectory()) { |
112 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for(auto const& [pdg, plots] : u_YvsX) { |
113 | int n_cols = 3; | ||
114 | int n_rows = 2; | ||
115 | 2 | TString canv_name = Form("canv%d", pdg); | |
116 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | auto canv = new TCanvas(canv_name, canv_name, n_cols * 800, n_rows * 600); |
117 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | canv->Divide(n_cols, n_rows); |
118 | int pad_num = 0; | ||
119 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2 times.
|
14 | for(auto const& plot : plots) { |
120 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | auto pad = canv->GetPad(++pad_num); |
121 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | pad->cd(); |
122 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | pad->SetGrid(1, 1); |
123 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | pad->SetLeftMargin(0.12); |
124 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | pad->SetRightMargin(0.12); |
125 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | pad->SetBottomMargin(0.12); |
126 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | plot->Draw("colz"); |
127 | } | ||
128 |
5/10✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
|
4 | canv->SaveAs(m_output_file_basename + "_" + std::to_string(pdg) + ".png"); |
129 | |||
130 | 2 | } | |
131 | |||
132 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | auto canv1D = new TCanvas("1D canvas","1D canvas",800, 600); |
133 | 1 | u_IsInFD->Draw(); | |
134 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
2 | canv1D->SaveAs(m_output_file_basename+"_elIsInFD.png"); |
135 | |||
136 | 1 | m_output_file->Write(); | |
137 | 1 | m_log->Info("Wrote output file {}", m_output_file->GetName()); | |
138 | 1 | m_output_file->Close(); | |
139 | } | ||
140 | 1 | } | |
141 | |||
142 | } | ||
143 |