3 #include <boost/format.hpp>
4 #include <boost/lexical_cast.hpp>
6 #include <det/Detector.h>
7 #include <cdet/CDetector.h>
8 #include <cdet/Station.h>
9 #include <det/VManager.h>
10 #include <utl/ErrorLogger.h>
11 #include <utl/AugerException.h>
12 #include <utl/TimeStamp.h>
14 #include <cevt/Station.h>
23 CDetector::~CDetector()
26 it != fFullStationMap.end(); ++it)
32 CDetector::UpdateDense()
36 for (vector<int>::iterator it = fDenseStationSubList.begin(), end = fDenseStationSubList.end();
38 Detector::GetInstance().GetCDetector().GetStation(*it).Update();
47 if (!fFullStationList.IsValid()) {
49 const vector<int>& sl = GetFullStationList();
51 for (vector<int>::const_iterator it = sl.begin(), end = sl.end();
57 const vector<int>::const_iterator denseIt =
58 find(fDenseStationSubList.begin(), fDenseStationSubList.end(), id);
59 if (denseIt != fDenseStationSubList.end()) {
64 fFullStationMap[id] = station;
71 const TimeStamp dTime = Detector::GetInstance().GetTime();
73 fCommissionedStationList.clear();
80 const Station*
const station = it->second;
84 fCommissionedStationList[it->first] = station;
101 CDetector::GetFullStationList()
104 if (!fFullStationList.IsValid()) {
106 const VManager& manager = Detector::GetInstance().GetCManagerRegister();
108 fFullStationList.Get().clear();
112 manager.
GetData(fFullStationList.Get(),
"fullStationList",
"stationList", indexMap);
114 if (status == VManager::eNotFound) {
116 err <<
"Could not find a list of SD Station ID's. "
117 "No station information will be available!";
121 fFullStationList.SetValid();
128 const VManager& smanager = Detector::GetInstance().GetSManagerRegister();
130 fDenseStationSubList.clear();
131 indexMap[
"reportErrors"] =
"0";
133 smanager.
GetData(fDenseStationSubList,
"denseStationList",
"stationList", indexMap);
136 if (status == VManager::eFound && !fDenseStationSubList.empty()) {
137 INFO(
"Using dense stations.");
138 fFullStationList.Get().insert(fFullStationList.Get().end(),
139 fDenseStationSubList.begin(),
140 fDenseStationSubList.end());
145 return fFullStationList.Get();
150 CDetector::FetchStationGroups()
153 const VManager& manager = Detector::GetInstance().GetCManagerRegister();
156 vector<int> stationGroupIds;
158 manager.
GetData(stationGroupIds,
"groupIds",
"stationList", indexMap);
160 if (status == VManager::eNotFound) {
161 WARNING(
"Could not find a list of SD Station groups ids.");
165 fStationGroups.clear();
167 vector<int> groupVec;
169 for (vector<int>::const_iterator gIt = stationGroupIds.begin(), end = stationGroupIds.end();
172 indexMap[
"groupId"] = boost::lexical_cast<
string>(*gIt);
173 manager.
GetData(groupVec,
"group",
"stationList", indexMap);
174 if (groupVec.empty())
177 groupSet.insert(groupVec.begin(), groupVec.end());
178 fStationGroups.insert(make_pair(*gIt, groupSet));
187 return GetStation(station.
GetId());
192 CDetector::GetStation(
const int id)
198 if (it != fCommissionedStationList.end())
210 if (it != fFullStationMap.end()) {
211 const Station*
const station = it->second;
217 if (!fFullStationList.IsValid())
218 GetFullStationList();
220 const vector<int>::const_iterator it =
221 find(fFullStationList.Get().begin(), fFullStationList.Get().end(), id);
224 if (it == fFullStationList.Get().end()) {
226 const Detector& detector = Detector::GetInstance();
230 indexMap[
"stationId"] = boost::lexical_cast<
string>(id);
234 manager.
GetData(stationName,
"name",
"stationList", indexMap) == VManager::eFound;
236 const bool hasNorthing =
237 manager.
GetData(dummy,
"northing",
"stationList", indexMap) == VManager::eFound;
238 const bool hasEasting =
239 manager.
GetData(dummy,
"easting",
"stationList", indexMap) == VManager::eFound;
240 const bool hasAltitude =
241 manager.
GetData(dummy,
"altitude",
"stationList", indexMap) == VManager::eFound;
243 if (hasName && hasNorthing && hasEasting && hasAltitude) {
246 fFullStationList.Get().push_back(
id);
247 const pair<int, const Station*> idStation(
id, station);
248 fFullStationMap.insert(idStation);
251 warn <<
"Station " << format(
"%4d") %
id <<
" was not in the station list. "
252 "It is being added individually.";
259 fCommissionedStationList.insert(idStation);
266 err <<
"No station with Id = " <<
id <<
" was found. At least the following information is missing:"
267 << (hasName ?
"" :
" name")
268 << (hasNorthing ?
"" :
" northing")
269 << (hasEasting ?
"" :
" easting")
270 << (hasAltitude ?
"" :
" altitude")
271 <<
". Do you have some station position manager registered in CManagerRegister?";
280 err <<
"Station with Id = " <<
id <<
" is not commissioned at "
281 "detector time = " << Detector::GetInstance().GetTime()
282 <<
" or else detector description was not properly configured";
288 CDetector::GetAllStation(
const int id)
292 if (it != fFullStationMap.end())
296 err <<
"Station with Id = " <<
id <<
" is not fund in the list of all stations.";
InternalStationMap::const_iterator InternalStationIterator
const utl::TimeRange & GetCommissionTimeRange() const
Station commission time range.
utl::TimeStamp GetTime() const
Get time pertaining to the detector description.
void Update(std::vector< double > &init, const std::vector< double > &res)
#define INFO(message)
Macro for logging informational messages.
Base class for exceptions trying to access non-existing components.
Interface for detector managers.
A TimeStamp holds GPS second and nanosecond for some event.
Detector description interface for MARTA Station-related data.
virtual Status GetData(double &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const =0
int GetId() const
Get the station Id.
utl::Validated< InGridType > fInGrid
#define DEBUGLOG(message)
Macro for logging debugging messages.
Top of the hierarchy of the detector description interface.
#define WARNING(message)
Macro for logging warning messages.
class to hold data at Station level
std::map< std::string, std::string > IndexMap
bool IsDense() const
Tells whether the station belongs to set of hypothetical "dense" stations.
Status
Specifies success or (eventually) various possible failure modes.
ManagerRegister & GetCManagerRegister() const