FDsimG4XMLManager.cc
Go to the documentation of this file.
1 #include <boost/lambda/lambda.hpp>
2 
3 #include "FDsimG4XMLManager.hh"
4 #include <fwk/CentralConfig.h>
5 #include <utl/ErrorLogger.h>
6 #include <utl/Reader.h>
7 #include <utl/AugerException.h>
8 
9 using namespace TelescopeSimulatorLX;
10 using namespace std;
11 using namespace utl;
12 using namespace fwk;
13 using namespace boost::lambda;
14 
15 
16 void
17 FDsimG4XMLManager::Init(const string& configLink)
18 {
19  FindConfig(configLink);
20  // FillMaps();
21  fIsInitialized = true;
22 }
23 
24 
25 void
26 FDsimG4XMLManager::FindConfig(const string& configLink)
27 {
28  if (fIsInitialized) {
29  ostringstream warn;
30  warn << "Attempt to initialize an already initialized manager: " << configLink;
31  WARNING(warn);
32  return;
33  }
34 
35  fBranch = CentralConfig::GetInstance()->GetTopBranch(configLink);
36 
37  if (!fBranch) {
38  ostringstream err;
39  err << '\'' << configLink << "' manager requested in the manager configuration but "
40  "the bootstrap file does not specify a configuration file for it.";
41  ERROR(err);
42  throw utl::XMLParseException(err.str());
43  }
44 }
45 
46 
47 //Generic data getters
48 //--------------------
51  const string& componentProperty,
52  const string& componentName)
53  const
54 {
55  // Find where requested data resides in DOM
56  Branch dataBranch =
57  FindBranch(componentProperty, componentName);
58 
59  if (!dataBranch)
60  return eNotFound;
61 
62  // Since this is tabulated data, retrieve the ordinate and abscissa
63  // NOTE THAT IT IS ASSUMED THAT THE ABSCISSA IS LABELED "x" AND
64  // THE ORDINATE IS LABELED "y"
65  Branch abscissaBranch = dataBranch.GetChild("x");
66  if (!abscissaBranch)
67  return eNotFound;
68  vector<double> abscissaVector;
69  abscissaBranch.GetData(abscissaVector);
70 
71  Branch ordinateBranch = dataBranch.GetChild("y");
72  if (!ordinateBranch)
73  return eNotFound;
74  vector<double> ordinateVector;
75  ordinateBranch.GetData(ordinateVector);
76 
77  // As a convenience, scale all ordinate values if a scale factor is given
78  double scaleY;
79  Branch scaleYBranch = dataBranch.GetChild("scaleY");
80  if (scaleYBranch) {
81  scaleYBranch.GetData(scaleY);
82  for_each(ordinateVector.begin(), ordinateVector.end(), _1 *= scaleY);
83  }
84 
85  for (unsigned int i = 0; i < abscissaVector.size(); ++i)
86  tabulatedReturnData.PushBack(abscissaVector[i], ordinateVector[i]);
87 
88  return eFound;
89 }
90 
91 
94 Branch
95 FDsimG4XMLManager::FindBranch(const string& componentProperty,
96  const string& componentName)
97  const
98 {
99  if (!fBranch)
100  return fBranch;
101 
102  Branch telescopeB = fBranch.GetChild("telescopeConfig");
103  if (!telescopeB)
104  return telescopeB;
105 
106  Branch NameB = telescopeB.GetChild(componentName);
107  if (!NameB)
108  return NameB;
109 
110  Branch dataB = NameB.GetChild(componentProperty);
111 
112  return dataB;
113 }
Class to hold collection (x,y) points and provide interpolation between them.
void PushBack(const double x, const double y)
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
Exception for errors encountered when parsing XML.
Class representing a document branch.
Definition: Branch.h:107
Status GetData(T &returnData, const std::string &componentProperty, const std::string &componentName) const
Return data as a TabulatedFunction.
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
utl::Branch FindBranch(const std::string &property, const std::string &component) const
void FindConfig(const std::string &configLink)
Locate the configuration file in CentralConfig and make a Reader for it.
void Init(const std::string &configLink)
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165

, generated on Tue Sep 26 2023.