10#include <top/modules/TOPWaveformFeatureExtractor/TOPWaveformFeatureExtractorModule.h>
13#include <framework/datastore/StoreArray.h>
16#include <framework/logging/Logger.h>
19#include <top/dataobjects/TOPRawDigit.h>
20#include <top/dataobjects/TOPRawWaveform.h>
22#include <top/geometry/TOPGeometryPar.h>
48 setDescription(
"Module adds raw digits that are found in waveforms "
49 "but not already present in TOPRawDigits. "
50 "Only waveforms related to TOPRawDigits are used.");
54 "name of TOPRawDigit store array",
string(
""));
56 "pulse height threshold [ADC counts]", 40);
58 "threshold hysteresis [ADC counts]", 10);
60 "minimal number of samples above threshold", 3);
62 "calculate and set integral for online-extracted hits",
true);
92 for (
int i = 0; i < initSize; i++) {
93 auto& rawDigit = *rawDigits[i];
95 if (!waveform)
continue;
97 auto integral = waveform->
getIntegral(rawDigit.getSampleRise(),
98 rawDigit.getSamplePeak(),
99 rawDigit.getSampleFall());
100 rawDigit.setIntegral(integral);
103 const auto& features = waveform->getFeatureExtractionData();
104 int sampleRise = rawDigit.getSampleRise();
105 int sampleFall = rawDigit.getSampleFall() + 1;
106 for (
const auto& feature : features) {
109 int sRise = feature.sampleRise;
110 if (sRise >= sampleRise and sRise <= sampleFall)
continue;
111 int sFall = feature.sampleFall + 1;
112 if (sFall >= sampleRise and sFall <= sampleFall)
continue;
115 auto* newDigit = rawDigits.
appendNew(rawDigit);
116 newDigit->setOfflineFlag();
117 newDigit->setSampleRise(feature.sampleRise);
118 newDigit->setDeltaSamplePeak(feature.samplePeak - feature.sampleRise);
119 newDigit->setDeltaSampleFall(feature.sampleFall - feature.sampleRise);
120 newDigit->setValueRise0(feature.vRise0);
121 newDigit->setValueRise1(feature.vRise1);
122 newDigit->setValueFall0(feature.vFall0);
123 newDigit->setValueFall1(feature.vFall1);
124 newDigit->setValuePeak(feature.vPeak);
125 newDigit->setIntegral(feature.integral);
126 double rawTime = newDigit->getCFDLeadingTime();
127 unsigned tfine = int(rawTime * sampleDivisions) % sampleDivisions;
128 newDigit->setTFine(tfine);
129 newDigit->addRelationTo(waveform);
134 B2DEBUG(20,
"TOPWaveformFeatureExtractor: appended " << finalSize - initSize
135 <<
" raw digits to initial " << initSize);
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...
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
int getEntries() const
Get the number of objects in the array.
const TOPNominalTDC & getNominalTDC() const
Returns nominal time-to-digit conversion parameters.
unsigned getSubBits() const
Returns number of bits per sample.
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
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.
int getIntegral(int sampleRise, int samplePeak, int sampleFall) const
Returns integral of a peak.
TOPWaveformFeatureExtractorModule()
Constructor.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual ~TOPWaveformFeatureExtractorModule()
Destructor.
virtual void endRun() override
End-of-run action.
virtual void terminate() override
Termination action.
virtual void beginRun() override
Called when entering a new run.
Abstract base class for different kinds of events.