RAntennaTypeXMLManager.cc
Go to the documentation of this file.
1 #include <string>
2 #include <algorithm>
3 #include <iterator>
4 #include <boost/lambda/lambda.hpp>
5 
6 #include <rdet/RAntennaTypeXMLManager.h>
7 #include <utl/ErrorLogger.h>
8 #include <utl/TabulatedFunction.h>
9 #include <utl/TabulatedFunctionComplexLgAmpPhase.h>
10 #include <rdet/RDetector.h>
11 #include <rdet/RManagerRegister.h> // needed for registration macro
12 
13 using namespace rdet;
14 using namespace std;
15 using namespace utl;
16 using namespace det;
17 using namespace xercesc;
18 using namespace boost::lambda;
19 
20 REGISTER_R_MANAGER("RAntennaTypeXMLManager", RAntennaTypeXMLManager)
21 
22 
23 void
24 RAntennaTypeXMLManager::Init(const string& configLink)
25 {
26  VManager::Init(configLink);
27 }
28 
29 
30 // Meant for finding GetData("AluLPDA", "EAHTheta", "idfreq"="10.00") where "idfreq"="10.00" is provided as IndexMap
32  const string& antennaType,
33  const string& antennaProp,
34  const IndexMap& propIndex)
35  const
36 {
37  Branch antennaPropB = FindAntennaTypeProperty(antennaType, antennaProp);
38  for ( ; antennaPropB; antennaPropB = antennaPropB.GetNextSibling())
39  if (antennaPropB.GetAttributes().find(propIndex.begin()->first)->second == propIndex.begin()->second)
40  return antennaPropB;
41 
42  ostringstream err;
43  err << "Cannot find antennaProp '" << antennaProp
44  << "' with index '" << propIndex.begin()->second
45  << "' while parsing for antennaType '" << antennaType << "' in XML.";
46  ERROR(err);
47  return antennaPropB;
48 }
49 
50 
51 // Meant for finding GetData("AluLPDA", "phi")
53  const string& antennaType,
54  const string& antennaProp)
55  const
56 {
57  Branch antennaB = FindAntennaType(antennaType);
58  if (!antennaB)
59  return antennaB;
60  Branch antennaPropB = antennaB.GetFirstChild();
61  for ( ; antennaPropB; antennaPropB = antennaPropB.GetNextSibling())
62  if (antennaPropB.GetName() == antennaProp)
63  return antennaPropB;
64  ostringstream err;
65  err << "Cannot find " + antennaProp + " while parsing for antennaType "+ antennaType +" in XML." ;
66  ERROR(err);
67  return antennaPropB;
68 }
69 
70 
71 // Find single antenna types:
72 Branch RAntennaTypeXMLManager::FindAntennaType(
73  const string& antennaType)
74  const
75 {
76  Branch antennaB = fBranch.GetFirstChild();
77  for ( ; antennaB; antennaB = antennaB.GetNextSibling())
78  if (antennaB.GetName() == "Antenna" &&
79  antennaB.GetAttributes().begin()->second == antennaType)
80  return antennaB;
81 
82  ostringstream err;
83  err << "Cannot find specifications for '" + antennaType + "' while XML parsing.\n"
84  << "You may want to use the RAntennaTypeListAll.xml config to include additional antenna models.";
85  ERROR(err);
86  return antennaB;
87 }
88 
89 
90 // InternalGetData to read data from antenna.xml files:
91 template<typename T>
93 RAntennaTypeXMLManager::InternalGetData(T& returnData,
94  const string& antennaProp,
95  const string& antennaType,
96  const IndexMap& propIndex)
97  const
98 {
99  Branch dataBranch;
100  // if the propIndex is not filled we are looking for an antenna property without further
101  // id such as "phi", "theta" or "frequency" - if there is an id, then we are probably
102  // looking for variables which are frequency dependend "idfreq"="10"...
103 
104  if (antennaProp != "frequency" &&
105  antennaProp != "theta" &&
106  antennaProp != "phi" &&
107  antennaProp != "MeanTransfer" &&
108  antennaProp != "EAHTheta_amp" &&
109  antennaProp != "EAHTheta_phase" &&
110  antennaProp != "EAHPhi_amp" &&
111  antennaProp != "EAHPhi_phase" ) {
112  return eNotFound;
113  }
114 
115  switch(propIndex.size()) {
116  case 0:
117  dataBranch = FindAntennaTypeProperty(antennaType, antennaProp);
118  break;
119  case 1:
120  dataBranch = FindAntennaTypePropertyIndex(antennaType, antennaProp, propIndex);
121  break;
122  default:
123  if (IsReportingErrors()) {
124  INFO(string("Searching for more than 1 property index not supported; ") +
125  QueryInfoMessage(antennaProp, antennaType, propIndex));
126  }
127  }
128  if (!dataBranch)
129  return eNotFound;
130  dataBranch.GetData(returnData);
131  return eFound;
132 }
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
AttributeMap GetAttributes() const
Get a map&lt;string, string&gt; containing all the attributes of this Branch.
Definition: Branch.cc:267
Branch GetNextSibling() const
Get next sibling of this branch.
Definition: Branch.cc:284
#define REGISTER_R_MANAGER(_name_, _Type_)
Class representing a document branch.
Definition: Branch.h:107
utl::Branch FindAntennaTypeProperty(const std::string &antennaType, const std::string &antennaProp) const
const double second
Definition: GalacticUnits.h:32
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
std::string GetName() const
function to get the Branch name
Definition: Branch.cc:374
utl::Branch FindAntennaTypePropertyIndex(const std::string &antennaType, const std::string &antennaProp, const IndexMap &propIndex) const
Manager for RD description in XML &quot;AntennaType&quot; files.
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
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
Status
Specifies success or (eventually) various possible failure modes.
Definition: VManager.h:127

, generated on Tue Sep 26 2023.