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 <filesystem>
5#include <map>
6#include <optional>
7#include <unordered_map>
8
9namespace R3B ::Neuland
10{
11
13 {
14 using Record = std::map<unsigned int, uint64_t>;
17 void add(unsigned int trigID, R3B::Side side, unsigned int counts = 1);
18 [[nodiscard]] auto findID(R3B::Side side) const -> std::optional<unsigned int>;
19 };
20
22 {
23 public:
24 using TrigIDMap = std::unordered_map<unsigned int, std::pair<unsigned int, unsigned int>>;
26 // add moduleID and trigID pair
27 void add_id_pair(std::pair<unsigned int, unsigned int> pair, R3B::Side side, unsigned int counts = 1);
28 void clear() { records_.clear(); }
29 void set_trigIDMap(TrigIDMap idMap) { idMap_ = std::move(idMap); }
30 auto extract_trigIDMap(bool force_find = false) -> TrigIDMap;
31
32 private:
33 std::unordered_map<unsigned int, TrigIDMappingRecorder> records_;
34 TrigIDMap idMap_;
35 void FindTrigIDMap();
36 static void AutoResolve(TrigIDMap& trigIDMap);
37 };
38
44
46 {
47 public:
48 TrigMappingIO() = default;
49
50 void SetFormat(TrigIDMappingPrintFormat format) { format_ = format; }
51 void SetFileName(std::string_view filename) { filename_ = filename; }
52 void SetDir(std::string_view dirname) { fileDir_ = dirname; }
53 void SetNumOfModule(unsigned int num) { numOfModule_ = num; }
54 void Print(const TrigIDMappingFinder::TrigIDMap& trigMap) const;
55 [[nodiscard]] auto Read_json() const -> TrigIDMappingFinder::TrigIDMap;
56 void Save_json(const TrigIDMappingFinder::TrigIDMap& trigMap) const;
57
58 private:
59 unsigned int numOfPlane_ = 0;
60 unsigned int numOfBar_ = 0;
61 unsigned int numOfModule_ = 0;
63 std::string filename_ = "trigIDMap.json";
64 std::string fileDir_ = ".";
65 void Print_screen(const TrigIDMappingFinder::TrigIDMap& trigMap) const;
66 };
67} // namespace R3B::Neuland
void add_id_pair(std::pair< unsigned int, unsigned int > pair, R3B::Side side, unsigned int counts=1)
std::unordered_map< unsigned int, std::pair< unsigned int, unsigned int > > TrigIDMap
void SetNumOfModule(unsigned int num)
void SetFileName(std::string_view filename)
void SetFormat(TrigIDMappingPrintFormat format)
void SetDir(std::string_view dirname)
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 >