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);
72 digits.registerInDataStore();
73 digits.registerRelationTo(waveforms);
78 B2ERROR(
"samplingPhase must be positive and less than " <<
c_SamplingCycle);
94 B2ERROR(
"No waveforms available for digitization");
97 unsigned revo9count = waveforms[0]->getRevo9Counter();
101 int bunchTimeStamp = int((revo9count + gRandom->Rndm()) *
static_cast<double>(
c_SamplingCycle) / 3.0);
102 mcInfo->setBunchTimeStamp(bunchTimeStamp);
106 for (
const auto& waveform : waveforms) {
107 const auto& data = waveform.getWaveform();
109 bool lastState =
false;
112 for (
int i = 0; i < (int) data.size(); i++) {
114 if (data[i] > currentThr) {
125 digit = digits.appendNew(waveform.getModuleID(),
126 waveform.getChannel(),
127 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]
@ c_SamplingCycle
timestamp sampling period [samples]
@ c_Frame9Period
number of sampling cycles per frame9 marker
int m_gateWidth
width of discriminator gate [samples]
int m_samplingPhase
sampling phase [samples]
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.
TOPTriggerDigitizerModule()
Constructor.
Abstract base class for different kinds of events.