6 #include <boost/lexical_cast.hpp>
8 #include <fdet/FParametricOpticalEfficiencyLossManager.h>
9 #include <fwk/CentralConfig.h>
10 #include <det/Detector.h>
12 #include <utl/ErrorLogger.h>
13 #include <utl/TimeStamp.h>
14 #include <utl/UTCDateTime.h>
15 #include <utl/Reader.h>
16 #include <utl/TabulatedFunction.h>
17 #include <utl/AugerException.h>
18 #include <utl/ShadowPtr.h>
20 #include <fdet/FManagerRegister.h>
21 #include <fdet/FDetector.h>
22 #include <fdet/Telescope.h>
37 fHasDefaultOpticalEfficiencyCorrection =
false;
41 if (fHasDefaultOpticalEfficiencyCorrection)
42 info <<
"fixed optical efficiency correction is " << fOpticalEfficiencyCorrection;
44 info <<
" no default fixed optical efficiency correction";
46 if (!fPerTelescopeOpticalEfficiencyCorrections.empty()) {
47 for (map<
int, map<
int, vector<double> > >::const_iterator eyeIt = fPerTelescopeOpticalEfficiencyCorrections.begin(),
48 eyeEnd = fPerTelescopeOpticalEfficiencyCorrections.end(); eyeIt != eyeEnd; ++eyeIt) {
50 for (map<
int, vector<double> >::const_iterator telIt = eyeIt->second.begin(),
51 telEnd = eyeIt->second.end(); telIt != telEnd; ++telIt) {
53 info <<
"\n Override eye " << eyeIt->first <<
" tel " << telIt->first
55 for (vector<unsigned int>::const_iterator epochIt = fPerTelescopeOpticalEfficiencyEpochs[eyeIt->first][telIt->first].begin(),
56 epochEnd = fPerTelescopeOpticalEfficiencyEpochs[eyeIt->first][telIt->first].end(); epochIt != epochEnd; ++epochIt) {
57 info <<
" " << *epochIt;
59 info <<
"\n corrections :";
60 for (vector<double>::const_iterator corrIt = telIt->second.begin(),
61 corrEnd = telIt->second.end(); corrIt != corrEnd; ++corrIt) {
62 info <<
" " << *corrIt;
74 FParametricOpticalEfficiencyLossManager::Initialize()
76 Branch defaultOpticalEffBranch = fBranch.
GetChild(
"fixedOpticalEfficiencyCorrection");
77 if (defaultOpticalEffBranch) {
78 defaultOpticalEffBranch.
GetData(fOpticalEfficiencyCorrection);
79 fHasDefaultOpticalEfficiencyCorrection =
true;
81 fHasDefaultOpticalEfficiencyCorrection =
false;
87 while (opticalEffBranch) {
90 AttributeMap::const_iterator attrEnd = attrs.end();
91 AttributeMap::const_iterator eyeIdIt = attrs.find(
"eyeId");
92 AttributeMap::const_iterator telIdIt = attrs.find(
"telId");
93 if (eyeIdIt == attrEnd || telIdIt == attrEnd) {
94 ERROR(
"telescopeOpticalEfficiencyCorrection tag is missing eyeId or telId attributes!");
97 const int eyeId = boost::lexical_cast<
int>(eyeIdIt->second);
98 const int telId = boost::lexical_cast<
int>(telIdIt->second);
100 vector<unsigned int> epochs;
101 vector<double> corrections;
103 opticalEffBranch.
GetChild(
"opticalEfficiencyCorrections").
GetData(corrections);
104 fPerTelescopeOpticalEfficiencyEpochs[eyeId][telId] = epochs;
105 fPerTelescopeOpticalEfficiencyCorrections[eyeId][telId] = corrections;
115 fAvailableComponents.insert(
"pixel_optical_efficiency_corrections");
116 fAvailableComponents.insert(
"status");
117 fAvailableComponents.insert(
"start_time");
118 fAvailableComponents.insert(
"end_time");
123 FParametricOpticalEfficiencyLossManager::GetData(
double& ,
142 FParametricOpticalEfficiencyLossManager::GetData(map<int, utl::TabulatedFunction>& returnData,
143 const string& componentProperty,
144 const string& componentName,
145 const IndexMap& componentIndex)
149 if (componentName !=
"fd_optical_efficiency")
153 if (fAvailableComponents.find(componentProperty) == fAvailableComponents.end())
158 if (componentProperty ==
"pixel_optical_efficiency_corrections") {
159 const fdet::FDetector& fdet = det::Detector::GetInstance().GetFDetector();
162 const string& eyeIdString = componentIndex.find(
"eyeId")->second;
163 const string& telescopeIdString = componentIndex.find(
"telescopeId")->second;
164 const int eyeId = boost::lexical_cast<
int>(eyeIdString);
165 const int telId = boost::lexical_cast<
int>(telescopeIdString);
167 double opticalEff = 0;
168 if (GetOpticalEfficiencyCorrectionForTelescope(eyeId, telId, opticalEff)) {
170 for (
int iPix = 1; iPix <= 440; ++iPix) {
172 effVsWavelength.
PushBack(wavelength, opticalEff);
173 returnData.insert(make_pair(iPix, effVsWavelength));
185 FParametricOpticalEfficiencyLossManager::GetOpticalEfficiencyCorrectionForTelescope(
const unsigned int eyeId,
186 const unsigned int telId,
190 map<int, map<int, vector<double> > >::const_iterator eyeIt = fPerTelescopeOpticalEfficiencyCorrections.find(eyeId);
191 if (eyeIt == fPerTelescopeOpticalEfficiencyCorrections.end()) {
192 if (fHasDefaultOpticalEfficiencyCorrection) {
193 value = fOpticalEfficiencyCorrection;
199 map<int, vector<double> >::const_iterator telIt = eyeIt->second.find(telId);
200 if (telIt == eyeIt->second.end()) {
201 if (fHasDefaultOpticalEfficiencyCorrection) {
202 value = fOpticalEfficiencyCorrection;
208 map<int, map<int, vector<unsigned int> > >::const_iterator eyeEpochIt = fPerTelescopeOpticalEfficiencyEpochs.find(eyeId);
209 map<int, vector<unsigned int> >::const_iterator telEpochIt = eyeEpochIt->second.find(telId);
211 const TimeStamp detTime = Detector::GetInstance().GetTime();
215 for (
unsigned int i = 0; i < telEpochIt->second.size(); ++i) {
217 if (telEpochIt->second[i] > gpsSecond) {
224 int lastBin = telEpochIt->second.size() - 2;
226 std::vector<double>
p;
228 for (
unsigned int i = 0; i < 3; ++i)
230 p.push_back(telIt->second[3*lastBin + i]);
232 for (
unsigned int i = 0; i < 3; ++i)
234 p.push_back(telIt->second[3*thisBin + i]);
243 unsigned int lastEpoch = telEpochIt->second[lastBin+1];
247 x = gpsSecond - 1016048411;
249 x = lastEpoch - 1016048411;
252 p[0] + p[1] * x + p[2] *
pow(x, 2);
261 FParametricOpticalEfficiencyLossManager::GetData(vector<int>& returnData,
262 const string& componentProperty,
263 const string& componentName,
267 if (componentProperty !=
"status" || componentName !=
"fd_optical_efficiency")
270 returnData.resize(441, 0);
276 FParametricOpticalEfficiencyLossManager::GetData(
int& returnData,
277 const string& componentProperty,
278 const string& componentName,
283 if (componentName !=
"fd_optical_efficiency")
287 if (fAvailableComponents.find(componentProperty) == fAvailableComponents.end())
291 const TimeStamp detTime = Detector::GetInstance().GetTime();
294 if (componentProperty ==
"start_time") {
295 returnData = gpsSecond-1;
299 if (componentProperty ==
"end_time") {
301 returnData = gpsSecond+1;
Class to hold collection (x,y) points and provide interpolation between them.
std::map< std::string, std::string > AttributeMap
#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.
double pow(const double x, const unsigned int i)
Detector description interface for FDetector-related data.
A TimeStamp holds GPS second and nanosecond for some event.
AttributeMap GetAttributes() const
Get a map<string, string> containing all the attributes of this Branch.
Branch GetNextSibling() const
Get next sibling of this branch.
Class representing a document branch.
void GetData(bool &b) const
Overloads of the GetData member template function.
double GetReferenceLambda() const
unsigned long GetGPSSecond() const
GPS second.
#define REGISTER_F_MANAGER(_name_, _Type_)
Branch GetFirstChild() const
Get first child of this Branch.
#define ERROR(message)
Macro for logging error messages.
Status
Specifies success or (eventually) various possible failure modes.