Belle II Software  release-05-02-19
RawCOPPERFormat_v2.h
1 //+
2 // File : RawCOPPERFormat_v2.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 RAWCOPPERFORMAT_V2_H
10 #define RAWCOPPERFORMAT_V2_H
11 
12 // Includes
13 #include <rawdata/dataobjects/RawCOPPERFormat.h>
14 #include <rawdata/dataobjects/RawHeader_v2.h>
15 #include <rawdata/dataobjects/RawTrailer_v2.h>
16 #include <rawdata/CRCCalculator.h>
17 
18 /* #include <framework/datastore/DataStore.h> */
19 /* #include <TObject.h> */
20 
21 //#define USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
22 
23 
24 namespace Belle2 {
37  public:
40 
42  //RawCOPPERFormat_v2(int* bufin, int nwords);
44  virtual ~RawCOPPERFormat_v2();
45 
46  //
47  // Get position of or pointer to data
48  //
50  // POINTER TO "DETECTOR BUFFER"
51  //( after removing "B2link headers" from "FINESSE buffer". THIS IS THE RAW DATA FROM A DETECTOR
53 
54 
56  /* cppcheck-suppress missingOverride */
57  int Get1stDetectorNwords(int n) OVERRIDE_CPP17;
58 
60  /* cppcheck-suppress missingOverride */
61  int Get2ndDetectorNwords(int n) OVERRIDE_CPP17;
62 
64  /* cppcheck-suppress missingOverride */
65  int Get3rdDetectorNwords(int n) OVERRIDE_CPP17;
66 
68  /* cppcheck-suppress missingOverride */
69  int Get4thDetectorNwords(int n) OVERRIDE_CPP17;
70 
72 
74  /* cppcheck-suppress missingOverride */
75  int* GetRawTrlBufPtr(int n) OVERRIDE_CPP17;
76 
77  //
78  // Get information from "RawCOPPERFormat_v2 header" attached by DAQ software
79  //
80 
81  /* cppcheck-suppress missingOverride */
82  int GetExpNo(int n) OVERRIDE_CPP17;
83 
84  /* cppcheck-suppress missingOverride */
85  unsigned int GetExpRunSubrun(int n) OVERRIDE_CPP17;
86 
87  /* cppcheck-suppress missingOverride */
88  int GetRunNo(int n) OVERRIDE_CPP17;
89 
90  /* cppcheck-suppress missingOverride */
91  int GetSubRunNo(int n) OVERRIDE_CPP17;
92 
93  /* cppcheck-suppress missingOverride */
94  unsigned int GetEveNo(int n) OVERRIDE_CPP17;
95 
96  /* cppcheck-suppress missingOverride */
97  int GetDataType(int n) OVERRIDE_CPP17;
98 
99  /* cppcheck-suppress missingOverride */
100  int GetTruncMask(int n) OVERRIDE_CPP17;
101 
103  /* cppcheck-suppress missingOverride */
104  unsigned int GetErrorBitFlag(int n) OVERRIDE_CPP17;
105 
107  /* cppcheck-suppress missingOverride */
108  void AddErrorBitFlag(int n, unsigned int error_bit_flag) OVERRIDE_CPP17;
109 
111  /* cppcheck-suppress missingOverride */
112  int GetPacketCRCError(int n) OVERRIDE_CPP17;
113 
115  /* cppcheck-suppress missingOverride */
116  int GetEventCRCError(int n) OVERRIDE_CPP17;
117 
119  /* cppcheck-suppress missingOverride */
120  unsigned int GetNodeID(int n) OVERRIDE_CPP17;
121 
122  //
123  // Get information from 13words "COPPER header" attached by COPPER board
124  //
125 
127  /* cppcheck-suppress missingOverride */
128  virtual int GetNumFINESSEBlock(int n) OVERRIDE_CPP17;
129 
131  /* cppcheck-suppress missingOverride */
132  int Get1stFINESSENwords(int n) OVERRIDE_CPP17;
133 
135  /* cppcheck-suppress missingOverride */
136  int Get2ndFINESSENwords(int n) OVERRIDE_CPP17;
137 
139  /* cppcheck-suppress missingOverride */
140  int Get3rdFINESSENwords(int n) OVERRIDE_CPP17;
141 
143  /* cppcheck-suppress missingOverride */
144  int Get4thFINESSENwords(int n) OVERRIDE_CPP17;
145 
146  //
147  // Get information from "B2link(attached by FEE and HLSB) header"
148  //
150  // virtual int* GetFTSW2Words(int n);
151 
152 #ifdef USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
153  /* cppcheck-suppress missingOverride */
155  void CheckB2LFEEHeaderVersion(int n) OVERRIDE_CPP17;
156 #endif
157 
159  /* cppcheck-suppress missingOverride */
160  unsigned int GetTTCtimeTRGType(int n) OVERRIDE_CPP17;
161 
163  /* cppcheck-suppress missingOverride */
164  unsigned int GetTTUtime(int n) OVERRIDE_CPP17;
165 
166  /* //! calc COPPER driver's checksum value */
167  /* virtual unsigned int CalcDriverChkSum(int n) = 0; */
168 
169 
171  /* cppcheck-suppress missingOverride */
172  int GetTTCtime(int n) OVERRIDE_CPP17;
173 
175  /* cppcheck-suppress missingOverride */
176  int GetTRGType(int n) OVERRIDE_CPP17;
177 
179  /* cppcheck-suppress missingOverride */
180  void GetTTTimeVal(int n, struct timeval* tv) OVERRIDE_CPP17;
181 
183  /* cppcheck-suppress missingOverride */
184  int GetMaxNumOfCh(int n) OVERRIDE_CPP17;
185 
187  enum {
188  DATA_FORMAT_VERSION = 2
189  };
190 
193 
196 
197 
198  protected :
200  // ClassDefOverride(RawCOPPERFormat_v2, 2);
201  };
202 
203 
204 
205 
207  {
208  int pos_nwords;
209  if (n == (m_num_events * m_num_nodes) - 1) {
210  pos_nwords = m_nwords - tmp_trailer.GetTrlNwords();
211  } else {
212  pos_nwords = GetBufferPos(n + 1) - tmp_trailer.GetTrlNwords();
213  }
214  return &(m_buffer[ pos_nwords ]);
215  }
216 
218  {
220  return tmp_header.GetExpNo();
221  }
222 
223 
224  inline unsigned int RawCOPPERFormat_v2::GetExpRunSubrun(int n)
225  {
227  return tmp_header.GetExpRunSubrun();
228  }
229 
230 
232  {
234  return tmp_header.GetRunNo();
235  }
236 
237 
239  {
241  return tmp_header.GetSubRunNo();
242  }
243 
244  inline unsigned int RawCOPPERFormat_v2::GetEveNo(int n)
245  {
247  return tmp_header.GetEveNo();
248  }
249 
250 
251  inline unsigned int RawCOPPERFormat_v2::GetNodeID(int n)
252  {
254  return tmp_header.GetNodeID();
255  }
256 
257 
259  {
261  return tmp_header.GetDataType();
262  }
263 
265  {
267  return tmp_header.GetTruncMask();
268  }
269 
270  inline unsigned int RawCOPPERFormat_v2::GetErrorBitFlag(int n)
271  {
273  return tmp_header.GetErrorBitFlag();
274  }
275 
276  inline void RawCOPPERFormat_v2::AddErrorBitFlag(int n, unsigned int error_bit_flag)
277  {
279  tmp_header.AddErrorBitFlag(error_bit_flag);
280  return;
281  }
282 
284  {
286  return tmp_header.GetPacketCRCError();
287  }
288 
290  {
292  return tmp_header.GetEventCRCError();
293  }
294 
295 
297  {
298  return GetDetectorNwords(n, 0);
299  }
300 
302  {
303  return GetDetectorNwords(n, 1);
304  }
305 
307  {
308  return GetDetectorNwords(n, 2);
309  }
310 
312  {
313  return GetDetectorNwords(n, 3);
314  }
315 
316 
317 
319  {
320  return GetFINESSENwords(n, 0);
321  }
322 
324  {
325  return GetFINESSENwords(n, 1);
326  }
327 
329  {
330  return GetFINESSENwords(n, 2);
331  }
332 
334  {
335  return GetFINESSENwords(n, 3);
336  }
337 
338 
339 
340  inline unsigned int RawCOPPERFormat_v2::GetTTCtimeTRGType(int n)
341  {
343  return tmp_header.GetTTCtimeTRGType();
344  }
345 
346  inline unsigned int RawCOPPERFormat_v2::GetTTUtime(int n)
347  {
349  return tmp_header.GetTTUtime();
350  }
351 
353  {
355  return tmp_header.GetTTCtime();
356  }
357 
359  {
361  return tmp_header.GetTRGType();
362  }
363 
364  inline void RawCOPPERFormat_v2::GetTTTimeVal(int n, struct timeval* tv)
365  {
368  return ;
369  }
370 
371  inline int RawCOPPERFormat_v2::GetMaxNumOfCh(int/* n */)
372  {
373  return MAX_COPPER_CH;
374  }
375 
377 }
378 #endif
Belle2::RawCOPPERFormat_v2::GetTRGType
int GetTRGType(int n) OVERRIDE_CPP17
Get trgtype.
Definition: RawCOPPERFormat_v2.h:358
Belle2::RawHeader_v2::GetPacketCRCError
int GetPacketCRCError()
Get Packet CRC error flag.
Definition: RawHeader_v2.h:433
Belle2::RawHeader_v2::GetDataType
int GetDataType()
get contents of header
Definition: RawHeader_v2.h:408
Belle2::RawCOPPERFormat::GetDetectorNwords
virtual int GetDetectorNwords(int n, int finesse_num)=0
set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
Belle2::RawCOPPERFormat_v2::GetEventCRCError
int GetEventCRCError(int n) OVERRIDE_CPP17
check CRC event Error
Definition: RawCOPPERFormat_v2.h:289
Belle2::RawHeader_v2::GetRunNo
int GetRunNo()
get contents of header
Definition: RawHeader_v2.h:376
Belle2::RawDataBlockFormat::m_nwords
int m_nwords
number of words of buffer
Definition: RawDataBlockFormat.h:89
Belle2::RawDataBlockFormat::m_buffer
int * m_buffer
Buffer.
Definition: RawDataBlockFormat.h:98
Belle2::RawDataBlockFormat::GetBufferPos
virtual int GetBufferPos(int n)
get position of data block in word
Definition: RawDataBlockFormat.cc:30
Belle2::RawCOPPERFormat_v2::RawCOPPERFormat_v2
RawCOPPERFormat_v2()
Default constructor.
Definition: RawCOPPERFormat_v2.cc:21
Belle2::RawCOPPERFormat_v2::Get1stFINESSENwords
int Get1stFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot A buffer
Definition: RawCOPPERFormat_v2.h:318
Belle2::RawHeader_v2::GetExpNo
int GetExpNo()
get a run/exp number combined word
Definition: RawHeader_v2.h:368
Belle2::RawCOPPERFormat_v2::GetRawTrlBufPtr
int * GetRawTrlBufPtr(int n) OVERRIDE_CPP17
get buffer pointer of rawcopper trailer
Definition: RawCOPPERFormat_v2.h:206
Belle2::RawHeader_v2::GetTRGType
int GetTRGType()
get TRGType
Definition: RawHeader_v2.h:495
Belle2::RawCOPPERFormat_v2::tmp_header
RawHeader_v2 tmp_header
header ( not recorded )
Definition: RawCOPPERFormat_v2.h:192
Belle2::RawCOPPERFormat_v2::GetTTTimeVal
void GetTTTimeVal(int n, struct timeval *tv) OVERRIDE_CPP17
Get timeval.
Definition: RawCOPPERFormat_v2.h:364
Belle2::RawDataBlockFormat::GetBuffer
virtual int * GetBuffer(int n)
get nth buffer pointer
Definition: RawDataBlockFormat.cc:124
Belle2::RawHeader_v2::GetTTCtime
int GetTTCtime()
get contents of header
Definition: RawHeader_v2.h:489
Belle2::RawTrailer_v2
The Raw Trailer class ver.1 ( the latest version since May, 2014 ) This class defines the format of t...
Definition: RawTrailer_v2.h:34
Belle2::RawCOPPERFormat_v2::GetMaxNumOfCh
int GetMaxNumOfCh(int n) OVERRIDE_CPP17
Get the max number of channels in a readout board.
Definition: RawCOPPERFormat_v2.h:371
Belle2::RawHeader_v2::GetTTTimeVal
void GetTTTimeVal(struct timeval *tv)
get contents of header
Definition: RawHeader_v2.h:507
Belle2::RawCOPPERFormat_v2::GetNodeID
unsigned int GetNodeID(int n) OVERRIDE_CPP17
get node-ID from data
Definition: RawCOPPERFormat_v2.h:251
Belle2::RawHeader_v2::GetTTCtimeTRGType
unsigned int GetTTCtimeTRGType()
get contents of header
Definition: RawHeader_v2.h:483
Belle2::RawCOPPERFormat_v2::Get2ndDetectorNwords
int Get2ndDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot B
Definition: RawCOPPERFormat_v2.h:301
Belle2::RawDataBlockFormat::m_num_nodes
int m_num_nodes
number of nodes in this object
Definition: RawDataBlockFormat.h:92
Belle2::RawCOPPERFormat_v2::GetNumFINESSEBlock
virtual int GetNumFINESSEBlock(int n) OVERRIDE_CPP17
get # of FINNESEs which contains data
Definition: RawCOPPERFormat_v2.cc:29
Belle2::RawHeader_v2::GetTruncMask
int GetTruncMask()
get contents of header
Definition: RawHeader_v2.h:414
Belle2::RawTrailer_v2::GetTrlNwords
int GetTrlNwords()
Set magic word.
Definition: RawTrailer_v2.h:130
Belle2::RawHeader_v2::GetSubRunNo
int GetSubRunNo()
get run # (14bit)
Definition: RawHeader_v2.h:383
Belle2::RawCOPPERFormat_v2::tmp_trailer
RawTrailer_v2 tmp_trailer
trailer ( not recorded )
Definition: RawCOPPERFormat_v2.h:195
Belle2::RawDataBlockFormat::m_num_events
int m_num_events
number of events in this object
Definition: RawDataBlockFormat.h:95
Belle2::RawCOPPERFormat_v2::GetTruncMask
int GetTruncMask(int n) OVERRIDE_CPP17
get contents of header
Definition: RawCOPPERFormat_v2.h:264
Belle2::RawCOPPERFormat_v2::Get3rdDetectorNwords
int Get3rdDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot C
Definition: RawCOPPERFormat_v2.h:306
Belle2::RawCOPPERFormat_v2::GetExpRunSubrun
unsigned int GetExpRunSubrun(int n) OVERRIDE_CPP17
get Experimental # from header
Definition: RawCOPPERFormat_v2.h:224
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::RawCOPPERFormat::GetFINESSENwords
virtual int GetFINESSENwords(int n, int finesse)=0
get data size of FINESSE buffer
Belle2::RawCOPPERFormat_v2::GetTTCtimeTRGType
unsigned int GetTTCtimeTRGType(int n) OVERRIDE_CPP17
get b2l block from "FEE b2link header"
Definition: RawCOPPERFormat_v2.h:340
Belle2::RawHeader_v2::GetEveNo
unsigned int GetEveNo()
get restart #(8bit)
Definition: RawHeader_v2.h:396
Belle2::RawCOPPERFormat_v2::GetPacketCRCError
int GetPacketCRCError(int n) OVERRIDE_CPP17
check CRC packet Error
Definition: RawCOPPERFormat_v2.h:283
Belle2::RawCOPPERFormat_v2::GetExpNo
int GetExpNo(int n) OVERRIDE_CPP17
get Experimental # from header
Definition: RawCOPPERFormat_v2.h:217
Belle2::RawCOPPERFormat_v2::Get4thDetectorNwords
int Get4thDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot D
Definition: RawCOPPERFormat_v2.h:311
Belle2::RawCOPPERFormat_v2::Get1stDetectorNwords
int Get1stDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot A
Definition: RawCOPPERFormat_v2.h:296
Belle2::RawCOPPERFormat_v2::Get4thFINESSENwords
int Get4thFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot D buffer
Definition: RawCOPPERFormat_v2.h:333
Belle2::RawCOPPERFormat_v2::Get3rdFINESSENwords
int Get3rdFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot C buffer
Definition: RawCOPPERFormat_v2.h:328
Belle2::RawCOPPERFormat_v2::GetRunNo
int GetRunNo(int n) OVERRIDE_CPP17
Exp# (10bit) run# (14bit) restart # (8bit)
Definition: RawCOPPERFormat_v2.h:231
Belle2::RawHeader_v2::GetTTUtime
unsigned int GetTTUtime()
get contents of header
Definition: RawHeader_v2.h:501
Belle2::RawCOPPERFormat_v2::GetSubRunNo
int GetSubRunNo(int n) OVERRIDE_CPP17
get run # (14bit)
Definition: RawCOPPERFormat_v2.h:238
Belle2::RawCOPPERFormat_v2::Get2ndFINESSENwords
int Get2ndFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot B buffer
Definition: RawCOPPERFormat_v2.h:323
Belle2::RawCOPPERFormat_v2::GetTTCtime
int GetTTCtime(int n) OVERRIDE_CPP17
Get ctime.
Definition: RawCOPPERFormat_v2.h:352
Belle2::RawCOPPERFormat_v2::GetEveNo
unsigned int GetEveNo(int n) OVERRIDE_CPP17
get subrun #(8bit)
Definition: RawCOPPERFormat_v2.h:244
Belle2::RawHeader_v2::AddErrorBitFlag
void AddErrorBitFlag(unsigned int error_bit_flag)
Add Detected Error bitflag.
Definition: RawHeader_v2.h:426
Belle2::RawCOPPERFormat_v2::GetTTUtime
unsigned int GetTTUtime(int n) OVERRIDE_CPP17
Check if COPPER Magic words are correct.
Definition: RawCOPPERFormat_v2.h:346
Belle2::RawCOPPERFormat_v2::AddErrorBitFlag
void AddErrorBitFlag(int n, unsigned int error_bit_flag) OVERRIDE_CPP17
Add Detected Error bitflag.
Definition: RawCOPPERFormat_v2.h:276
Belle2::RawHeader_v2
The Raw Header class ver.1 ( the latest version since May, 2014 ) This class defines the format of th...
Definition: RawHeader_v2.h:32
Belle2::RawCOPPERFormat_v2::GetErrorBitFlag
unsigned int GetErrorBitFlag(int n) OVERRIDE_CPP17
get contents of header
Definition: RawCOPPERFormat_v2.h:270
Belle2::RawHeader_v2::GetNodeID
unsigned int GetNodeID()
get contents of header
Definition: RawHeader_v2.h:402
Belle2::RawCOPPERFormat
The Raw COPPER class This class stores data received by COPPER via belle2linkt Data from all detector...
Definition: RawCOPPERFormat.h:53
Belle2::RawCOPPERFormat_v2
The Raw COPPER class ver.1 ( the latest version since May, 2014 ) This class stores data received by ...
Definition: RawCOPPERFormat_v2.h:36
Belle2::RawCOPPERFormat_v2::~RawCOPPERFormat_v2
virtual ~RawCOPPERFormat_v2()
Constructor using existing pointer to raw data buffer.
Definition: RawCOPPERFormat_v2.cc:25
Belle2::RawCOPPERFormat_v2::GetDataType
int GetDataType(int n) OVERRIDE_CPP17
get contents of header
Definition: RawCOPPERFormat_v2.h:258
Belle2::RawHeader_v2::SetBuffer
void SetBuffer(int *bufin)
set buffer
Definition: RawHeader_v2.h:47
Belle2::RawHeader_v2::GetErrorBitFlag
unsigned int GetErrorBitFlag()
get contents of header
Definition: RawHeader_v2.h:420
Belle2::RawHeader_v2::GetExpRunSubrun
unsigned int GetExpRunSubrun()
get contents of header
Definition: RawHeader_v2.h:389
Belle2::RawHeader_v2::GetEventCRCError
int GetEventCRCError()
Get Detected Error bitflag.
Definition: RawHeader_v2.h:443