GCC Code Coverage Report


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

Line Branch Exec Source
1 #pragma once
2
3 #include "iguana/algorithms/Algorithm.h"
4
5 namespace iguana::clas12 {
6
7 /// @brief_algo Find the sector for all rows in `REC::Particle`
8 ///
9 /// @begin_doc_algo{clas12::SectorFinder | Creator}
10 /// @input_banks{REC::Particle}
11 /// @output_banks{%REC::Particle::Sector}
12 /// @end_doc
13 ///
14 /// @begin_doc_config
15 /// @config_param{bank | string | if not `default`, use this bank for sector finding}
16 /// @end_doc
17 class SectorFinder : public Algorithm
18 {
19
20
6/14
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
40 DEFINE_IGUANA_ALGORITHM(SectorFinder, clas12::SectorFinder)
21
22 public:
23
24 void Start(hipo::banklist& banks) override;
25 void Run(hipo::banklist& banks) const override;
26 void Stop() override;
27
28 /// @action_function{vector creator} for a given particle with index `pindex`, get its sector from a detector bank's list of `sectors` and `pindices` (both must be ordered in the same way);
29 /// _nb_: this is done instead of finding the `pindex` in the bank directly, to have an action function
30 ///
31 /// **Example:**
32 /// ```cpp
33 ///
34 /// //... Initialise algorithms & banks ...
35 ///
36 /// //For each event, do:
37 ///
38 /// std::vector<int> sectors;
39 /// std::vector<int> pindices
40 ///
41 /// //bank is a hipo::bank object from which we want to get the sectors
42 /// //for example the bank object related to REC::Calorimeter
43 /// for(auto const& row : bank.getRowList()) {
44 ///
45 /// int det=bank.getInt("detector",row);
46 ///
47 /// //NB: you should check you read from an FD detector
48 /// // eg det 7 is the ECAL
49 /// if(det==7){
50 /// sectors.push_back(bank.getInt("sector", row));
51 /// pindices.push_back(bank.getShort("pindex", row));
52 /// }
53 /// }
54 ///
55 /// //partbank is a hipo::bank object related to REC::Particle
56 /// //algo_sector_finder is the iguana::clas12::SectorFinder object
57 /// for(auto const& row : partbank.getRowList()) {
58 /// int sector = algo_sector_finder.GetSector(sectors, pindices, row);
59 /// }
60 /// ```
61 ///
62 /// @param sectors list of sectors in a detector bank
63 /// @param pindices list of pindices in a detector bank
64 /// @param pindex index in `REC::Particle` bank for which to get sector
65 /// @returns sector for `pindex` in list, -1 if `pindex` not in inputted list
66 int GetSector(std::vector<int> const& sectors, std::vector<int> const& pindices, int const pindex) const;
67
68 /// fill lists of sectors and pindices present in the input bank
69 /// @param bank bank from which to get lists of sectors and pindices
70 /// @param sectors list to fill with sectors in the bank
71 /// @param pindices list to fill with pindices in the bank
72 void GetListsSectorPindex(hipo::bank const& bank, std::vector<int>& sectors, std::vector<int>& pindices) const;
73
74 private:
75
76 /// `hipo::banklist` index for the particle bank
77 hipo::banklist::size_type b_particle;
78 hipo::banklist::size_type b_calorimeter;
79 hipo::banklist::size_type b_track;
80 hipo::banklist::size_type b_scint;
81 hipo::banklist::size_type b_user_charged;
82 hipo::banklist::size_type b_user_uncharged;
83 hipo::banklist::size_type b_result;
84 bool userSpecifiedBank_charged{false};
85 bool userSpecifiedBank_uncharged{true};
86
87 // `b_result` bank item indices
88 int i_sector;
89 int i_pindex;
90
91 /// Configuration options
92 std::string o_bankname_charged;
93 std::string o_bankname_uncharged;
94
95 //only want sectors from FD detectors
96 std::set<int> const listFDDets{6,7,12,15,16,18};
97 };
98
99 }
100