Belle II Software  release-06-01-15
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 
16 
17 namespace Belle2 {
29  class SVDEventInfo : public TObject {
30  public:
31 
34  m_modeByte(mode.getID()), m_triggerType(type.getType()) {m_ModeByteMatch = true; m_TriggerTypeMatch = true; m_Xtalk = false; m_relativeTimeShift = 0;}
35 
38 
42  void setMatchTriggerType(bool triggermatch) {m_TriggerTypeMatch = triggermatch;}
43 
47  void setMatchModeByte(bool modematch) {m_ModeByteMatch = modematch;}
48 
52  void setModeByte(SVDModeByte mode) {m_modeByte = mode.getID();}
53 
57  void setTriggerType(SVDTriggerType type) {m_triggerType = type.getType();}
58 
62  void setCrossTalk(bool xtalk) {m_Xtalk = xtalk;}
63 
68  void setRelativeShift(int relativeShift) {m_relativeTimeShift = relativeShift;}
69 
73  void setNSamples(int nAPVsamples) {m_nAPVsamples = nAPVsamples;}
74 
79 
84 
89  { return m_modeByte; }
90 
97  float getSVD2FTSWTimeShift(int firstFrame) const
98  { return 4000. / 509 * (3 - SVDModeByte(m_modeByte).getTriggerBin() + 4 * firstFrame); }
99 
103  int getNSamples() const
104  { return m_nAPVsamples; }
105 
112  float getSamplingDelayInNs() const
113  {
114  if (m_nAPVsamples == 3) {
115 
116  int nTriggerClocks = SVDModeByte(m_modeByte).getTriggerBin() + m_relativeTimeShift;
117 
118  return floor(nTriggerClocks / 4) * 16000. / 509.;
119  }
120 
121  return 0;
122  }
123 
128  int getRelativeShift() const
129  {
130  return m_relativeTimeShift;
131  }
132 
139  double getTimeInFTSWReference(double time_in_SVD, int firstFrame) const
140  {
141  return time_in_SVD + getSamplingDelayInNs() + getSVD2FTSWTimeShift(firstFrame);
142  }
143 
144 
151  double getTimeInSVDReference(double time_in_FTSW, int firstFrame) const
152  {
153  return time_in_FTSW - getSamplingDelayInNs() - getSVD2FTSWTimeShift(firstFrame);
154  }
155 
160  { return SVDTriggerType(m_triggerType); }
161 
165  bool isCrossTalkEvent() { return m_Xtalk; }
166 
167 
169  std::string toString() const
170  {
171  SVDModeByte thisMode(m_modeByte);
172  SVDTriggerType thisType(m_triggerType);
173 
174  bool thisModeMatch(m_ModeByteMatch);
175  bool thisTriggerMatch(m_TriggerTypeMatch);
176  bool thisXtalk(m_Xtalk);
177  int thisRelativeShift(m_relativeTimeShift);
178  int thisNsamples(m_nAPVsamples);
179 
180  std::ostringstream os;
181 
182  os << " Full SVDModeByte: " << (unsigned int)thisMode << std::endl;
183  os << " Triggerbin: " << (unsigned int) thisMode.getTriggerBin() << std::endl;
184  os << "RunType: " << (unsigned int)thisMode.getRunType() << ", EventType: " << (unsigned int) thisMode.getEventType() <<
185  ", DAQMode: " << (unsigned int) thisMode.getDAQMode() << std::endl;
186  os << " ModeByte Match: " << thisModeMatch << std::endl;
187  os << " Trigger Type: " << (unsigned int)thisType.getType() << std::endl;
188  os << " TriggerType Match: " << thisTriggerMatch << std::endl;
189  os << " Cross Talk: " << (thisXtalk ? "true" : "false") << std::endl;
190  os << " Relative Shift 3/6: " << (unsigned int)thisRelativeShift << std::endl;
191  os << " Number of APV samples: " << (unsigned int)thisNsamples << std::endl;
192  return os.str();
193  }
194 
195  private:
196 
201  bool m_Xtalk = false;
203  int m_nAPVsamples = 0;
207 
208  }; //class
210 } // namespace Belle2
211 
212 
213 
214 
Stores SVDModeByte object with Trigger time, DAQ mode, Run type & Event type! Also - the information ...
Definition: SVDEventInfo.h:29
bool isCrossTalkEvent()
X-talk info getter Gets the X-talk info for the event.
Definition: SVDEventInfo.h:165
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:139
void setModeByte(SVDModeByte mode)
SVDModeByte setter Sets the SVDModeByte data in the EventInfo object.
Definition: SVDEventInfo.h:52
~SVDEventInfo()
Destructor.
Definition: SVDEventInfo.h:37
float getSVD2FTSWTimeShift(int firstFrame) const
returns the time shift between SVD reference and FTSW (Trigger) reference: time in FTSW reference = t...
Definition: SVDEventInfo.h:97
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:68
std::string toString() const
Display main parameters in this object.
Definition: SVDEventInfo.h:169
void setCrossTalk(bool xtalk)
x-Talk setter Sets the x-talk info in the EventInfo object
Definition: SVDEventInfo.h:62
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:47
void setNSamples(int nAPVsamples)
nAPVsamples setter Sets the number of acquired samples (3 or 6) found in the raw data
Definition: SVDEventInfo.h:73
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:42
int getNSamples() const
returns the number of samples: 6, 3 or 1
Definition: SVDEventInfo.h:103
SVDTriggerType::baseType m_triggerType
information on the Trigger type
Definition: SVDEventInfo.h:198
ClassDef(SVDEventInfo, 2)
class def needed by root
float getSamplingDelayInNs() const
getSamplingDelayInNs() returns the delay of the sampling with respect to the sampling of the 6-sample...
Definition: SVDEventInfo.h:112
void setTriggerType(SVDTriggerType type)
SVDTriggerType setter Sets the type of SVDTrigger in the EventInfo object.
Definition: SVDEventInfo.h:57
bool m_ModeByteMatch
flag telling if the SVDModeByte object is the same for each FADCs in the event
Definition: SVDEventInfo.h:199
SVDEventInfo(SVDModeByte mode=SVDModeByte(), SVDTriggerType type=SVDTriggerType())
Constructor.
Definition: SVDEventInfo.h:33
SVDModeByte getModeByte() const
SVDModeByte getter Gets the SVDModeByte info for the event.
Definition: SVDEventInfo.h:88
bool m_Xtalk
information on the x-talk
Definition: SVDEventInfo.h:201
bool getMatchModeByte()
MatchModeByte getter Gets the flag telling us if the SVDModeByte object is the same for each FADCs in...
Definition: SVDEventInfo.h:83
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:151
SVDModeByte::baseType m_modeByte
SVDModeByte object (runType + eventType + DAQmode + TriggerBin)
Definition: SVDEventInfo.h:197
bool m_TriggerTypeMatch
flag telling if the SVDTriggerType object is the same for each FADCs in the event
Definition: SVDEventInfo.h:200
int m_relativeTimeShift
relative shift in units of APV-clock/4 between 3- and 6-sample acquired events
Definition: SVDEventInfo.h:202
SVDTriggerType getTriggerType() const
SVDTriggerType getter Gets the type of SVDTrigger for the event.
Definition: SVDEventInfo.h:159
int m_nAPVsamples
number of acquired samples
Definition: SVDEventInfo.h:203
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:128
bool getMatchTriggerType()
Match TriggerType getter Gets the flag telling us if the SVDTriggerType object is the same for each F...
Definition: SVDEventInfo.h:78
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.