Belle II Software light-2406-ragdoll
HardwareClockSettings Class Reference

Database object containing the nominal accelerator RF value and the prescales to derive the clock frequencies of the sub-detectors. More...

#include <HardwareClockSettings.h>

Inheritance diagram for HardwareClockSettings:
Collaboration diagram for HardwareClockSettings:

Public Member Functions

 HardwareClockSettings ()
 Constructor.
 
double getClockPrescale (Const::EDetector detector, std::string label) const
 Get the prescale factor used to derive a detector clock from the global clock frequency.
 
double getClockFrequency (Const::EDetector detector, std::string label) const
 Get the frequency of a detector clock.
 
double getGlobalClockFrequency () const
 Get the global clock (system clock) frequency.
 
double getAcceleratorRF () const
 Get the accelerator RF value.
 
void setClockPrescale (const Const::EDetector detector, std::string label, double prescale)
 Set the prescale value used to derive a detector clock from the global clock frequency.
 
void setClockFrequency (const Const::EDetector detector, std::string label, double frequency)
 Set the frequency value of detector clock not derived from the global clock.
 
void setAcceleratorRF (double acceleratorRF)
 Set the accelerator RF value.
 
bool isPrescaleAvailable (Const::EDetector detector, std::string label) const
 Check if the prescale of a clock is available.
 
bool isFrequencyAvailable (Const::EDetector detector, std::string label) const
 Check if the frequency of a detector clock is available.
 
void print () const
 Print the content of the class.
 

Private Attributes

std::map< Const::EDetector, std::map< std::string, double > > m_prescaleMap
 Map of prescale factors used to derive the clock frequencies from the global clock frequency.
 
std::map< Const::EDetector, std::map< std::string, double > > m_clocksMap
 Map of clock frequencies not derived from the global clock frequency.
 
double m_acceleratorRF = 0
 Accelerator radio frequency [GHz].
 

Detailed Description

Database object containing the nominal accelerator RF value and the prescales to derive the clock frequencies of the sub-detectors.

Global clock frequency (system clock) is RF/4.

Definition at line 25 of file HardwareClockSettings.h.

Constructor & Destructor Documentation

◆ HardwareClockSettings()

Constructor.

Definition at line 15 of file HardwareClockSettings.cc.

15{}

Member Function Documentation

◆ getAcceleratorRF()

double getAcceleratorRF ( ) const

Get the accelerator RF value.

Returns
frequency [GHz]

Definition at line 57 of file HardwareClockSettings.cc.

58{
59 return m_acceleratorRF;
60}
double m_acceleratorRF
Accelerator radio frequency [GHz].

◆ getClockFrequency()

double getClockFrequency ( Const::EDetector  detector,
std::string  label 
) const

Get the frequency of a detector clock.

Parameters
detectorThe ID of the detector.
labelThe label for the clock.
Returns
frequency [GHz]

Definition at line 34 of file HardwareClockSettings.cc.

35{
36 bool isDetectorInPrescaleMap = true;
37
38 if (m_prescaleMap.find(detector) == m_prescaleMap.end()) isDetectorInPrescaleMap = false;
39 else if (m_prescaleMap.at(detector).find(label) != m_prescaleMap.at(detector).end())
40 return m_acceleratorRF / 4. / m_prescaleMap.at(detector).at(label);
41
42 if (m_clocksMap.find(detector) == m_clocksMap.end()) {
43 if (!isDetectorInPrescaleMap) B2ERROR("No clocks available for " << Const::parseDetectors(detector));
44 else B2ERROR("Clock named " << label << " not available for " << Const::parseDetectors(detector));
45 } else if (m_clocksMap.at(detector).find(label) != m_clocksMap.at(detector).end())
46 return m_clocksMap.at(detector).at(label);
47 else B2ERROR("Clock named " << label << " not available for " << Const::parseDetectors(detector));
48
49 return std::numeric_limits<double>::quiet_NaN();
50}
static std::string parseDetectors(EDetector det)
Converts Const::EDetector object to string.
Definition: UnitConst.cc:162
std::map< Const::EDetector, std::map< std::string, double > > m_prescaleMap
Map of prescale factors used to derive the clock frequencies from the global clock frequency.
std::map< Const::EDetector, std::map< std::string, double > > m_clocksMap
Map of clock frequencies not derived from the global clock frequency.

◆ getClockPrescale()

double getClockPrescale ( Const::EDetector  detector,
std::string  label 
) const

Get the prescale factor used to derive a detector clock from the global clock frequency.

Parameters
detectorThe ID of the detector.
labelThe label for the clock.
Returns
prescale factor

Definition at line 62 of file HardwareClockSettings.cc.

63{
64 if (m_prescaleMap.find(detector) == m_prescaleMap.end()) B2ERROR("No clocks available for " << Const::parseDetectors(detector));
65 else if (m_prescaleMap.at(detector).find(label) != m_prescaleMap.at(detector).end())
66 return m_prescaleMap.at(detector).at(label);
67 else B2ERROR("Clock named " << label << " not available for " << Const::parseDetectors(detector));
68
69 return std::numeric_limits<double>::quiet_NaN();
70}

