1 #include <sdet/EventStationPositionsManager.h>
3 #include <fwk/RunController.h>
5 #include <sevt/SEvent.h>
6 #include <utl/ErrorLogger.h>
9 #include <AugerEvent.h>
12 #include <det/Detector.h>
13 #include <sdet/SDetector.h>
14 #include <sdet/SManagerRegister.h>
30 "Station list source is outdated or no real manager present";
39 fBranch.GetChild(
"Band").GetData(fBand);
40 fBranch.GetChild(
"Zone").GetData(fZone);
41 fBranch.GetChild(
"Ellipsoid").GetData(fEllipsoid);
46 if (fBranch.GetChild(
"IsUUB"))
47 fBranch.GetChild(
"IsUUB").GetData(fIsUUB);
50 fBranch.GetChild(
"Commission").GetData(fCommission);
51 fBranch.GetChild(
"CommissionUUB").GetData(fCommissionUUB);
52 fBranch.GetChild(
"Decommission").GetData(fDecommission);
58 UTMToAxes(
const double easting,
const double northing,
59 double& axis1,
double& axis2)
61 axis1 = 6.666970851e-4*easting + 3.849861836e-4*northing - 2559.709820;
62 axis2 = 6.082521603e-8*easting + 7.698225084e-4*northing - 4592.669600;
69 double& easting,
double& northing)
71 easting = 394392 + 1500*axis1 - 750.146*axis2;
72 northing = 5965850 - 0.118518*axis1 + 1299.06*axis2;
80 EventStationPositionsManager::GetStationData<>(
int& returnData,
81 const string& componentProperty,
82 const string& componentName,
86 if (componentName !=
"stationList")
89 if (componentProperty ==
"axis1" ||
90 componentProperty ==
"axis2") {
93 GetData(easting,
"easting", componentName, componentIndex);
95 GetData(northing,
"northing", componentName, componentIndex);
98 UTMToAxes(easting, northing, axis1, axis2);
100 returnData = int(round(componentProperty ==
"axis1" ? axis1 : axis2));
103 warn << outdatedMessage <<
", guessing station with id="
104 << FindComponent<string>(
"stationId", componentIndex) <<
" has "
105 << componentProperty <<
'=' << returnData;
109 }
else if (componentProperty ==
"groupId") {
112 warn << outdatedMessage <<
", guessing "
113 << componentProperty <<
" for station with id="
114 << FindComponent<string>(
"stationId", componentIndex) <<
" is impossible!";
119 }
else if (componentProperty ==
"zone") {
124 }
else if (componentProperty ==
"isUUB") {
136 EventStationPositionsManager::GetStationData(
double& returnData,
137 const string& componentProperty,
138 const string& componentName,
142 if (componentName !=
"stationList")
145 if (componentProperty ==
"northing" ||
146 componentProperty ==
"easting" ||
147 componentProperty ==
"altitude") {
149 const IoSdStation*
const st = FindStation(componentIndex);
151 ostringstream message;
155 returnData = (componentProperty ==
"northing") ? st->northing() :
156 (componentProperty ==
"easting" ? st->easting() : st->altitude());
157 message <<
", taking " << componentProperty <<
'=' << returnData <<
" "
158 "for station id=" << st->id() <<
" from raw event";
163 message <<
", station with id=" << FindComponent<string>(
"stationId", componentIndex)
164 <<
" can not be found in raw event either";
168 }
else if (componentProperty ==
"axis1" ||
169 componentProperty ==
"axis2") {
173 GetStationData(axis, componentProperty, componentName, componentIndex);
185 EventStationPositionsManager::GetStationData(
string& returnData,
186 const string& componentProperty,
187 const string& componentName,
191 if (componentName !=
"stationList")
194 if (componentProperty ==
"name") {
196 const auto st = FindStation(componentIndex);
198 ostringstream message;
202 returnData = st->name();
203 message <<
", taking " << componentProperty <<
"='" << returnData <<
"' "
204 "for station id=" << st->id() <<
" from raw event";
209 message <<
", station with id=" << FindComponent<string>(
"stationId", componentIndex)
210 <<
" can not be found in raw event either";
214 }
else if (componentProperty ==
"commission") {
216 returnData = fCommission;
219 }
else if (componentProperty ==
"commissionUUB") {
221 returnData = fCommissionUUB;
224 }
else if (componentProperty ==
"decommission") {
226 returnData = fDecommission;
229 }
else if (componentProperty ==
"band") {
234 }
else if (componentProperty ==
"ellipsoid") {
236 returnData = fEllipsoid;
247 EventStationPositionsManager::GetStationData(vector<int>& returnData,
248 const string& componentProperty,
249 const string& componentName,
253 if (componentName !=
"stationList")
256 if (componentProperty ==
"stationGroup") {
257 ostringstream message;
258 message << outdatedMessage <<
", station will not be part of any group";
270 EventStationPositionsManager::GetStationData(vector<bool>& returnData,
271 const string& componentProperty,
272 const string& componentName,
276 if (componentName ==
"stationList" && componentProperty ==
"inGrid") {
278 const int sId = FindComponent<int>(
"stationId", componentIndex);
280 const auto& sDetector = det::Detector::GetInstance().GetSDetector();
281 const auto& pos = sDetector.GetStation(sId).GetPosition();
283 for (
const auto&
s : sDetector.AllStationsRange()) {
284 if (
s.GetId() == sId )
287 const double d = (pos -
s.GetPosition()).GetMag();
288 if (d < 100*
meter &&
s.GetId() < sId) {
298 }
else if (fabs(d - 1500*
meter) < 150*
meter) {
304 ostringstream message;
305 message <<
"guessed inGrid property from distances to neighbours =";
309 for (
size_t i = 0, n = grid.size(); i < n; ++i) {
311 message <<
' ' << (i + 1);
326 EventStationPositionsManager::FindStation(
const int id)
329 const auto&
event = RunController::GetInstance().GetCurrentEvent();
331 if (!event.HasRawEvent()) {
332 ERROR(
"Event has no raw event!");
336 const auto& rawEvent =
event.GetRawEvent();
338 if (!rawEvent.HasSd()) {
339 ERROR(
"Event has no raw SD event!");
343 const auto& stations = rawEvent.Sd().Stations;
345 for (
const auto&
s : stations)
346 if (
int(
s.id()) ==
id)
Manager to retrieve station positions from the raw event.
void AxesToUTM(const double axis1, const double axis2, double &easting, double &northing)
void UTMToAxes(const double easting, const double northing, double &axis1, double &axis2)
void Init()
Initialise the registry.
#define REGISTER_S_MANAGER(_name_, _Type_)
const unsigned char kGridIndexSize
#define WARNING(message)
Macro for logging warning messages.
std::map< std::string, std::string > IndexMap
const string outdatedMessage
#define ERROR(message)
Macro for logging error messages.
Status
Specifies success or (eventually) various possible failure modes.