Belle II Software development
KLMTime Class Reference

KLM time conversion. More...

#include <KLMTime.h>

Public Member Functions

void updateConstants ()
 Update constants from database objects.
 
double getTDCPeriod () const
 Get TDC period.
 
double getCTimePeriod () const
 Get CTIME period.
 
double getScintillatorTime (int ctime, int tdc, int triggerCTime) const
 Get time for scintillator.
 
std::pair< int, double > getRPCTimes (int ctime, int tdc, int triggerTime) const
 Get coarse and fine times for RPC.
 
double getTimeSimulation (int tdc, bool scintillator) const
 Get time for simulation.
 
uint16_t getTDCByTime (double time) const
 Get TDC by time.
 

Static Public Member Functions

static KLMTimeInstance ()
 Instantiation.
 

Private Member Functions

 KLMTime ()
 Constructor.
 
 ~KLMTime ()
 Destructor.
 

Private Attributes

DBObjPtr< KLMTimeConversionm_KLMTimeConversion
 KLM time conversion.
 
DBObjPtr< HardwareClockSettingsm_HardwareClockSettings
 Hardware clock settings.
 
double m_TDCPeriod = 0.
 TDC period (stored here because getting it from m_HardwareClockSettings requires to search in a map).
 
double m_CTimePeriod = 0.
 CTIME period.
 

Detailed Description

KLM time conversion.

Definition at line 27 of file KLMTime.h.

Constructor & Destructor Documentation

◆ KLMTime()

KLMTime ( )
inlineprivate

Constructor.

Definition at line 91 of file KLMTime.h.

92 {
93 }

◆ ~KLMTime()

~KLMTime ( )
inlineprivate

Destructor.

Definition at line 98 of file KLMTime.h.

99 {
100 }

Member Function Documentation

◆ getCTimePeriod()

double getCTimePeriod ( ) const
inline

Get CTIME period.

Definition at line 53 of file KLMTime.h.

54 {
55 return m_CTimePeriod;
56 }
double m_CTimePeriod
CTIME period.
Definition: KLMTime.h:115

◆ getRPCTimes()

std::pair< int, double > getRPCTimes ( int  ctime,
int  tdc,
int  triggerTime 
) const

Get coarse and fine times for RPC.

Parameters
[in]ctimeREVO9 time.
[in]tdcTDC.
[in]triggerTimeREVO9 Trigger time.

Definition at line 46 of file KLMTime.cc.

47{
48 /* Relative time in TDC periods for RPC hits. */
49 int relativeTime = tdc & 0x7FF;
50 /*
51 * TDC frequency is 8 times greater than revo9 frequency.
52 * The 2 last bits are zero, thus, the precision is 4 * (TDC period).
53 * The TDC has 11 bits of dynamic range. Shift the triggerTime by
54 * 10 ticks to align the new prompt-time peak with the old
55 * TriggerCTime-relative peak (for backward compatibility of calibration).
56 */
57 int trigger = ((triggerTime - 10) & 0x0FF) << 3;
58 if (relativeTime <= trigger)
59 relativeTime -= trigger;
60 else
61 relativeTime -= trigger + 0x800;
62 return std::pair<int, double>(ctime - triggerTime,
63 relativeTime * m_TDCPeriod);
64}
double m_TDCPeriod
TDC period (stored here because getting it from m_HardwareClockSettings requires to search in a map).
Definition: KLMTime.h:112

◆ getScintillatorTime()

double getScintillatorTime ( int  ctime,
int  tdc,
int  triggerCTime 
) const

Get time for scintillator.

Parameters
[in]ctimeCTIME.
[in]tdcTDC.
[in]triggerCTimeTrigger CTIME.

Definition at line 27 of file KLMTime.cc.

28{
29 int cTimeShift = m_KLMTimeConversion->getCTimeShift();
30 /* Relative time in TDC periods for scintillators. */
31 int relativeTime;
32 /*
33 * All time values were shifted by 2 bits for the phase2 data.
34 */
35 int correctedCTime = (((ctime << cTimeShift) & 0xFFFF) << 3) + (tdc & 0x7);
36 int correctedTriggerCTime = ((triggerCTime << cTimeShift) & 0xFFFF) << 3;
37 /* Scintillator: 16-bit CTIME. */
38 if (correctedCTime <= correctedTriggerCTime)
39 relativeTime = correctedCTime - correctedTriggerCTime;
40 else
41 relativeTime = correctedCTime - correctedTriggerCTime - (0x10000 << 3);
42 /* Get time in TDC periods. */
43 return relativeTime * m_TDCPeriod;
44}
DBObjPtr< KLMTimeConversion > m_KLMTimeConversion
KLM time conversion.
Definition: KLMTime.h:103

◆ getTDCByTime()

uint16_t getTDCByTime ( double  time) const

Get TDC by time.

Definition at line 73 of file KLMTime.cc.

74{
75 double timeOffset = m_KLMTimeConversion->getTimeOffset();
76 return (time - timeOffset) / m_TDCPeriod;
77}

◆ getTDCPeriod()

double getTDCPeriod ( ) const
inline

Get TDC period.

Definition at line 45 of file KLMTime.h.

46 {
47 return m_TDCPeriod;
48 }

◆ getTimeSimulation()

double getTimeSimulation ( int  tdc,
bool  scintillator 
) const

Get time for simulation.

Parameters
[in]tdcTDC.
[in]scintillatorScintillator (true) or RPC (false).

Definition at line 66 of file KLMTime.cc.

67{
68 double timeOffset = m_KLMTimeConversion->getTimeOffset();
69 (void)scintillator;
70 return tdc * m_TDCPeriod + timeOffset;
71}

◆ Instance()

KLMTime & Instance ( )
static

Instantiation.

Definition at line 14 of file KLMTime.cc.

15{
16 static KLMTime klmElementNumbers;
17 return klmElementNumbers;
18}
KLM time conversion.
Definition: KLMTime.h:27

◆ updateConstants()

void updateConstants ( )

Update constants from database objects.

This function needs to be called when database objects change, for example, at the beginning of the run.

Definition at line 20 of file KLMTime.cc.

21{
23 1.0 / m_HardwareClockSettings->getClockFrequency(Const::KLM, "TDC");
24 m_CTimePeriod = 1.0 / m_HardwareClockSettings->getGlobalClockFrequency();
25}
DBObjPtr< HardwareClockSettings > m_HardwareClockSettings
Hardware clock settings.
Definition: KLMTime.h:106

Member Data Documentation

◆ m_CTimePeriod

double m_CTimePeriod = 0.
private

CTIME period.

Definition at line 115 of file KLMTime.h.

◆ m_HardwareClockSettings

DBObjPtr<HardwareClockSettings> m_HardwareClockSettings
private

Hardware clock settings.

Definition at line 106 of file KLMTime.h.

◆ m_KLMTimeConversion

DBObjPtr<KLMTimeConversion> m_KLMTimeConversion
private

KLM time conversion.

Definition at line 103 of file KLMTime.h.

◆ m_TDCPeriod

double m_TDCPeriod = 0.
private

TDC period (stored here because getting it from m_HardwareClockSettings requires to search in a map).

Definition at line 112 of file KLMTime.h.


The documentation for this class was generated from the following files: