EventPointingManager.cc
Go to the documentation of this file.
1 
9 #include <sstream>
10 
11 #include <fwk/CentralConfig.h>
12 #include <fwk/RunController.h>
13 
14 #include <utl/Reader.h>
15 #include <utl/TimeStamp.h>
16 #include <utl/UTCDateTime.h>
17 #include <utl/ErrorLogger.h>
18 
19 #include <det/Detector.h>
20 
21 #include <fdet/FDetector.h>
22 #include <fdet/EventPointingManager.h>
23 
24 #include <evt/Event.h>
25 #include <fevt/FEvent.h>
26 #include <fevt/Eye.h>
27 #include <fevt/Telescope.h>
28 
29 using namespace fwk;
30 using namespace det;
31 using namespace fdet;
32 using namespace utl;
33 using namespace std;
34 
35 
36 REGISTER_F_MANAGER("EventPointingManager", EventPointingManager);
37 
38 
39 void
40 EventPointingManager::Init(const string& configLink)
41 {
42  // call shadowed VManager::Init() first
43  VManager::Init(configLink);
44 
45  if (!fBranch) {
46  ERROR("No configuration file found ....");
47  }
48 
49  for (Branch cB = fBranch.GetFirstChild(); cB; cB = cB.GetNextSibling()) {
50 
51  const string id = FindComponent<string>("id", cB.GetAttributes());
52  EventPointingManager::Pointing pointing(id);
53  cB.GetChild("minElevation").GetData(pointing.minElevation);
54  cB.GetChild("maxElevation").GetData(pointing.maxElevation);
55 
56  if (pointing.minElevation > pointing.maxElevation) {
57  ostringstream err;
58  err << "You defined minimal elevation larger than maximal elevation! Please fix!\n"
59  << " Error in : id=" << id
60  << " minElevation=" << pointing.minElevation/deg << " deg, "
61  << " maxElevation=" << pointing.maxElevation/deg << " deg\n";
62  throw utl::XMLParseException(err.str());
63  }
64 
65  // check consistency
66  for (vector<Pointing>::const_iterator iP = fPointings.begin();
67  iP != fPointings.end(); ++iP) {
68  if ((pointing.minElevation > iP->minElevation &&
69  pointing.minElevation < iP->maxElevation ) ||
70  (pointing.maxElevation > iP->minElevation &&
71  pointing.maxElevation < iP->maxElevation ) ||
72  (pointing.minElevation < iP->minElevation &&
73  pointing.maxElevation > iP->maxElevation ) ||
74  (id == iP->pointingId) ) {
75  ostringstream err;
76  err << "You defined overlapping pointing elevation ranges! Please fix!\n"
77  << " Range with problem: id=" << id
78  << " minElevation=" << pointing.minElevation/deg << " deg, "
79  << " maxElevation=" << pointing.maxElevation/deg << " deg\n"
80  << " overlapping with: id=" << iP->pointingId
81  << " minElevation=" << iP->minElevation/deg << " deg, "
82  << " maxElevation=" << iP->maxElevation/deg << " deg";
83  throw utl::XMLParseException(err.str());
84  }
85  }
86 
87  fPointings.push_back(pointing);
88 
89  }
90 }
91 
92 
94 EventPointingManager::GetPointing(string& returnData,
95  const string& componentProperty,
96  const string& /*componentName*/,
97  const IndexMap& componentIndex)
98  const
99 {
100  if (componentProperty != "pointing")
101  return eNotFound;
102 
103  IndexMap::const_iterator iEyeId, iTelId;
104  iEyeId = componentIndex.find("eyeId");
105  iTelId = componentIndex.find("telescopeId");
106  if (iEyeId == componentIndex.end() ||
107  iTelId == componentIndex.end()) {
108  INFO("Called EventPointingManager with wrong number of arguments!");
109  return eNotFound;
110  }
111 
112  int eyeId, telId;
113  istringstream ssEyeId(iEyeId->second);
114  ssEyeId >> eyeId;
115  istringstream ssTelId(iTelId->second);
116  ssTelId >> telId;
117 
118 //#warning AP: fix me once IoAuger is re-remerged
119  if (eyeId < 5) {
120  returnData = "downward";
121  return eFound;
122  }
123  //end of temporary fixing
124 
125  /*
126  In principle the telescope pointing is stored in the FDAS raw data and
127  could be read from there directly. However, it is more general to read
128  that data during event reading and store it in the Offline/fevt::Telescope
129  since this information can also be saved into Offline ROOT files as well
130  as handled correctly in Offline simulations.
131  */
132 
133  // get current event
134  const evt::Event& event = fwk::RunController::GetInstance().GetCurrentEvent();
135  if (!event.HasFEvent())
136  return eNotFound;
137  const fevt::FEvent& fdEvent = event.GetFEvent();
138 
139  if (!fdEvent.HasEye(eyeId, fevt::ComponentSelector::eInDAQ))
140  return eNotFound;
141  const fevt::Eye& eye = fdEvent.GetEye(eyeId, fevt::ComponentSelector::eInDAQ);
142 
144  return eNotFound;
146 
147  const string& pointing = tel.GetRawTelPointing();
148  istringstream pointingSS(pointing);
149 
150  string what;
151  pointingSS >> what;
152  if (what == "data:") {
153  double angle;
154  pointingSS >> angle;
155 
156  for (vector<Pointing>::const_iterator iP = fPointings.begin();
157  iP != fPointings.end(); ++iP) {
158  if (angle > iP->minElevation/deg && angle < iP->maxElevation/deg) {
159  returnData = iP->pointingId;
160  return eFound;
161  }
162  }
163  if (IsReportingErrors()) {
164  ostringstream info;
165  info << "Pointing for angle=" << angle << " not defined. Available settings are:";
166  for (vector<Pointing>::const_iterator iP = fPointings.begin();
167  iP != fPointings.end(); ++iP) {
168  info << "\n id=" << iP->pointingId << ","
169  << " minElevation=" << iP->minElevation/deg << " deg, "
170  << " maxElevation=" << iP->maxElevation/deg << " deg";
171  }
172  INFO(info);
173  }
174 
175  return eNotFound;
176  }
177  else if (what == "sim:") {
178  string id;
179  pointingSS >> id;
180  returnData = id;
181 
182  return eFound;
183  }
184 
185  return eNotFound;
186 }
187 
188 
189 // Configure (x)emacs for this file ...
190 // Local Variables:
191 // mode: c++
192 // compile-command: "make -C .. -k"
193 // End:
Telescope & GetTelescope(const unsigned int telescopeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Retrieve Telescope by Id, throw exception if not existent.
Definition: FEvent/Eye.cc:57
Fluorescence Detector Eye Event.
Definition: FEvent/Eye.h:29
std::string GetRawTelPointing() const
The pointing.
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
Exception for errors encountered when parsing XML.
constexpr double deg
Definition: AugerUnits.h:140
Branch GetNextSibling() const
Get next sibling of this branch.
Definition: Branch.cc:284
Class representing a document branch.
Definition: Branch.h:107
Top of Fluorescence Detector event hierarchy.
Definition: FEvent.h:33
Eye & GetEye(const unsigned int eyeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
return Eye by id
Definition: FEvent.cc:70
reads the telescope point from the current Fd event
bool HasEye(const unsigned int eyeId, const ComponentSelector::Status status=ComponentSelector::eHasData) const
Definition: FEvent.cc:57
#define REGISTER_F_MANAGER(_name_, _Type_)
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
bool HasTelescope(const unsigned int telescopeId, const ComponentSelector::Status status=ComponentSelector::eHasData) const
Check if the telescope is in the event.
Definition: FEvent/Eye.cc:117
Branch GetFirstChild() const
Get first child of this Branch.
Definition: Branch.cc:98
Fluorescence Detector Telescope Event.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
Status
Specifies success or (eventually) various possible failure modes.
Definition: VManager.h:127

, generated on Tue Sep 26 2023.