Belle II Software  release-05-02-19
RawFTSW.h
1 //+
2 // File : RawFTSW.h
3 // Description : Module to handle raw data from COPPER
4 //
5 // Author : Satoru Yamada, IPNS, KEK
6 // Date : 2 - Aug - 2013
7 //-
8 
9 #ifndef RAWFTSW_H
10 #define RAWFTSW_H
11 
12 // Includes
13 #include <rawdata/dataobjects/RawDataBlock.h>
14 #include <rawdata/dataobjects/RawFTSWFormat.h>
15 #include <rawdata/dataobjects/RawFTSWFormat_v1.h>
16 #include <rawdata/dataobjects/RawFTSWFormat_v2.h>
17 #include <rawdata/dataobjects/RawFTSWFormat_latest.h>
18 
19 namespace Belle2 {
30  class RawFTSW : public RawDataBlock {
31  public:
33  RawFTSW();
34 
36  //RawFTSW(int* bufin, int nwords);
38  virtual ~RawFTSW();
39 
41  void SetBuffer(int* bufin, int nwords, int delete_flag, int num_events, int num_nodes) OVERRIDE_CPP17;
42 
44  void SetVersion();
45 
47  void CheckVersionSetBuffer();
48 
50  int GetNwordsHeader(int n)
51  {
53  return m_access->GetNwordsHeader(n);
54  }
55 
57  unsigned int GetFTSWNodeID(int n)
58  {
60  return m_access->GetFTSWNodeID(n);
61  }
62 
64  unsigned int GetEveNo(int n)
65  {
67  return m_access->GetEveNo(n);
68  }
69 
71  unsigned int GetTTCtimeTRGType(int n)
72  {
74  return m_access->GetTTCtimeTRGType(n);
75  }
76 
78  unsigned int GetTTUtime(int n)
79  {
81  return m_access->GetTTUtime(n);
82  }
83 
85  int GetTTCtime(int n)
86  {
88  return m_access->GetTTCtime(n);
89  }
90 
92  int GetTRGType(int n)
93  {
95  return m_access->GetTRGType(n);
96  }
97 
99  void GetTTTimeVal(int n, struct timeval* tv)
100  {
102  return m_access->GetTTTimeVal(n, tv);
103  }
104 
106  void GetPCTimeVal(int n, struct timeval* tv)
107  {
109  return m_access->GetPCTimeVal(n, tv);
110  }
111 
113  unsigned int GetMagicTrailer(int n)
114  {
116  return m_access->GetMagicTrailer(n);
117  }
118 
120  void CheckData(int n,
121  unsigned int prev_evenum, unsigned int* cur_evenum,
122  unsigned int prev_exprunsubrun_no, unsigned int* cur_exprunsubrun_no)
123  {
125  return m_access->CheckData(n, prev_evenum, cur_evenum, prev_exprunsubrun_no, cur_exprunsubrun_no);
126  }
127 
129  unsigned int GetExpRunSubrun(int n)
130  {
132  return m_access->GetExpRunSubrun(n);
133  }
134 
136  int GetRunNo(int n)
137  {
139  return m_access->GetRunNo(n);
140  }
141 
142 
144  int GetSubRunNo(int n)
145  {
147  return m_access->GetSubRunNo(n);
148  }
149 
151  int GetRunNoSubRunNo(int n)
152  {
154  return m_access->GetRunNoSubRunNo(n);
155  }
156 
158  int GetExpNo(int n)
159  {
161  return m_access->GetExpNo(n);
162  }
163 
165  int Get15bitTLUTag(int n)
166  {
168  return m_access->Get15bitTLUTag(n);
169  }
170 
172  int GetIsHER(int n)
173  {
175  return m_access->GetIsHER(n);
176  }
177 
179  unsigned int GetTimeSinceLastInjection(int n)
180  {
183  }
184 
186  unsigned int GetTimeSincePrevTrigger(int n)
187  {
190  }
191 
193  unsigned int GetBunchNumber(int n)
194  {
196  return m_access->GetBunchNumber(n);
197  }
198 
200  unsigned int GetFrameCount(int n)
201  {
203  return m_access->GetFrameCount(n);
204  }
205 
206  enum {
216  POS_NODE_FORMAT_ID = 6, // Position of format ID in header
217  FTSW_FORMAT_MASK = 0x000000FF,
218 
219  FORMAT_ID_VER_0TO2 = 0x54544420,
220  FORMAT_ID_VER_0TO3 = 0x54544431,
221 
222  POS_HEADER_SIZE = 1,
223  // header size is used to distinguish different version number for ver. 0, 1, and 2
225  VER_1_HEADER_SIZE = 0, // ! Unpacker for ver.1(late DESY version) is available but it is unlikely for a user to read this ver. Until there is a request to read ver.1, it is closed.
226  VER_2_HEADER_SIZE = 8,
227  VER_3_HEADER_SIZE = 8
228  };
229 
232 
234  int m_version = -1;
235 
236  protected :
244  };
245 
247  {
248  if (m_version < 0 || m_access == NULL) {
249  // Since both ver.0, 1 and ver.2 will show m_buffer[ POS_NODE_ID ] & FORMAT_MASK == 0x0, I need to ignore the check for ver.0 and 1
250  SetVersion();
251  }
253  }
254 
256 }
257 
258 #endif
Belle2::RawFTSWFormat::GetFTSWNodeID
virtual unsigned int GetFTSWNodeID(int n)=0
Get Node # ( should be "TTD " )
Belle2::RawDataBlockFormat::SetBuffer
virtual void SetBuffer(int *bufin, int nwords, int delete_flag, int num_events, int num_nodes)
set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
Definition: RawDataBlockFormat.cc:131
Belle2::RawFTSW::GetExpNo
int GetExpNo(int n)
Get Exp #.
Definition: RawFTSW.h:158
Belle2::RawFTSW::GetSubRunNo
int GetSubRunNo(int n)
Get subrun #.
Definition: RawFTSW.h:144
Belle2::RawFTSW::VER_1_HEADER_SIZE
@ VER_1_HEADER_SIZE
Unpacker for ver.0(early DESY version) is not available.
Definition: RawFTSW.h:225
Belle2::RawFTSW::m_version
int m_version
do not record
Definition: RawFTSW.h:234
Belle2::RawFTSWFormat::GetPCTimeVal
virtual void GetPCTimeVal(int n, struct timeval *tv)
Get stored information of getimeofday in a PC.
Definition: RawFTSWFormat.cc:97
Belle2::RawFTSW::~RawFTSW
virtual ~RawFTSW()
Constructor using existing pointer to raw data buffer.
Definition: RawFTSW.cc:19
Belle2::RawDataBlock::m_num_events
int m_num_events
number of events in this object
Definition: RawDataBlock.h:151
Belle2::RawFTSWFormat::GetIsHER
virtual int GetIsHER(int n)
HER injection = 1 or LER injection = 0.
Definition: RawFTSWFormat.cc:35
Belle2::RawFTSW::GetTRGType
int GetTRGType(int n)
Get trgtype.
Definition: RawFTSW.h:92
Belle2::RawFTSWFormat::GetTTCtime
virtual int GetTTCtime(int n)=0
Get ctime of the trigger.
Belle2::RawFTSW::m_access
RawFTSWFormat * m_access
class to access
Definition: RawFTSW.h:231
Belle2::RawFTSW::CheckVersionSetBuffer
void CheckVersionSetBuffer()
Check the version number of data format.
Definition: RawFTSW.h:246
Belle2::RawFTSW::GetRunNoSubRunNo
int GetRunNoSubRunNo(int n)
get a word cotaining run # and subrun #
Definition: RawFTSW.h:151
Belle2::RawFTSWFormat::GetRunNoSubRunNo
virtual int GetRunNoSubRunNo(int n)=0
get a word cotaining run # and subrun #
Belle2::RawFTSW::GetTTCtime
int GetTTCtime(int n)
Get ctime of the trigger.
Definition: RawFTSW.h:85
Belle2::RawFTSWFormat::GetRunNo
virtual int GetRunNo(int n)=0
Get run #.
Belle2::RawFTSW::GetExpRunSubrun
unsigned int GetExpRunSubrun(int n)
Exp# (10bit) run# (14bit) restart # (8bit)
Definition: RawFTSW.h:129
Belle2::RawFTSWFormat::GetTimeSincePrevTrigger
virtual unsigned int GetTimeSincePrevTrigger(int n)
Get time since the previous trigger.
Definition: RawFTSWFormat.cc:60
Belle2::RawFTSW::Get15bitTLUTag
int Get15bitTLUTag(int n)
DESY test only.
Definition: RawFTSW.h:165
Belle2::RawFTSW::RawFTSW
RawFTSW()
Default constructor.
Definition: RawFTSW.cc:13
Belle2::RawFTSWFormat::GetExpRunSubrun
virtual unsigned int GetExpRunSubrun(int n)=0
Exp# (10bit) run# (14bit) restart # (8bit)
Belle2::RawDataBlock::m_num_nodes
int m_num_nodes
number of nodes in this object
Definition: RawDataBlock.h:148
Belle2::RawFTSWFormat::GetTRGType
virtual int GetTRGType(int n)=0
Get trgtype.
Belle2::RawFTSW::GetRunNo
int GetRunNo(int n)
Get run #.
Definition: RawFTSW.h:136
Belle2::RawFTSWFormat::GetEveNo
virtual unsigned int GetEveNo(int n)=0
Get event #.
Belle2::RawFTSWFormat::GetMagicTrailer
virtual unsigned int GetMagicTrailer(int n)=0
Get magic number for data corruption check.
Belle2::RawFTSW::GetTTCtimeTRGType
unsigned int GetTTCtimeTRGType(int n)
Get a word containing ctime and trigger type info.
Definition: RawFTSW.h:71
Belle2::RawFTSW::GetFTSWNodeID
unsigned int GetFTSWNodeID(int n)
Get Node # ( should be "TTD " )
Definition: RawFTSW.h:57
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::RawFTSWFormat::GetNwordsHeader
virtual int GetNwordsHeader(int n)=0
Get # of words of header.
Belle2::RawFTSWFormat::GetBunchNumber
virtual unsigned int GetBunchNumber(int n)
Get a bunch number.
Definition: RawFTSWFormat.cc:71
Belle2::RawFTSW::GetIsHER
int GetIsHER(int n)
HER injection = 1 or LER injection = 0.
Definition: RawFTSW.h:172
Belle2::RawFTSWFormat::GetTTTimeVal
virtual void GetTTTimeVal(int n, struct timeval *tv)=0
Get timeval from ctime and utime.
Belle2::RawFTSW::GetPCTimeVal
void GetPCTimeVal(int n, struct timeval *tv)
Get timeval obtained from gettimeval()
Definition: RawFTSW.h:106
Belle2::RawFTSWFormat::GetFrameCount
virtual unsigned int GetFrameCount(int n)
Get a frame count.
Definition: RawFTSWFormat.cc:82
Belle2::RawFTSW::POS_NODE_FORMAT_ID
@ POS_NODE_FORMAT_ID
Added to distinguish different version.
Definition: RawFTSW.h:216
Belle2::RawFTSW::GetMagicTrailer
unsigned int GetMagicTrailer(int n)
Get magic number for data corruption check.
Definition: RawFTSW.h:113
Belle2::RawFTSW::CheckData
void CheckData(int n, unsigned int prev_evenum, unsigned int *cur_evenum, unsigned int prev_exprunsubrun_no, unsigned int *cur_exprunsubrun_no)
check the data contents
Definition: RawFTSW.h:120
Belle2::RawFTSW::GetEveNo
unsigned int GetEveNo(int n)
Get event #.
Definition: RawFTSW.h:64
Belle2::RawFTSWFormat::Get15bitTLUTag
virtual int Get15bitTLUTag(int n)
DESY test only (ver.1)
Definition: RawFTSWFormat.cc:23
Belle2::RawFTSWFormat
The Raw FTSW class.
Definition: RawFTSWFormat.h:24
Belle2::RawFTSW::GetTTUtime
unsigned int GetTTUtime(int n)
get unixtime of the trigger
Definition: RawFTSW.h:78
Belle2::RawFTSWFormat::GetTTUtime
virtual unsigned int GetTTUtime(int n)=0
get unixtime of the trigger
Belle2::RawFTSW::GetBunchNumber
unsigned int GetBunchNumber(int n)
Get a bunch number.
Definition: RawFTSW.h:193
Belle2::RawFTSW::VER_0_HEADER_SIZE
@ VER_0_HEADER_SIZE
The same number of this information must appear in RawFTSWFormat*.h. Information should be placed in ...
Definition: RawFTSW.h:224
Belle2::RawFTSW::SetVersion
void SetVersion()
read data, detect and set the version number of the data format
Definition: RawFTSW.cc:25
Belle2::RawFTSWFormat::GetExpNo
virtual int GetExpNo(int n)=0
Get Exp #.
Belle2::RawFTSW::GetTTTimeVal
void GetTTTimeVal(int n, struct timeval *tv)
Get timeval from ctime and utime.
Definition: RawFTSW.h:99
Belle2::RawDataBlock::m_nwords
int m_nwords
do not record
Definition: RawDataBlock.h:145
Belle2::RawFTSW::SetBuffer
void SetBuffer(int *bufin, int nwords, int delete_flag, int num_events, int num_nodes) OVERRIDE_CPP17
set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
Definition: RawFTSW.cc:107
Belle2::RawFTSWFormat::GetTimeSinceLastInjection
virtual unsigned int GetTimeSinceLastInjection(int n)
Get time since the last injection.
Definition: RawFTSWFormat.cc:48
Belle2::RawFTSWFormat::GetSubRunNo
virtual int GetSubRunNo(int n)=0
Get subrun #.
Belle2::RawFTSWFormat::GetTTCtimeTRGType
virtual unsigned int GetTTCtimeTRGType(int n)=0
Get a word containing ctime and trigger type info.
Belle2::RawFTSW::GetTimeSincePrevTrigger
unsigned int GetTimeSincePrevTrigger(int n)
Get time since the previous trigger.
Definition: RawFTSW.h:186
Belle2::RawDataBlock
The RawDataBlock class Base class for rawdata handling.
Definition: RawDataBlock.h:27
Belle2::RawDataBlock::m_buffer
int * m_buffer
Buffer.
Definition: RawDataBlock.h:154
Belle2::RawFTSWFormat::CheckData
virtual void CheckData(int n, unsigned int prev_evenum, unsigned int *cur_evenum, unsigned int prev_exprunsubrun_no, unsigned int *cur_exprunsubrun_no)=0
check the data contents
Belle2::RawFTSW::GetTimeSinceLastInjection
unsigned int GetTimeSinceLastInjection(int n)
Get time since the last injection.
Definition: RawFTSW.h:179
Belle2::RawFTSW::GetFrameCount
unsigned int GetFrameCount(int n)
Get a frame count.
Definition: RawFTSW.h:200
Belle2::RawFTSW::ClassDefOverride
ClassDefOverride(RawFTSW, 2)
do not record
Belle2::RawFTSW::GetNwordsHeader
int GetNwordsHeader(int n)
Get # of words of header.
Definition: RawFTSW.h:50
Belle2::RawFTSW
The Raw FTSW class.
Definition: RawFTSW.h:30