1 #include <boost/lambda/lambda.hpp>
2 #include <boost/lexical_cast.hpp>
3 #include <sdet/SModelsXMLManager.h>
4 #include <utl/ErrorLogger.h>
5 #include <utl/TabulatedFunction.h>
6 #include <sdet/SDetector.h>
7 #include <sdet/SManagerRegister.h>
13 using namespace xercesc;
14 using namespace boost::lambda;
25 AddAvailability<unsigned int>(
"scintillator");
26 AddAvailability<unsigned int>(
"electronics");
35 const string& componentProperty,
36 const string& componentName,
42 FindBranch(componentProperty, componentName, componentIndex);
54 const string& componentProperty,
55 const string& componentName,
62 FindBranch(componentProperty, componentName, componentIndex);
88 for_each(y.begin(), y.end(), _1 *= scaleY);
91 const unsigned int n = x.size();
92 for (
unsigned int i = 0; i < n; ++i)
109 const string& modelType,
120 const int nIndices = componentIndex.size();
127 string hardwareVersion;
133 const IndexMap::const_iterator stIt = componentIndex.find(
"stationId");
134 if (stIt == componentIndex.end()) {
135 if (IsReportingErrors())
136 INFO(
string(
"Request with " + boost::lexical_cast<string>(nIndices) +
137 " indices, none of which specifies 'stationId'; ") +
138 QueryInfoMessage(componentProperty, modelType, componentIndex));
141 stationId = stIt->second;
144 const IndexMap::const_iterator hardIt = componentIndex.find(
"isUUB");
145 if (hardIt == componentIndex.end()) {
146 if (IsReportingErrors())
147 INFO(
string(
"Request with " + boost::lexical_cast<string>(nIndices) +
148 " indices, none of which specifies 'isUUB'; ") +
149 QueryInfoMessage(componentProperty, modelType, componentIndex));
152 hardwareVersion = hardIt->second;
162 const IndexMap::const_iterator pmtIt = componentIndex.find(
"PMTId");
163 if (pmtIt == componentIndex.end()) {
164 if (IsReportingErrors())
165 INFO(
string(
"Request with three indices, "
166 "none of which specifies 'PMTId'; ") +
167 QueryInfoMessage(componentProperty, modelType, componentIndex));
170 componentAtts[
"PMTId"] = pmtIt->second;
174 if (IsReportingErrors())
175 INFO(
string(
"Three indices in query: not yet supported; ") +
176 QueryInfoMessage(componentProperty, modelType, componentIndex));
180 if (IsReportingErrors()) {
181 INFO(
string(
"Invalid number of parameters; ") +
182 QueryInfoMessage(componentProperty, modelType, componentIndex));
188 const std::map<std::string, IndexIndexMap>::const_iterator sHardwareVersions =
189 fStationModelMap.find(stationId);
190 if (sHardwareVersions != fStationModelMap.end())
191 hardwareVersionsMap = sHardwareVersions->second;
192 else if (!fAllStationsModelMap.empty())
193 hardwareVersionsMap = fAllStationsModelMap;
196 err <<
"Cannot map station " << stationId <<
" to the list of known hardware "
197 "versions since hardware versions for 'all' does not exist.";
204 const IndexIndexMap::const_iterator sModels =
205 hardwareVersionsMap.find(hardwareVersion);
206 if (sModels != hardwareVersionsMap.end())
207 modelMap = sModels->second;
210 err <<
"cannot access model map for requested hardware version "
211 << hardwareVersion <<
" since this version "
212 <<
"does not exist for the specified station or 'all' station "
213 <<
"configuration if that was requested.";
220 string modelTypeFull;
228 if (modelType ==
"PMT" || modelType ==
"pmtElectronics") {
229 modelTypeFull = modelType+componentAtts[
"PMTId"];
231 modelTypeFull = modelType;
233 const IndexMap::const_iterator mIt = modelMap.find(modelTypeFull);
234 if (mIt != modelMap.end()) {
235 modelId = mIt->second;
242 atts[
"id"] = modelId;
246 return stationModelsB;
263 dataB = modelTypeB.
GetChild(componentProperty);
269 dataB = modelTypeB.
GetChild(componentProperty, componentAtts);
294 std::map<std::string, IndexMap> hardwareVersionMap;
304 const IndexMap atts(modelB.GetAttributes());
312 if (modelB.GetName() ==
"PMT" || modelB.GetName() ==
"pmtElectronics") {
313 modelMap[modelB.GetName()+atts.find(
"PMTId")->second] = atts.find(
"id")->second;
315 modelMap[modelB.GetName()] = atts.find(
"id")->second;
319 hardwareVersionMap[hardwareB.GetAttributes().find(
"isUUB")->second] = modelMap;
325 optAtts[
"id"] =
"all";
328 fAllStationsModelMap = hardwareVersionMap;
337 const IndexMap atts(stationB.GetAttributes());
338 const string stationIdString(atts.find(
"id")->second);
341 fStationModelMap[stationIdString] = hardwareVersionMap;
350 const std::string& component,
351 const std::string& property,
355 if (!returnData.
Is<
unsigned int>())
357 if (!((property ==
"barCount" && component ==
"scintillator") ||
358 (property ==
"traceBins" && component ==
"electronics")))
362 FindBranch(property, component, index);
367 returnData.
Get<
unsigned int>() = dataBranch.
Get<
unsigned int>();
Status GetData(utl::TabulatedFunction &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const
Class to hold collection (x,y) points and provide interpolation between them.
virtual Status GenericGetData(Handle &returnData, const std::string &component, const std::string &property, const IndexMap &index) const
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
void PushBack(const double x, const double y)
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Branch GetNextSibling() const
Get next sibling of this branch.
Manager for SD description in XML "model" files.
Class representing a document branch.
#define REGISTER_S_MANAGER(_name_, _Type_)
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.
std::map< std::string, std::string > IndexMap
Branch GetFirstChild() const
Get first child of this Branch.
boost::add_reference< typename boost::remove_const< T >::type >::type Get()
utl::Branch FindBranch(const std::string &property, const std::string &modelType, const IndexMap &componentIndex) const
std::map< std::string, IndexMap > IndexIndexMap
#define ERROR(message)
Macro for logging error messages.
Status
Specifies success or (eventually) various possible failure modes.