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/EclConfiguration.h>
17 #include <ecl/dbobjects/ECLChannelMap.h>
33 setDescription(
"Compress recorded waveforms for beam backround overlay in simulation.");
34 setPropertyFlags(c_ParallelProcessingCertified);
35 addParam(
"CompressionAlgorithm", m_compAlgo,
"Waveform compression algorithm (0..127)", 0u);
36 addParam(
"WithTriggerTime", m_trgTime,
"Trigger time from each create", 1u);
37 addParam(
"eclWaveformsName", m_eclWaveformsName,
"Name of the collection with compressed waveforms", std::string(
""));
46 m_eclDsps.registerInDataStore();
47 m_eclWaveforms.registerInDataStore(m_eclWaveformsName);
48 m_comp = selectAlgo(m_compAlgo & 0x7f);
49 if (m_comp ==
nullptr)
50 B2FATAL(
"Unknown compression algorithm: " << m_compAlgo);
59 if (m_eclDsps.getEntries() != ec.
m_nch)
return;
62 unsigned short indx[ec.
m_nch], count = 0;
63 memset(indx, 0xff,
sizeof(indx));
64 for (
const auto& t : m_eclDsps) indx[t.getCellId() - 1] = count++;
67 for (
auto t : indx)
if (t >= ec.
m_nch)
return;
73 out.putNBits((m_compAlgo & 0x7f) | (m_trgTime << 7), 8);
75 if (!m_eclTrigs.isValid()) B2WARNING(
"Crate trigger times are asked to be saved but they are not provided.");
77 if (m_eclTrigs.getEntries() != ECL::ECL_CRATES)
return;
78 unsigned char ttime[ECL::ECL_CRATES];
79 for (
const auto& t : m_eclTrigs) {
80 int id = t.getTrigId(), time = t.getTimeTrig();
82 ttime[
id - 1] = (time - 2 * (time / 8)) / 2;
84 for (
int i = 0; i < ECL::ECL_CRATES; i++) out.putNBits(ttime[i], 7);
86 for (
int j = 0; j < ec.
m_nch; j++) {
87 m_eclDsps[indx[j]]->getDspA(FitA);
88 m_comp->compress(out, FitA);
93 m_eclWaveforms.assign(wf);
95 std::swap(out.getStore(), wf->
getStore());
101 if (m_comp)
delete m_comp;
The ECLCompressBGOverlay module compresses recorded waveforms triggered by the random trigger and to ...
~ECLCompressBGOverlayModule()
Destructor
void initialize() override
Initialize variables
void event() override
Compression happens here.
void terminate() override
Cleanup variables
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
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.