Belle II Software development
EventLevelTriggerTimeInfo.h
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#pragma once
9
10#include <TObject.h>
11
12namespace Belle2 {
24 class EventLevelTriggerTimeInfo : public TObject {
25
26 public:
27
29 enum EventT0Source : unsigned int {
30 // In case additional subdetectors are included in the EventT0 determination,
31 // they must be added here.
32 // Flags are set in the EventT0Combiner module.
33 c_fromSVD = (1 << 0),
34 c_fromCDC = (1 << 1),
35 c_fromECL = (1 << 2)
36 };
37
46 explicit EventLevelTriggerTimeInfo(bool isValid = false, bool isHER = false, bool revo2 = false,
47 unsigned int timeSinceLastInjection = c_flagNoInjection,
48 unsigned int timeSincePrevTrigger = 0,
49 unsigned int bunchNumber = 0) :
51 m_timeSinceLastInjection(timeSinceLastInjection), m_timeSincePrevTrigger(timeSincePrevTrigger),
52 m_bunchNumber(bunchNumber) {}
53
56
57 // Simple Getters
59 bool isValid() const {return m_isValid;}
61 bool isHER() const {return m_isHER;}
63 bool isRevo2() const {return m_revo2;}
67 unsigned int getTimeSincePrevTrigger() const {return m_timeSincePrevTrigger;}
69 unsigned int getBunchNumber() const {return m_bunchNumber;}
72
73 // Simple Setters
75 void setValid() {m_isValid = true;}
77 void setInvalid() {m_isValid = false;}
79 void setIsHER(bool isHER) {m_isHER = isHER;}
81 void setRevo2(bool revo2) {m_revo2 = revo2;}
83 void setTimeSinceLastInjection(unsigned int timeSinceLastInjection) {m_timeSinceLastInjection = timeSinceLastInjection;}
85 void setTimeSincePrevTrigger(unsigned int timeSincePrevTrigger) {m_timeSincePrevTrigger = timeSincePrevTrigger;}
87 void setBunchNumber(unsigned int bunchNumber) {m_bunchNumber = bunchNumber;}
90
91 // Additional Functions (not inline)
97 int getTimeSinceInjectedBunch() const;
102
103 // Setters and getters for EventT0Source flags
106
109
111 bool hasEventT0SourceFromSVD() const { return hasEventT0Sources(EventT0Source::c_fromSVD); }
112
115
118
120 bool hasEventT0SourceFromCDC() const { return hasEventT0Sources(EventT0Source::c_fromCDC); }
121
124
127
129 bool hasEventT0SourceFromECL() const { return hasEventT0Sources(EventT0Source::c_fromECL); }
130
133
136
138 bool hasEventT0Sources(EventT0Source sources) const { return EventT0Source(m_eventT0Source bitand sources); }
139
142
145
148
149 private:
150
154 template<EventT0Source source>
155 void setSources(bool setTo)
156 {
157 if (setTo) {
158 addEventT0Sources(source);
159 } else {
160 unsetEventT0Sources(source);
161 }
162 }
163
200 unsigned int m_bunchNumber;
201
203 static const unsigned int c_flagNoInjection = 0x7FFFFFFF;
204
205 static constexpr EventT0Source c_fromAllSubdetectors = EventT0Source(EventT0Source::c_fromSVD +
206 EventT0Source::c_fromCDC +
207 EventT0Source::c_fromECL);
208
209 ClassDef(EventLevelTriggerTimeInfo, 2)
210 };
211
212}
void setInvalid()
set that stored information is valid
void setTimeSinceLastInjection(unsigned int timeSinceLastInjection)
set time since the last injection (i.e. the injection-pre-kick signal) in clock ticks (FTSW clock)
EventLevelTriggerTimeInfo(bool isValid=false, bool isHER=false, bool revo2=false, unsigned int timeSinceLastInjection=c_flagNoInjection, unsigned int timeSincePrevTrigger=0, unsigned int bunchNumber=0)
Constructor.
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 getBunchNumber() const
get number of triggered bunch as provided by TTD
void addEventT0SourceFromSVD()
Add the flag c_fromSVD to the EventT0 source mask.
void addEventT0SourceFromECL()
Add the flag c_fromECL to the EventT0 source mask.
static const unsigned int c_flagNoInjection
This number is defined by the FTSW to indicate no injection happened recently.
unsigned int m_timeSincePrevTrigger
Time since the previous trigger in clock ticks (127MHz=RF/4 clock)
unsigned int getTimeSincePrevTrigger() const
get time since the previous trigger in clock ticks (FTSW clock)
bool hasInjection() const
get if an injection happened recently (and the corresponding stored data is actually valid)
void unsetEventT0SourceFromSVD()
Remove the flag c_fromSVD from the EventT0 source mask.
void setIsHER(bool isHER)
set if injection in HER/LER
void addEventT0Sources(EventT0Source sources)
Add a specific flag (or combination of flags) to the EventT0 source mask.
bool isValid() const
get if stored information is valid
bool hasAnyEventT0Sources() const
Return if at least one flag is set in the EventT0 source mask.
void unsetEventT0SourceFromCDC()
Remove the flag c_fromCDC from the EventT0 source mask.
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 getTimeSinceLastInjection() const
get time since the last injection (i.e. the injection-pre-kick signal) in clock ticks (FTSW clock)
unsigned int m_timeSinceLastInjection
Time since the last injection in clock ticks (127MHz=RF/4 clock) Note: A value of 0x7FFFFFFF (see c_f...
void resetEventT0Sources()
Reset all the flags from the EventT0 source mask (aka: set the "total" mask to 0)
double getTimeSincePrevTriggerInMicroSeconds() const
get time since the previous trigger in microseconds
bool m_revo2
Lowest bit of revolution counter (PXD needs ~2 revolutions to readout one frame)
void setRevo2(bool revo2)
set lowest bit of revolution counter
bool hasEventT0SourceFromECL() const
Return if the c_fromECL flag is set in the EventT0 source mask.
void addEventT0SourceFromCDC()
Add the flag c_fromCDC to the EventT0 source mask.
void setSources(bool setTo)
Generic setter for the EventT0Source flags.
bool hasEventT0SourceFromCDC() const
Return if the c_fromCDC flag is set in the EventT0 source mask.
bool isRevo2() const
get lowest bit of revolution counter
EventT0Source
Flags for the EventT0 source.
void setBunchNumber(unsigned int bunchNumber)
set number of triggered bunch
static constexpr EventT0Source c_fromAllSubdetectors
tells ROOT not to write it to file (transient)
void unsetEventT0Sources(EventT0Source sources)
Unset a specific flag (or combination of flags) from the EventT0 source mask.
void setValid()
set that stored information is valid
void setTimeSincePrevTrigger(unsigned int timeSincePrevTrigger)
set time since the previous trigger in clock ticks (FTSW clock)
const EventT0Source & getEventT0Sources() const
Return the EventT0 source mask.
bool isHER() const
get if last injection was in HER/LER
bool hasEventT0Sources(EventT0Source sources) const
Return if the specific flag is set in the EventT0 source mask.
void setNoInjection()
set that no injection happened recently (and the corresponding stored data is actually invalid)
void unsetEventT0SourceFromECL()
Remove the flag c_fromECL from the EventT0 source mask.
bool m_isValid
Data stored in this TTD info object is actually valid.
double getTimeSinceInjectedBunchInMicroSeconds() const
get time since the injected bunch passed the detector in microseconds
bool hasEventT0SourceFromSVD() const
Return if the c_fromSVD flag is set in the EventT0 source mask.
EventT0Source m_eventT0Source
Mask for storing which subdetectors contributed to the EventT0.
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.