Belle II Software  release-08-01-10
RawTrailer_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 RAWTRAILER_V1_H
10 #define RAWTRAILER_V1_H
11 
12 #include <stdio.h>
13 #include <rawdata/switch_basf2_standalone.h>
14 
15 /* #include <framework/datastore/DataStore.h> */
16 /* #include <TObject.h> */
17 
18 //#define TRAILER_SIZE 16
19 /* #define POS_CHKSUM 0 */
20 /* #define POS_TERM_WORD 1 */
21 /* #define RAWCOPPER_TRAILER_SIZE 2 */
22 /* #define MAGIC_WORD_TERM_TRAILER 0x7fff0006 */
23 
24 namespace Belle2 {
35  // class RawTrailer_v1 : public TObject {
36  class RawTrailer_v1 {
37  public:
39  RawTrailer_v1();
40 
43 
45  void CheckBuffer();
46 
47  int* GetBuffer();
48 
49  void SetBuffer(int* bufin);
50 
51  void Initialize();
52 
53  void SetChksum(int chksum);
54 
55  void SetMagicWord();
56 
57  int GetTrlNwords();
58 
59  unsigned int GetChksum();
60 
61  int GetMagicWord();
62 
63  enum {
64  RAWTRAILER_NWORDS = 2
65  };
66 
67  enum {
68  MAGIC_WORD_TERM_TRAILER = 0x7fff0006
69  };
70 
71  enum {
72  POS_CHKSUM = 0,
73  POS_TERM_WORD = 1
74  };
75 
76  private:
78  int* m_buffer;
79 
81  // ver.2 Do not record m_buffer pointer. (Dec.19, 2014)
82  // ClassDef(RawTrailer_v1, 1);
83  };
84 
85 
87  {
88  if (m_buffer == NULL) {
89  B2FATAL("m_buffer is NULL. Exiting...");
90  }
91  }
92 
94  {
95  return m_buffer;
96  }
97 
98  inline void RawTrailer_v1::SetBuffer(int* bufin)
99  {
100  m_buffer = bufin;
101  }
102 
104  {
105  SetMagicWord();
106  }
107 
108  inline void RawTrailer_v1::SetChksum(int chksum)
109  {
110  CheckBuffer();
111  m_buffer[ POS_CHKSUM ] = chksum;
112  }
113 
115  {
116  CheckBuffer();
117  m_buffer[ POS_TERM_WORD ] = MAGIC_WORD_TERM_TRAILER;
118  }
119 
121  {
122  CheckBuffer();
123  return m_buffer[ POS_TERM_WORD ];
124  }
125 
126  inline unsigned int RawTrailer_v1::GetChksum()
127  {
128  CheckBuffer();
129  return (unsigned int)(m_buffer[ POS_CHKSUM ]);
130  }
131 
133  {
134  return RAWTRAILER_NWORDS;
135  }
136 
137 
138 
139 
141 }
142 
143 #endif
The Raw Trailer class ver.1 ( the latest version since May, 2014 ) This class defines the format of t...
Definition: RawTrailer_v1.h:36
~RawTrailer_v1()
Destructor.
int * m_buffer
do not record buffer ( RawCOPPER includes buffer of RawHeader and RawTrailer_v1 )
Definition: RawTrailer_v1.h:78
RawTrailer_v1()
Default constructor.
void CheckBuffer()
set buffer
Definition: RawTrailer_v1.h:86
int GetTrlNwords()
Set magic word.
int GetMagicWord()
initialize header
unsigned int GetChksum()
Set # of trailer words.
void SetMagicWord()
initialize header
void SetBuffer(int *bufin)
return buffer
Definition: RawTrailer_v1.h:98
void SetChksum(int chksum)
set buffer
void Initialize()
set buffer
int * GetBuffer()
set buffer
Definition: RawTrailer_v1.h:93
Abstract base class for different kinds of events.