SStationListXMLManager.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <algorithm>
3 
4 #include <sdet/SStationListXMLManager.h>
5 #include <utl/ErrorLogger.h>
6 #include <utl/Reader.h>
7 #include <sdet/SManagerRegister.h>
8 
9 using namespace std;
10 using namespace sdet;
11 using namespace utl;
12 using namespace det;
13 
14 
15 REGISTER_S_MANAGER("SStationListXMLManager", SStationListXMLManager);
16 
17 
18 void
19 SStationListXMLManager::Init(const std::string& configLink)
20 {
21  // first do the normal Init()
22  VManager::Init(configLink);
23 
24  for (auto cB = fBranch.GetFirstChild(); cB; cB = cB.GetNextSibling()) {
25 
26  if (cB.GetName() != "station")
27  continue;
28 
30 
31  station.fId = FindComponent<int>("id", cB.GetAttributes());
32 
33  cB.GetChild("northing").GetData(station.fNorthing);
34  cB.GetChild("easting").GetData(station.fEasting);
35  cB.GetChild("altitude").GetData(station.fAltitude);
36  station.fName = cB.GetChild("name").GetDataString();
37  station.fCommissionTime = cB.GetChild("commission").GetDataString();
38  station.fDecommissionTime = cB.GetChild("decommission").GetDataString();
39 
40  /* If the isUUB property does not exist (as is the case for real
41  measurements and may be the case for pre-upgrade simulation
42  station list XML), set isUUB to 0. Same holds for small PMT and
43  scintillator. */
44 
45  auto isUUBB = cB.GetChild("isUUB");
46  if (isUUBB)
47  isUUBB.GetData(station.fIsUUB);
48  else
49  station.fIsUUB = false;
50 
51  auto hasSmallPMTB = cB.GetChild("hasSmallPMT");
52  if (hasSmallPMTB)
53  hasSmallPMTB.GetData(station.fHasSmallPMT);
54  else
55  station.fHasSmallPMT = false;
56 
57  auto hasScintillatorB = cB.GetChild("hasScintillator");
58  if (hasScintillatorB)
59  hasScintillatorB.GetData(station.fHasScintillator);
60  else
61  station.fHasScintillator = false;
62 
63  /* If the commissionUUB property does not exist (as is the case
64  for simulations and uncommissioned stations), return the
65  decommission time in all cases except when isUUB property
66  exists (which is the case for simulations). In this case,
67  return the station commission time. */
68 
69  auto commissionUUBB = cB.GetChild("commissionUUB");
70  if (commissionUUBB)
71  commissionUUBB.GetData(station.fUUBCommissionTime);
72  else
73  station.fUUBCommissionTime =
74  station.fIsUUB ? station.fCommissionTime : station.fDecommissionTime;
75 
76  // interpret inGrid as indices where vector<bool> is true
77  const auto inGrid = cB.GetChild("inGrid").Get<vector<int>>();
78  if (inGrid.empty())
79  station.fInGrid.clear();
80  else {
81  const int maxGrid = *max_element(inGrid.begin(), inGrid.end());
82  station.fInGrid = vector<bool>(maxGrid);
83  for (const auto ig : inGrid) {
84  // skip 0, map 1 -> 1000, 2 -> 0100 etc
85  if (ig <= 0)
86  continue;
87  station.fInGrid[ig - 1] = true;
88  }
89  }
90 
91  cB.GetChild("groupId").GetData(station.fGroupId);
92 
93  const auto axes = cB.GetChild("axes").Get<vector<double>>();
94  station.fAxis1 = axes[0];
95  station.fAxis2 = axes[1];
96 
97  station.fEllipsoid = cB.GetChild("ellipsoid").GetDataString();
98  cB.GetChild("zone").GetData(station.fZone);
99  station.fBand = cB.GetChild("band").GetDataString();
100 
101  const bool ok = fStationManager.ConditionalAddStationData(station);
102 
103  if (!ok) {
104  ostringstream err;
105  err << "multiple instances of station id=" << station.fId
106  << " found in XML configuration";
107  ERROR(err);
108  throw utl::XMLParseException(err.str());
109  }
110 
111  }
112 }
void Init()
Initialise the registry.
bool ok(bool okay)
Definition: testlib.cc:89
Exception for errors encountered when parsing XML.
Manager for SD description in XML station lists.
#define REGISTER_S_MANAGER(_name_, _Type_)
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165

, generated on Tue Sep 26 2023.