Belle II Software  release-08-01-10
RawTrailer_v0.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_V0_H
10 #define RAWTRAILER_V0_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_v0 : public TObject {
36  class RawTrailer_v0 {
37  public:
38  RawTrailer_v0();
39 
40  ~RawTrailer_v0();
41 
42  void CheckBuffer();
43 
44  int* GetBuffer();
45 
46  void SetBuffer(int* bufin);
47 
48  void Initialize();
49 
50  void SetChksum(int chksum);
51 
52  void SetMagicWord();
53 
54  int GetTrlNwords();
55 
56  unsigned int GetChksum();
57 
58  int GetMagicWord();
59 
60  enum {
61  RAWTRAILER_NWORDS = 2
62  };
63 
64  enum {
65  MAGIC_WORD_TERM_TRAILER = 0x7fff0006
66  };
67 
68  enum {
69  POS_CHKSUM = 0,
70  POS_TERM_WORD = 1
71  };
72 
73  private:
75  int* m_buffer;
76 
78  // ver.2 Do not record m_buffer pointer. (Dec.19, 2014)
79  // ClassDef(RawTrailer_v0, 2);
80  };
81 
82 
84  {
85  if (m_buffer == NULL) {
86  B2FATAL("m_buffer is NULL. Exiting...");
87  }
88  }
89 
91  {
92  return m_buffer;
93  }
94 
95  inline void RawTrailer_v0::SetBuffer(int* bufin)
96  {
97  m_buffer = bufin;
98  }
99 
101  {
102  SetMagicWord();
103  }
104 
105  inline void RawTrailer_v0::SetChksum(int chksum)
106  {
107  CheckBuffer();
108  m_buffer[ POS_CHKSUM ] = chksum;
109  }
110 
112  {
113  CheckBuffer();
114  m_buffer[ POS_TERM_WORD ] = MAGIC_WORD_TERM_TRAILER;
115  }
116 
118  {
119  CheckBuffer();
120  return m_buffer[ POS_TERM_WORD ];
121  }
122 
123  inline unsigned int RawTrailer_v0::GetChksum()
124  {
125  CheckBuffer();
126  return (unsigned int)(m_buffer[ POS_CHKSUM ]);
127  }
128 
130  {
131  return RAWTRAILER_NWORDS;
132  }
133 
134 
135 
136 
138 }
139 
140 #endif
The Raw Trailer class ver.0 ( from August, 2013 to April, 2014 ) This class defines the format of the...
Definition: RawTrailer_v0.h:36
int * m_buffer
do not record buffer ( RawCOPPER includes buffer of RawHeader and RawTrailer_v0 )
Definition: RawTrailer_v0.h:75
~RawTrailer_v0()
Default constructor.
void CheckBuffer()
Destructor.
Definition: RawTrailer_v0.h:83
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_v0.h:95
void SetChksum(int chksum)
set buffer
void Initialize()
set buffer
int * GetBuffer()
set buffer
Definition: RawTrailer_v0.h:90
Abstract base class for different kinds of events.