R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BTrigIDMappingFinder.h
Go to the documentation of this file.
1#pragma once
2
3#include <R3BShared.h>
4#include <cstdint>
5#include <map>
6#include <optional>
7#include <string>
8#include <string_view>
9#include <unordered_map>
10#include <utility>
11
12namespace R3B::Neuland
13{
14
16 {
17 using Record = std::map<unsigned int, uint64_t>;
20 void add(unsigned int trigID, R3B::Side side, unsigned int counts = 1);
21 [[nodiscard]] auto findID(R3B::Side side) const -> std::optional<unsigned int>;
22 };
23
25 {
26 public:
27 using TrigIDMap = std::unordered_map<unsigned int, std::pair<unsigned int, unsigned int>>;
29 // add moduleID and trigID pair
30 void add_id_pair(std::pair<unsigned int, unsigned int> pair, R3B::Side side, unsigned int counts = 1);
31 void clear() { records_.clear(); }
32 void set_trigIDMap(TrigIDMap idMap) { idMap_ = std::move(idMap); }
33 auto extract_trigIDMap(bool force_find = false) -> TrigIDMap;
34
35 private:
36 std::unordered_map<unsigned int, TrigIDMappingRecorder> records_;
38 void FindTrigIDMap();
39 static void AutoResolve(TrigIDMap& trigIDMap);
40 };
41
42 enum class TrigIDMappingPrintFormat : uint8_t
43 {
46 };
47
49 {
50 public:
51 TrigMappingIO() = default;
52
53 void SetFormat(TrigIDMappingPrintFormat format) { format_ = format; }
54 void SetFileName(std::string_view filename) { filename_ = filename; }
55 void SetDir(std::string_view dirname) { fileDir_ = dirname; }
56 void SetNumOfModule(unsigned int num) { numOfModule_ = num; }
57 void Print(const TrigIDMappingFinder::TrigIDMap& trigMap) const;
58 [[nodiscard]] auto Read_json() const -> TrigIDMappingFinder::TrigIDMap;
59 void Save_json(const TrigIDMappingFinder::TrigIDMap& trigMap) const;
60
61 private:
62 unsigned int numOfModule_ = 0;
64 std::string filename_ = "trigIDMap.json";
65 std::string fileDir_ = ".";
66 void Print_screen(const TrigIDMappingFinder::TrigIDMap& trigMap) const;
67 };
68} // namespace R3B::Neuland
std::unordered_map< unsigned int, TrigIDMappingRecorder > records_
void add_id_pair(std::pair< unsigned int, unsigned int > pair, R3B::Side side, unsigned int counts=1)
auto extract_trigIDMap(bool force_find=false) -> TrigIDMap
std::unordered_map< unsigned int, std::pair< unsigned int, unsigned int > > TrigIDMap
static void AutoResolve(TrigIDMap &trigIDMap)
void SetFormat(TrigIDMappingPrintFormat format)
TrigIDMappingPrintFormat format_
void SetFileName(std::string_view filename)
void SetNumOfModule(unsigned int num)
void Save_json(const TrigIDMappingFinder::TrigIDMap &trigMap) const
void SetDir(std::string_view dirname)
auto Read_json() const -> TrigIDMappingFinder::TrigIDMap
void Print_screen(const TrigIDMappingFinder::TrigIDMap &trigMap) const
void Print(const TrigIDMappingFinder::TrigIDMap &trigMap) const
STL class.
Simulation of NeuLAND Bar/Paddle.
std::map< unsigned int, uint64_t > Record
void add(unsigned int trigID, R3B::Side side, unsigned int counts=1)
auto findID(R3B::Side side) const -> std::optional< unsigned int >