12 #include <top/modules/TOPDoublePulseGenerator/TOPCalPulseGeneratorModule.h>
13 #include <top/geometry/TOPGeometryPar.h>
16 #include <framework/datastore/StoreArray.h>
19 #include <framework/logging/Logger.h>
49 setDescription(
"Realistic generator of calibration double pulses. "
50 "Needs TOPDigitizer to digitize");
51 setPropertyFlags(c_ParallelProcessingCertified);
54 addParam(
"moduleIDs", m_moduleIDs,
55 "list of slots for which to generate cal pulse, empty list means all slots.",
57 m_asicChannels.push_back(0);
58 addParam(
"asicChannels", m_asicChannels,
59 "ASIC calibration channels (0 - 7), empty list means all channels.",
61 addParam(
"amplitude", m_amplitude,
62 "amplitude of cal pulse [ADC counts]", 700.0);
66 TOPCalPulseGeneratorModule::~TOPCalPulseGeneratorModule()
70 void TOPCalPulseGeneratorModule::initialize()
74 m_calPulses.registerInDataStore();
78 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
80 if (m_moduleIDs.empty()) {
81 for (
const auto& module : geo->getModules()) {
82 m_moduleIDs.push_back(module.getModuleID());
85 for (
auto moduleID : m_moduleIDs) {
86 if (!geo->isModuleIDValid(moduleID))
87 B2ERROR(
"Invalid module ID found in input list: " << moduleID);
91 if (m_asicChannels.empty()) {
92 for (
unsigned ch = 0; ch < 8; ch++) m_asicChannels.push_back(ch);
94 for (
unsigned ch : m_asicChannels) {
96 B2ERROR(
"Invalid ASIC channel found in input list: " << ch);
103 void TOPCalPulseGeneratorModule::beginRun()
108 void TOPCalPulseGeneratorModule::event()
111 const auto& chMapper = TOPGeometryPar::Instance()->getChannelMapper();
112 const auto& tdc = TOPGeometryPar::Instance()->getGeometry()->getNominalTDC();
113 double windowWidth = tdc.getSyncTimeBase() / 2;
115 for (
auto moduleID : m_moduleIDs) {
116 for (
unsigned asic = 0; asic < 64; asic++) {
119 auto pixelID = chMapper.getPixelID(channel);
120 double time = windowWidth + gRandom->Uniform(windowWidth);
121 m_calPulses.appendNew(moduleID, channel, pixelID, time, m_amplitude);
129 void TOPCalPulseGeneratorModule::endRun()
133 void TOPCalPulseGeneratorModule::terminate()