10#include <top/modules/TOPDigitizer/TOPTriggerDigitizerModule.h>
13#include <top/dataobjects/TOPRawWaveform.h>
14#include <top/dataobjects/TOPTriggerDigit.h>
15#include <top/dataobjects/TOPTriggerMCInfo.h>
18#include <framework/datastore/StoreArray.h>
19#include <framework/datastore/StoreObjPtr.h>
22#include <framework/logging/Logger.h>
50 setDescription(
"Digitizer that provides time stamps for TOP trigger");
55 "pulse height threshold [ADC counts]", 27);
57 "pulse height threshold hysteresis [ADC counts]", 10);
59 "width of discriminator gate [samples]", 8);
61 "sampling phase [samples]", 7);
76 digits.registerInDataStore();
77 digits.registerRelationTo(waveforms);
82 B2ERROR(
"samplingPhase must be positive and less than " <<
c_SamplingCycle);
102 B2ERROR(
"No waveforms available for digitization");
105 unsigned revo9count = waveforms[0]->getRevo9Counter();
109 int bunchTimeStamp = int((revo9count + gRandom->Rndm()) *
static_cast<double>(
c_SamplingCycle) / 3.0);
110 mcInfo->setBunchTimeStamp(bunchTimeStamp);
114 for (
const auto& waveform : waveforms) {
115 const auto& data = waveform.getWaveform();
117 bool lastState =
false;
120 for (
int i = 0; i < (int) data.size(); i++) {
122 if (data[i] > currentThr) {
133 digit = digits.appendNew(waveform.getModuleID(),
134 waveform.getChannel(),
135 waveform.getScrodID());
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
bool create(bool replace=false)
Create a default object in the data store.
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
Type-safe access to single objects in the data store.
Class to store trigger time stamps.
void appendTimeStamp(short timeStamp)
Append time stamp.
int m_hysteresis
pulse height threshold hysteresis [ADC counts]
int m_threshold
pulse height threshold [ADC counts]
int m_gateWidth
width of discriminator gate [samples]
int m_samplingPhase
sampling phase [samples]
@ c_SamplingCycle
timestamp sampling period [samples]
@ c_Frame9Period
number of sampling cycles per frame9 marker
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual void endRun() override
End-of-run action.
virtual void terminate() override
Termination action.
TOPTriggerDigitizerModule()
Constructor.
virtual ~TOPTriggerDigitizerModule()
Destructor.
virtual void beginRun() override
Called when entering a new run.
Abstract base class for different kinds of events.