RdStationSimulationRejector.cc
Go to the documentation of this file.
2 
3 #include <fwk/CentralConfig.h>
4 
5 #include <det/Detector.h>
6 #include <rdet/RDetector.h>
7 
8 #include <utl/Branch.h>
9 #include <utl/ErrorLogger.h>
10 #include <utl/RadioGeometryUtilities.h>
11 #include <utl/CoordinateSystem.h>
12 #include <utl/Point.h>
13 
14 #include <evt/Event.h>
15 #include <evt/RadioSimulation.h>
16 #include <evt/ShowerSimData.h>
17 
18 #include <revt/REvent.h>
19 #include <revt/Station.h>
20 
21 #include <sevt/SEvent.h>
22 #include <sevt/StationTriggerData.h>
23 
24 
25 using namespace std;
26 using namespace fwk;
27 using namespace det;
28 using namespace utl;
29 using namespace evt;
30 using namespace revt;
31 
32 
34 
37  {
38  const Branch topB = CentralConfig::GetInstance()->GetTopBranch("RdStationSimulationRejector");
39  topB.GetChild("InfoLevel").GetData(fInfoLevel);
40  topB.GetChild("RejectStationAffectedByThinning").GetData(fRejectStationAffectedByThinning);
41  topB.GetChild("RemoveNonTriggeredRdStationsFromEvent").GetData(fRemoveNonTriggeredRdStationsFromEvent);
42 
43  ostringstream info;
44  info << "Module config:"
45  << "\n\tReject station affected by thinning: " << fRejectStationAffectedByThinning
46  << "\n\tReject RD station when WCD is not triggered: " << fRemoveNonTriggeredRdStationsFromEvent;
47  INFOFinal(info);
48 
49  return eSuccess;
50  }
51 
52 
54  RdStationSimulationRejector::Run(Event& event)
55  {
56  if (!event.HasREvent())
57  return eSuccess;
58 
59  REvent& rEvent = event.GetREvent();
60  const Detector& detector = Detector::GetInstance();
61  const rdet::RDetector& rDetector = detector.GetRDetector();
62 
63  unsigned int numberOfNotTriggeredRDStations = 0;
64  unsigned int numberOfAcceptedStations = 0;
65  ostringstream info;
66 
67  for (auto& station : rEvent.StationsRange()) {
68  const int rStationID = station.GetId();
69 
70  // For the Rd we will just get data for stations with a trigger in the WCD.
71  // If corresponding WCD did not trigger do not add Rd station to REvent.
72  if (rStationID > rDetector.GetRdSdStationIdLink() && fRemoveNonTriggeredRdStationsFromEvent) {
73  const int sStationID = rStationID - rDetector.GetRdSdStationIdLink();
74 
75  const sevt::SEvent& sEvent = event.GetSEvent();
76  if (!sEvent.HasStation(sStationID) || !sEvent.GetStation(sStationID).HasTriggerData()) {
77  info.str("");
78  info << "Not add RD station " << rStationID
79  << ". No corresponding SD station in has trigger data.";
80  INFODebug(info);
81  ++numberOfNotTriggeredRDStations;
82  station.SetExcludedReason(eStationWithoutTrigger);
83  continue;
84  }
85 
86  const sevt::StationTriggerData& trig = sEvent.GetStation(sStationID).GetTriggerData();
87  if (!trig.IsT2() && !trig.IsT1()) { // This is not equal to station.IsSilent() but this is desired here
88  info.str("");
89  info << "Not add RD station " << rStationID
90  << ". No corresponding SD station in has trigger data.";
91  INFODebug(info);
92  ++numberOfNotTriggeredRDStations;
93  station.SetExcludedReason(eStationWithoutTrigger);
94  continue;
95  }
96  }
97 
98  if (fRejectStationAffectedByThinning) {
99  const ShowerSimData& simshow = event.GetSimShower();
100  const RadioSimulation& rsim = simshow.GetRadioSimulation();
101  const CoordinateSystemPtr corsys = simshow.GetLocalCoordinateSystem();
102 
103  // exclude (most) simulated pulses (stations) which are affected by thinning
104  const Vector refShowerAxis = -1 * simshow.GetDirection(); // sim shower direction defined in particle direction
105  const double zenith = refShowerAxis.GetTheta(corsys);
106 
107  // not optimized for below
108  if (zenith > 65*deg) {
109  const Point& simCore = simshow.GetPosition();
110  const double maximumAllowedDistance = RdStationSimulationRejector::thinning_distance(zenith);
111 
112  const Point Position = rDetector.GetStation(station).GetPosition();
113  const double axisDistance = RadioGeometryUtilities::GetDistanceToAxis(refShowerAxis, simCore, Position);
114 
115  // not quite correct since the early late correction should be included
116  if (axisDistance > maximumAllowedDistance) {
117  info.str("");
118  info << "Station " << rStationID << " excluded because of thinning:";
119  INFOFinal(info);
120  station.SetExcludedReason(eThinningArtefacts);
121  continue;
122  } else {
123  numberOfAcceptedStations++;
124  }
125  }
126 
127  if (numberOfAcceptedStations / rsim.GetNumPulses() < 0.3) {
128  WARNING("A lot of stations have been excluded due to the thinning cut.\n"
129  "Please check if the core definition (e.g. SimShowerData or RadioSimulation core) is correct!");
130  }
131  }
132  }
133 
134  if (numberOfNotTriggeredRDStations) {
135  info.str("");
136  info << numberOfNotTriggeredRDStations << " RD stations have not been triggered.";
137  INFO(info);
138  }
139 
140  return eSuccess;
141  }
142 
143 
145  RdStationSimulationRejector::Finish()
146  {
147  return eSuccess;
148  }
149 
150 }
Branch GetTopBranch() const
Definition: Branch.cc:63
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger coordinate system associated to the shower core position.
Point object.
Definition: Point.h:32
bool HasStation(const int stationId) const
Check whether station exists.
Definition: SEvent.cc:81
Interface class to access to the Radio part of an event.
Definition: REvent.h:42
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
Definition: BasicVector.h:248
bool HasTriggerData() const
Check whether trigger data object exists.
Data structure for a radio simulation (including several SimRadioPulses)
#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
Detector description interface for RDetector-related data.
Definition: RDetector.h:46
constexpr double deg
Definition: AugerUnits.h:140
Interface class to access Shower Simulated parameters.
Definition: ShowerSimData.h:49
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
Class representing a document branch.
Definition: Branch.h:107
int GetRdSdStationIdLink() const
Get Rd - Sd Station Id link.
Definition: RDetector.h:127
const utl::Vector & GetDirection() const
Get the direction of the shower axis. This is the true direction of shower movement.
RadioSimulation & GetRadioSimulation()
Get the radio simulation data.
const utl::Point & GetPosition() const
Get the position of the shower core.
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
#define INFODebug(y)
Definition: VModule.h:163
Station & GetStation(const int stationId)
retrieve station by id throw utl::NonExistentComponentException if n.a.
Definition: SEvent.h:116
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
Station Trigger Data description
Vector object.
Definition: Vector.h:30
const rdet::RDetector & GetRDetector() const
Definition: Detector.cc:143
sevt::StationTriggerData & GetTriggerData()
Get Trigger data for the station.
long GetNumPulses() const
Get the number of radio pulses contained in the RadioSimulation.
utl::Point GetPosition() const
Tank position in Site Cartesian Coordinates.
#define INFOFinal(y)
Definition: VModule.h:161
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: RDetector.cc:141

, generated on Tue Sep 26 2023.