1 #include <boost/format.hpp>
3 #include <boost/lexical_cast.hpp>
5 #include <det/Detector.h>
6 #include <sdet/SDetector.h>
7 #include <sdet/Station.h>
8 #include <det/VManager.h>
9 #include <utl/ErrorLogger.h>
10 #include <utl/AugerException.h>
11 #include <utl/TimeStamp.h>
13 #include <sevt/Station.h>
22 SDetector::~SDetector()
24 for (
const auto& idp : fFullStationMap)
30 SDetector::UpdateDense()
34 const auto& sDet = Detector::GetInstance().GetSDetector();
35 for (
const auto id : fDenseStationSubList)
36 sDet.GetStation(
id).Update();
45 if (!fFullStationList.IsValid()) {
47 const auto& sl = GetFullStationList();
48 for (
const auto id : sl) {
49 const auto station =
new Station(
id);
57 station->GetStationData(isUUB,
"isUUB",
"stationList",
"is uub");
58 station->UpdateElectronics(isUUB);
61 station->GetStationData(hasSmallPMT,
"hasSmallPMT",
"stationList",
"has small pmt");
63 station->MakeSmallPMT();
65 int hasScintillator = 0;
66 station->GetStationData(hasScintillator,
"hasScintillator",
"stationList",
"has scintillator");
68 station->MakeScintillator();
71 const auto denseIt = find(fDenseStationSubList.begin(), fDenseStationSubList.end(), id);
72 if (denseIt != fDenseStationSubList.end()) {
73 station->fDense =
true;
76 fFullStationMap[id] = station;
83 const auto dTime = Detector::GetInstance().GetTime();
85 fCommissionedStationList.clear();
89 for (
const auto&
is : fFullStationMap) {
93 fCommissionedStationList[
is.first] = station;
110 SDetector::GetFullStationList()
113 if (!fFullStationList.IsValid()) {
115 const auto& manager = Detector::GetInstance().GetSManagerRegister();
117 fFullStationList.Get().clear();
120 auto status = manager.GetData(fFullStationList.Get(),
"fullStationList",
"stationList", indexMap);
122 if (status == VManager::eNotFound) {
124 err <<
"Could not find a list of SD Station ID's. "
125 "No station information will be available!";
129 fFullStationList.SetValid();
134 fDenseStationSubList.clear();
135 indexMap[
"reportErrors"] =
"0";
136 status = manager.GetData(fDenseStationSubList,
"denseStationList",
"stationList", indexMap);
138 if (status == VManager::eFound && !fDenseStationSubList.empty()) {
139 INFO(
"Using dense stations.");
140 fFullStationList.Get().insert(fFullStationList.Get().end(),
141 fDenseStationSubList.begin(),
142 fDenseStationSubList.end());
147 return fFullStationList.Get();
152 SDetector::FetchStationGroups()
155 const auto& manager = Detector::GetInstance().GetSManagerRegister();
158 vector<int> stationGroupIds;
159 const auto status = manager.GetData(stationGroupIds,
"groupIds",
"stationList", indexMap);
161 if (status == VManager::eNotFound) {
162 WARNING(
"Could not find a list of SD Station groups ids.");
166 fStationGroups.clear();
168 vector<int> groupVec;
170 for (
const auto gid : stationGroupIds) {
172 indexMap[
"groupId"] = boost::lexical_cast<
string>(gid);
173 manager.GetData(groupVec,
"group",
"stationList", indexMap);
174 if (groupVec.empty())
177 groupSet.insert(groupVec.begin(), groupVec.end());
178 fStationGroups.insert(make_pair(gid, groupSet));
187 return GetStation(station.
GetId());
192 SDetector::GetStation(
const int id)
196 const auto it = fCommissionedStationList.find(
id);
197 if (it != fCommissionedStationList.end())
208 const auto it = fFullStationMap.find(
id);
209 if (it != fFullStationMap.end()) {
210 const Station*
const station = it->second;
216 if (!fFullStationList.IsValid())
217 GetFullStationList();
219 const auto it = find(fFullStationList.Get().begin(), fFullStationList.Get().end(), id);
222 if (it == fFullStationList.Get().end()) {
224 const auto& detector = Detector::GetInstance();
225 const auto& manager = detector.GetSManagerRegister();
227 const VManager::IndexMap indexMap({{
"stationId", boost::lexical_cast<
string>(id) }});
230 const bool hasName = manager.GetData(stationName,
"name",
"stationList", indexMap) == VManager::eFound;
232 const bool hasNorthing = manager.GetData(dummy,
"northing",
"stationList", indexMap) == VManager::eFound;
233 const bool hasEasting = manager.GetData(dummy,
"easting",
"stationList", indexMap) == VManager::eFound;
234 const bool hasAltitude = manager.GetData(dummy,
"altitude",
"stationList", indexMap) == VManager::eFound;
236 if (hasName && hasNorthing && hasEasting && hasAltitude) {
238 const auto station =
new Station(
id);
239 fFullStationList.Get().push_back(
id);
240 const pair<int, const Station*> idStation(
id, station);
241 fFullStationMap.insert(idStation);
244 warn <<
"Station " << format(
"%4d") %
id <<
" was not in the station list. "
245 "It is being added individually.";
249 const auto dTime = detector.GetTime();
250 if (station->GetCommissionTimeRange() == dTime) {
252 fCommissionedStationList.insert(idStation);
259 err <<
"No station with Id = " <<
id <<
" was found. At least the following information is missing:"
260 << (hasName ?
"" :
" name")
261 << (hasNorthing ?
"" :
" northing")
262 << (hasEasting ?
"" :
" easting")
263 << (hasAltitude ?
"" :
" altitude")
264 <<
". Do you have some station position manager registered in SManagerRegister?";
274 err <<
"Station with Id = " <<
id <<
" is not commissioned at "
275 "detector time = " << Detector::GetInstance().GetTime()
276 <<
" or else detector description was not properly configured";
282 SDetector::GetAllStation(
const int id)
285 const auto it = fFullStationMap.find(
id);
286 if (it != fFullStationMap.end())
290 err <<
"Station with Id = " <<
id <<
" is not fund in the list of all stations.";
const utl::TimeRange & GetCommissionTimeRange() const
Station commission time range.
int GetId() const
Get the station Id.
class to hold data at PMT level
Detector description interface for Station-related data.
Detector description interface for PMT-related data.
bool is(const double a, const double b)
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.
unsigned int GetId() const
Return Id of the PMT.
class to hold data at Station level
#define DEBUGLOG(message)
Macro for logging debugging messages.
#define WARNING(message)
Macro for logging warning messages.
std::map< std::string, std::string > IndexMap
bool IsDense() const
Tells whether the station belongs to set of hypothetical "dense" stations.