10#include <ecl/modules/eclCompressBGOverlay/ECLCompressBGOverlayModule.h>
13#include <ecl/dataobjects/ECLDsp.h>
14#include <ecl/dataobjects/ECLTrig.h>
15#include <ecl/dataobjects/ECLWaveforms.h>
16#include <ecl/digitization/BitStream.h>
17#include <ecl/digitization/EclConfiguration.h>
18#include <ecl/dbobjects/ECLChannelMap.h>
34 setDescription(
"Compress recorded waveforms for beam background overlay in simulation.");
36 addParam(
"CompressionAlgorithm",
m_compAlgo,
"Waveform compression algorithm (0..127)", 0u);
51 B2FATAL(
"Unknown compression algorithm: " <<
m_compAlgo);
63 unsigned short indx[ec.
m_nch], count = 0;
64 memset(indx, 0xff,
sizeof(indx));
65 for (
const auto& t :
m_eclDsps) indx[t.getCellId() - 1] = count++;
68 for (
auto t : indx)
if (t >= ec.
m_nch)
return;
76 if (!
m_eclTrigs.isValid()) B2WARNING(
"Crate trigger times are asked to be saved but they are not provided.");
78 if (
m_eclTrigs.getEntries() != ECL::ECL_CRATES)
return;
79 unsigned char ttime[ECL::ECL_CRATES];
81 int id = t.getTrigId(), time = t.getTimeTrig();
83 ttime[
id - 1] = (time - 2 * (time / 8)) / 2;
85 for (
int i = 0; i < ECL::ECL_CRATES; i++) out.putNBits(ttime[i], 7);
87 for (
int j = 0; j < ec.
m_nch; j++) {
96 std::swap(out.getStore(), wf->
getStore());
StoreArray< ECLDsp > m_eclDsps
recorded waveforms
~ECLCompressBGOverlayModule()
Destructor
StoreObjPtr< ECLWaveforms > m_eclWaveforms
compressed waveforms
void initialize() override
Initialize variables
void event() override
Compression happens here.
StoreArray< ECLTrig > m_eclTrigs
recorded trigger time and tags
void terminate() override
Cleanup variables
unsigned int m_compAlgo
Module parameters.
unsigned int m_trgTime
store or not trigger time from each crate
ECL::ECLCompress * m_comp
pointer to a compression object which do all work
ECLCompressBGOverlayModule()
Constructor.
std::string m_eclWaveformsName
name of background waveforms storage
virtual void compress(BitStream &out, const int *adc)=0
Compress the ECL waveform.
Singleton class to hold the ECL configuration.
static EclConfiguration & get()
return this instance
static constexpr int m_nch
total number of electronic channels (crystals) in calorimeter
static constexpr int m_nsmp
number of ADC measurements for signal fitting
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
void setReturnValue(int value)
Sets the return value for this module as integer.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
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.
Abstract base class for different kinds of events.