Skip to content

Commit c78a372

Browse files
authored
Merge pull request #142 from SBNSoftware/lnguyen/frame_shift_pr_dev
Frame Shift Module to Correct Timing in Data - PR For Develop
2 parents 4df6011 + 05e6156 commit c78a372

7 files changed

Lines changed: 245 additions & 1 deletion

File tree

sbnobj/SBND/Timing/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
cet_make_library(
22
SOURCE
33
DAQTimestamp.cxx
4+
TimingInfo.cxx
5+
FrameShiftInfo.cxx
46
LIBRARIES
57
cetlib_except::cetlib_except
68
)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @file sbnobj/SBND/Timing/FrameShiftInfo.cxx
3+
* @brief Defines data structures for SBND Frame Shift products (docdb#43090).
4+
* @author Vu Chi Lan Nguyen
5+
* @date August 29, 2025
6+
*
7+
*/
8+
9+
#ifndef SBND_FRAMESHIFTINFO_CXX
10+
#define SBND_FRAMESHIFTINFO_CXX
11+
12+
#include "sbnobj/SBND/Timing/FrameShiftInfo.hh"
13+
14+
namespace sbnd::timing {
15+
16+
FrameShiftInfo::FrameShiftInfo(uint16_t timingType, double frameTdcCrtt1, double frameTdcBes, double frameTdcRwm, double frameHltCrtt1, double frameHltBeamGate, double frameApplyAtCaf)
17+
: fTimingType(timingType)
18+
, fFrameTdcCrtt1(frameTdcCrtt1)
19+
, fFrameTdcBes(frameTdcBes)
20+
, fFrameTdcRwm(frameTdcRwm)
21+
, fFrameHltCrtt1(frameHltCrtt1)
22+
, fFrameHltBeamGate(frameHltBeamGate)
23+
, fFrameApplyAtCaf(frameApplyAtCaf)
24+
{}
25+
}
26+
27+
#endif
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/**
2+
* @file sbnobj/SBND/Timing/FrameShiftInfo.hh
3+
* @brief Defines data structures for SBND Frame Shift products (docdb#43090).
4+
* @author Vu Chi Lan Nguyen
5+
* @date August 29, 2025
6+
*
7+
*/
8+
9+
#ifndef SBND_FRAMESHIFTINFO_HH
10+
#define SBND_FRAMESHIFTINFO_HH
11+
12+
#include <stdint.h>
13+
#include <limits>
14+
15+
namespace sbnd::timing {
16+
17+
/**
18+
* @brief A class to store the shifts across different time reference frames in SBND Data
19+
*
20+
* Each shift is in [ns]
21+
*
22+
* For more information, see
23+
* [SBN DocDB 43090](https://sbn-docdb.fnal.gov/cgi-bin/sso/ShowDocument?docid=43090).
24+
*/
25+
26+
class FrameShiftInfo {
27+
28+
public:
29+
static constexpr uint16_t InvalidTimingType = 99; ///< Invalid timing type for decoded frame
30+
static constexpr uint64_t NoShift = 0; ///< No shift.
31+
32+
private:
33+
34+
uint16_t fTimingType = InvalidTimingType; ///< Types of decoded frames: 0 - SPEC TDC ETRIG, 1 - HLT ETRIG, 2 - Do Nothing
35+
double fFrameTdcCrtt1 = NoShift; ///< Shift from decoded frame to SPEC-TDC CRT T1 [ns]
36+
double fFrameTdcBes = NoShift; ///< Shift from decoded frame to SPEC-TDC BES [ns]
37+
double fFrameTdcRwm = NoShift; ///< Shift from decoded frame to SPEC-TDC RWM [ns]
38+
double fFrameHltCrtt1 = NoShift; ///< Shift from decoded frame to HLT CRT T1 [ns]
39+
double fFrameHltBeamGate = NoShift; ///< Shift from decoded frame to HLT Beam Gate [ns]
40+
double fFrameApplyAtCaf = NoShift; ///< Frame to shift to when running at CAF stage
41+
42+
public:
43+
44+
/**
45+
* Default constructor.
46+
*/
47+
FrameShiftInfo() = default;
48+
49+
/**
50+
* Constructor to set all frames
51+
*
52+
* @param timingType Types of decoded frames
53+
* @param frameTdcCrtt1 Shift from decoded frame to SPEC-TDC CRT T1 [ns]
54+
* @param frameTdcBes Shift from decoded frame to SPEC-TDC BES [ns]
55+
* @param frameTdcRwm Shift from decoded frame to SPEC-TDC RWM [ns]
56+
* @param frameHltCrtt1 Shift from decoded frame to HLT CRT T1 [ns]
57+
* @param frameHltBeamGate Shift from decoded frame to HLT Beam Gate [ns]
58+
* @param frameApplyAtCaf Frame to shift to when running at CAF stage
59+
*/
60+
FrameShiftInfo(uint16_t timingType, double frameTdcCrtt1, double frameTdcBes, double frameTdcRwm, double frameHltCrtt1, double frameHltBeamGate, double frameApplyAtCaf);
61+
62+
/// @name Getters
63+
/// @{
64+
uint16_t TimingType() const { return fTimingType; }
65+
double FrameTdcCrtt1() const { return fFrameTdcCrtt1; }
66+
double FrameTdcBes() const { return fFrameTdcBes; }
67+
double FrameTdcRwm() const { return fFrameTdcRwm; }
68+
double FrameHltCrtt1() const { return fFrameHltCrtt1;}
69+
double FrameHltBeamGate() const { return fFrameHltBeamGate; }
70+
double FrameApplyAtCaf() const { return fFrameApplyAtCaf; }
71+
/// @}
72+
73+
/// @name Setters
74+
/// @{
75+
void SetTimingType(uint16_t type){ fTimingType = type; }
76+
void SetFrameTdcCrtt1(double frame){ fFrameTdcCrtt1 = frame; }
77+
void SetFrameTdcBes(double frame){ fFrameTdcBes = frame; }
78+
void SetFrameTdcRwm(double frame){ fFrameTdcRwm = frame; }
79+
void SetFrameHltCrtt1(double frame){ fFrameHltCrtt1 = frame; }
80+
void SetFrameHltBeamGate(double frame){ fFrameHltBeamGate = frame; }
81+
void SetFrameApplyAtCaf(double frame){ fFrameApplyAtCaf = frame; }
82+
/// @}
83+
};
84+
}
85+
86+
#endif

sbnobj/SBND/Timing/TimingInfo.cxx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @file sbnobj/SBND/Timing/TimingInfo.cxx
3+
* @brief Defines data structures for SBND Timing Product (docdb#43090).
4+
* @author Vu Chi Lan Nguyen
5+
* @date August 29, 2025
6+
*
7+
*/
8+
9+
#ifndef SBND_TIMINGINFO_CXX
10+
#define SBND_TIMINGINFO_CXX
11+
12+
#include "sbnobj/SBND/Timing/TimingInfo.hh"
13+
14+
namespace sbnd::timing {
15+
16+
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)
17+
: fRawDAQHeaderTimestamp(rawDAQHeaderTimestamp)
18+
, fTdcCrtt1(tdcCrtt1)
19+
, fTdcBes(tdcBes)
20+
, fTdcRwm(tdcRwm)
21+
, fTdcEtrig(tdcEtrig)
22+
, fHltCrtt1(hltCrtt1)
23+
, fHltEtrig(hltEtrig)
24+
, fHltBeamGate(hltBeamGate)
25+
{}
26+
}
27+
28+
#endif

sbnobj/SBND/Timing/TimingInfo.hh

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
* @file sbnobj/SBND/Timing/TimingInfo.hh
3+
* @brief Defines data structures for SBND Timing products (docdb#43090).
4+
* @author Vu Chi Lan Nguyen
5+
* @date August 29, 2025
6+
*
7+
*/
8+
9+
#ifndef SBND_TIMINGINFO_HH
10+
#define SBND_TIMINGINFO_HH
11+
12+
#include <stdint.h>
13+
14+
namespace sbnd::timing {
15+
16+
/**
17+
* @brief A class to store important timestamps in SBND Data
18+
*
19+
* Each timestamp is in UNIX Timestamp Format [ns]
20+
*
21+
* For more information, see
22+
* [SBN DocDB 43090](https://sbn-docdb.fnal.gov/cgi-bin/sso/ShowDocument?docid=43090).
23+
*/
24+
25+
class TimingInfo {
26+
27+
public:
28+
static constexpr uint64_t InvalidTimestamp = 0; ///< Invalid timestamp
29+
30+
private:
31+
32+
uint64_t fRawDAQHeaderTimestamp = InvalidTimestamp; ///< Timestamp when the event is built by the event builder at DAQ-level
33+
uint64_t fTdcCrtt1 = InvalidTimestamp; ///< Timestamp of BNB stream CRT T1 Reset recorded by the SPEC-TDC
34+
uint64_t fTdcBes = InvalidTimestamp; ///< Timestamp of BES signal sent by MFTU recorded by the SPEC-TDC
35+
uint64_t fTdcRwm = InvalidTimestamp; ///< Timestamp of RWM signal recorded by the SPEC-TDC
36+
uint64_t fTdcEtrig = InvalidTimestamp; ///< Timestamp of Event Trigger (ETRIG) sent by the PTB recorded by the SPEC-TDC
37+
uint64_t fHltCrtt1 = InvalidTimestamp; ///< Timestamp of BNB and Offbeam stream CRT T1 Reset High Level Trigger (HLT) created by the PTB
38+
uint64_t fHltEtrig = InvalidTimestamp; ///< Timestamp of ETRIG HLT created by the PTB
39+
uint64_t fHltBeamGate = InvalidTimestamp; ///< Timestamp of Beam Gate Acceptance HLT created by the PTB
40+
41+
public:
42+
43+
/**
44+
* Default constructor.
45+
*/
46+
TimingInfo() = default;
47+
48+
/**
49+
* Constructor to set all timestamps
50+
*
51+
* @param rawDAQHeaderTimestamp Raw DAQ Timestamp in UNIX format [ns]
52+
* @param tdcCrtt1 CRT T1 Timestamp in UNIX format [ns]
53+
* @param tdcBes BES Timestamp recorded by TDC in UNIX format [ns]
54+
* @param tdcRwm RWM Timestamp recorded by TDC in UNIX format [ns]
55+
* @param tdcEtrig ETRIG Timestamp recorded by TDC in UNIX format [ns]
56+
* @param hltCrtt1 CRT T1 Timestamp created by PTB in UNIX format [ns]
57+
* @param hltEtrig ETRIG Timestamp created by PTB in UNIX format [ns]
58+
* @param hltBeamGate Beam Gate Timestamp created by PTB in UNIX format [ns]
59+
*/
60+
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);
61+
62+
/// @name Getters
63+
/// @{
64+
uint64_t RawDAQHeaderTimestamp() const { return fRawDAQHeaderTimestamp; }
65+
uint64_t TdcCrtt1() const { return fTdcCrtt1; }
66+
uint64_t TdcBes() const { return fTdcBes; }
67+
uint64_t TdcRwm() const { return fTdcRwm; }
68+
uint64_t TdcEtrig() const { return fTdcEtrig; }
69+
uint64_t HltCrtt1() const { return fHltCrtt1; }
70+
uint64_t HltEtrig() const { return fHltEtrig; }
71+
uint64_t HltBeamGate() const { return fHltBeamGate; }
72+
/// @}
73+
74+
/// @name Setters
75+
/// @{
76+
void SetRawDAQHeaderTimestamp(uint64_t timestamp){ fRawDAQHeaderTimestamp = timestamp; }
77+
void SetTdcCrtt1(uint64_t timestamp){ fTdcCrtt1 = timestamp; }
78+
void SetTdcBes(uint64_t timestamp){ fTdcBes = timestamp; }
79+
void SetTdcRwm(uint64_t timestamp){ fTdcRwm = timestamp; }
80+
void SetTdcEtrig(uint64_t timestamp){ fTdcEtrig = timestamp; }
81+
void SetHltCrtt1(uint64_t timestamp){ fHltCrtt1 = timestamp; }
82+
void SetHltEtrig(uint64_t timestamp){ fHltEtrig = timestamp; }
83+
void SetHltBeamGate(uint64_t timestamp){ fHltBeamGate = timestamp; }
84+
/// @}
85+
86+
};
87+
}
88+
89+
#endif

sbnobj/SBND/Timing/classes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#include "canvas/Persistency/Common/Wrapper.h"
22
#include "canvas/Persistency/Common/Assns.h"
33
#include "sbnobj/SBND/Timing/DAQTimestamp.hh"
4+
#include "sbnobj/SBND/Timing/TimingInfo.hh"
5+
#include "sbnobj/SBND/Timing/FrameShiftInfo.hh"

sbnobj/SBND/Timing/classes_def.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
<lcgdict>
22
<class name="sbnd::timing::DAQTimestamp" ClassVersion="11">
33
<version ClassVersion="11" checksum="2804806845"/>
4-
<version ClassVersion="10" checksum="810700615"/>
4+
<version ClassVersion="10" checksum="810700615"/>
55
</class>
66
<class name="std::vector<sbnd::timing::DAQTimestamp>"/>
77
<class name="art::Wrapper< std::vector<sbnd::timing::DAQTimestamp> >"/>
8+
9+
<class name="sbnd::timing::TimingInfo" ClassVersion="10" >
10+
<version ClassVersion="10" checksum="1023077770"/>
11+
</class>
12+
<class name="art::Wrapper<sbnd::timing::TimingInfo>"/>
13+
14+
<class name="sbnd::timing::FrameShiftInfo" ClassVersion="10" >
15+
<version ClassVersion="10" checksum="515138667"/>
16+
</class>
17+
<class name="art::Wrapper<sbnd::timing::FrameShiftInfo>"/>
818
</lcgdict>

0 commit comments

Comments
 (0)