Belle II Software  release-05-01-25
RawTrailer_latest.h
1 //+
2 // File : RawTrailer_latest.cc
3 // Description : Module to handle RawTraeiler attached to raw data from COPPER
4 //
5 // Author : Satoru Yamada, IPNS, KEK
6 // Date : 2 - Aug - 2013
7 //-
8 
9 #ifndef RAWTRAILER_LATEST_H
10 #define RAWTRAILER_LATEST_H
11 
12 #include <stdio.h>
13 
14 #include <rawdata/switch_basf2_standalone.h>
15 
16 //#define TRAILER_SIZE 16
17 /* #define POS_CHKSUM 0 */
18 /* #define POS_TERM_WORD 1 */
19 /* #define RAWCOPPER_TRAILER_SIZE 2 */
20 /* #define MAGIC_WORD_TERM_TRAILER 0x7fff0006 */
21 
22 namespace Belle2 {
33  // class RawTrailer_latest : public TObject {
35  public:
38 
41 
43  void CheckBuffer();
44 
45  int* GetBuffer();
46 
47  void SetBuffer(int* bufin);
48 
49  void Initialize();
50 
51  void SetChksum(int chksum);
52 
53  void SetMagicWord();
54 
55  int GetTrlNwords();
56 
57  unsigned int GetChksum();
58 
59  int GetMagicWord();
60 
61  enum {
62  RAWTRAILER_NWORDS = 2
63  };
64 
65  enum {
66  MAGIC_WORD_TERM_TRAILER = 0x7fff0006
67  };
68 
69  enum {
70  POS_CHKSUM = 0,
71  POS_TERM_WORD = 1
72  };
73 
74  private:
76  int* m_buffer;
77 
79  // ver.2 Do not record m_buffer pointer. (Dec.19, 2014)
80  // ClassDef(RawTrailer_latest, 1);
81  };
82 
83 
85  {
86  if (m_buffer == NULL) {
87  B2FATAL("m_buffer is NULL. Exiting...");
88  }
89  }
90 
92  {
93  return m_buffer;
94  }
95 
96  inline void RawTrailer_latest::SetBuffer(int* bufin)
97  {
98  m_buffer = bufin;
99  }
100 
102  {
103  SetMagicWord();
104  }
105 
106  inline void RawTrailer_latest::SetChksum(int chksum)
107  {
108  CheckBuffer();
109  m_buffer[ POS_CHKSUM ] = chksum;
110  }
111 
113  {
114  CheckBuffer();
115  m_buffer[ POS_TERM_WORD ] = MAGIC_WORD_TERM_TRAILER;
116  }
117 
119  {
120  CheckBuffer();
121  return m_buffer[ POS_TERM_WORD ];
122  }
123 
124  inline unsigned int RawTrailer_latest::GetChksum()
125  {
126  CheckBuffer();
127  return (unsigned int)(m_buffer[ POS_CHKSUM ]);
128  }
129 
131  {
132  return RAWTRAILER_NWORDS;
133  }
134 
135 
136 
137 
139 }
140 
141 #endif
Belle2::RawTrailer_latest::GetBuffer
int * GetBuffer()
set buffer
Definition: RawTrailer_latest.h:91
Belle2::RawTrailer_latest::CheckBuffer
void CheckBuffer()
set buffer
Definition: RawTrailer_latest.h:84
Belle2::RawTrailer_latest::GetChksum
unsigned int GetChksum()
Set # of trailer words.
Definition: RawTrailer_latest.h:124
Belle2::RawTrailer_latest::RawTrailer_latest
RawTrailer_latest()
Default constructor.
Definition: RawTrailer_latest.cc:15
Belle2::RawTrailer_latest::SetBuffer
void SetBuffer(int *bufin)
return buffer
Definition: RawTrailer_latest.h:96
Belle2::RawTrailer_latest::GetTrlNwords
int GetTrlNwords()
Set magic word.
Definition: RawTrailer_latest.h:130
Belle2::RawTrailer_latest::GetMagicWord
int GetMagicWord()
initialize header
Definition: RawTrailer_latest.h:118
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::RawTrailer_latest::~RawTrailer_latest
~RawTrailer_latest()
Destructor.
Definition: RawTrailer_latest.cc:20
Belle2::RawTrailer_latest::m_buffer
int * m_buffer
do not record buffer ( RawCOPPER includes buffer of RawHeader and RawTrailer_latest )
Definition: RawTrailer_latest.h:76
Belle2::RawTrailer_latest::SetChksum
void SetChksum(int chksum)
set buffer
Definition: RawTrailer_latest.h:106
Belle2::RawTrailer_latest::Initialize
void Initialize()
set buffer
Definition: RawTrailer_latest.h:101
Belle2::RawTrailer_latest::SetMagicWord
void SetMagicWord()
initialize header
Definition: RawTrailer_latest.h:112
Belle2::RawTrailer_latest
The Raw Trailer class ver.1 ( the latest version since May, 2014 ) This class defines the format of t...
Definition: RawTrailer_latest.h:34