REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestRawReadoutMetadata.cxx
1//
2// Created by lobis on 24-Aug-23.
3//
4
5#include "TRestRawReadoutMetadata.h"
6
7using namespace std;
8
9const std::string unknownChannelType = "unknown";
10
12
13void TRestRawReadoutMetadata::PrintMetadata() const {
14 cout << "Number of channels: " << fChannelInfo.size() << endl;
15 map<string, int> typesCount;
16 for (const auto& channel : fChannelInfo) {
17 const auto& info = channel.second;
18 typesCount[info.type]++;
19 }
20 cout << "Channel types: ";
21 for (const auto& type : typesCount) {
22 cout << type.first << " (" << type.second << "), ";
23 }
24 cout << endl;
25
26 for (const auto& [channelDaqId, info] : fChannelInfo) {
27 cout << " - Channel DAQ ID: " << channelDaqId << ", channel ID: " << info.channelId
28 << ", type: " << info.type << ", name: " << info.name << endl;
29 }
30}
31
32std::string TRestRawReadoutMetadata::GetTypeForChannelDaqId(UShort_t channel) const {
33 if (fChannelInfo.find(channel) == fChannelInfo.end()) {
34 return unknownChannelType;
35 }
36 return fChannelInfo.at(channel).type;
37}
38
39std::string TRestRawReadoutMetadata::GetNameForChannelDaqId(UShort_t channel) const {
40 if (fChannelInfo.find(channel) == fChannelInfo.end()) {
41 return unknownChannelType;
42 }
43 return fChannelInfo.at(channel).name;
44}
45
46std::vector<UShort_t> TRestRawReadoutMetadata::GetChannelDaqIDsForType(const std::string& type) const {
47 std::vector<UShort_t> result;
48 for (const auto& channel : fChannelInfo) {
49 if (channel.second.type == type) {
50 result.push_back(channel.first);
51 }
52 }
53 return result;
54}