RdEventPostSelector.cc
Go to the documentation of this file.
1 #include "RdEventPostSelector.h"
2 
3 #include <fwk/CentralConfig.h>
4 
5 #include <utl/ErrorLogger.h>
6 #include <utl/Reader.h>
7 #include <utl/config.h>
8 #include <utl/RadioGeometryUtilities.h>
9 
10 #include <det/Detector.h>
11 #include <rdet/RDetector.h>
12 
13 #include <evt/Event.h>
14 #include <evt/ShowerRecData.h>
15 #include <evt/ShowerRRecData.h>
16 #include <evt/ShowerSRecData.h>
17 #include <evt/ShowerFRecData.h>
18 
19 #include <sevt/SEvent.h>
20 #include <revt/REvent.h>
21 #include <fevt/FEvent.h>
22 #include <fevt/Eye.h>
23 #include <fevt/EyeRecData.h>
24 
25 using namespace fwk;
26 using namespace utl;
27 using namespace std;
28 using namespace evt;
29 using namespace revt;
30 using namespace sevt;
31 using namespace fevt;
32 
33 
35 
38  {
39  const Branch topBranch = CentralConfig::GetInstance()->GetTopBranch("RdEventPostSelector");
40 
41  topBranch.GetChild("InfoLevel").GetData(fInfoLevel);
42  topBranch.GetChild("MaxZenithCut").GetData(fMaxZenith);
43  topBranch.GetChild("UseConverged").GetData(fUseConverged);
44  topBranch.GetChild("UseSuccessfulFits").GetData(fUseSuccessfulFits);
45  topBranch.GetChild("MinNumberOfStationsWithPulseFound").GetData(
46  fMinNumberOfStationsWithPulseFound);
47  topBranch.GetChild("UseCoincidenceCheck").GetData(fUseCoincidenceCheck);
48  topBranch.GetChild("MaximumAngularDeviation").GetData(fMaximumAngularDeviation);
49  topBranch.GetChild("MaximumAxisToCoreDistance").GetData(fMaximumAxisToCoreDistance);
50  topBranch.GetChild("MaximumNumberOfRejectedStations").GetData(fMaximumNumberOfRejectedStations);
51  topBranch.GetChild("AERA24Distance").GetData(fAERA24Distance);
52 
53  string tmp = topBranch.GetChild("UsedEye").Get<string>();
54  if (tmp == "CO")
55  fWhichEye = 4;
56  if (tmp == "HE")
57  fWhichEye = 5;
58  if (tmp == "HECO")
59  fWhichEye = 6;
60 
61  ostringstream info;
62  info.str("");
63 
64  if (fMaxZenith < 0)
65  info << " \n No zenith cut apllied";
66  else
67  info << " \n Maximum zenith angle: " << fMaxZenith / degree << " deg";
68  if (fUseConverged)
69  info << " \n Use only converged shower reconstructions";
70  if (fUseSuccessfulFits)
71  info << " \n Use only successfully fitted shower reconstructions";
72  if (fMinNumberOfStationsWithPulseFound > 0)
73  info << " \n Requiring " << fMinNumberOfStationsWithPulseFound << " stations with pulse found";
74  if (fUseCoincidenceCheck == "SD" || fUseCoincidenceCheck == "FD") {
75  info << " \n Checking for coincidences with SD/FD with the following parameter:";
76  info << " \n Maximum angular deviation: " << fMaximumAngularDeviation / degree << " degree.";
77  info << " \n Maximum axis to core distance: " << fMaximumAxisToCoreDistance / kilometer << " km.";
78  }
79  INFOFinal(info);
80 
81  return eSuccess;
82  }
83 
84 
86  RdEventPostSelector::Run(Event& event)
87  {
88  // Check if there is an radio event at all
89  if (!event.HasREvent()) {
90  INFOFinal("No radio event found!");
91  ++fNumberOfRejectedEvents;
92  return eContinueLoop;
93  }
94  const REvent& rEvent = event.GetREvent();
95 
96  // Check for SD/FD event if coincidence check is active
97  if (!event.HasSEvent() && fUseCoincidenceCheck == "SD") {
98  INFOFinal("No SD event found, but needed for coincidence check. Skipping event.");
99  ++fNumberOfRejectedEvents;
100  return eContinueLoop;
101  }
102 
103  if (!event.HasFEvent() && fUseCoincidenceCheck == "FD") {
104  INFOFinal("No FD event found, but needed for coincidence check. Skipping event.");
105  ++fNumberOfRejectedEvents;
106  return eContinueLoop;
107  }
108 
109  if (!event.HasRecShower()) {
110  INFOFinal("Event has no RRecShower!");
111  ++fNumberOfRejectedEvents;
112  return eContinueLoop;
113  }
114  const ShowerRecData& recShower = event.GetRecShower();
115 
116  if (!recShower.HasRRecShower()) {
117  INFOFinal("Event has no RecShower!");
118  ++fNumberOfRejectedEvents;
119  return eContinueLoop;
120  }
121  const ShowerRRecData& rRecShower = recShower.GetRRecShower();
122 
123  ostringstream info;
124 
125  if (fMaxZenith > 0) {
126  const double thisZenith = rRecShower.GetZenith();
127  if (thisZenith > fMaxZenith) {
128  INFOFinal("Shower zenith is above cut value. Skipping event");
129  ++fNumberOfRejectedEvents;
130  ++fNumberOfRejectedEventsZenithCut;
131  return eContinueLoop;
132  }
133  }
134 
135  if (fMaximumNumberOfRejectedStations != -1) {
136  //Note: manually rejected stations (i.e. rejectionStatus=1) are not taken into account
137  const int nRejectedStations =
138  count_if(rEvent.RejectedStationsBegin(), rEvent.RejectedStationsEnd(),
139  [&](auto const& station){ return station.GetRejectedReason() > 1; });
140 
141  if (nRejectedStations > fMaximumNumberOfRejectedStations) {
142  INFOFinal("Too many rejected stations. Skipping event.");
143  ++fNumberOfRejectedEvents;
144  return eContinueLoop;
145  }
146  }
147 
148  if (fMinNumberOfStationsWithPulseFound != 0) {
149  const int numberOfStations = rEvent.GetNumberOfSignalStations();
150 
151  if (numberOfStations < fMinNumberOfStationsWithPulseFound) {
152  INFOFinal("Event has not enough stations with pulse found. Skipping event.");
153  info.str("");
154  info << " Pulse found in " << numberOfStations << " stations, requested are "
155  << fMinNumberOfStationsWithPulseFound << " stations";
156  INFOIntermediate(info);
157  ++fNumberOfRejectedEvents;
158  ++fNumberOfRejectedEventsPulseFound;
159  return eContinueLoop;
160  }
161  }
162 
163  // RdDirectionConvergenceChecker
164  if (rRecShower.HasParameter(eFitConvergence)) {
165  if (!rRecShower.GetParameter(eFitConvergence) && fUseConverged) {
166  INFOFinal("Reconstruction did not converge. Skipping event.");
167  ++fNumberOfRejectedEvents;
168  return eContinueLoop;
169  }
170  } else if (!rRecShower.HasParameter(eFitConvergence) && fUseConverged) {
171  INFOFinal("Parameter eFitConvergence not set. Skipping event.");
172  ++fNumberOfRejectedEvents;
173  return eContinueLoop;
174  }
175 
176  // succesful wavefront fit
177  if (rRecShower.HasParameter(eFitSuccess)) {
178  if (!rRecShower.GetParameter(eFitSuccess) && fUseSuccessfulFits) {
179  INFOFinal("Reconstruction fit was not successful. Skipping event.");
180  ++fNumberOfRejectedEvents;
181  return eContinueLoop;
182  }
183  } else if (!rRecShower.HasParameter(eFitSuccess) && fUseSuccessfulFits) {
184  INFOFinal("Parameter eFitSuccess not set. Skipping event.");
185  ++fNumberOfRejectedEvents;
186  return eContinueLoop;
187  }
188 
189  // coindidencxe checks
190  if (fUseCoincidenceCheck == "SD" && event.GetRecShower().HasSRecShower()) {
191  const ShowerSRecData& sRecShower = event.GetRecShower().GetSRecShower();
192  const Vector& rShowerAxis = rRecShower.GetAxis();
193  const Vector& sShowerAxis = sRecShower.GetAxis();
194 
195  if (!rRecShower.HasCorePosition()) {
196  INFOFinal("no radio core reconstructed. Event is skipped.");
197  ++fNumberOfRejectedEvents;
198  return eContinueLoop;
199  }
200 
201  const Point& rCore = rRecShower.GetCorePosition();
202  const Point& sCore = sRecShower.GetCorePosition();
203 
204  const bool passes = passesCoincidenceCheck(rCore, rShowerAxis, sCore, sShowerAxis);
205  if (!passes) {
206  ++fNumberOfRejectedEvents;
207  return eContinueLoop;
208  }
209  }
210 
211  if (fUseCoincidenceCheck == "FD") {
212  FEvent& fdEvent = event.GetFEvent();
213 
214  for (auto eyeIter = fdEvent.EyesBegin(ComponentSelector::eHasData);
215  eyeIter != fdEvent.EyesEnd(ComponentSelector::eHasData); ++eyeIter) {
216  if (eyeIter->GetId() != fWhichEye) // continue until selected eye
217  continue;
218 
219  const Eye& eye = *eyeIter;
220  if (!eye.HasRecData() || !eye.GetRecData().HasFRecShower()) {
221  ERROR("Eye has no RecData or FRecShower but FDCore specified in the settings!");
222  ++fNumberOfRejectedEvents;
223  return eContinueLoop;
224  }
225 
226  const ShowerFRecData& fRecShower = eye.GetRecData().GetFRecShower();
227  const Vector& rShowerAxis = rRecShower.GetAxis();
228  const Vector& fShowerAxis = fRecShower.GetAxis();
229 
230  if (!rRecShower.HasCorePosition()) {
231  INFOFinal("no radio core reconstructed. Event is skipped");
232  ++fNumberOfRejectedEvents;
233  return eContinueLoop;
234  }
235 
236  const Point& rCore = rRecShower.GetCorePosition();
237  const Point& fCore = fRecShower.GetCorePosition();
238 
239  const bool passes = passesCoincidenceCheck(rCore, rShowerAxis, fCore, fShowerAxis);
240  if (!passes) {
241  ++fNumberOfRejectedEvents;
242  return eContinueLoop;
243  }
244  }
245  }
246 
247  // get min distance of reference core and AERA24 stations
248  double minDistance = 100 * km;
249  const rdet::RDetector& rDetector = det::Detector::GetInstance().GetRDetector();
250  for (const auto& station : rEvent.SignalStationsRange()) {
251  if(station.GetId() > 124) { // skip all not AERA24 stations
252  continue;
253  }
254 
255  const Point sPos = rDetector.GetStation(station).GetPosition();
256  const double distance = (sPos - rRecShower.GetReferenceCorePosition(event)).GetMag();
257  if(distance < minDistance) {
258  minDistance = distance;
259  }
260  }
261 
262  if (minDistance > fAERA24Distance) {
263  INFOFinal("Core position too far away from AERA24 sub array. Skipping event.");
264  ++fNumberOfRejectedEvents;
265  return eContinueLoop;
266  }
267 
268  // if all cuts are passed, return eSuccess at the end
269  return eSuccess;
270  }
271 
272 
274  RdEventPostSelector::Finish()
275  {
276  ostringstream sstr;
277  sstr << "\n\t" << fNumberOfRejectedEventsZenithCut
278  << " events rejected because of zenith angle cut (zenith was larger than "
279  << fMaxZenith / degree << " deg)"
280  << "\n\t" << fNumberOfRejectedEventsPulseFound
281  << " events rejected because of not enough stations with pulse found"
282  " (number of stations with pulse found was smaller than "
283  << fMinNumberOfStationsWithPulseFound << ")"
284  << "\n\t" << fNumberOfRejectedEventsAngularDeviation
285  << " events rejected because of angular deviation cut"
286  " (angular deviation SD/RD or FD/RD was larger than "
287  << round(fMaximumAngularDeviation / degree * 10.) / 10. << " deg)"
288  << "\n\t" << fNumberOfRejectedEventsAxisToCoreDistance
289  << " events rejected because of axis to core distance cut"
290  " (axis to core distance SD/RD or FD/RD was larger than "
291  << fMaximumAxisToCoreDistance << " m)"
292  << "\n\t" << fNumberOfRejectedEvents << " events rejected in total";
293  INFO(sstr);
294 
295  return eSuccess;
296  }
297 
298 
299  bool
300  RdEventPostSelector::passesCoincidenceCheck(const Point& rCore, const Vector& rAxis,
301  const Point& oCore, const Vector& oAxis)
302  {
303  ostringstream info;
304 
305  if (fMaximumAngularDeviation >= 0) {
306  const double angleDiff = acos(Normalized(rAxis) * Normalized(oAxis));
307  info.str("");
308  info << "Angular deviation of " << round((angleDiff / degree) * 10.) / 10
309  << " degree between RD and other axis ";
310 
311  if (angleDiff / degree >= fMaximumAngularDeviation / degree) {
312  info << "is larger than allowed difference of "
313  << round((fMaximumAngularDeviation / degree) * 10.) / 10
314  << " degree. Skipping event.";
315  INFOFinal(info);
316  ++fNumberOfRejectedEventsAngularDeviation;
317  return false;
318  } else {
319  info << "is in allowed range of maximal "
320  << round((fMaximumAngularDeviation / degree) * 10) / 10
321  << " degree. Event is coincident candidate";
322  INFOIntermediate(info);
323  }
324  }
325 
326  if (fMaximumAxisToCoreDistance >= 0) {
327  const double axisToCoreDistance = RadioGeometryUtilities::GetDistanceToAxis(oAxis, oCore, rCore);
328  info.str("");
329  info << "Core distance of " << round((axisToCoreDistance / kilometer) * 100.) / 100 << " km ";
330 
331  if (axisToCoreDistance / kilometer >= fMaximumAxisToCoreDistance / kilometer) {
332  info << "is larger than allowed difference of "
333  << round((fMaximumAxisToCoreDistance / kilometer) * 100.) / 100
334  << " km. Skipping event.";
335  INFOFinal(info);
336  ++fNumberOfRejectedEventsAxisToCoreDistance;
337  return false;
338  } else {
339  info << "is in allowed range of "
340  << round((fMaximumAxisToCoreDistance / kilometer) * 100) / 100
341  << " km. Event is coincident candidate.";
342  INFOIntermediate(info);
343  }
344  }
345 
346  // if comes here, event meets all coincidence criteria
347  INFOIntermediate("Event meets all coincidence criteria.");
348  return true;
349  }
350 
351 }
bool HasParameter(const Parameter i) const
utl::Vector GetAxis() const
Returns vector of the shower axis.
utl::Point GetReferenceCorePosition(const Event &event) const
Returning the reference core position depending on the corresponding flag.
const double degree
Point object.
Definition: Point.h:32
bool HasRecData() const
Definition: FEvent/Eye.h:116
Fluorescence Detector Eye Event.
Definition: FEvent/Eye.h:29
Interface class to access to the SD Reconstruction of a Shower.
Interface class to access Shower Reconstructed parameters.
Definition: ShowerRecData.h:33
bool HasRecShower() const
bool HasFEvent() const
Interface class to access to the Radio part of an event.
Definition: REvent.h:42
RejectedStationIterator RejectedStationsBegin(const int rejectionMask=~0)
Definition: REvent.h:177
ShowerRecData & GetRecShower()
Interface class to access to the RD Reconstruction of a Shower.
EyeIterator EyesEnd(const ComponentSelector::Status status)
Definition: FEvent.h:66
bool HasCorePosition() const
Return true if all 3 core parameter are set.
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
bool HasREvent() const
ShowerRRecData & GetRRecShower()
Detector description interface for RDetector-related data.
Definition: RDetector.h:46
T Get() const
Definition: Branch.h:271
#define INFOIntermediate(y)
Definition: VModule.h:162
Class representing a document branch.
Definition: Branch.h:107
double GetZenith() const
returns the zenith angle (from the wave fit)
bool HasRRecShower() const
bool HasFRecShower() const
Check if reconstructed shower info has been allocated.
Definition: EyeRecData.h:330
evt::ShowerFRecData & GetFRecShower()
Reconstructed shower info for this eye.
Definition: EyeRecData.h:323
EyeIterator EyesBegin(const ComponentSelector::Status status)
Definition: FEvent.h:58
const double km
const utl::Vector & GetAxis() const
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
Top of Fluorescence Detector event hierarchy.
Definition: FEvent.h:33
AxialVector Normalized(const AxialVector &v)
Definition: AxialVector.h:81
int GetNumberOfSignalStations() const
Get number of signal stations in the event.
Definition: REvent.h:209
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
constexpr double kilometer
Definition: AugerUnits.h:93
Vector object.
Definition: Vector.h:30
Interface class to access to Fluorescence reconstruction of a Shower.
const utl::Point & GetCorePosition() const
utl::Point GetCorePosition() const
returns pointer of the position vector of the core in the reference coor system
RejectedStationIterator RejectedStationsEnd(const int rejectionMask=~0)
Definition: REvent.h:179
double GetParameter(const Parameter i) const
utl::Point GetPosition() const
Tank position in Site Cartesian Coordinates.
#define INFOFinal(y)
Definition: VModule.h:161
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: RDetector.cc:141
const utl::Point & GetCorePosition() const
Shower core as reconstructed by the FD or FD eye.
bool HasSRecShower() const
bool HasSEvent() const
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
fevt::EyeRecData & GetRecData()
Reconstructed data for this eye.
Definition: FEvent/Eye.cc:130
const utl::Vector & GetAxis() const
Shower Axis as reconstructed by the FD or FD eye.

, generated on Tue Sep 26 2023.