3 #include <fwk/CentralConfig.h>
5 #include <det/Detector.h>
6 #include <rdet/RDetector.h>
7 #include <rdet/Channel.h>
9 #include <utl/Branch.h>
10 #include <utl/ErrorLogger.h>
11 #include <utl/String.h>
13 #include <evt/Event.h>
14 #include <revt/REvent.h>
30 RdStationRejector::ExcludeOrRejectStation(
Station& station,
unsigned long long int reason=1)
32 if (fExcludeStations) {
48 topB.
GetChild(
"useStationsInStationList").
GetData(fUseStationsInStationList);
57 const auto rejectAllExceptOf =
58 topB.
GetChild(
"rejectAllBadPeriodReasonsExceptOf").
Get<vector<string>>();
59 for (
const auto& elem : rejectAllExceptOf) {
65 if (fUseStationsInStationList) {
66 if (fStationList.empty()) {
67 ERROR(
"Only select stations for list but list is empty!");
70 msg <<
"Use only the following stations:";
72 msg <<
"Exclude or reject the following stations:";
74 for (
auto &
id: fStationList)
78 msg <<
"\nExclude stations (instead of rejecting them) : " << fExcludeStations
79 <<
"\nExclude all stations with NL electronis: " << fExcludeNlStations
80 <<
"\nUse BadPeriod DB: " << fUseBadPeriodDB
81 <<
"\nRegister additional BadStations:";
85 if (
b.GetName() !=
"BadStation")
88 const size_t stationId = VManager::FindComponent<size_t>(
"id",
b.GetAttributes());
89 const string reason = VManager::FindComponent<string>(
"reason",
b.GetAttributes());
90 vector<utl::TimeStamp> range;
92 fRejectMap.insert(make_pair(range[0], make_pair(range[1], stationId)));
93 msg <<
"\n registered: id = " << stationId <<
" [" << range[0] <<
", " << range[1] <<
")";
98 return fRejectMap.empty() ? eFailure :
eSuccess;
103 RdStationRejector::Run(
Event& event)
108 REvent& rEvent =
event.GetREvent();
109 Detector& detector = Detector::GetInstance();
113 if (detector.
GetTime() !=
event.GetHeader().GetTime())
118 if (fExcludeNlStations) {
119 for (
auto& station : rEvent.StationsRange()) {
121 const auto& detChannel = rDetector.
GetStation(station.GetId()).GetChannel(1);
122 const int bitDepth = detChannel.GetBitDepth();
124 if (bitDepth != 12 && bitDepth != 14) {
126 info <<
"Station " << station.
GetId() <<
" has invalid bit depth of " << bitDepth
127 <<
". Can not decide if DE or NL electronics. Station is not rejected.";
132 if (bitDepth == 14) {
134 info <<
"Station " << station.GetId() <<
" has NL electronics. Station is excluded.";
144 if (fUseBadPeriodDB) {
145 for (
auto& station : rEvent.StationsRange()) {
147 if (reason & fBadPeriodReasons) {
149 info <<
"Excluded station " << station.GetId()
150 <<
" as bad period because of reason " << (reason & fBadPeriodReasons);
152 ExcludeOrRejectStation(station, reason);
160 vector<int> deselectedIds;
162 for (
auto& stationId : badIds) {
164 deselectedIds.push_back(stationId);
165 ExcludeOrRejectStation(rEvent.
GetStation(stationId));
170 if (fStationList.size() > 0) {
171 if (fUseStationsInStationList) {
172 for (
auto& station : rEvent.StationsRange()) {
173 const int stationId = station.GetId();
176 auto it = find(fStationList.begin(), fStationList.end(), stationId);
177 if (it == fStationList.end()) {
178 deselectedIds.push_back(stationId);
179 ExcludeOrRejectStation(station);
183 for (
auto& stationId : fStationList) {
185 deselectedIds.push_back(stationId);
186 ExcludeOrRejectStation(rEvent.
GetStation(stationId));
192 if (!deselectedIds.empty()) {
204 RdStationRejector::Finish()
Branch GetTopBranch() const
void Update(const utl::TimeStamp &time, const bool invData=true, const bool invComp=true, const bool forceRadio=false)
Update detector: deletes currently constructed stations and sets new time.
evt::Header & GetHeader()
Interface class to access to the Radio part of an event.
utl::TimeStamp GetTime() const
Get time pertaining to the detector description.
std::vector< size_t > IdCollection
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
unsigned long long int GetBadStationReason(const int stationId) const
Station & GetStation(const int stationId)
retrieve station by id throw utl::NonExistentComponentException if n.a.
A TimeStamp holds GPS second and nanosecond for some event.
Detector description interface for RDetector-related data.
const char * Plural(const T n)
#define INFOIntermediate(y)
Class representing a document branch.
class to hold data at the radio Station level.
Top of the hierarchy of the detector description interface.
int GetId() const
Station ID.
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
void SetRejectedReason(const unsigned long long int reason)
static std::map< std::string, RejectionStatus > gMapRejectionStatus
ResultFlag
Flag returned by module methods to the RunController.
void SetExcludedReason(const ExcludedReason reason)
const rdet::RDetector & GetRDetector() const
Branch GetFirstChild() const
Get first child of this Branch.
bool HasStation(const int stationId) const
Check whether station exists.
string OfSortedIds(vector< int > ids)
#define ERROR(message)
Macro for logging error messages.
const Station & GetStation(const int stationId) const
Get station by Station Id.