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