Belle II Software  release-05-01-25
SVDEventInfo.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2019 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Jarek Wiechczynski *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 #include <TObject.h>
13 #include <string>
14 #include <cmath>
15 #include <svd/dataobjects/SVDModeByte.h>
16 #include <svd/dataobjects/SVDTriggerType.h>
17 
18 
19 namespace Belle2 {
31  class SVDEventInfo : public TObject {
32  public:
33 
35  explicit SVDEventInfo(SVDModeByte mode = SVDModeByte(), SVDTriggerType type = SVDTriggerType()):
36  m_modeByte(mode.getID()), m_triggerType(type.getType()) {m_ModeByteMatch = true; m_TriggerTypeMatch = true; m_Xtalk = false; m_relativeTimeShift = 0;}
37 
40 
44  void setMatchTriggerType(bool triggermatch) {m_TriggerTypeMatch = triggermatch;}
45 
49  void setMatchModeByte(bool modematch) {m_ModeByteMatch = modematch;}
50 
54  void setModeByte(SVDModeByte mode) {m_modeByte = mode.getID();}
55 
59  void setTriggerType(SVDTriggerType type) {m_triggerType = type.getType();}
60 
64  void setCrossTalk(bool xtalk) {m_Xtalk = xtalk;}
65 
70  void setRelativeShift(int relativeShift) {m_relativeTimeShift = relativeShift;}
71 
75  void setNSamples(int nAPVsamples) {m_nAPVsamples = nAPVsamples;}
76 
81 
85  bool getMatchModeByte() {return m_ModeByteMatch;}
86 
90  SVDModeByte getModeByte() const
91  { return m_modeByte; }
92 
99  float getSVD2FTSWTimeShift(int firstFrame) const
100  { return 4000. / 509 * (3 - SVDModeByte(m_modeByte).getTriggerBin() + 4 * firstFrame); }
101 
105  int getNSamples() const
106  { return m_nAPVsamples; }
107 
114  float getSamplingDelayInNs() const
115  {
116  if (m_nAPVsamples == 3) {
117 
118  int nTriggerClocks = SVDModeByte(m_modeByte).getTriggerBin() + m_relativeTimeShift;
119 
120  return floor(nTriggerClocks / 4) * 16000. / 509.;
121  }
122 
123  return 0;
124  }
125 
130  int getRelativeShift() const
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 
146 
153  double getTimeInSVDReference(double time_in_FTSW, int firstFrame) const
154  {
155  return time_in_FTSW - getSamplingDelayInNs() - getSVD2FTSWTimeShift(firstFrame);
156  }
157 
162  { return SVDTriggerType(m_triggerType); }
163 
167  bool isCrossTalkEvent() { return m_Xtalk; }
168 
169 
171  std::string toString() const
172  {
173  SVDModeByte thisMode(m_modeByte);
174  SVDTriggerType thisType(m_triggerType);
175 
176  bool thisModeMatch(m_ModeByteMatch);
177  bool thisTriggerMatch(m_TriggerTypeMatch);
178  bool thisXtalk(m_Xtalk);
179  int thisRelativeShift(m_relativeTimeShift);
180  int thisNsamples(m_nAPVsamples);
181 
182  std::ostringstream os;
183 
184  os << " Full SVDModeByte: " << (unsigned int)thisMode << std::endl;
185  os << " Triggerbin: " << (unsigned int) thisMode.getTriggerBin() << std::endl;
186  os << "RunType: " << (unsigned int)thisMode.getRunType() << ", EventType: " << (unsigned int) thisMode.getEventType() <<
187  ", DAQMode: " << (unsigned int) thisMode.getDAQMode() << std::endl;
188  os << " ModeByte Match: " << thisModeMatch << std::endl;
189  os << " Trigger Type: " << (unsigned int)thisType.getType() << std::endl;
190  os << " TriggerType Match: " << thisTriggerMatch << std::endl;
191  os << " Cross Talk: " << (thisXtalk ? "true" : "false") << std::endl;
192  os << " Relative Shift 3/6: " << (unsigned int)thisRelativeShift << std::endl;
193  os << " Number of APV samples: " << (unsigned int)thisNsamples << std::endl;
194  return os.str();
195  }
196 
197  private:
198 
201  bool m_ModeByteMatch;
202  bool m_TriggerTypeMatch;
203  bool m_Xtalk = false;
204  int m_relativeTimeShift = 0;
205  int m_nAPVsamples = 0;
209 
210  }; //class
212 } // namespace Belle2
213 
214 
215 
216 
Belle2::SVDEventInfo
Stores SVDModeByte object with Trigger time, DAQ mode, Run type & Event type! Also - the information ...
Definition: SVDEventInfo.h:39
Belle2::SVDEventInfo::getSamplingDelayInNs
float getSamplingDelayInNs() const
getSamplingDelayInNs() returns the delay of the sampling with respect to the sampling of the 6-sample...
Definition: SVDEventInfo.h:122
Belle2::SVDEventInfo::setTriggerType
void setTriggerType(SVDTriggerType type)
SVDTriggerType setter Sets the type of SVDTrigger in the EventInfo object.
Definition: SVDEventInfo.h:67
Belle2::SVDTriggerType
Class to store Trigger Type information.
Definition: SVDTriggerType.h:33
Belle2::SVDModeByte::c_DefaultID
static const baseType c_DefaultID
Default / non-informative id 10010111 = 151 Run type: zero-suppressed, 2 Event type: global run,...
Definition: SVDModeByte.h:116
Belle2::SVDEventInfo::setModeByte
void setModeByte(SVDModeByte mode)
SVDModeByte setter Sets the SVDModeByte data in the EventInfo object.
Definition: SVDEventInfo.h:62
Belle2::SVDEventInfo::setRelativeShift
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:78
Belle2::SVDModeByte::getTriggerBin
baseType getTriggerBin() const
Get the triggerBin id.
Definition: SVDModeByte.h:150
Belle2::SVDEventInfo::ClassDef
ClassDef(SVDEventInfo, 2)
class def needed by root
Belle2::SVDTriggerType::getType
baseType getType() const
Get the unique type.
Definition: SVDTriggerType.h:49
Belle2::SVDEventInfo::toString
std::string toString() const
Display main parameters in this object.
Definition: SVDEventInfo.h:179
Belle2::getID
int getID(const std::vector< double > &breaks, double t)
get id of the time point t
Definition: calibTools.h:71
Belle2::SVDEventInfo::setMatchModeByte
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:57
Belle2::SVDEventInfo::~SVDEventInfo
~SVDEventInfo()
Destructor.
Definition: SVDEventInfo.h:47
Belle2::SVDEventInfo::m_ModeByteMatch
bool m_ModeByteMatch
flag telling if the SVDModeByte object is the same for each FADCs in the event
Definition: SVDEventInfo.h:209
Belle2::SVDEventInfo::m_triggerType
SVDTriggerType::baseType m_triggerType
information on the Trigger type
Definition: SVDEventInfo.h:208
Belle2::SVDModeByte
Class to store SVD mode information.
Definition: SVDModeByte.h:79
Belle2::SVDEventInfo::getTimeInFTSWReference
double getTimeInFTSWReference(double time_in_SVD, int firstFrame) const
getTimeInFTSWReference it takes the cluster time in SVD reference (in either 3- or 6-sample DAQ mode)...
Definition: SVDEventInfo.h:149
Belle2::SVDEventInfo::m_nAPVsamples
int m_nAPVsamples
number of acquired samples
Definition: SVDEventInfo.h:213
Belle2::SVDModeByte::getDAQMode
baseType getDAQMode() const
Get the daqMode id.
Definition: SVDModeByte.h:152
Belle2::SVDEventInfo::m_TriggerTypeMatch
bool m_TriggerTypeMatch
flag telling if the SVDTriggerType object is the same for each FADCs in the event
Definition: SVDEventInfo.h:210
Belle2::SVDEventInfo::getNSamples
int getNSamples() const
returns the number of samples: 6, 3 or 1
Definition: SVDEventInfo.h:113
Belle2::SVDEventInfo::setNSamples
void setNSamples(int nAPVsamples)
nAPVsamples setter Sets the number of acquired samples (3 or 6) found in the raw data
Definition: SVDEventInfo.h:83
Belle2::SVDEventInfo::getMatchModeByte
bool getMatchModeByte()
MatchModeByte getter Gets the flag telling us if the SVDModeByte object is the same for each FADCs in...
Definition: SVDEventInfo.h:93
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SVDModeByte::baseType
uint8_t baseType
The base integer type for SVDModeByte.
Definition: SVDModeByte.h:82
Belle2::SVDEventInfo::setMatchTriggerType
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:52
Belle2::SVDEventInfo::m_Xtalk
bool m_Xtalk
information on the x-talk
Definition: SVDEventInfo.h:211
Belle2::SVDEventInfo::getTriggerType
SVDTriggerType getTriggerType() const
SVDTriggerType getter Gets the type of SVDTrigger for the event.
Definition: SVDEventInfo.h:169
Belle2::SVDModeByte::getRunType
baseType getRunType() const
Get the runMode id.
Definition: SVDModeByte.h:156
Belle2::SVDEventInfo::m_modeByte
SVDModeByte::baseType m_modeByte
SVDModeByte object (runType + eventType + DAQmode + TriggerBin)
Definition: SVDEventInfo.h:207
Belle2::SVDEventInfo::m_relativeTimeShift
int m_relativeTimeShift
relative shift in units of APV-clock/4 between 3- and 6-sample acquired events
Definition: SVDEventInfo.h:212
Belle2::SVDEventInfo::getSVD2FTSWTimeShift
float getSVD2FTSWTimeShift(int firstFrame) const
returns the time shift between SVD reference and FTSW (Trigger) reference: time in FTSW reference = t...
Definition: SVDEventInfo.h:107
Belle2::SVDEventInfo::SVDEventInfo
SVDEventInfo(SVDModeByte mode=SVDModeByte(), SVDTriggerType type=SVDTriggerType())
Constructor.
Definition: SVDEventInfo.h:43
Belle2::SVDEventInfo::isCrossTalkEvent
bool isCrossTalkEvent()
X-talk info getter Gets the X-talk info for the event.
Definition: SVDEventInfo.h:175
Belle2::SVDEventInfo::getTimeInSVDReference
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:161
Belle2::SVDEventInfo::getMatchTriggerType
bool getMatchTriggerType()
Match TriggerType getter Gets the flag telling us if the SVDTriggerType object is the same for each F...
Definition: SVDEventInfo.h:88
Belle2::SVDEventInfo::getRelativeShift
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:138
Belle2::SVDEventInfo::getModeByte
SVDModeByte getModeByte() const
SVDModeByte getter Gets the SVDModeByte info for the event.
Definition: SVDEventInfo.h:98
Belle2::SVDEventInfo::setCrossTalk
void setCrossTalk(bool xtalk)
x-Talk setter Sets the x-talk info in the EventInfo object
Definition: SVDEventInfo.h:72
Belle2::SVDTriggerType::baseType
uint8_t baseType
The base integer type for SVDTriggerType.
Definition: SVDTriggerType.h:37
Belle2::SVDModeByte::getEventType
baseType getEventType() const
Get the eventMode id.
Definition: SVDModeByte.h:154