GCC Code Coverage Report


Directory: ./
File: src/iguana/algorithms/clas12/ZVertexFilter/Algorithm.h
Date: 2025-01-05 09:03:17
Exec Total Coverage
Lines: 1 1 100.0%
Functions: 4 4 100.0%
Branches: 5 14 35.7%

Line Branch Exec Source
1 #pragma once
2
3 #include "iguana/algorithms/Algorithm.h"
4 #include "iguana/services/ConcurrentParam.h"
5
6 namespace iguana::clas12 {
7
8 /// @brief_algo Filter the `REC::Particle` (or similar) bank by cutting on Z Vertex
9 ///
10 /// @begin_doc_algo{clas12::ZVertexFilter | Filter}
11 /// @input_banks{REC::Particle, RUN::config}
12 /// @output_banks{REC::Particle}
13 /// @end_doc
14 ///
15 /// @begin_doc_config
16 /// @config_param{electron_vz | list[double] | lower and upper electron @f$z@f$-vertex cuts; run-range dependent; cuts are not applied to FT electrons (FD and CD only)}
17 /// @end_doc
18 class ZVertexFilter : public Algorithm
19 {
20
21
5/14
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
66 DEFINE_IGUANA_ALGORITHM(ZVertexFilter, clas12::ZVertexFilter)
22
23 public:
24
25 void Start(hipo::banklist& banks) override;
26 void Run(hipo::banklist& banks) const override;
27 void Stop() override;
28
29 /// @action_function{reload} prepare the event
30 /// @when_to_call{for each event}
31 /// @param runnum the run number
32 /// @returns the key to be used in `::Filter`
33 concurrent_key_t PrepareEvent(int const runnum) const;
34
35 /// @action_function{scalar filter} checks if the Z Vertex is within specified bounds if pid is one for which the filter should be applied to.;
36 /// Cuts applied to particles in FD or CD (ie not in FT).
37 /// @when_to_call{for each particle}
38 /// @param zvertex the particle Z Vertex to check
39 /// @param pid the particle pid
40 /// @param status particle status used to check particle is not in FT
41 /// @param key the return value of `::PrepareEvent`
42 /// @returns `true` if `zvertex` is within specified bounds
43 bool Filter(double const zvertex, int const pid, int const status, concurrent_key_t const key) const;
44
45 /// @param key the return value of `::PrepareEvent`
46 /// @returns the current run number
47 int GetRunNum(concurrent_key_t const key) const;
48
49 /// @param key the return value of `::PrepareEvent`
50 /// @returns the current z-vertex cuts
51 std::vector<double> GetElectronZcuts(concurrent_key_t const key) const;
52
53 /// @brief sets the z-vertex cuts
54 /// @warning this method is not thread safe; instead, for thread safety,
55 /// use `::PrepareEvent` and a custom configuration file.
56 /// @param zcut_lower the lower bound of the cut
57 /// @param zcut_upper the upper bound of the cut
58 /// @param key the, for `::GetElectronZcuts`
59 void SetElectronZcuts(double zcut_lower, double zcut_upper, concurrent_key_t const key);
60
61 private:
62 hipo::banklist::size_type b_particle, b_config;
63
64 // Reload function
65 void Reload(int const runnum, concurrent_key_t key) const;
66
67 /// Run number
68 mutable std::unique_ptr<ConcurrentParam<int>> o_runnum;
69
70 /// Electron Z-vertex cuts
71 mutable std::unique_ptr<ConcurrentParam<std::vector<double>>> o_electron_vz_cuts;
72
73 };
74
75 }
76