10#include <top/modules/TOPTimeRecalibrator/TOPTimeRecalibratorModule.h>
13#include <top/geometry/TOPGeometryPar.h>
16#include <framework/datastore/StoreArray.h>
17#include <framework/datastore/StoreObjPtr.h>
20#include <framework/logging/Logger.h>
47 setDescription(
"Utility module for re-calibrating time of TOPDigits. "
48 "Useful for checking new calibrations on existing cDST files. "
49 "Note that pulseWidth and timeError are not changed "
50 "although they also depend on time calibration.");
55 "if true, use sample time calibration",
true);
57 "if true, use ASIC shifts calibration",
true);
59 "if true, use channel T0 calibration",
true);
61 "if true, use module T0 calibration",
true);
63 "if true, use common T0 calibration",
true);
65 "if true, use time-walk calibration",
true);
67 "if true, subtract reconstructed bunch time",
true);
93 B2FATAL(
"Sample time calibration requested but not available for run "
94 << evtMetaData->getRun()
95 <<
" of experiment " << evtMetaData->getExperiment());
100 B2FATAL(
"Channel T0 calibration requested but not available for run "
101 << evtMetaData->getRun()
102 <<
" of experiment " << evtMetaData->getExperiment());
107 B2FATAL(
"ASIC shifts calibration requested but not available for run "
108 << evtMetaData->getRun()
109 <<
" of experiment " << evtMetaData->getExperiment());
114 B2FATAL(
"Module T0 calibration requested but not available for run "
115 << evtMetaData->getRun()
116 <<
" of experiment " << evtMetaData->getExperiment());
121 B2FATAL(
"Common T0 calibration requested but not available for run "
122 << evtMetaData->getRun()
123 <<
" of experiment " << evtMetaData->getExperiment());
129 B2WARNING(
"Time-walk calibration is not available for run "
130 << evtMetaData->getRun()
131 <<
" of experiment " << evtMetaData->getExperiment());
136 B2FATAL(
"Front-end settings are not available for run "
137 << evtMetaData->getRun()
138 <<
" of experiment " << evtMetaData->getExperiment());
146 double SSTfrac = (revo9cnt % 6) / 6.0;
155 bool offsetStatus = digit.hasStatus(TOPDigit::c_OffsetSubtracted);
158 unsigned short statusBits = 0;
159 digit.setStatus(statusBits);
162 double rawTimeLeading = digit.getRawTime();
163 auto window = digit.getFirstWindow();
164 auto moduleID = digit.getModuleID();
165 auto channel = digit.getChannel();
170 auto bs = channel / 128;
171 const auto* feemap = feMapper.getMap(moduleID, bs);
173 B2ERROR(
"No front-end map available."
174 <<
LogVar(
"slot", moduleID)
175 <<
LogVar(
"boardstack", bs));
178 auto scrodID = feemap->getScrodID();
179 sampleTimes =
m_timebase->getSampleTimes(scrodID, channel % 128);
180 if (sampleTimes->isCalibrated()) {
181 statusBits |= TOPDigit::c_TimeBaseCalibrated;
184 double time = sampleTimes->getTime(window, rawTimeLeading) - timeOffset;
189 time -=
m_timeWalk->getTimeWalk(digit.getPulseHeight());
194 if (cal->isCalibrated(moduleID, channel)) {
195 time -= cal->getT0(moduleID, channel);
196 statusBits |= TOPDigit::c_ChannelT0Calibrated;
200 auto asic = channel / 8;
207 if (cal->isCalibrated(moduleID)) {
208 time -= cal->getT0(moduleID);
209 statusBits |= TOPDigit::c_ModuleT0Calibrated;
214 if (cal->isCalibrated()) {
215 time -= cal->getT0();
216 statusBits |= TOPDigit::c_CommonT0Calibrated;
223 statusBits |= TOPDigit::c_EventT0Subtracted;
228 time -= geo->getNominalTDC().getOffset();
229 statusBits |= TOPDigit::c_OffsetSubtracted;
234 digit.setStatus(statusBits);
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...
Type-safe access to single objects in the data store.
bool m_subtractBunchTime
if true, subtract reconstructed bunch time
DBObjPtr< TOPCalTimebase > m_timebase
sample time calibration constants
StoreObjPtr< TOPRecBunch > m_recBunch
reconstructed bunch
DBObjPtr< TOPCalAsicShift > m_asicShift
ASIC shifts calibration constants.
DBObjPtr< TOPFrontEndSetting > m_feSetting
front-end settings
DBObjPtr< TOPCalCommonT0 > m_commonT0
common T0 calibration constants
bool m_useAsicShiftCalibration
if true, use asic shifts calibration
bool m_useSampleTimeCalibration
if true, use sample time calibration
DBObjPtr< TOPCalChannelT0 > m_channelT0
channel T0 calibration constants
bool m_useTimeWalkCalibration
if true, use time-walk calibration
double m_syncTimeBase
SSTin period.
OptionalDBObjPtr< TOPCalTimeWalk > m_timeWalk
time-walk calibration constants
bool m_useChannelT0Calibration
if true, use channel T0 calibration
bool m_useCommonT0Calibration
if true, use common T0 calibration
bool m_useModuleT0Calibration
if true, use module T0 calibration
StoreArray< TOPDigit > m_digits
collection of digits
DBObjPtr< TOPCalModuleT0 > m_moduleT0
module T0 calibration constants
TOPSampleTimes m_sampleTimes
equidistant in case no calibration required
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
const FrontEndMapper & getFrontEndMapper() const
Returns front-end mapper (mapping of SCROD's to positions within TOP modules)
Class to store variables with their name which were sent to the logging service.
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.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual void beginRun() override
Called when entering a new run.
TOPTimeRecalibratorModule()
Constructor.
void setTimeAxis(double syncTimeBase)
Sets equidistant time axis (uncalibrated).
Abstract base class for different kinds of events.