◆ getGlobalClockFrequency()

double getGlobalClockFrequency ( ) const

Get the global clock (system clock) frequency.

Returns
frequency [GHz]

Definition at line 52 of file HardwareClockSettings.cc.

53{
54 return m_acceleratorRF / 4.;
55}

◆ isFrequencyAvailable()

bool isFrequencyAvailable ( Const::EDetector  detector,
std::string  label 
) const

Check if the frequency of a detector clock is available.

The check is performed for both the clocks derived from the globalclock and the clocks not derived from it.

Parameters
detectorThe ID of the detector.
labelThe label for the clock.
Returns
true, if available

Definition at line 25 of file HardwareClockSettings.cc.

26{
27 if (((m_prescaleMap.find(detector) == m_prescaleMap.end()) or
28 (m_prescaleMap.at(detector).find(label) == m_prescaleMap.at(detector).end()))
29 and ((m_clocksMap.find(detector) == m_clocksMap.end()) or
30 (m_clocksMap.at(detector).find(label) == m_clocksMap.at(detector).end()))) return false;
31 else return true;
32}

◆ isPrescaleAvailable()

bool isPrescaleAvailable ( Const::EDetector  detector,
std::string  label 
) const

Check if the prescale of a clock is available.

Parameters
detectorThe ID of the detector.
labelThe label for the clock.
Returns
true, if available

Definition at line 18 of file HardwareClockSettings.cc.

19{
20 if ((m_prescaleMap.find(detector) == m_prescaleMap.end())
21 or (m_prescaleMap.at(detector).find(label) == m_prescaleMap.at(detector).end())) return false;
22 else return true;
23}

◆ print()

void print ( ) const

Print the content of the class.

Definition at line 88 of file HardwareClockSettings.cc.

89{
90 std::cout << std::endl;
91 std::cout << "Accelerator RF: " << m_acceleratorRF / Unit::MHz << " MHz" << std::endl;
92 std::cout << "Clock prescale factors:" << std::endl;
93 std::cout << "===================================" << std::endl;
94
95 for (const auto& det : m_prescaleMap) {
96 std::cout << Const::parseDetectors(det.first) << ":" << std::endl;
97 for (const auto& clock : det.second) std::cout << " " << clock.first << " " << clock.second << std::endl;
98 }
99 std::cout << "===================================" << std::endl;
100
101 std::cout << "Clock frequencies:" << std::endl;
102 std::cout << "===================================" << std::endl;
103 for (const auto& det : m_clocksMap) {
104 std::cout << Const::parseDetectors(det.first) << ":" << std::endl;
105 for (const auto& clock : det.second) {
106 std::cout << " " << clock.first << " " << clock.second / Unit::MHz << " MHz" << std::endl;
107 }
108 }
109 std::cout << "===================================" << std::endl;
110}
static const double MHz
[Megahertz]
Definition: Unit.h:104

◆ setAcceleratorRF()

void setAcceleratorRF ( double  acceleratorRF)

Set the accelerator RF value.

Parameters
acceleratorRFAccelerator RF value [GHz].

Definition at line 83 of file HardwareClockSettings.cc.

84{
85 m_acceleratorRF = acceleratorRF;
86}

◆ setClockFrequency()

void setClockFrequency ( const Const::EDetector  detector,
std::string  label,
double  frequency 
)

Set the frequency value of detector clock not derived from the global clock.

Parameters
detectorThe ID of the detector.
labelThe label for the clock.
frequencyThe frequency for the clock [GHz]

Definition at line 78 of file HardwareClockSettings.cc.

79{
80 m_clocksMap[detector][label] = frequency;
81}

◆ setClockPrescale()

void setClockPrescale ( const Const::EDetector  detector,
std::string  label,
double  prescale 
)

Set the prescale value used to derive a detector clock from the global clock frequency.

Parameters
detectorThe ID of the detector.
labelThe label for the clock.
prescaleThe prescale factor of the clock.

Definition at line 72 of file HardwareClockSettings.cc.

73{
74 m_prescaleMap[detector][label] = prescale;
75}

Member Data Documentation

◆ m_acceleratorRF

double m_acceleratorRF = 0
private

Accelerator radio frequency [GHz].

Definition at line 119 of file HardwareClockSettings.h.

◆ m_clocksMap

std::map<Const::EDetector, std::map<std::string, double> > m_clocksMap
private

Map of clock frequencies not derived from the global clock frequency.

Clock frequency units are GHz.

Definition at line 114 of file HardwareClockSettings.h.

◆ m_prescaleMap

std::map<Const::EDetector, std::map<std::string, double> > m_prescaleMap
private

Map of prescale factors used to derive the clock frequencies from the global clock frequency.

Definition at line 108 of file HardwareClockSettings.h.


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