CStationListXMLManager.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <algorithm>
3 
4 #include <cdet/CStationListXMLManager.h>
5 #include <utl/ErrorLogger.h>
6 #include <utl/Reader.h>
7 #include <cdet/CManagerRegister.h>
8 
9 using namespace std;
10 using namespace cdet;
11 using namespace utl;
12 using namespace det;
13 
14 
15 REGISTER_C_MANAGER("CStationListXMLManager", CStationListXMLManager);
16 
17 
18 void
19 CStationListXMLManager::Init(const std::string& configLink)
20 {
21  // first do the normal Init()
22  VManager::Init(configLink);
23 
24  for (Branch cB = fBranch.GetFirstChild(); cB; cB = cB.GetNextSibling()) {
25 
26  if (cB.GetName() == "station") {
27 
29 
30  station.fId = FindComponent<int>("id", cB.GetAttributes());
31 
32  cB.GetChild("northing").GetData(station.fNorthing);
33  cB.GetChild("easting").GetData(station.fEasting);
34  cB.GetChild("altitude").GetData(station.fAltitude);
35  station.fName = cB.GetChild("name").GetDataString();
36  cB.GetChild("commission").GetData(station.fCommissionTime);
37  cB.GetChild("decommission").GetData(station.fDecommissionTime);
38 
39  /*
40  * If the isUUB property does not exist (as is the case
41  * for the pre-upgrade XML), set isUUB to 0. Same for small
42  * PMT and scintillator.
43  */
44 /*
45  if (cB.GetChild("isUUB"))
46  cB.GetChild("isUUB").GetData(station.fIsUUB);
47  else
48  station.fIsUUB = 0;
49 
50  if (cB.GetChild("hasSmallPMT"))
51  cB.GetChild("hasSmallPMT").GetData(station.fHasSmallPMT);
52  else
53  station.fHasSmallPMT = 0;
54 
55  if (cB.GetChild("hasScintillator"))
56  cB.GetChild("hasScintillator").GetData(station.fHasScintillator);
57  else
58  station.fHasScintillator = 0;
59 */
60  // interpret rawInGrid as indices where vector<bool> is true
61  vector<int> rawInGrid;
62  cB.GetChild("inGrid").GetData(rawInGrid);
63  station.fInGrid = vector<bool>(*max_element(rawInGrid.begin(),rawInGrid.end()));
64  for (size_t i = 0; i < rawInGrid.size(); ++i)
65  {
66  // skip 0, map 1 -> L000, 2 -> 0L00, etc.
67  const int index = rawInGrid[i]-1;
68  if (index<0) continue;
69  station.fInGrid[index] = true;
70  }
71  cB.GetChild("groupId").GetData(station.fGroupId);
72 
73  vector<double> axes;
74  cB.GetChild("axes").GetData(axes);
75  station.fAxis1 = axes.at(0);
76  station.fAxis2 = axes.at(1);
77 
78  cB.GetChild("ellipsoid").GetData(station.fEllipsoid);
79  cB.GetChild("zone").GetData(station.fZone);
80  cB.GetChild("band").GetData(station.fBand);
81 
82  const bool ok =
83  fStationManager.ConditionalAddStationData(station);
84 
85  if (!ok) {
86  ostringstream err;
87  err << "multiple instances of station id=" << station.fId
88  << " found in XML configuration";
89  ERROR(err);
90  throw utl::XMLParseException(err.str());
91  }
92 
93  }
94 
95  }
96 }
void Init()
Initialise the registry.
bool ok(bool okay)
Definition: testlib.cc:89
Exception for errors encountered when parsing XML.
Branch GetNextSibling() const
Get next sibling of this branch.
Definition: Branch.cc:284
Class representing a document branch.
Definition: Branch.h:107
REGISTER_C_MANAGER("CStationListXMLManager", CStationListXMLManager)
Branch GetFirstChild() const
Get first child of this Branch.
Definition: Branch.cc:98
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
Manager for MARTA description in XML station lists.

, generated on Tue Sep 26 2023.