Belle II Software development
TOPCalPulseGeneratorModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9// Own header.
10#include <top/modules/TOPDoublePulseGenerator/TOPCalPulseGeneratorModule.h>
11
12// TOP headers.
13#include <top/geometry/TOPGeometryPar.h>
14
15// framework - DataStore
16#include <framework/datastore/StoreArray.h>
17
18// framework aux
19#include <framework/logging/Logger.h>
20
21// root
22#include <TRandom.h>
23
24
25using namespace std;
26
27namespace Belle2 {
33 using namespace TOP;
34
35 //-----------------------------------------------------------------
37 //-----------------------------------------------------------------
38
39 REG_MODULE(TOPCalPulseGenerator);
40
41 //-----------------------------------------------------------------
42 // Implementation
43 //-----------------------------------------------------------------
44
46
47 {
48 // set module description
49 setDescription("Realistic generator of calibration double pulses. "
50 "Needs TOPDigitizer to digitize");
52
53 // Add parameters
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 // default for these three below are set according to laser run 8/414
62 addParam("amplitude", m_amplitude, "amplitude of cal pulse [ADC counts]", 600.0);
63 addParam("delay", m_delay, "delay of cal pulse [ns]", 10.5);
64 addParam("windowSize", m_windowSize, "size of time window in which to generate cal pulses [ns]", 8.0);
65 }
66
67
69 {
70 // Output
71
72 m_calPulses.registerInDataStore();
73
74 // prepare vectors to loop on
75
76 const auto* geo = TOPGeometryPar::Instance()->getGeometry();
77
78 if (m_moduleIDs.empty()) {
79 for (const auto& module : geo->getModules()) {
80 m_moduleIDs.push_back(module.getModuleID());
81 }
82 } else {
83 for (auto moduleID : m_moduleIDs) {
84 if (!geo->isModuleIDValid(moduleID))
85 B2ERROR("Invalid module ID found in input list: " << moduleID);
86 }
87 }
88
89 if (m_asicChannels.empty()) {
90 for (unsigned ch = 0; ch < 8; ch++) m_asicChannels.push_back(ch);
91 } else {
92 for (unsigned ch : m_asicChannels) {
93 if (ch > 7)
94 B2ERROR("Invalid ASIC channel found in input list: " << ch);
95 }
96 }
97
98 }
99
100
102 {
103 const auto& chMapper = TOPGeometryPar::Instance()->getChannelMapper();
104
105 double time = m_delay + gRandom->Uniform(m_windowSize);
106 for (auto moduleID : m_moduleIDs) {
107 for (unsigned asic = 0; asic < 64; asic++) {
108 for (auto asicChannel : m_asicChannels) {
109 unsigned channel = asic * 8 + asicChannel;
110 auto pixelID = chMapper.getPixelID(channel);
111 m_calPulses.appendNew(moduleID, channel, pixelID, time, m_amplitude);
112 }
113 }
114 }
115
116 }
117
119} // end Belle2 namespace
120
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
std::vector< unsigned > m_asicChannels
ASIC calibration channels.
StoreArray< TOPSimCalPulse > m_calPulses
collection of simulated cal pulses
double m_windowSize
window size in which to generate cal pulses [ns]
double m_amplitude
cal pulse amplitude [ADC counts]
std::vector< int > m_moduleIDs
slot ID's to generate for
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
const ChannelMapper & getChannelMapper() const
Returns default channel mapper (mapping of channels to pixels)
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
Abstract base class for different kinds of events.
STL namespace.
record to be used to store ASIC info