Line data Source code
1 : /**
2 : * @file dummy_map_example.cxx
3 : *
4 : * This is part of the DUNE DAQ Application Framework, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : #include "detchannelmaps/TPCChannelMap.hpp"
10 :
11 : #include "logging/Logging.hpp" // NOLINT
12 :
13 : #include "fmt/core.h"
14 : #include <iostream>
15 : #include <map>
16 : #include <memory>
17 : #include <string>
18 :
19 : using namespace dunedaq::detchannelmaps;
20 :
21 : void
22 0 : test_tpc_map(const std::string& map_name, int det_id, int crate_id, int slot_id, int stream_id, int chan_id)
23 : {
24 :
25 0 : TLOG() << "----------------------------------------------------";
26 0 : TLOG() << fmt::format("Testing '{}', det={}, crate={}, slot={}, stream={}, channel={}",
27 : map_name,
28 : det_id,
29 : crate_id,
30 : slot_id,
31 : stream_id,
32 0 : chan_id);
33 :
34 0 : std::shared_ptr<TPCChannelMap> the_map = make_tpc_map(map_name);
35 :
36 0 : uint oc, plane, elem_id;
37 0 : std::string elem_name;
38 :
39 0 : oc = the_map->get_offline_channel_from_det_crate_slot_stream_chan(det_id, crate_id, slot_id, stream_id, chan_id);
40 0 : plane = the_map->get_plane_from_offline_channel(oc);
41 0 : elem_id = the_map->get_element_id_from_offline_channel(oc);
42 0 : elem_name = the_map->get_element_name_from_offline_channel(oc);
43 0 : auto ci = the_map->get_channel_info_from_offline_channel(oc);
44 :
45 0 : if (ci) {
46 0 : TLOG() << fmt::format("{} offline channel={}: det={}, crate={}, slot={}, stream={}, channel={}",
47 : map_name,
48 : oc,
49 0 : ci->detector,
50 0 : ci->crate,
51 0 : ci->slot,
52 0 : ci->stream,
53 0 : ci->channel);
54 : } else {
55 0 : TLOG() << fmt::format("{} channel not found", map_name);
56 : }
57 :
58 0 : TLOG() << fmt::format(
59 0 : "{} offline channel={}: plane={}, element={}, name={}", map_name, oc, plane, elem_id, elem_name);
60 0 : }
61 :
62 : int
63 0 : main()
64 : {
65 0 : TLOG() << "Creating Module instances...";
66 :
67 0 : uint oc, plane, elem_id;
68 0 : std::string elem_name;
69 :
70 0 : test_tpc_map("DummyTPCChannelMap", 1, 2, 3, 4, 5);
71 :
72 0 : test_tpc_map("VDColdboxTPCChannelMap", 10, 6, 1, 1, 63);
73 :
74 0 : test_tpc_map("HDColdboxTPCChannelMap", 3, 1, 1, 1, 45);
75 :
76 0 : test_tpc_map("PD2VDBottomTPCChannelMap", 10, 10, 0, 0, 52);
77 :
78 0 : test_tpc_map("PD2VDTPCChannelMap", 10, 10, 0, 0, 52);
79 0 : test_tpc_map("PD2VDTPCChannelMap", 11, 8, 0, 0, 52);
80 :
81 0 : TLOG() << "Test complete";
82 0 : }
|