SdSimCalibrationManager.cc
Go to the documentation of this file.
1 #include <sdet/SManagerRegister.h>
2 #include <sdet/SdSimCalibrationManager.h>
3 #include <boost/lexical_cast.hpp>
4 
5 using namespace std;
6 using namespace det;
7 using namespace utl;
8 
9 
10 namespace sdet {
11 
12  REGISTER_S_MANAGER("SdSimCalibrationManager", SdSimCalibrationManager)
13 
14 
16  SdSimCalibrationManager::GetData(double& returnData,
17  const string& componentProperty,
18  const string& componentName,
19  const IndexMap& componentIndex)
20  const
21  {
22  const int nIndices = componentIndex.size();
23 
24  // pmtId must be present in indices
25  const auto pmtIt = componentIndex.find("PMTId");
26  if (pmtIt == componentIndex.end()) {
27  if (IsReportingErrors())
28  INFO(string("Request with " + boost::lexical_cast<string>(nIndices) +
29  " indices, none of which specifies 'PMTId'; ") +
30  QueryInfoMessage(componentProperty, componentName, componentIndex));
31  return eNotFound;
32  }
33  const string& pmtId = pmtIt->second;
34 
35  // isUUB must be present in indices
36  const auto uubIt = componentIndex.find("isUUB");
37  if (uubIt == componentIndex.end()) {
38  if (IsReportingErrors())
39  INFO(string("Request with " + boost::lexical_cast<string>(nIndices) +
40  " indices, none of which specifies 'isUUB'; ") +
41  QueryInfoMessage(componentProperty, componentName, componentIndex));
42  return eNotFound;
43  }
44  const string& isUUB = uubIt->second;
45 
46  // iteration over <simModule> to match "name" attribute
47  for (auto simB = fBranch.GetFirstChild(); simB; simB = simB.GetNextSibling()) {
48 
49  const auto& simAtts = simB.GetAttributes();
50 
51  if (simAtts.find("name")->second != componentName)
52  continue;
53 
54  // iteration over <electronics> to match "isUUB" attribute
55  for (auto elecB = simB.GetFirstChild(); elecB; elecB = elecB.GetNextSibling()) {
56 
57  const auto& elecAtts = elecB.GetAttributes();
58 
59  if (elecAtts.find("isUUB")->second != isUUB)
60  continue;
61 
62  // iteration over <PMT> to match "id" attribute
63  for (auto pmtB = elecB.GetFirstChild(); pmtB; pmtB = pmtB.GetNextSibling()) {
64 
65  const auto& pmtAtts = pmtB.GetAttributes();
66 
67  if (pmtAtts.find("id")->second != pmtId)
68  continue;
69 
70  pmtB.GetChild(componentProperty).GetData(returnData);
71 
72  return eFound;
73 
74  }
75 
76  }
77 
78  }
79 
80  return eNotFound;
81  }
82 
83 }
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
Interface for detector managers.
Definition: VManager.h:115
Status
Return code for seek operation.
Definition: IoCodes.h:24
#define REGISTER_S_MANAGER(_name_, _Type_)

, generated on Tue Sep 26 2023.