Belle II Software development
EventLevelTriggerTimeInfo.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <mdst/dataobjects/EventLevelTriggerTimeInfo.h>
9
10#include <framework/database/DBObjPtr.h>
11#include <framework/dbobjects/HardwareClockSettings.h>
12#include <mdst/dbobjects/TTDOffsets.h>
13
14using namespace Belle2;
15
16// get time since the last injection (i.e. the injection-pre-kick signal) in microseconds
18{
19 // use the 'HardwareClockSettings' to get the frequency the clock
20 static DBObjPtr<HardwareClockSettings> m_clockSettings;
21 // GlobalClockFrequency is in GHz, so we need an additional factor to convert to microseconds
22 return ((double)m_timeSinceLastInjection) / (m_clockSettings->getGlobalClockFrequency() * 1e3);
23}
24
25// get time since the previous trigger in microseconds
27{
28 // use the 'HardwareClockSettings' to get the frequency the clock
29 static DBObjPtr<HardwareClockSettings> m_clockSettings;
30 // GlobalClockFrequency is in GHz, so we need an additional factor to convert to microseconds
31 return ((double)m_timeSincePrevTrigger) / (m_clockSettings->getGlobalClockFrequency() * 1e3);
32}
33
34// get time since the injected bunch passed the detector in clock ticks (FTSW clock)
36{
37 // Use the 'TTDOffsets' to get the delay between injection pre-kick signal and passage of the bunch at the IP
38 static DBObjPtr<TTDOffsets> m_ttdOffsets;
39 int delay = 0;
40 if (m_ttdOffsets.isValid()) {
41 delay = m_isHER ? m_ttdOffsets->getInjectionDelayHER() : m_ttdOffsets->getInjectionDelayLER();
42 } else {
43 B2ERROR("Payload 'TTDOffsets' not found. To get the (uncorrected) information from TTD, use 'getTimeSinceLastInjection() or 'getTimeSinceLastInjectionInMicroSeconds()'.");
44 }
45 // a negative number means the "just" injected bunch has not yet passed the detector
46 return m_timeSinceLastInjection - delay;
47}
48
49// get time since injected bunch passed the detector in microseconds
51{
52 // use the 'HardwareClockSettings' to get the frequency the clock
53 static DBObjPtr<HardwareClockSettings> m_clockSettings;
54 // GlobalClockFrequency is in GHz, so we need an additional factor to convert to microseconds
55 return ((double)getTimeSinceInjectedBunch()) / (m_clockSettings->getGlobalClockFrequency() * 1e3);
56}
57
58// get the actual (=global) number of the triggered bunch
60{
61 // Use the 'TTDOffsets' to get the offset between TTD and SKB bunch numbering
62 static DBObjPtr<TTDOffsets> m_ttdOffsets;
63 int offset = 0;
64 if (m_ttdOffsets.isValid()) {
65 offset = m_isHER ? m_ttdOffsets->getTriggeredBunchOffsetHER() : m_ttdOffsets->getTriggeredBunchOffsetLER();
66 } else {
67 B2ERROR("Payload 'TTDOffsets' not found. To get the (uncorrected) information from TTD, use 'getBunchNumber()'.");
68 }
69 return m_bunchNumber + offset;
70}
bool isValid() const
Check whether a valid object was obtained from the database.
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
bool m_isHER
Injection is in HER/LER.
int getTriggeredBunchNumberGlobal() const
get the actual (=global) number of the triggered bunch
int getTimeSinceInjectedBunch() const
get time since the injected bunch passed the detector in clock ticks (FTSW clock)
unsigned int m_timeSincePrevTrigger
Time since the previous trigger in clock ticks (127MHz=RF/4 clock)
unsigned int m_bunchNumber
Number of triggered bunch, ranging from 0-1279 (in 127MHz clock ticks) Note: There are a maximum of 5...
unsigned int m_timeSinceLastInjection
Time since the last injection in clock ticks (127MHz=RF/4 clock) Note: A value of 0x7FFFFFFF (see c_f...
double getTimeSincePrevTriggerInMicroSeconds() const
get time since the previous trigger in microseconds
double getTimeSinceInjectedBunchInMicroSeconds() const
get time since the injected bunch passed the detector in microseconds
double getTimeSinceLastInjectionInMicroSeconds() const
get time since the last injection (i.e. the injection-pre-kick signal) in microseconds
Abstract base class for different kinds of events.