Belle II Software  release-08-01-10
RawCOPPERFormat_v1.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 #ifndef RAWCOPPERFORMAT_V1_H
10 #define RAWCOPPERFORMAT_V1_H
11 
12 // Includes
13 #include <rawdata/dataobjects/RawCOPPERFormat.h>
14 #include <rawdata/dataobjects/RawHeader_v1.h>
15 #include <rawdata/dataobjects/RawTrailer_v1.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 {
36  public:
39 
41  //RawCOPPERFormat_v1(int* bufin, int nwords);
43  virtual ~RawCOPPERFormat_v1();
44 
45  //
46  // Get position of or pointer to data
47  //
49  // POINTER TO "DETECTOR BUFFER"
50  //( after removing "B2link headers" from "FINESSE buffer". THIS IS THE RAW DATA FROM A DETECTOR
52 
53 
55  /* cppcheck-suppress missingOverride */
56  int Get1stDetectorNwords(int n) OVERRIDE_CPP17;
57 
59  /* cppcheck-suppress missingOverride */
60  int Get2ndDetectorNwords(int n) OVERRIDE_CPP17;
61 
63  /* cppcheck-suppress missingOverride */
64  int Get3rdDetectorNwords(int n) OVERRIDE_CPP17;
65 
67  /* cppcheck-suppress missingOverride */
68  int Get4thDetectorNwords(int n) OVERRIDE_CPP17;
69 
71 
73  /* cppcheck-suppress missingOverride */
74  int* GetRawTrlBufPtr(int n) OVERRIDE_CPP17;
75 
76  //
77  // Get information from "RawCOPPERFormat_v1 header" attached by DAQ software
78  //
79 
80  /* cppcheck-suppress missingOverride */
81  int GetExpNo(int n) OVERRIDE_CPP17;
82 
83  /* cppcheck-suppress missingOverride */
84  unsigned int GetExpRunSubrun(int n) OVERRIDE_CPP17;
85 
86  /* cppcheck-suppress missingOverride */
87  int GetRunNo(int n) OVERRIDE_CPP17;
88 
89  /* cppcheck-suppress missingOverride */
90  int GetSubRunNo(int n) OVERRIDE_CPP17;
91 
92  /* cppcheck-suppress missingOverride */
93  unsigned int GetEveNo(int n) OVERRIDE_CPP17;
94 
95  /* cppcheck-suppress missingOverride */
96  int GetDataType(int n) OVERRIDE_CPP17;
97 
98  /* cppcheck-suppress missingOverride */
99  int GetTruncMask(int n) OVERRIDE_CPP17;
100 
102  /* cppcheck-suppress missingOverride */
103  unsigned int GetErrorBitFlag(int n) OVERRIDE_CPP17;
104 
106  /* cppcheck-suppress missingOverride */
107  void AddErrorBitFlag(int n, unsigned int error_bit_flag) OVERRIDE_CPP17;
108 
110  /* cppcheck-suppress missingOverride */
111  unsigned int GetNodeID(int n) OVERRIDE_CPP17;
112 
113  //
114  // Get information from 13words "COPPER header" attached by COPPER board
115  //
116 
118  /* cppcheck-suppress missingOverride */
119  virtual int GetNumFINESSEBlock(int n) OVERRIDE_CPP17;
120 
122  /* cppcheck-suppress missingOverride */
123  int Get1stFINESSENwords(int n) OVERRIDE_CPP17;
124 
126  /* cppcheck-suppress missingOverride */
127  int Get2ndFINESSENwords(int n) OVERRIDE_CPP17;
128 
130  /* cppcheck-suppress missingOverride */
131  int Get3rdFINESSENwords(int n) OVERRIDE_CPP17;
132 
134  /* cppcheck-suppress missingOverride */
135  int Get4thFINESSENwords(int n) OVERRIDE_CPP17;
136 
137  //
138  // Get information from "B2link(attached by FEE and HLSB) header"
139  //
141  // virtual int* GetFTSW2Words(int n);
142 
143 #ifdef USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
145  /* cppcheck-suppress missingOverride */
146  void CheckB2LFEEHeaderVersion(int n) OVERRIDE_CPP17;
147 #endif
148 
150  /* cppcheck-suppress missingOverride */
151  unsigned int GetTTCtimeTRGType(int n) OVERRIDE_CPP17;
152 
154  /* cppcheck-suppress missingOverride */
155  unsigned int GetTTUtime(int n) OVERRIDE_CPP17;
156 
157  /* //! calc COPPER driver's checksum value */
158  /* virtual unsigned int CalcDriverChkSum(int n) = 0; */
159 
160 
162  /* cppcheck-suppress missingOverride */
163  int GetTTCtime(int n) OVERRIDE_CPP17;
164 
166  /* cppcheck-suppress missingOverride */
167  int GetTRGType(int n) OVERRIDE_CPP17;
168 
170  /* cppcheck-suppress missingOverride */
171  void GetTTTimeVal(int n, struct timeval* tv) OVERRIDE_CPP17;
172 
174  /* cppcheck-suppress missingOverride */
175  int GetMaxNumOfCh(int n) OVERRIDE_CPP17;
176 
178  enum {
179  DATA_FORMAT_VERSION = 1
180  };
181 
184 
187 
188 
189  protected :
191  // ClassDefOverride(RawCOPPERFormat_v1, 2);
192  };
193 
194 
195 
196 
198  {
199  int pos_nwords;
200  if (n == (m_num_events * m_num_nodes) - 1) {
201  pos_nwords = m_nwords - tmp_trailer.GetTrlNwords();
202  } else {
203  pos_nwords = GetBufferPos(n + 1) - tmp_trailer.GetTrlNwords();
204  }
205  return &(m_buffer[ pos_nwords ]);
206  }
207 
209  {
211  return tmp_header.GetExpNo();
212  }
213 
214  inline unsigned int RawCOPPERFormat_v1::GetExpRunSubrun(int n)
215  {
217  return tmp_header.GetExpRunSubrun();
218  }
219 
221  {
223  return tmp_header.GetRunNo();
224  }
225 
226 
228  {
230  return tmp_header.GetSubRunNo();
231  }
232 
233  inline unsigned int RawCOPPERFormat_v1::GetEveNo(int n)
234  {
236  return tmp_header.GetEveNo();
237  }
238 
239 
240  inline unsigned int RawCOPPERFormat_v1::GetNodeID(int n)
241  {
243  return tmp_header.GetNodeID();
244  }
245 
246 
248  {
250  return tmp_header.GetDataType();
251  }
252 
254  {
256  return tmp_header.GetTruncMask();
257  }
258 
259  inline unsigned int RawCOPPERFormat_v1::GetErrorBitFlag(int n)
260  {
262  return tmp_header.GetErrorBitFlag();
263  }
264 
265  inline void RawCOPPERFormat_v1::AddErrorBitFlag(int n, unsigned int error_bit_flag)
266  {
268  tmp_header.AddErrorBitFlag(error_bit_flag);
269  return;
270  }
271 
273  {
274  return GetDetectorNwords(n, 0);
275  }
276 
278  {
279  return GetDetectorNwords(n, 1);
280  }
281 
283  {
284  return GetDetectorNwords(n, 2);
285  }
286 
288  {
289  return GetDetectorNwords(n, 3);
290  }
291 
292 
293 
295  {
296  return GetFINESSENwords(n, 0);
297  }
298 
300  {
301  return GetFINESSENwords(n, 1);
302  }
303 
305  {
306  return GetFINESSENwords(n, 2);
307  }
308 
310  {
311  return GetFINESSENwords(n, 3);
312  }
313 
314 
315 
316  inline unsigned int RawCOPPERFormat_v1::GetTTCtimeTRGType(int n)
317  {
319  return tmp_header.GetTTCtimeTRGType();
320  }
321 
322  inline unsigned int RawCOPPERFormat_v1::GetTTUtime(int n)
323  {
325  return tmp_header.GetTTUtime();
326  }
327 
329  {
331  return tmp_header.GetTTCtime();
332  }
333 
335  {
337  return tmp_header.GetTRGType();
338  }
339 
340  inline void RawCOPPERFormat_v1::GetTTTimeVal(int n, struct timeval* tv)
341  {
344  return ;
345  }
346 
347  inline int RawCOPPERFormat_v1::GetMaxNumOfCh(int/* n */)
348  {
349  return MAX_COPPER_CH;
350  }
352 }
353 #endif
The Raw COPPER class ver.1 ( the latest version since May, 2014 ) This class stores data received by ...
virtual ~RawCOPPERFormat_v1()
Constructor using existing pointer to raw data buffer.
RawTrailer_v1 tmp_trailer
trailer ( not recorded )
RawHeader_v1 tmp_header
header ( not recorded )
virtual int GetNumFINESSEBlock(int n) OVERRIDE_CPP17
get # of FINNESEs which contains data
RawCOPPERFormat_v1()
Default constructor.
The Raw COPPER class This class stores data received by COPPER via belle2linkt Data from all detector...
virtual int GetFINESSENwords(int n, int finesse)=0
get data size of FINESSE buffer
virtual int GetDetectorNwords(int n, int finesse_num)=0
set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
int m_num_events
number of events in this object
int m_num_nodes
number of nodes in this object
virtual int GetBufferPos(int n)
get position of data block in word
virtual int * GetBuffer(int n)
get nth buffer pointer
int m_nwords
number of words of buffer
The Raw Header class ver.1 ( the latest version since May, 2014 ) This class defines the format of th...
Definition: RawHeader_v1.h:31
void SetBuffer(int *bufin)
set buffer
Definition: RawHeader_v1.h:47
The Raw Trailer class ver.1 ( the latest version since May, 2014 ) This class defines the format of t...
Definition: RawTrailer_v1.h:36
int GetMaxNumOfCh(int n) OVERRIDE_CPP17
Get the max number of channels in a readout board.
int GetTTCtime(int n) OVERRIDE_CPP17
Get ctime.
int Get3rdFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot C buffer
unsigned int GetEveNo()
get restart #(8bit)
Definition: RawHeader_v1.h:381
unsigned int GetEveNo(int n) OVERRIDE_CPP17
get subrun #(8bit)
int Get1stFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot A buffer
int GetTruncMask(int n) OVERRIDE_CPP17
get contents of header
int Get3rdDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot C
unsigned int GetErrorBitFlag(int n) OVERRIDE_CPP17
get contents of header
int GetTRGType(int n) OVERRIDE_CPP17
Get trgtype.
void AddErrorBitFlag(unsigned int error_bit_flag)
Add Detected Error bitflag.
Definition: RawHeader_v1.h:411
int GetTTCtime()
get contents of header
Definition: RawHeader_v1.h:454
void GetTTTimeVal(struct timeval *tv)
get contents of header
Definition: RawHeader_v1.h:472
void GetTTTimeVal(int n, struct timeval *tv) OVERRIDE_CPP17
Get timeval.
int GetSubRunNo()
get run # (14bit)
Definition: RawHeader_v1.h:368
int GetTrlNwords()
Set magic word.
void AddErrorBitFlag(int n, unsigned int error_bit_flag) OVERRIDE_CPP17
Add Detected Error bitflag.
unsigned int GetExpRunSubrun(int n) OVERRIDE_CPP17
get Experimental # from header
int GetExpNo(int n) OVERRIDE_CPP17
get Experimental # from header
int GetDataType()
get contents of header
Definition: RawHeader_v1.h:393
unsigned int GetTTUtime()
get contents of header
Definition: RawHeader_v1.h:466
int Get4thFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot D buffer
int GetTRGType()
get TRGType
Definition: RawHeader_v1.h:460
int GetRunNo(int n) OVERRIDE_CPP17
Exp# (10bit) run# (14bit) restart # (8bit)
unsigned int GetNodeID()
get contents of header
Definition: RawHeader_v1.h:387
int Get4thDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot D
int Get2ndDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot B
int GetRunNo()
get contents of header
Definition: RawHeader_v1.h:361
unsigned int GetTTUtime(int n) OVERRIDE_CPP17
Check if COPPER Magic words are correct.
unsigned int GetNodeID(int n) OVERRIDE_CPP17
get node-ID from data
int GetDataType(int n) OVERRIDE_CPP17
get contents of header
int * GetRawTrlBufPtr(int n) OVERRIDE_CPP17
get buffer pointer of rawcopper trailer
int GetTruncMask()
get contents of header
Definition: RawHeader_v1.h:399
unsigned int GetErrorBitFlag()
get contents of header
Definition: RawHeader_v1.h:405
unsigned int GetTTCtimeTRGType()
get contents of header
Definition: RawHeader_v1.h:448
unsigned int GetTTCtimeTRGType(int n) OVERRIDE_CPP17
get b2l block from "FEE b2link header"
unsigned int GetExpRunSubrun()
get contents of header
Definition: RawHeader_v1.h:374
int GetExpNo()
get a run/exp number combined word
Definition: RawHeader_v1.h:354
int Get1stDetectorNwords(int n) OVERRIDE_CPP17
get Detector buffer length of slot A
int Get2ndFINESSENwords(int n) OVERRIDE_CPP17
get data size of FINESSE slot B buffer
int GetSubRunNo(int n) OVERRIDE_CPP17
get run # (14bit)
Abstract base class for different kinds of events.