9 #include <sdet/SDetector.h>
10 #include <sdet/SDetectorConstants.h>
11 #include <evt/Event.h>
12 #include <sevt/SEvent.h>
13 #include <sevt/SEventSimData.h>
15 #include <sevt/EventTrigger.h>
16 #include <sevt/Header.h>
17 #include <sevt/Station.h>
18 #include <sevt/StationSimData.h>
19 #include <sevt/StationTriggerData.h>
20 #include <sevt/StationGPSData.h>
22 #include <sevt/PMTSimData.h>
23 #include <fevt/FEvent.h>
25 #include <fevt/EyeTriggerData.h>
26 #include <utl/ErrorLogger.h>
27 #include <utl/UTMPoint.h>
28 #include <utl/AugerUnits.h>
29 #include <utl/TabularStream.h>
30 #include <utl/String.h>
35 using namespace CentralTriggerSimulatorXb;
39 using std::ostringstream;
56 namespace CentralTriggerSimulatorXb {
114 auto& sEvent =
event.GetSEvent();
119 const auto& sDetector = det::Detector::GetInstance().GetSDetector();
125 map<int, vector<t2>> t2InputSeconds;
127 for (
const auto&
s : sEvent.StationsRange()) {
133 const auto& dStation = sDetector.GetStation(
s);
140 const auto& sSim =
s.GetSimData();
142 for (
const auto& t : sSim.TriggerTimesRange()) {
143 const auto& trig = sSim.GetTriggerData(t);
146 const auto& gps = sSim.GetGPSData(t);
147 const int sec = gps.GetSecond();
148 if (
Is(sec).NotIn(t2InputSeconds)) {
150 t2Input.reserve(fgMaxStations);
151 t2InputSeconds.insert(make_pair(sec, t2Input));
154 t2station.
time = gps.GetCorrectedNanosecond() / 1000;
155 t2station.
ID =
s.GetId();
156 t2station.
energy = trig.IsT2TimeOverThresholdLike() ?
TOTVALUE : 0;
157 t2InputSeconds[sec].push_back(t2station);
164 for (
auto& st2 : t2InputSeconds) {
166 auto& t2Input = st2.second;
168 const auto allT3Clusters =
XbAlgoT2Process(&t2Input[0], t2Input.size());
170 if (allT3Clusters.empty()) {
171 WARNING(
"no T3 clusters found.");
176 info <<
"found " << allT3Clusters.size()
178 <<
" while processing event second " <<
second_ <<
':';
182 for (
const auto& cluster : allT3Clusters) {
186 const unsigned int refSecond = t3Cluster.refSecond;
187 const int refMicroSecond = t3Cluster.refuSecond;
188 const TimeStamp trigTime(refSecond, 1000*refMicroSecond);
193 const auto& algo = cluster.algo;
197 info <<
"T3 cluster: algorithm " << algo <<
", "
198 "reference time " << trigTime <<
" "
199 "(" << t3Cluster.refSecond <<
" s, " << t3Cluster.refuSecond <<
" us)";
203 for (
unsigned int i = 0; i < cluster.nelem; ++i) {
204 const auto& t3Station = cluster.point[i];
206 const int dt = int(t3Station.time) - refMicroSecond;
214 for (
const auto&
s : sDetector.StationsRange()) {
216 simT3.
AddStation(
s.GetId(), fDefaultOffset, fDefaultWindow);
220 const auto& t3Stations = t3Cluster.point;
222 for (
const auto& station : t3Stations) {
228 if (!sEvent.HasSimData())
229 sEvent.MakeSimData();
231 sEvent.GetSimData().AddT3(simT3);
236 for (
const auto& cluster : allT3Clusters)
258 fStations.reserve(fgMaxStations);
260 const auto& sDetector = det::Detector::GetInstance().GetSDetector();
264 for (
const auto& station : sDetector.StationsRange()) {
266 const int sId = station.GetId();
271 s.
Northing = position.GetNorthing();
272 s.
Easting = position.GetEasting();
274 fStations.push_back(s);
283 fStations.push_back(s);
287 nstat = fStations.size() - 1;
288 array = &fStations[0];
IsProxy< T > Is(const T &x)
Detector description interface for Station-related data.
void SetAlgorithm(const std::string &algo)
Set the trigger algorithm.
bool HasStation(const int id) const
Class to hold and convert a point in geodetic coordinates.
This class contains the basic information to build a surface event.
void SetTime(const utl::TimeStamp &stamp)
Set the trigger time stamp.
#define INFO(message)
Macro for logging informational messages.
bool IsInGrid(const SDetectorConstants::GridIndex index=SDetectorConstants::eStandard) const
Tells whether the station is in the regular triangular grid.
Base class for exceptions trying to access non-existing components.
A TimeStamp holds GPS second and nanosecond for some event.
const char * Plural(const T n)
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
void XbAlgoT2Init()
initialisation of XbAlgoT2 algorithm, building fake station and resetting histograms ...
vector< t2list > XbAlgoT2Process(struct t2 *input, int nt2)
Main function, processing T2 and returning clusters of T2.
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
#define WARNING(message)
Macro for logging warning messages.
t3 XbAlgoT3Build(struct t2list in)
builds t3 from a list of t2
bool IsSpecialStation(const sdet::Station &station)
A TimeInterval is used to represent time elapsed between two events.
ResultFlag
Flag returned by module methods to the RunController.
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
constexpr double microsecond
void AddStation(const int id, const utl::TimeInterval &offset, const utl::TimeInterval &window)
Add a station to request data, specifying offset and window size.