Belle II Software  release-06-02-00
ARICHUnpackerModule.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 ARICHUNPACKERMODULE_H
10 #define ARICHUNPACKERMODULE_H
11 
12 // mapper
13 #include <arich/dbobjects/ARICHMergerMapping.h>
14 #include <framework/database/DBObjPtr.h>
15 
16 #include <framework/core/Module.h>
17 #include <arich/modules/arichUnpacker/ARICHRawDataHeader.h>
18 #include <string>
19 
20 namespace Belle2 {
32  class ARICHUnpackerModule : public Module {
33 
34  public:
35 
40 
44  virtual ~ARICHUnpackerModule();
45 
50  virtual void initialize() override;
51 
56  virtual void beginRun() override;
57 
61  virtual void event() override;
62 
67  virtual void endRun() override;
68 
73  virtual void terminate() override;
74 
75  private:
76 
83  void printBits(const int* buffer, int bufferSize);
84  void readHeader(const int* buffer, unsigned& ibyte, ARICHRawHeader& head);
85  void readFEHeader(const int* buffer, unsigned& ibyte, ARICHRawHeader& head);
89  uint8_t m_bitMask;
90  int m_debug;
92  int m_rawmode;
95  std::string m_outputDigitsName;
96  std::string m_outputRawDigitsName;
97  std::string m_outputarichinfoName;
98  std::string m_inputRawDataName;
102  protected:
103  unsigned int calbyte(const int* buf);
104  unsigned int cal2byte(const int* buf);
105  unsigned int calword(const int* buf);
106  unsigned int m_ibyte = 0;
107  };
108 
112  inline unsigned int ARICHUnpackerModule::calbyte(const int* buf)
113  {
114  int shift = (3 - m_ibyte % 4) * 8;
115  unsigned int val = 0xff & (buf[m_ibyte / 4] >> shift);
116  m_ibyte++;
117  return val;
118  }
119 
123  inline unsigned int ARICHUnpackerModule::cal2byte(const int* buf)
124  {
125  return (calbyte(buf) << 8) | calbyte(buf);
126  }
127 
131  inline unsigned int ARICHUnpackerModule::calword(const int* buf)
132  {
133  return (calbyte(buf) << 24) | (calbyte(buf) << 16)
134  | (calbyte(buf) << 8) | calbyte(buf);
135  }
136 
138 } // Belle2 namespace
139 
140 #endif
Raw data unpacker for ARICH.
DBObjPtr< ARICHMergerMapping > m_mergerMap
mapping of modules to mergers
std::string m_outputarichinfoName
name of ARICHInfo store object
int m_rawmode
Activate Raw Unpacker.
std::string m_outputRawDigitsName
name of ARICHRawDigit store array
uint8_t m_bitMask
read FE header
std::string m_outputDigitsName
name of ARICHDigit store array
int m_disable_unpacker
Disable regular Unpacker.
std::string m_inputRawDataName
name of RawARICH store array
unsigned int m_ibyte
bye index of raw unpacker
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Base class for Modules.
Definition: Module.h:72
unsigned int calbyte(const int *buf)
calculate number of bytes in raw Unpacker
virtual void initialize() override
Initialize the Module.
unsigned int calword(const int *buf)
calculate number of words in raw Unpacker
virtual void event() override
Event processor.
virtual void endRun() override
End-of-run action.
virtual void terminate() override
Termination action.
virtual void beginRun() override
Called when entering a new run.
void printBits(const int *buffer, int bufferSize)
Unpack raw data given in production format.
unsigned int cal2byte(const int *buf)
calculate number of lines (2 bytes) in raw Unpacker
void readFEHeader(const int *buffer, unsigned &ibyte, ARICHRawHeader &head)
read Merger header
virtual ~ARICHUnpackerModule()
Destructor.
Abstract base class for different kinds of events.