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
176 { return SVDTriggerType(m_triggerType); }
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;
222 double m_apvClockPeriod = 16000. / 509.;
223
226
227 }; //class
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
Stores SVDModeByte object with Trigger time, DAQ mode, Run type & Event type! Also - the information ...
Definition: SVDEventInfo.h:31
bool isCrossTalkEvent()
X-talk info getter Gets the X-talk info for the event.
Definition: SVDEventInfo.h:181
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...
Definition: SVDEventInfo.h:141
void setModeByte(SVDModeByte mode)
SVDModeByte setter Sets the SVDModeByte data in the EventInfo object.
Definition: SVDEventInfo.h:57
~SVDEventInfo()
Destructor.
Definition: SVDEventInfo.h:42
float getSVD2FTSWTimeShift(int firstFrame) const
returns the time shift between SVD reference (t = 0 at the FF) and the FTSW (Trigger) reference
Definition: SVDEventInfo.h:99
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 ...
Definition: SVDEventInfo.h:73
std::string toString() const
Display main parameters in this object.
Definition: SVDEventInfo.h:185
void setCrossTalk(bool xtalk)
x-Talk setter Sets the x-talk info in the EventInfo object
Definition: SVDEventInfo.h:67
void setMatchModeByte(bool modematch)
Match ModeByte setter Sets the flag telling us if the SVDModeByte object is the same for each FADCs i...
Definition: SVDEventInfo.h:52
bool setAPVClock(DBObjPtr< HardwareClockSettings > hwClock)
sets the APV clock period.
Definition: SVDEventInfo.h:151
void setNSamples(int nAPVsamples)
nAPVsamples setter Sets the number of acquired samples (3 or 6) found in the raw data
Definition: SVDEventInfo.h:78
void setMatchTriggerType(bool triggermatch)
Match TriggerType setter Sets the flag telling us if the SVDTriggerType object is the same for each F...
Definition: SVDEventInfo.h:47
int getNSamples() const
returns the number of samples: 6, 3 or 1
Definition: SVDEventInfo.h:105
SVDTriggerType::baseType m_triggerType
information on the Trigger type
Definition: SVDEventInfo.h:214
float getSamplingDelayInNs() const
getSamplingDelayInNs() returns the delay of the sampling with respect to the sampling of the 6-sample...
Definition: SVDEventInfo.h:114
ClassDef(SVDEventInfo, 3)
class def needed by root
void setTriggerType(SVDTriggerType type)
SVDTriggerType setter Sets the type of SVDTrigger in the EventInfo object.
Definition: SVDEventInfo.h:62
bool m_ModeByteMatch
flag telling if the SVDModeByte object is the same for each FADCs in the event
Definition: SVDEventInfo.h:215
SVDEventInfo(SVDModeByte mode=SVDModeByte(), SVDTriggerType type=SVDTriggerType())
Constructor.
Definition: SVDEventInfo.h:35
SVDModeByte getModeByte() const
SVDModeByte getter Gets the SVDModeByte info for the event.
Definition: SVDEventInfo.h:93
bool m_Xtalk
information on the x-talk
Definition: SVDEventInfo.h:217
bool getMatchModeByte()
MatchModeByte getter Gets the flag telling us if the SVDModeByte object is the same for each FADCs in...
Definition: SVDEventInfo.h:88
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...
Definition: SVDEventInfo.h:167
SVDModeByte::baseType m_modeByte
SVDModeByte object (runType + eventType + DAQmode + TriggerBin)
Definition: SVDEventInfo.h:213
bool m_TriggerTypeMatch
flag telling if the SVDTriggerType object is the same for each FADCs in the event
Definition: SVDEventInfo.h:216
int m_relativeTimeShift
relative shift in units of APV-clock/4 between 3- and 6-sample acquired events
Definition: SVDEventInfo.h:218
SVDTriggerType getTriggerType() const
SVDTriggerType getter Gets the type of SVDTrigger for the event.
Definition: SVDEventInfo.h:175
int m_nAPVsamples
number of acquired samples
Definition: SVDEventInfo.h:219
int getRelativeShift() const
getRelativeShift returns the relative shift in data taken in 3/6 samples A number between 0 and 15 as...
Definition: SVDEventInfo.h:130
bool getMatchTriggerType()
Match TriggerType getter Gets the flag telling us if the SVDTriggerType object is the same for each F...
Definition: SVDEventInfo.h:83
double m_apvClockPeriod
APV clock period.
Definition: SVDEventInfo.h:222
Class to store SVD mode information.
Definition: SVDModeByte.h:69
baseType getRunType() const
Get the runMode id.
Definition: SVDModeByte.h:146
baseType getEventType() const
Get the eventMode id.
Definition: SVDModeByte.h:144
baseType getTriggerBin() const
Get the triggerBin id.
Definition: SVDModeByte.h:140
uint8_t baseType
The base integer type for SVDModeByte.
Definition: SVDModeByte.h:72
baseType getDAQMode() const
Get the daqMode id.
Definition: SVDModeByte.h:142
Class to store Trigger Type information.
uint8_t baseType
The base integer type for SVDTriggerType.
baseType getType() const
Get the unique type.
static const baseType c_DefaultID
Default / non-informative id 10010111 = 151 Run type: zero-suppressed, 2 Event type: global run,...
Definition: SVDModeByte.h:106
int getID(const std::vector< double > &breaks, double t)
get id of the time point t
Definition: calibTools.h:60
Abstract base class for different kinds of events.