9#include <trg/top/modules/trgtopTRD2TTSConverter/trgtopTRD2TTSConverterModule.h>
30 return std::string(
"1.00");
43 std::string desc =
"TRGTOPTRD2TTSConverterModule(" +
version() +
")" +
"converts TOPRawDigits to TOP TRG timestamps";
47 B2DEBUG(20,
"TRGTOPTRD2TTSConverter: Constructor done.");
53 "name of TOPRawDigit store array", std::string(
""));
56 "name of TOPDigit store array", std::string(
""));
60 "name of TRGTOPTimeStampsSlot store array", std::string(
""));
63 "name of TRGTOPTimeStamp store array", std::string(
""));
70 addParam(
"minNumberOfTimeStamps", m_minNumberOfTimeStamps,
"minimum number of timestamps in a slot (when required, default:5)",
71 MIN_NUMBER_OF_TIMESTAMPS);
75TRGTOPTRD2TTSConverterModule::~TRGTOPTRD2TTSConverterModule()
87 m_TRGTOPTimeStampsSlots.registerRelationTo(m_TRGTOPTimeStamps);
88 m_TRGTOPTimeStamps.registerRelationTo(m_TRGTOPTimeStampsSlots);
106 for (
int slot = 0; slot < NUMBER_OF_TOP_SLOTS; slot++) m_interimTimeStamps[slot].clear();
113 int slot = convertedDigit.getModuleID() - 1;
115 auto relRawDigits = convertedDigit.getRelationsTo<
TOPRawDigit>();
117 if (relRawDigits.size()) {
122 int deltaRevo9 = revo9Counter - latencyL1;
125 int revo9CounterEvent = deltaRevo9 >= 0 ? deltaRevo9 : revo9CounterMax + deltaRevo9 ;
129 for (
int i = 1; i < 9; i++) {
130 if (revo9CounterEvent < timeOfWindows[i])
break;
134 auto window = relRawDigits[0]->getASICWindow();
135 auto sample = relRawDigits[0]->getSampleRise();
137 if (phase >= 0 && phase <= 8) {
142 double timeStamp_ns_d = ((numberOfWindows[phase] + window) * 64 + sample) * 0.375 + 0.5 + timeCorrection;
143 int timeStamp_ns = timeStamp_ns_d;
146 thisTimeStamp.slot = slot + 1;
148 thisTimeStamp.value = timeStamp_ns / 2;
149 thisTimeStamp.refDigit = &convertedDigit;
151 m_interimTimeStamps[slot].push_back(thisTimeStamp);
157 for (
int slot = 0; slot < NUMBER_OF_TOP_SLOTS; slot++) {
159 int numberOfTimeStamps = m_interimTimeStamps[slot].size();
162 && numberOfTimeStamps)) {
166 auto* timeStampsSlotStore = m_TRGTOPTimeStampsSlots.appendNew(slot + 1, numberOfTimeStamps);
177 sort(m_interimTimeStamps[slot].begin(), m_interimTimeStamps[slot].end(),
timeOrder());
179 for (std::vector<interimTimeStamp>::const_iterator it = m_interimTimeStamps[slot].begin(); it != m_interimTimeStamps[slot].end();
184 int value = thisInterimTimeStamp.value;
188 auto* timeStampStore = m_TRGTOPTimeStamps.appendNew(timeStamp);
190 timeStampsSlotStore->addRelationTo(timeStampStore);
191 timeStampStore->addRelationTo(timeStampsSlotStore);
194 timeStampStore->addRelationTo(thisInterimTimeStamp.refDigit);
195 thisInterimTimeStamp.refDigit->
addRelationTo(timeStampStore);
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...
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
Class to store unpacked raw data (hits in feature-extraction format) It provides also calculation of ...
unsigned short getRevo9Counter() const
Returns 127 MHz clock ticks since last revo9 marker.
StoreArray< TOPRawDigit > m_rawDigits
collection of raw digits
std::string m_outputTimeStampsSlotName
name of TOPTRGTimeStampsSlot store array
bool m_requireMinNumberOfTimeStamps
switch ON/OFF min number of timestamps requirement for individual slots
virtual void initialize() override
Initialize the Module.
std::string m_outputTimeStampName
name of TOPTRGTimeStamp store array
virtual void event() override
This method is the core of the module.
virtual void endRun() override
This method is called if the current run ends.
virtual void terminate() override
This method is called at the end of the event processing.
TRGTOPTRD2TTSConverterModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::string m_inputRawDigitsName
name of TOPRawDigit store array
virtual void beginRun() override
Called when entering a new run.
StoreArray< TOPDigit > m_convertedDigits
collection of raw digits
bool m_addRelations
switch ON/OFF relations to TOPRawDigits
std::string m_inputConvertedDigitsName
name of TOPRawDigit store array
std::string version() const
returns version of TRGTOPTRD2TTSConverterModule.
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.
Event number (according to L1/global)