Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "Algorithm.h" | ||
2 | |||
3 | namespace iguana::clas12 { | ||
4 | |||
5 | REGISTER_IGUANA_ALGORITHM(EventBuilderFilter); | ||
6 | |||
7 | 8 | void EventBuilderFilter::Start(hipo::banklist& banks) | |
8 | { | ||
9 | |||
10 | // define options, their default values, and cache them | ||
11 | 8 | ParseYAMLConfig(); | |
12 |
2/4✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
16 | o_pids = GetOptionSet<int>("pids"); |
13 | |||
14 | // get expected bank indices | ||
15 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | b_particle = GetBankIndex(banks, "REC::Particle"); |
16 | 8 | } | |
17 | |||
18 | |||
19 | 5100 | void EventBuilderFilter::Run(hipo::banklist& banks) const | |
20 | { | ||
21 | |||
22 | // get the banks | ||
23 |
1/2✓ Branch 0 taken 5100 times.
✗ Branch 1 not taken.
|
10200 | auto& particleBank = GetBank(banks, b_particle, "REC::Particle"); |
24 | |||
25 | // dump the bank | ||
26 |
1/2✓ Branch 0 taken 5100 times.
✗ Branch 1 not taken.
|
5100 | ShowBank(particleBank, Logger::Header("INPUT PARTICLES")); |
27 | |||
28 | // filter the input bank for requested PDG code(s) | ||
29 |
1/2✓ Branch 0 taken 5100 times.
✗ Branch 1 not taken.
|
10200 | particleBank.getMutableRowList().filter([this](auto bank, auto row) { |
30 | 35004 | auto pid = bank.getInt("pid", row); | |
31 | 35004 | auto accept = Filter(pid); | |
32 | 35004 | m_log->Debug("input PID {} -- accept = {}", pid, accept); | |
33 |
2/2✓ Branch 0 taken 25384 times.
✓ Branch 1 taken 9620 times.
|
35004 | return accept ? 1 : 0; |
34 | }); | ||
35 | |||
36 | // dump the modified bank | ||
37 |
1/2✓ Branch 0 taken 5100 times.
✗ Branch 1 not taken.
|
5100 | ShowBank(particleBank, Logger::Header("OUTPUT PARTICLES")); |
38 | 5100 | } | |
39 | |||
40 | |||
41 | 36408 | bool EventBuilderFilter::Filter(int const pid) const | |
42 | { | ||
43 | 36408 | return o_pids.find(pid) != o_pids.end(); | |
44 | } | ||
45 | |||
46 | 100 | std::deque<bool> EventBuilderFilter::Filter(std::vector<int> const pids) const | |
47 | { | ||
48 | std::deque<bool> result; | ||
49 |
2/2✓ Branch 0 taken 702 times.
✓ Branch 1 taken 100 times.
|
802 | for(auto const& pid : pids) |
50 |
2/4✓ Branch 0 taken 702 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 702 times.
✗ Branch 3 not taken.
|
702 | result.push_back(Filter(pid)); |
51 | 100 | return result; | |
52 | } | ||
53 | |||
54 | 3 | void EventBuilderFilter::Stop() | |
55 | { | ||
56 | 3 | } | |
57 | |||
58 | } | ||
59 |