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 <iostream>
14 : #include <map>
15 : #include <memory>
16 : #include <string>
17 : #include "fmt/core.h"
18 :
19 : using namespace dunedaq::detchannelmaps;
20 :
21 0 : void test_tpc_map(const std::string& map_name, int det_id, int crate_id, int slot_id, int stream_id, int chan_id ) {
22 :
23 0 : TLOG() << "----------------------------------------------------";
24 0 : TLOG() << fmt::format("Testing '{}', det={}, crate={}, slot={}, stream={}, channel={}", map_name, det_id, crate_id, slot_id, stream_id, chan_id);
25 :
26 0 : std::shared_ptr<TPCChannelMap> the_map = make_tpc_map(map_name);
27 :
28 0 : uint oc, plane, elem_id;
29 0 : std::string elem_name;
30 :
31 0 : oc = the_map->get_offline_channel_from_det_crate_slot_stream_chan(det_id, crate_id, slot_id, stream_id, chan_id);
32 0 : plane = the_map->get_plane_from_offline_channel(oc);
33 0 : elem_id = the_map->get_element_id_from_offline_channel(oc);
34 0 : elem_name = the_map->get_element_name_from_offline_channel(oc);
35 0 : auto ci = the_map->get_channel_info_from_offline_channel(oc);
36 :
37 0 : if (ci) {
38 0 : TLOG() << fmt::format("{} offline channel={}: det={}, crate={}, slot={}, stream={}, channel={}", map_name, oc, ci->detector, ci->crate, ci->slot, ci->stream, ci->channel);
39 : } else {
40 0 : TLOG() << fmt::format("{} channel not found", map_name);
41 : }
42 :
43 0 : TLOG() << fmt::format("{} offline channel={}: plane={}, element={}, name={}", map_name, oc, plane, elem_id, elem_name);
44 0 : }
45 :
46 : int
47 0 : main()
48 : {
49 0 : TLOG() << "Creating Module instances...";
50 :
51 0 : uint oc, plane, elem_id;
52 0 : std::string elem_name;
53 :
54 0 : test_tpc_map("DummyTPCChannelMap", 1, 2, 3, 4, 5);
55 :
56 0 : test_tpc_map("VDColdboxTPCChannelMap", 10, 6, 1, 1, 63);
57 :
58 0 : test_tpc_map("HDColdboxTPCChannelMap", 3, 1, 1, 1, 45);
59 :
60 0 : test_tpc_map("PD2VDBottomTPCChannelMap", 10, 10, 0, 0, 52);
61 :
62 0 : test_tpc_map("PD2VDTPCChannelMap", 10, 10, 0, 0, 52);
63 0 : test_tpc_map("PD2VDTPCChannelMap", 11, 8, 0, 0, 52);
64 :
65 0 : TLOG() << "Test complete";
66 0 : }
|