1 #include <boost/lambda/lambda.hpp>
3 #include <rdet/RDetector.h>
4 #include <rdet/RModelsXMLManager.h>
5 #include <rdet/RManagerRegister.h>
6 #include <rdet/RSimulationStationListManager.h>
8 #include <utl/ErrorLogger.h>
9 #include <utl/TabulatedFunction.h>
10 #include <utl/TabulatedFunctionComplexLgAmpPhase.h>
11 #include <utl/ComplexLgAmpPhase.h>
17 using namespace xercesc;
18 using namespace boost::lambda;
37 const string& componentProperty,
38 const string& componentName,
42 if (componentName ==
"stationList")
43 return VManager::eNotFound;
46 if (componentIndex.size()) {
47 const IndexMap::const_iterator stIt = componentIndex.find(
"station");
48 if (stIt == componentIndex.end()) {
49 if (IsReportingErrors()) {
50 INFO(
string(
"Request with two indices, "
51 "neither of which specifies 'stationId'; ") +
52 QueryInfoMessage(componentProperty, componentName, componentIndex));
62 if (componentProperty ==
"addSStationList") {
63 fBranch.GetChild(
"AddStationsFromSManager").GetData(returnData);
70 FindBranch(componentProperty, componentName, componentIndex);
84 const string& componentProperty,
85 const string& componentName,
91 FindBranch(componentProperty, componentName, componentIndex);
110 vector<double> lgAmp;
117 vector<double> phase;
120 const unsigned int n = x.size();
122 for (
unsigned int i = 0; i < n; ++i)
131 const string& componentProperty,
132 const string& componentName,
142 FindBranch(componentProperty, componentName, componentIndex);
150 double ResponseWeight;
153 returnData[ResponseId] += ResponseWeight;
170 const string& modelType,
176 const int nIndices = componentIndex.size();
191 const IndexMap::const_iterator stIt = componentIndex.begin();
192 if (stIt->first ==
"station") {
193 componentAtts[
"channel"] = stIt->second;
197 if (IsReportingErrors())
198 INFO(
string(
"If data request is made using 1 index, "
199 "that index must specify 'station'; ") +
200 QueryInfoMessage(componentProperty, modelType, componentIndex));
206 const IndexMap::const_iterator stIt = componentIndex.find(
"station");
207 if (stIt == componentIndex.end()) {
208 if (IsReportingErrors()) {
209 INFO(
string(
"Request with two indices, "
210 "neither of which specifies 'stationId'; ") +
211 QueryInfoMessage(componentProperty, modelType, componentIndex));
215 componentAtts[
"station"] = stIt->second;
217 const IndexMap::const_iterator chIt = componentIndex.find(
"channel");
218 if (chIt != componentIndex.end())
219 componentAtts[
"channel"] = chIt->second;
225 if (IsReportingErrors())
226 INFO(
string(
"Three indices in query: not yet supported; ") +
227 QueryInfoMessage(componentProperty, modelType, componentIndex));
231 if (IsReportingErrors()) {
232 INFO(
string(
"Invalid number of parameters; ") +
233 QueryInfoMessage(componentProperty, modelType, componentIndex));
239 const map<pair<std::string, std::string>,
IndexMap>::const_iterator sModel =
240 fStationChannelModelMap.find(make_pair(componentAtts[
"station"], componentAtts[
"channel"]));
242 const map<std::string, IndexMap>::const_iterator sAugerPrimeModel =
243 fAugerPrimeStationsModelMap.find(componentAtts[
"channel"]);
248 bool isAugerPrimeStation =
249 std::atoi(componentAtts[
"station"].c_str()) > det::Detector::GetInstance().GetRDetector().GetRdSdStationIdLink();
251 const map<std::string, IndexMap>::const_iterator sDefaultModel =
252 fDefaultStationsModelMap.find(componentAtts[
"channel"]);
254 if (sModel != fStationChannelModelMap.end())
255 modelMap = sModel->second;
256 else if (isAugerPrimeStation && sAugerPrimeModel != fAugerPrimeStationsModelMap.end())
257 modelMap = sAugerPrimeModel->second;
258 else if (sDefaultModel != fDefaultStationsModelMap.end())
259 modelMap = sDefaultModel->second;
260 else if (IsReportingErrors()) {
262 err <<
"Cannot map channel " << componentAtts[
"channel"] <<
" to the list of known models "
263 "since model for 'default' does not exist.";
270 const IndexMap::const_iterator mIt = modelMap.find(modelType);
271 if (mIt != modelMap.end())
272 modelId = mIt->second;
277 return channelModelsB;
294 dataB = modelTypeB.
GetChild(componentProperty);
299 dataB = modelTypeB.
GetChild(componentProperty, componentAtts);
321 const IndexMap atts(modelB.GetAttributes());
322 modelMap[modelB.GetName()] = atts.find(
"id")->second;
329 optAtts[
"id"] =
"default";
330 optAtts2[
"id"] =
"AugerPrime";
332 if (protoB.GetChild(
"stations", optAtts)) {
339 const IndexMap atts(channelB.GetAttributes());
340 const string channelIdString(atts.find(
"id")->second);
341 fDefaultStationsModelMap[channelIdString] = modelMap;
344 }
else if (protoB.GetChild(
"stations", optAtts2)) {
351 const IndexMap atts(channelB.GetAttributes());
352 const string channelIdString(atts.find(
"id")->second);
353 fAugerPrimeStationsModelMap[channelIdString] = modelMap;
364 const IndexMap atts(stationB.GetAttributes());
365 const string stationIdString(atts.find(
"id")->second);
371 const IndexMap atts(channelB.GetAttributes());
372 const string channelIdString(atts.find(
"id")->second);
373 fStationChannelModelMap[pair<std::string, std::string>(stationIdString,channelIdString)] = modelMap;
Status GetDataMap(std::map< std::string, double > &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Branch GetNextSibling() const
Get next sibling of this branch.
#define REGISTER_R_MANAGER(_name_, _Type_)
Class representing a document branch.
Class to hold collection (x,y) points and provide interpolation between them, where y are complex num...
Status InternalGetData(T &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const
void GetData(bool &b) const
Overloads of the GetData member template function.
A class to store complex numbers which are internally represented by log10(amplitude) and phase (and ...
utl::Branch FindBranch(const std::string &property, const std::string &modelType, const IndexMap &componentIndex) const
void PushBack(const double x, const utl::ComplexLgAmpPhase &y)
std::map< std::string, std::string > IndexMap
Branch GetFirstChild() const
Get first child of this Branch.
Status GetTFCLAPData(utl::TabulatedFunctionComplexLgAmpPhase &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const
Manager for RD description in XML "model" files.
#define ERROR(message)
Macro for logging error messages.
Status
Specifies success or (eventually) various possible failure modes.
static std::string GetSourceType(const std::string stationIdstring)