Line data Source code
1 : #include "artdaq-ots/Overlays/FragmentType.hh"
2 :
3 : #include <algorithm>
4 : #include <cassert>
5 : #include <string>
6 : #include <vector>
7 :
8 0 : ots::FragmentType ots::toFragmentType(std::string t_string)
9 : {
10 0 : std::transform(t_string.begin(), t_string.end(), t_string.begin(), toupper);
11 0 : auto it = std::find(names.begin(), names.end(), t_string);
12 0 : return (it == names.end())
13 0 : ? FragmentType::INVALID
14 0 : : static_cast<FragmentType>(artdaq::Fragment::FirstUserFragmentType +
15 0 : (it - names.begin()));
16 : }
17 :
18 0 : std::string ots::fragmentTypeToString(FragmentType val)
19 : {
20 0 : if(val < FragmentType::INVALID)
21 : {
22 0 : return names[val - FragmentType::MISSED];
23 : }
24 : else
25 : {
26 0 : return "INVALID/UNKNOWN";
27 : }
28 : }
29 :
30 0 : std::map<artdaq::Fragment::type_t, std::string> ots::makeFragmentTypeMap()
31 : {
32 0 : auto output = artdaq::Fragment::MakeSystemTypeMap();
33 0 : for(auto name : names)
34 : {
35 0 : output[toFragmentType(name)] = name;
36 0 : }
37 0 : return output;
38 0 : }
|