FSimulationCalibManager.cc
Go to the documentation of this file.
1 #include <string>
2 #include <sstream>
3 #include <set>
4 
5 #include <boost/lexical_cast.hpp>
6 
7 #include <fdet/FSimulationCalibManager.h>
8 #include <fwk/CentralConfig.h>
9 #include <det/Detector.h>
10 
11 #include <utl/ErrorLogger.h>
12 #include <utl/TimeStamp.h>
13 #include <utl/Reader.h>
14 #include <utl/TabulatedFunction.h>
15 #include <utl/AugerException.h>
16 #include <utl/ShadowPtr.h>
17 
18 #include <fdet/FManagerRegister.h>
19 #include <fdet/FDetector.h>
20 #include <fdet/Telescope.h>
21 
22 using namespace std;
23 using namespace fdet;
24 using namespace utl;
25 using namespace det;
26 using namespace fwk;
27 
28 
29 REGISTER_F_MANAGER("FSimulationCalibManager", FSimulationCalibManager);
30 
31 
32 void
33 FSimulationCalibManager::Init(const std::string& configLink)
34 {
35  VManager::Init(configLink);
36 
37  for (Branch curB = fBranch.GetFirstChild(); curB;
38  curB = curB.GetNextSibling()) {
39  vector<double> val;
40  curB.GetChild("calibration").GetData(val);
41  fCalibConst[FindComponent<string>("signature", curB.GetAttributes())] = val;
42  }
43 }
44 
45 
47 FSimulationCalibManager::GetData(double& returnData,
48  const string& componentProperty,
49  const string& componentName,
50  const IndexMap& index)
51  const
52 {
53  // this manager only knows about fd_calib
54  if (componentName!="fd_sim_calib")
55  return eNotFound;
56 
57  if (componentProperty == "sim_pixel_calibs") {
58 
59  const IndexMap::const_iterator iSig = index.find("signature");
60  if (iSig == index.end()) {
61  ostringstream err;
62  err << "Could not find \"signature\" in index map.";
63  ERROR(err);
64  return eNotFound;
65  }
66  const IndexMap::const_iterator iPix = index.find("pixelId");
67  if (iPix == index.end()) {
68  ostringstream err;
69  err << "Could not find \"pixelId\" in index map.";
70  ERROR(err);
71  return eNotFound;
72  }
73  const map<string, vector<double> >::const_iterator iCal = fCalibConst.find(iSig->second);
74  if (iCal == fCalibConst.end()) {
75  ostringstream err;
76  err << "Could not find signature=\"" << iSig->second << "\".";
77  ERROR(err);
78  return eNotFound;
79  }
80  const int pixelId = boost::lexical_cast<int>(iPix->second);
81  if (pixelId < 1 || pixelId > int(iCal->second.size())+1) {
82  ostringstream err;
83  err << "Could not find pixel with Id=\"" << pixelId << "\". "
84  "Configuration provieds only \"" << iCal->second.size()+1 << "\" "
85  "calibration constants!";
86  ERROR(err);
87  return eNotFound;
88  }
89  returnData = iCal->second[pixelId-1];
90  return eFound;
91 
92  }
93 
94  return eNotFound;
95 }
96 
97 
98 // Configure (x)emacs for this file ...
99 // Local Variables:
100 // mode: c++
101 // compile-command: "make -C .. FDetector/FSimulationCalibManager.o -k"
102 // End:
void Init()
Initialise the registry.
Branch GetNextSibling() const
Get next sibling of this branch.
Definition: Branch.cc:284
Class representing a document branch.
Definition: Branch.h:107
#define REGISTER_F_MANAGER(_name_, _Type_)
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
Manager for FD calibration with a fixed constant.
Status
Specifies success or (eventually) various possible failure modes.
Definition: VManager.h:127

, generated on Tue Sep 26 2023.