Belle II Software development
SVDEventInfo.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
9#pragma once
10#include <TObject.h>
11#include <string>
12#include <cmath>
13#include <svd/dataobjects/SVDModeByte.h>
14#include <svd/dataobjects/SVDTriggerType.h>
15#include <framework/database/DBObjPtr.h>
16#include <framework/dbobjects/HardwareClockSettings.h>
17
18
19namespace Belle2 {
31 class SVDEventInfo : public TObject {
32 public:
33
36 m_modeByte(mode.getID()), m_triggerType(type.getType())
37 {
39 }
40
43
47 void setMatchTriggerType(bool triggermatch) {m_TriggerTypeMatch = triggermatch;}
48
52 void setMatchModeByte(bool modematch) {m_ModeByteMatch = modematch;}
53
57 void setModeByte(SVDModeByte mode) {m_modeByte = mode.getID();}
58
62 void setTriggerType(SVDTriggerType type) {m_triggerType = type.getType();}
63
67 void setCrossTalk(bool xtalk) {m_Xtalk = xtalk;}
68
73 void setRelativeShift(int relativeShift) {m_relativeTimeShift = relativeShift;}
74
78 void setNSamples(int nAPVsamples) {m_nAPVsamples = nAPVsamples;}
79
84
89
94 { return m_modeByte; }
95
99 float getSVD2FTSWTimeShift(int firstFrame) const
100 { return m_apvClockPeriod / 4 * (3 - SVDModeByte(m_modeByte).getTriggerBin() + 4 * firstFrame); }
101
105 int getNSamples() const
106 { return m_nAPVsamples; }
107
115 {
116 if (m_nAPVsamples == 3) {
117
119
120 return floor(nTriggerClocks / 4) * m_apvClockPeriod;
121 }
122
123 return 0;
124 }
125
131 {
132 return m_relativeTimeShift;
133 }
134
141 double getTimeInFTSWReference(double time_in_SVD, int firstFrame) const
142 {
143 return time_in_SVD + getSamplingDelayInNs() + getSVD2FTSWTimeShift(firstFrame);
144 }
145
152 {
153 if (hwClock.isValid())
154 m_apvClockPeriod = 1. / hwClock->getClockFrequency(Const::EDetector::SVD, "sampling");
155 else
156 return false;
157
158 return true;
159 }
160
167 double getTimeInSVDReference(double time_in_FTSW, int firstFrame) const
168 {
169 return time_in_FTSW - getSamplingDelayInNs() - getSVD2FTSWTimeShift(firstFrame);
170 }
171
177
181 bool isCrossTalkEvent() { return m_Xtalk; }
182
183
185 std::string toString() const
186 {
187 SVDModeByte thisMode(m_modeByte);
189
190 bool thisModeMatch(m_ModeByteMatch);
191 bool thisTriggerMatch(m_TriggerTypeMatch);
192 bool thisXtalk(m_Xtalk);
193 int thisRelativeShift(m_relativeTimeShift);
194 int thisNsamples(m_nAPVsamples);
195
196 std::ostringstream os;
197
198 os << " Full SVDModeByte: " << (unsigned int)thisMode << std::endl;
199 os << " Triggerbin: " << (unsigned int) thisMode.getTriggerBin() << std::endl;
200 os << "RunType: " << (unsigned int)thisMode.getRunType() << ", EventType: " << (unsigned int) thisMode.getEventType() <<
201 ", DAQMode: " << (unsigned int) thisMode.getDAQMode() << std::endl;
202 os << " ModeByte Match: " << thisModeMatch << std::endl;
203 os << " Trigger Type: " << (unsigned int)thisType.getType() << std::endl;
204 os << " TriggerType Match: " << thisTriggerMatch << std::endl;
205 os << " Cross Talk: " << (thisXtalk ? "true" : "false") << std::endl;
206 os << " Relative Shift 3/6: " << (unsigned int)thisRelativeShift << std::endl;
207 os << " Number of APV samples: " << (unsigned int)thisNsamples << std::endl;
208 return os.str();
209 }
210
211 private:
212
217 bool m_Xtalk = false;
220
222 double m_apvClockPeriod = 16000. / 509.;
223
226
227 }; //class
228
229} // namespace Belle2
230
231
232
233
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 isCrossTalkEvent()
X-talk info getter Gets the X-talk info for the event.
double getTimeInFTSWReference(double time_in_SVD, int firstFrame) const
getTimeInFTSWReference it takes the cluster time in SVD reference (t = 0 at FF, in either 3- or 6-sam...
void setModeByte(SVDModeByte mode)
SVDModeByte setter Sets the SVDModeByte data in the EventInfo object.
~SVDEventInfo()
Destructor.
float getSVD2FTSWTimeShift(int firstFrame) const
returns the time shift between SVD reference (t = 0 at the FF) and the FTSW (Trigger) reference
void setRelativeShift(int relativeShift)
relative 3/6 shift Sets the relative shift in latency in data taken in 3/6 samples int between 0 and ...
std::string toString() const
Display main parameters in this object.
void setCrossTalk(bool xtalk)
x-Talk setter Sets the x-talk info in the EventInfo object
void setMatchModeByte(bool modematch)
Match ModeByte setter Sets the flag telling us if the SVDModeByte object is the same for each FADCs i...
bool setAPVClock(DBObjPtr< HardwareClockSettings > hwClock)
sets the APV clock period.
void setNSamples(int nAPVsamples)
nAPVsamples setter Sets the number of acquired samples (3 or 6) found in the raw data
void setMatchTriggerType(bool triggermatch)
Match TriggerType setter Sets the flag telling us if the SVDTriggerType object is the same for each F...
int getNSamples() const
returns the number of samples: 6, 3 or 1
SVDTriggerType::baseType m_triggerType
information on the Trigger type
float getSamplingDelayInNs() const
getSamplingDelayInNs() returns the delay of the sampling with respect to the sampling of the 6-sample...
ClassDef(SVDEventInfo, 3)
class def needed by root
void setTriggerType(SVDTriggerType type)
SVDTriggerType setter Sets the type of SVDTrigger in the EventInfo object.
bool m_ModeByteMatch
flag telling if the SVDModeByte object is the same for each FADCs in the event
SVDEventInfo(SVDModeByte mode=SVDModeByte(), SVDTriggerType type=SVDTriggerType())
Constructor.
SVDModeByte getModeByte() const
SVDModeByte getter Gets the SVDModeByte info for the event.
bool m_Xtalk
information on the x-talk
bool getMatchModeByte()
MatchModeByte getter Gets the flag telling us if the SVDModeByte object is the same for each FADCs in...
double getTimeInSVDReference(double time_in_FTSW, int firstFrame) const
getTimeInSVDReference it takes the cluster time in FTSW reference and provides the time in the SVD re...
SVDModeByte::baseType m_modeByte
SVDModeByte object (runType + eventType + DAQmode + TriggerBin)
bool m_TriggerTypeMatch
flag telling if the SVDTriggerType object is the same for each FADCs in the event
int m_relativeTimeShift
relative shift in units of APV-clock/4 between 3- and 6-sample acquired events
SVDTriggerType getTriggerType() const
SVDTriggerType getter Gets the type of SVDTrigger for the event.
int m_nAPVsamples
number of acquired samples
int getRelativeShift() const
getRelativeShift returns the relative shift in data taken in 3/6 samples A number between 0 and 15 as...
bool getMatchTriggerType()
Match TriggerType getter Gets the flag telling us if the SVDTriggerType object is the same for each F...
double m_apvClockPeriod
APV clock period.
Class to store SVD mode information.
Definition SVDModeByte.h:69
baseType getRunType() const
Get the runMode id.
baseType getEventType() const
Get the eventMode id.
baseType getTriggerBin() const
Get the triggerBin id.
uint8_t baseType
The base integer type for SVDModeByte.
Definition SVDModeByte.h:72
baseType getDAQMode() const
Get the daqMode id.
Class to store Trigger Type information.
uint8_t baseType
The base integer type for SVDTriggerType.
baseType getType() const
Get the unique type.
int getID(const std::vector< double > &breaks, double t)
get id of the time point t
Definition calibTools.h:60
static const baseType c_DefaultID
Default / non-informative id 10010111 = 151 Run type: zero-suppressed, 2 Event type: global run,...
Abstract base class for different kinds of events.