Belle II Software  release-08-01-10
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 #pragma once
9 
10 // mapper
11 #include <arich/dbobjects/ARICHMergerMapping.h>
12 #include <framework/database/DBObjPtr.h>
13 
14 #include <framework/core/Module.h>
15 #include <arich/modules/arichUnpacker/ARICHRawDataHeader.h>
16 #include <string>
17 
18 namespace Belle2 {
30  class ARICHUnpackerModule : public Module {
31 
32  public:
33 
38 
42  virtual ~ARICHUnpackerModule();
43 
48  virtual void initialize() override;
49 
53  virtual void event() override;
54 
55  private:
56 
63  void printBits(const int* buffer, int bufferSize);
64  void readHeader(const int* buffer, unsigned& ibyte, ARICHRawHeader& head);
65  void readFEHeader(const int* buffer, unsigned& ibyte, ARICHRawHeader& head);
69  uint8_t m_bitMask;
70  int m_debug;
72  int m_rawmode;
75  std::string m_outputDigitsName;
76  std::string m_outputRawDigitsName;
77  std::string m_outputarichinfoName;
78  std::string m_inputRawDataName;
82  protected:
83  unsigned int calbyte(const int* buf);
84  unsigned int cal2byte(const int* buf);
85  unsigned int calword(const int* buf);
86  unsigned int m_ibyte = 0;
87  };
88 
92  inline unsigned int ARICHUnpackerModule::calbyte(const int* buf)
93  {
94  int shift = (3 - m_ibyte % 4) * 8;
95  unsigned int val = 0xff & (buf[m_ibyte / 4] >> shift);
96  m_ibyte++;
97  return val;
98  }
99 
103  inline unsigned int ARICHUnpackerModule::cal2byte(const int* buf)
104  {
105  return (calbyte(buf) << 8) | calbyte(buf);
106  }
107 
111  inline unsigned int ARICHUnpackerModule::calword(const int* buf)
112  {
113  return (calbyte(buf) << 24) | (calbyte(buf) << 16)
114  | (calbyte(buf) << 8) | calbyte(buf);
115  }
116 
118 } // Belle2 namespace
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.
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.