11 #include <evt/Event.h>
13 #include <sevt/SEvent.h>
14 #include <sevt/SEventSimData.h>
16 #include <sevt/EventTrigger.h>
17 #include <sevt/Header.h>
18 #include <sevt/Station.h>
19 #include <sevt/StationSimData.h>
20 #include <sevt/StationTriggerData.h>
21 #include <sevt/StationGPSData.h>
23 #include <sevt/PMTSimData.h>
24 #include <sevt/SEventSimData.h>
26 #include <fevt/FEvent.h>
28 #include <fevt/EyeTriggerData.h>
30 #include <sdet/SDetector.h>
32 #include <utl/ErrorLogger.h>
33 #include <utl/String.h>
34 #include <utl/UTMPoint.h>
35 #include <utl/AugerUnits.h>
36 #include <utl/TabularStream.h>
38 #include <fwk/CentralConfig.h>
40 using namespace CentralTriggerEventBuilderNS;
49 fSDetector = &det::Detector::GetInstance().GetSDetector();
53 Branch topB = CentralConfig::GetInstance()->
GetTopBranch(
"CentralTriggerEventBuilder");
54 topB.
GetChild(
"ForceEventBuildWithoutT3").
GetData(fForceEventBuildWithoutT3);
63 return BuildEvent(event);
91 if (eyeIt->HasTriggerData() && eyeIt->GetTriggerData().IsT3Accepted()) {
93 const TimeStamp& eyeT3time = eyeIt->GetTriggerData().GetT3Time();
94 if (!t3Time || eyeT3time < t3Time)
119 if (initAlgo ==
"None" &&
122 if (!fForceEventBuildWithoutT3) {
123 INFO(
"no FD trigger and no SD T3, continuing");
124 return eContinueLoop;
128 INFO(
"No T3. As specified, forcing build of event in spite of no T3.");
129 t3Time = det::Detector::GetInstance().GetTime();
143 if (initAlgo !=
"None") {
150 sIt != fSDetector->StationsEnd(); ++sIt)
151 t3.
AddStation(sIt->GetId(), fDefaultOffset, fDefaultWindow);
154 info <<
"Trigger (FD or forced) time set to: " << t3Time;
159 const auto begin = simData.T3sBegin();
160 const auto end = simData.T3sEnd();
163 info <<
"Got " << nT3 <<
" T3 trigger" << (nT3 != 1 ?
"s" :
"") <<
':';
164 unsigned int it3 = 0;
165 for (
auto t3It = begin; t3It != end; ++t3It) {
166 info <<
"\n#" << ++it3 <<
" n=" << t3It->GetNumberOfStations() <<
" (" << t3It->GetAlgorithm() <<
"):\n";
169 for (
auto sIt = t3It->StationsBegin(); sIt != t3It->StationsEnd(); ++sIt)
181 for ( ; t3It != end; t3It++)
183 t3.
AddStation(sIt->fId, sIt->fOffset, sIt->fWindow);
194 WARNING(
"No valid trigger combination found.");
200 vector<int> addedTOTStations;
201 vector<int> addedMopsStations;
202 vector<int> addedRDStations;
203 vector<int> addedT1Stations;
204 vector<int> addedT2Stations;
207 int errorZeroStations = 0;
209 bool outOfWindowStations =
false;
216 const int sId = t3sIt->fId;
218 const TimeStamp start = evTrig.
GetTime() + (t3sIt->fOffset - t3sIt->fWindow);
223 info <<
"skipping station " << sId;
232 info <<
"station " << station.
GetId() <<
" does not have sim data";
259 const int offset = 0;
260 const int current100 = 100000000;
261 const int next100 = 100000000;
262 const int current40 = 40000000;
263 const int next40 = 40000000;
264 const int previousST = 0;
265 const int nextST = 0;
266 const int currentST = 0;
268 const int tickFall = 0;
271 (next100 > 0 ? (1e9 + nextST - currentST)/next100 : 10.0));
292 if (trigTime < start || trigTime > end) {
293 outOfWindowStations =
true;
294 const bool early = (trigTime < start);
296 <<
' ' << (early ? (start - trigTime) : (trigTime - end)) /
nanosecond <<
endc
297 << (early ?
" early" :
" late") <<
endr;
301 if (candidateTrigger.IsT1() || candidateTrigger.IsT2()) {
303 sTrig = candidateTrigger;
312 if (!pmtIt->HasSimData()) {
314 warn <<
"Station " << sId <<
", "
315 "pmt " << pmtIt->GetId() <<
" does not have sim data but is still in the event?";
334 simIt != end; ++simIt) {
336 if (!pmtIt->HasFADCTrace(label))
338 pmtIt->GetFADCTrace(
gain, label) = simIt->GetTrace();
343 simIt != end; ++simIt) {
345 if (!pmtIt->HasFADCTrace(label))
346 pmtIt->MakeFADCTrace(label);
347 pmtIt->GetFADCTraceD(
gain, label) = simIt->GetTrace();
354 addedTOTStations.push_back(sId);
356 addedMopsStations.push_back(sId);
358 addedRDStations.push_back(sId);
360 addedT2Stations.push_back(sId);
362 addedT1Stations.push_back(sId);
370 if (outOfWindowStations) {
379 if (!addedTOTStations.empty() ||
380 !addedMopsStations.empty() ||
381 !addedRDStations.empty() ||
382 !addedT1Stations.empty() ||
383 !addedT2Stations.empty()) {
385 info <<
"\nAdding stations:";
386 if (!addedTOTStations.empty())
388 if (!addedMopsStations.empty())
390 if (!addedRDStations.empty())
392 if (!addedT1Stations.empty())
394 if (!addedT2Stations.empty())
StationIterator StationsEnd() const
Iterator over the list of T3Stations in T3.
Branch GetTopBranch() const
bool IsTimeOverThresholdDeconvoluted() const
Time Over Threshold deconvoluted.
Station Level Simulated Data
int GetId() const
Get the station Id.
bool HasStation(const int stationId) const
Check whether station exists.
void SetAlgorithm(const std::string &algo)
Set the trigger algorithm.
void SetCurrentST(const int num)
boost::filter_iterator< ComponentSelector, ConstAllEyeIterator > ConstEyeIterator
Interface class to access to the SD part of an event.
This class contains the basic information to build a surface event.
void SetCurrent100(const int num)
PMTIterator PMTsBegin(const sdet::PMTConstants::PMTType type=sdet::PMTConstants::eWaterCherenkovLarge)
begin PMT iterator for read/write
void SetOffsetMicroSecond(const int offset)
bool HasTriggerData() const
Check whether trigger data object exists.
void SetTime(const utl::TimeStamp &time)
Set time of the trigger.
sevt::StationGPSData & GetGPSData(const utl::TimeStamp &time)
Get simulated GPSData.
void SetNext40(const int num)
unsigned int GetNumberOfT3s() const
Get the number of T3s.
EventTrigger & GetTrigger()
Get the object with central trigger data, throw if n.a.
EyeIterator EyesEnd(const ComponentSelector::Status status)
void SetTick(const unsigned int num)
#define INFO(message)
Macro for logging informational messages.
FADCTriggeredTraceIterator FADCTriggeredTracesBegin(const utl::TimeStamp &stamp, const sdet::PMTConstants::PMTGain gain)
void SetCurrent40(const int num)
void SetPreviousId(const unsigned int id)
Set Id of the FD trigger that contains data for this event.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
void MakeTriggerData()
Make trigger data object.
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
bool HasSimData() const
check whether the SimData object exists
bool HasFADCTrace(StationConstants::SignalComponent source=StationConstants::eTotal) const
Check if FADC trace (prior to local trigger simulation) exists.
A TimeStamp holds GPS second and nanosecond for some event.
sevt::StationTriggerData & GetTriggerData(const utl::TimeStamp &time)
Get simulated TriggerData.
Class representing a document branch.
class to hold data at Station level
bool IsT1Threshold() const
T1 threshold.
bool HasSimData() const
Check whether station simulated data exists.
void SetNErrorZeroStations(const unsigned int n)
Set number of error zero stations.
Interface class to access the Event Trigger (T3)
constexpr double nanosecond
decltype(std::begin(boost::adaptors::keys(TriggerGPSMap()))) typedef TriggerTimeIterator
bool HasTrigger() const
check whether the central trigger object exists
void SetSecond(const unsigned int sec)
Set end of traces raw time.
void MakeTrigger()
Create the central trigger object.
EyeIterator EyesBegin(const ComponentSelector::Status status)
utl::TimeStamp GetTime() const
Get the trigger time stamp.
a t3: algo, second, usecond and a vector of <t3stat>
PMTIterator PMTsEnd(const sdet::PMTConstants::PMTType type=sdet::PMTConstants::eWaterCherenkovLarge)
end PMT iterator for read/write
sevt::StationGPSData & GetGPSData()
Get GPS data for the station.
void SetOffset(const int os)
Set GPS offset compared to a reference.
StationIterator StationsBegin() const
Iterator over the list of T3Stations in T3.
class to format data in tabular form
fwk::VModule::ResultFlag BuildEvent(evt::Event &event)
void SetId(const unsigned int id)
Set Id of the trigger.
#define WARNING(message)
Macro for logging warning messages.
SEventSimData & GetSimData()
Get the object with simulated data, throw if n.a.
void GetData(bool &b) const
Overloads of the GetData member template function.
bool IsT2Threshold() const
T2 threshold.
Top of Fluorescence Detector event hierarchy.
bool HasGPSData() const
Check whether GPS data object edists.
TriggerTimeIterator TriggerTimesBegin() const
Beginning of simulated local trigger times list.
Station & GetStation(const int stationId)
retrieve station by id throw utl::NonExistentComponentException if n.a.
FADCTriggeredTraceIterator FADCTriggeredTracesEnd(const utl::TimeStamp &stamp, const sdet::PMTConstants::PMTGain gain)
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
bool IsMultiplicityOfPositiveSteps() const
bool IsTimeOverThreshold() const
T1 TOT is always promoted to T2 TOT.
A TimeInterval is used to represent time elapsed between two events.
utl::TimeStamp GetTime() const
Get time of the trigger.
ResultFlag
Flag returned by module methods to the RunController.
void SetNStations(const unsigned int num)
Set number of stations in the trigger.
unsigned long GetGPSSecond() const
GPS second.
double GetGPSNanoSecond() const
GPS nanosecond.
void SetSDPAngle(const double ang)
Set SDPAngle of the trigger.
bool IsRDThreshold() const
Station Trigger Data description
T3Iterator T3sEnd()
Iterator over the list of T3s.
Class to hold simulated data at PMT level.
void SetNext100(const int num)
void SetWindowMicroSecond(const int window)
void SetAlgorithm(const std::string &algo)
Set algorithm of the trigger.
TriggerTimeIterator TriggerTimesEnd() const
End of simulated local trigger times list.
FADCTriggeredTraceDIterator FADCTriggeredTracesDEnd(const utl::TimeStamp &stamp, const sdet::PMTConstants::PMTGain gain)
sevt::Header & GetHeader()
FADCTriggeredTraceDIterator FADCTriggeredTracesDBegin(const utl::TimeStamp &stamp, const sdet::PMTConstants::PMTGain gain)
sevt::StationSimData & GetSimData()
Get simulated data at station level.
boost::transform_iterator< InternalStationFunctor, ConstInternalStationIterator, const sevt::T3::T3Station & > StationIterator
StationIterator returns a pointer to a T3Station.
sevt::StationTriggerData & GetTriggerData()
Get Trigger data for the station.
string OfSortedIds(vector< int > ids)
void MakeGPSData()
Make GPS data object.
T3Iterator T3sBegin()
Iterator over the list of T3s.
constexpr double microsecond
void SetNextST(const int num)
void AddStation(const int id, const utl::TimeInterval &offset, const utl::TimeInterval &window)
Add a station to request data, specifying offset and window size.
void SetErrorCode(const int errorCode)
void SetPreviousST(const int num)
void MakeFADCTrace(StationConstants::SignalComponent source=StationConstants::eTotal)
Make FADC trace prior to local trigger simulation.
void SetSender(const std::string &sender)
Set sender of the trigger.
std::string GetAlgorithm() const
Get the trigger algorithm.
void SetTickFall(const unsigned int num)
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)