EventChecker.cc
Go to the documentation of this file.
1 #include "EventChecker.h"
2 
3 #include <fwk/CentralConfig.h>
4 
5 #include <det/Detector.h>
6 
7 #include <fdet/FDetector.h>
8 #include <fdet/Eye.h>
9 
10 #include <sdet/SDetector.h>
11 #include <sdet/Station.h>
12 
13 #include <evt/Header.h>
14 #include <evt/Event.h>
15 
16 #include <sevt/SEvent.h>
17 #include <sevt/Header.h>
18 #include <sevt/EventTrigger.h>
19 
20 #include <mdet/MDetector.h>
21 #include <mdet/Counter.h>
22 #include <mevt/MEvent.h>
23 #include <mevt/Header.h>
24 
25 
26 #include <fevt/FEvent.h>
27 #include <fevt/Eye.h>
28 #include <fevt/EyeHeader.h>
29 #include <fevt/FdComponentSelector.h>
30 
31 #include <utl/ErrorLogger.h>
32 #include <utl/Reader.h>
33 #include <utl/TimeStamp.h>
34 #include <utl/TabularStream.h>
35 
36 #include <cstddef>
37 #include <cstdio>
38 #include <sstream>
39 
40 using namespace EventCheckerOG;
41 using namespace fwk;
42 using sdet::SDetector;
43 using namespace evt;
44 using sevt::SEvent;
45 using namespace utl;
46 using namespace std;
47 
48 
51 {
52  Branch topBranch = CentralConfig::GetInstance()->GetTopBranch("EventChecker");
53 
54  topBranch.GetChild("SkipTimeZeroEvents").GetData(fSkipTimeZeroEvents);
55 
56  // whether FD is configured
57  fHaveFDetectorConfig = (
58  det::Detector::GetInstance().GetFDetector().EyesBegin() !=
59  det::Detector::GetInstance().GetFDetector().EyesEnd()
60  );
61 
62  if (fHaveFDetectorConfig)
63  INFO("FDetector configuration available");
64  else
65  INFO("FDetector configuration not available, related check disabled");
66 
67  return eSuccess;
68 }
69 
70 
73 {
74  ++fNEventsProcessed;
75 
76  const auto& time = event.GetHeader().GetTime();
77 
78  if (fSkipTimeZeroEvents && !time) {
79  WARNING("Skipping event with zero time.");
80  ++fNEventsWithZeroTime;
81  return eContinueLoop;
82  }
83 
84  // Check the SDetector definition
85  if (event.HasSEvent()) {
86  const auto& sEvent = event.GetSEvent();
87  for (const auto& station : sEvent.StationsRange()) {
88  try {
89  det::Detector::GetInstance().GetSDetector().GetStation(station);
91  WARNING("Skipping event with SDetector mismatch.");
92  ++fNEventsWithMissingStations;
93  return eContinueLoop;
94  }
95  }
96  }
97 
98  // Check the FDetector definition
99  if (event.HasFEvent() && fHaveFDetectorConfig) {
100  const auto& fEvent = event.GetFEvent();
102  end = fEvent.EyesEnd(fevt::ComponentSelector::eHasData); eIt != end; ++eIt) {
103  try {
104  det::Detector::GetInstance().GetFDetector().GetEye(*eIt);
106  end = eIt->TelescopesEnd(fevt::ComponentSelector::eHasData); tIt != end; ++tIt) {
107  det::Detector::GetInstance().GetFDetector().GetTelescope(*tIt);
108  }
110  WARNING("Skipping event with FDetector mismatch.");
111  ++fNEventsWithMissingEyes;
112  return eContinueLoop;
113  }
114  }
115  }
116 
117  // Check the MDetector definition
118  if (event.HasMEvent()) {
119  const auto& mEvent = event.GetMEvent();
120  for (mevt::MEvent::CounterConstIterator cIt = mEvent.CountersBegin(),
121  end = mEvent.CountersEnd(); cIt != end; ++cIt) {
122  try {
123  det::Detector::GetInstance().GetMDetector().GetCounter(cIt->GetId());
125  WARNING("Skipping event with MDetector mismatch.");
126  ++fNEventsWithMissingCounters;
127  return eContinueLoop;
128  }
129  }
130  }
131 
132  ++fNEventsAccepted;
133 
134  return eSuccess;
135 }
136 
137 
140 {
141  if (fNEventsProcessed) {
142 
143  const int nDiscarded = fNEventsProcessed - fNEventsAccepted;
144 
145  TabularStream tab("r r .");
146 
147  tab << endc << 'N' << endc << '%' << endr
148  << "Events processed:" << endc << fNEventsProcessed << endc << 100 << endr
149  << "Events skiped:" << endc << nDiscarded << endc << int(nDiscarded*1000./fNEventsProcessed)/10. << endr
150  << "1980 (time-zero):" << endc << fNEventsWithZeroTime << endc << int(fNEventsWithZeroTime*1000./fNEventsProcessed)/10. << endr
151  << "SD station err:" << endc << fNEventsWithMissingStations << endc << int(fNEventsWithMissingStations*1000./fNEventsProcessed)/10. << endr
152  << "FD eye err:" << endc << fNEventsWithMissingEyes << endc << int(fNEventsWithMissingEyes*1000./fNEventsProcessed)/10.
153  << endr << "MD counter err:" << endc << fNEventsWithMissingCounters << endc << int(fNEventsWithMissingCounters*1000./fNEventsProcessed)/10.
154  ;
155  ostringstream info;
156  info << '\n' << tab;
157  INFO(info);
158 
159  } else {
160  INFO("No events processed.");
161  }
162 
163  return eSuccess;
164 }
Branch GetTopBranch() const
Definition: Branch.cc:63
InternalCounterCollection::ComponentConstIterator CounterConstIterator
Definition: MEvent.h:30
bool HasMEvent() const
boost::filter_iterator< ComponentSelector, ConstAllEyeIterator > ConstEyeIterator
Definition: FEvent.h:56
fwk::VModule::ResultFlag Init() override
Initialize: invoked at beginning of run (NOT beginning of event)
Definition: EventChecker.cc:50
bool HasFEvent() const
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
Base class for exceptions trying to access non-existing components.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
Class representing a document branch.
Definition: Branch.h:107
const EndRow endr
const int tab
Definition: SdInspector.cc:35
class to format data in tabular form
#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
fwk::VModule::ResultFlag Finish() override
Finish: invoked at end of the run (NOT end of the event)
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
Detector description interface for SDetector-related data.
Definition: SDetector.h:42
fwk::VModule::ResultFlag Run(evt::Event &event) override
Run: invoked once per event.
Definition: EventChecker.cc:72
const EndColumn endc
bool HasSEvent() const
boost::filter_iterator< ComponentSelector, ConstAllTelescopeIterator > ConstTelescopeIterator
Definition: FEvent/Eye.h:73

, generated on Tue Sep 26 2023.