1 #include <fwk/CentralConfig.h>
2 #include <det/Detector.h>
3 #include <sdet/SDetector.h>
4 #include <sdet/Station.h>
7 #include <sevt/PMTCalibData.h>
8 #include <sevt/SEvent.h>
9 #include <sevt/Header.h>
10 #include <sevt/Station.h>
11 #include <sevt/StationTriggerData.h>
12 #include <utl/AugerUnits.h>
13 #include <utl/ErrorLogger.h>
14 #include <utl/TimeDistribution.h>
15 #include <utl/MultiTrace.h>
16 #include <utl/PhysicalConstants.h>
17 #include <utl/Reader.h>
18 #include <utl/TimeStamp.h>
19 #include <utl/RandomEngine.h>
20 #include <utl/TabularStream.h>
21 #include <sdet/StationTriggerAlgorithm.h>
22 #include <sdet/StationTriggerUtil.h>
36 namespace TankTriggerSimulatorOG {
38 #define PARAMETER_SET(_p_, _b_) f##_p_ = _b_.GetChild(#_p_).Get<decltype(f##_p_)>()
41 TankTriggerSimulator::T1ThresholdParameters::Set(
const Branch&
b)
49 TankTriggerSimulator::T2ThresholdParameters::Set(
const Branch&
b)
57 TankTriggerSimulator::TOTParameters::Set(
const Branch&
b)
67 TankTriggerSimulator::IntegralParameters::Set(
const Branch&
b)
78 TankTriggerSimulator::TOTdParameters::Set(
const Branch&
b)
90 TankTriggerSimulator::MOPSParameters::Set(
const Branch&
b)
110 WARNING(
"Top branch <TankTriggerSimulatorOG> not found, trying <TankTriggerSimulator> instead.");
114 fT1Threshold.Set(topB.
GetChild(
"T1Threshold"));
116 fT2Threshold.Set(topB.
GetChild(
"T2Threshold"));
120 fIntegral.Set(topB.
GetChild(
"Integral"));
134 ERROR(
"Nonexisting SEvent.");
138 auto& sEvent =
event.GetSEvent();
140 const auto& eventTime =
event.GetHeader().GetTime();
142 vector<const TimeDistributionI*> traces;
146 <<
"(start, stop)" <<
endc
151 for (
auto& station : sEvent.StationsRange()) {
153 using namespace sdet::Trigger;
158 if (traces.size() < 3)
161 const auto& dStation = Detector::GetInstance().GetSDetector().GetStation(station);
165 const int nThresholds = GetCalibInfo(station, calib);
171 const ThresholdUp t1th(calib.fT1Threshold, fT1Threshold.fMultiplicity, n);
172 const ThresholdUp t2th(calib.fT2Threshold, fT2Threshold.fMultiplicity, n);
173 const TimeOverThreshold tot(calib.fTOTThreshold, fTOT.fOccupancy, fTOT.fWindow, fTOT.fMultiplicity, n);
175 const int adcFactor = station.IsUUB() ? 4 : 1;
176 const int integralThreshold = adcFactor * fIntegral.fThreshold;
177 const DecayingIntegral integ(fIntegral.fWindow, fIntegral.fDecrement, integralThreshold,
178 calib.fBaseline, fIntegral.fBaselineTolerance, fIntegral.fBaselineStep, n);
180 fTOTd.fDecayFD, fTOTd.fDecayFN,
181 fTOTd.fOccupancy, fTOTd.fWindow,
182 fTOTd.fMultiplicity, n);
183 const int mopsMinUp = adcFactor * fMOPS.fMinUp;
184 const int mopsMaxUp = adcFactor * fMOPS.fMaxUp;
187 const int vetoOffset = station.IsUUB() ? fMOPS.fVetoOffset+3 : fMOPS.fVetoOffset;
189 mopsMinUp, mopsMaxUp, vetoOffset,
190 fMOPS.fMultiplicity, n);
193 dStation.GetLatchBin(), dStation.GetFADCTraceLength());
195 const auto info = stationTrigger.
Run(startBin, stopBin, traces);
200 for (
const auto& i : info) {
201 tab << station.GetId() <<
endc
202 <<
"(" << startBin <<
", " << stopBin <<
")" <<
endc
203 <<
"(" << i.GetStart() <<
", " << i.GetStop() <<
")" <<
endc
204 << i.GetLatch() <<
endc;
205 if (i.IsT1Threshold())
207 if (i.IsTimeOverThreshold())
209 if (i.IsTimeOverThresholdDeconvoluted())
211 if (i.IsMultiplicityOfPositiveSteps())
213 if (i.IsT2Threshold())
217 Buffer(station, eventTime, i.GetTrigger(), i.GetPLDBits(), i.GetStart(), i.GetStop());
233 const bool isUUB = station.
IsUUB();
237 for (
const auto& pmt : station.PMTsRange()) {
239 const auto& calib = pmt.GetCalibData();
240 const auto base = calib.GetBaseline();
242 const auto& sim = pmt.GetSimData();
243 const double vem = sim.GetTriggerVEMPeak(isUUB);
247 calibInfo.
fT1Threshold[pmtId] = round(base + vem * fT1Threshold.fLevelVEM);
248 calibInfo.
fT2Threshold[pmtId] = round(base + vem * fT2Threshold.fLevelVEM);
249 calibInfo.
fTOTThreshold[pmtId] = round(base + vem * fTOT.fLevelVEM);
250 calibInfo.
fTOTdThreshold[pmtId] = round(base + vem * fTOTd.fLevelVEM);
Branch GetTopBranch() const
void PrepareTraces(const sevt::Station &station, int &startBin, int &stopBin, std::vector< const TimeDistributionI * > &traces)
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Class representing a document branch.
class to hold data at Station level
#define DEBUGLOG(message)
Macro for logging debugging messages.
class to format data in tabular form
Local station hardware (PLD) and software (T2) trigger algorithm.
#define WARNING(message)
Macro for logging warning messages.
ResultFlag
Flag returned by module methods to the RunController.
static unsigned int GetFirstPMTId()
Id of first pmt in station.
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
std::vector< StationTriggerInfo > Run(const int start, const int stop, const std::vector< const Trace< T > * > &traces)
void Buffer(sevt::Station &station, const TimeStamp &eventTime, const StationTriggerData::Algorithm algorithm, const int pldBits, const int start, const int stop)
#define ERROR(message)
Macro for logging error messages.
#define PARAMETER_SET(_p_, _b_)