diff --git a/sbnobj/SBND/Timing/CMakeLists.txt b/sbnobj/SBND/Timing/CMakeLists.txt index bf0b0c475..243c00e44 100644 --- a/sbnobj/SBND/Timing/CMakeLists.txt +++ b/sbnobj/SBND/Timing/CMakeLists.txt @@ -1,6 +1,8 @@ cet_make_library( SOURCE DAQTimestamp.cxx + TimingInfo.cxx + FrameShiftInfo.cxx LIBRARIES cetlib_except::cetlib_except ) diff --git a/sbnobj/SBND/Timing/FrameShiftInfo.cxx b/sbnobj/SBND/Timing/FrameShiftInfo.cxx new file mode 100644 index 000000000..3c328c115 --- /dev/null +++ b/sbnobj/SBND/Timing/FrameShiftInfo.cxx @@ -0,0 +1,27 @@ +/** + * @file sbnobj/SBND/Timing/FrameShiftInfo.cxx + * @brief Defines data structures for SBND Frame Shift products (docdb#43090). + * @author Vu Chi Lan Nguyen + * @date August 29, 2025 + * + */ + +#ifndef SBND_FRAMESHIFTINFO_CXX +#define SBND_FRAMESHIFTINFO_CXX + +#include "sbnobj/SBND/Timing/FrameShiftInfo.hh" + +namespace sbnd::timing { + + FrameShiftInfo::FrameShiftInfo(uint16_t timingType, double frameTdcCrtt1, double frameTdcBes, double frameTdcRwm, double frameHltCrtt1, double frameHltBeamGate, double frameApplyAtCaf) + : fTimingType(timingType) + , fFrameTdcCrtt1(frameTdcCrtt1) + , fFrameTdcBes(frameTdcBes) + , fFrameTdcRwm(frameTdcRwm) + , fFrameHltCrtt1(frameHltCrtt1) + , fFrameHltBeamGate(frameHltBeamGate) + , fFrameApplyAtCaf(frameApplyAtCaf) + {} +} + +#endif diff --git a/sbnobj/SBND/Timing/FrameShiftInfo.hh b/sbnobj/SBND/Timing/FrameShiftInfo.hh new file mode 100644 index 000000000..a7730a3fc --- /dev/null +++ b/sbnobj/SBND/Timing/FrameShiftInfo.hh @@ -0,0 +1,86 @@ +/** + * @file sbnobj/SBND/Timing/FrameShiftInfo.hh + * @brief Defines data structures for SBND Frame Shift products (docdb#43090). + * @author Vu Chi Lan Nguyen + * @date August 29, 2025 + * + */ + +#ifndef SBND_FRAMESHIFTINFO_HH +#define SBND_FRAMESHIFTINFO_HH + +#include +#include + +namespace sbnd::timing { + + /** + * @brief A class to store the shifts across different time reference frames in SBND Data + * + * Each shift is in [ns] + * + * For more information, see + * [SBN DocDB 43090](https://sbn-docdb.fnal.gov/cgi-bin/sso/ShowDocument?docid=43090). + */ + + class FrameShiftInfo { + + public: + static constexpr uint16_t InvalidTimingType = 99; ///< Invalid timing type for decoded frame + static constexpr uint64_t NoShift = 0; ///< No shift. + + private: + + uint16_t fTimingType = InvalidTimingType; ///< Types of decoded frames: 0 - SPEC TDC ETRIG, 1 - HLT ETRIG, 2 - Do Nothing + double fFrameTdcCrtt1 = NoShift; ///< Shift from decoded frame to SPEC-TDC CRT T1 [ns] + double fFrameTdcBes = NoShift; ///< Shift from decoded frame to SPEC-TDC BES [ns] + double fFrameTdcRwm = NoShift; ///< Shift from decoded frame to SPEC-TDC RWM [ns] + double fFrameHltCrtt1 = NoShift; ///< Shift from decoded frame to HLT CRT T1 [ns] + double fFrameHltBeamGate = NoShift; ///< Shift from decoded frame to HLT Beam Gate [ns] + double fFrameApplyAtCaf = NoShift; ///< Frame to shift to when running at CAF stage + + public: + + /** + * Default constructor. + */ + FrameShiftInfo() = default; + + /** + * Constructor to set all frames + * + * @param timingType Types of decoded frames + * @param frameTdcCrtt1 Shift from decoded frame to SPEC-TDC CRT T1 [ns] + * @param frameTdcBes Shift from decoded frame to SPEC-TDC BES [ns] + * @param frameTdcRwm Shift from decoded frame to SPEC-TDC RWM [ns] + * @param frameHltCrtt1 Shift from decoded frame to HLT CRT T1 [ns] + * @param frameHltBeamGate Shift from decoded frame to HLT Beam Gate [ns] + * @param frameApplyAtCaf Frame to shift to when running at CAF stage + */ + FrameShiftInfo(uint16_t timingType, double frameTdcCrtt1, double frameTdcBes, double frameTdcRwm, double frameHltCrtt1, double frameHltBeamGate, double frameApplyAtCaf); + + /// @name Getters + /// @{ + uint16_t TimingType() const { return fTimingType; } + double FrameTdcCrtt1() const { return fFrameTdcCrtt1; } + double FrameTdcBes() const { return fFrameTdcBes; } + double FrameTdcRwm() const { return fFrameTdcRwm; } + double FrameHltCrtt1() const { return fFrameHltCrtt1;} + double FrameHltBeamGate() const { return fFrameHltBeamGate; } + double FrameApplyAtCaf() const { return fFrameApplyAtCaf; } + /// @} + + /// @name Setters + /// @{ + void SetTimingType(uint16_t type){ fTimingType = type; } + void SetFrameTdcCrtt1(double frame){ fFrameTdcCrtt1 = frame; } + void SetFrameTdcBes(double frame){ fFrameTdcBes = frame; } + void SetFrameTdcRwm(double frame){ fFrameTdcRwm = frame; } + void SetFrameHltCrtt1(double frame){ fFrameHltCrtt1 = frame; } + void SetFrameHltBeamGate(double frame){ fFrameHltBeamGate = frame; } + void SetFrameApplyAtCaf(double frame){ fFrameApplyAtCaf = frame; } + /// @} + }; +} + +#endif diff --git a/sbnobj/SBND/Timing/TimingInfo.cxx b/sbnobj/SBND/Timing/TimingInfo.cxx new file mode 100644 index 000000000..84ba5dd41 --- /dev/null +++ b/sbnobj/SBND/Timing/TimingInfo.cxx @@ -0,0 +1,28 @@ +/** + * @file sbnobj/SBND/Timing/TimingInfo.cxx + * @brief Defines data structures for SBND Timing Product (docdb#43090). + * @author Vu Chi Lan Nguyen + * @date August 29, 2025 + * + */ + +#ifndef SBND_TIMINGINFO_CXX +#define SBND_TIMINGINFO_CXX + +#include "sbnobj/SBND/Timing/TimingInfo.hh" + +namespace sbnd::timing { + + TimingInfo::TimingInfo(uint64_t rawDAQHeaderTimestamp, uint64_t tdcCrtt1, uint64_t tdcBes, uint64_t tdcRwm, uint64_t tdcEtrig, uint64_t hltCrtt1, uint64_t hltEtrig, uint64_t hltBeamGate) + : fRawDAQHeaderTimestamp(rawDAQHeaderTimestamp) + , fTdcCrtt1(tdcCrtt1) + , fTdcBes(tdcBes) + , fTdcRwm(tdcRwm) + , fTdcEtrig(tdcEtrig) + , fHltCrtt1(hltCrtt1) + , fHltEtrig(hltEtrig) + , fHltBeamGate(hltBeamGate) + {} +} + +#endif diff --git a/sbnobj/SBND/Timing/TimingInfo.hh b/sbnobj/SBND/Timing/TimingInfo.hh new file mode 100644 index 000000000..32b89e840 --- /dev/null +++ b/sbnobj/SBND/Timing/TimingInfo.hh @@ -0,0 +1,89 @@ +/** + * @file sbnobj/SBND/Timing/TimingInfo.hh + * @brief Defines data structures for SBND Timing products (docdb#43090). + * @author Vu Chi Lan Nguyen + * @date August 29, 2025 + * + */ + +#ifndef SBND_TIMINGINFO_HH +#define SBND_TIMINGINFO_HH + +#include + +namespace sbnd::timing { + + /** + * @brief A class to store important timestamps in SBND Data + * + * Each timestamp is in UNIX Timestamp Format [ns] + * + * For more information, see + * [SBN DocDB 43090](https://sbn-docdb.fnal.gov/cgi-bin/sso/ShowDocument?docid=43090). + */ + + class TimingInfo { + + public: + static constexpr uint64_t InvalidTimestamp = 0; ///< Invalid timestamp + + private: + + uint64_t fRawDAQHeaderTimestamp = InvalidTimestamp; ///< Timestamp when the event is built by the event builder at DAQ-level + uint64_t fTdcCrtt1 = InvalidTimestamp; ///< Timestamp of BNB stream CRT T1 Reset recorded by the SPEC-TDC + uint64_t fTdcBes = InvalidTimestamp; ///< Timestamp of BES signal sent by MFTU recorded by the SPEC-TDC + uint64_t fTdcRwm = InvalidTimestamp; ///< Timestamp of RWM signal recorded by the SPEC-TDC + uint64_t fTdcEtrig = InvalidTimestamp; ///< Timestamp of Event Trigger (ETRIG) sent by the PTB recorded by the SPEC-TDC + uint64_t fHltCrtt1 = InvalidTimestamp; ///< Timestamp of BNB and Offbeam stream CRT T1 Reset High Level Trigger (HLT) created by the PTB + uint64_t fHltEtrig = InvalidTimestamp; ///< Timestamp of ETRIG HLT created by the PTB + uint64_t fHltBeamGate = InvalidTimestamp; ///< Timestamp of Beam Gate Acceptance HLT created by the PTB + + public: + + /** + * Default constructor. + */ + TimingInfo() = default; + + /** + * Constructor to set all timestamps + * + * @param rawDAQHeaderTimestamp Raw DAQ Timestamp in UNIX format [ns] + * @param tdcCrtt1 CRT T1 Timestamp in UNIX format [ns] + * @param tdcBes BES Timestamp recorded by TDC in UNIX format [ns] + * @param tdcRwm RWM Timestamp recorded by TDC in UNIX format [ns] + * @param tdcEtrig ETRIG Timestamp recorded by TDC in UNIX format [ns] + * @param hltCrtt1 CRT T1 Timestamp created by PTB in UNIX format [ns] + * @param hltEtrig ETRIG Timestamp created by PTB in UNIX format [ns] + * @param hltBeamGate Beam Gate Timestamp created by PTB in UNIX format [ns] + */ + TimingInfo(uint64_t rawDAQHeaderTimestamp, uint64_t tdcCrtt1, uint64_t tdcBes, uint64_t tdcRwm, uint64_t tdcEtrig, uint64_t hltCrtt1, uint64_t hltEtrig, uint64_t hltBeamGate); + + /// @name Getters + /// @{ + uint64_t RawDAQHeaderTimestamp() const { return fRawDAQHeaderTimestamp; } + uint64_t TdcCrtt1() const { return fTdcCrtt1; } + uint64_t TdcBes() const { return fTdcBes; } + uint64_t TdcRwm() const { return fTdcRwm; } + uint64_t TdcEtrig() const { return fTdcEtrig; } + uint64_t HltCrtt1() const { return fHltCrtt1; } + uint64_t HltEtrig() const { return fHltEtrig; } + uint64_t HltBeamGate() const { return fHltBeamGate; } + /// @} + + /// @name Setters + /// @{ + void SetRawDAQHeaderTimestamp(uint64_t timestamp){ fRawDAQHeaderTimestamp = timestamp; } + void SetTdcCrtt1(uint64_t timestamp){ fTdcCrtt1 = timestamp; } + void SetTdcBes(uint64_t timestamp){ fTdcBes = timestamp; } + void SetTdcRwm(uint64_t timestamp){ fTdcRwm = timestamp; } + void SetTdcEtrig(uint64_t timestamp){ fTdcEtrig = timestamp; } + void SetHltCrtt1(uint64_t timestamp){ fHltCrtt1 = timestamp; } + void SetHltEtrig(uint64_t timestamp){ fHltEtrig = timestamp; } + void SetHltBeamGate(uint64_t timestamp){ fHltBeamGate = timestamp; } + /// @} + + }; +} + +#endif diff --git a/sbnobj/SBND/Timing/classes.h b/sbnobj/SBND/Timing/classes.h index ee7955a38..5e8436bdc 100644 --- a/sbnobj/SBND/Timing/classes.h +++ b/sbnobj/SBND/Timing/classes.h @@ -1,3 +1,5 @@ #include "canvas/Persistency/Common/Wrapper.h" #include "canvas/Persistency/Common/Assns.h" #include "sbnobj/SBND/Timing/DAQTimestamp.hh" +#include "sbnobj/SBND/Timing/TimingInfo.hh" +#include "sbnobj/SBND/Timing/FrameShiftInfo.hh" diff --git a/sbnobj/SBND/Timing/classes_def.xml b/sbnobj/SBND/Timing/classes_def.xml index 88cb51adf..717e1bfff 100644 --- a/sbnobj/SBND/Timing/classes_def.xml +++ b/sbnobj/SBND/Timing/classes_def.xml @@ -1,8 +1,18 @@ - + + + + + + + + + + +