Belle II Software  release-05-02-19
ARICHUnpackerModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Luka Santelj *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef ARICHUNPACKERMODULE_H
12 #define ARICHUNPACKERMODULE_H
13 
14 // mapper
15 #include <arich/dbobjects/ARICHMergerMapping.h>
16 #include <framework/database/DBObjPtr.h>
17 
18 #include <framework/core/Module.h>
19 #include <arich/modules/arichUnpacker/ARICHRawDataHeader.h>
20 #include <string>
21 
22 namespace Belle2 {
34  class ARICHUnpackerModule : public Module {
35 
36  public:
37 
42 
46  virtual ~ARICHUnpackerModule();
47 
52  virtual void initialize() override;
53 
58  virtual void beginRun() override;
59 
63  virtual void event() override;
64 
69  virtual void endRun() override;
70 
75  virtual void terminate() override;
76 
77  private:
78 
85  void printBits(const int* buffer, int bufferSize);
86  void readHeader(const int* buffer, unsigned& ibyte, ARICHRawHeader& head);
87  void readFEHeader(const int* buffer, unsigned& ibyte, ARICHRawHeader& head);
91  uint8_t m_bitMask;
92  int m_debug;
94  int m_rawmode;
95  int m_disable_unpacker;
97  std::string m_outputDigitsName;
98  std::string m_outputRawDigitsName;
99  std::string m_outputarichinfoName;
100  std::string m_inputRawDataName;
104  protected:
105  unsigned int calbyte(const int* buf);
106  unsigned int cal2byte(const int* buf);
107  unsigned int calword(const int* buf);
108  unsigned int m_ibyte = 0;
109  };
110 
114  inline unsigned int ARICHUnpackerModule::calbyte(const int* buf)
115  {
116  int shift = (3 - m_ibyte % 4) * 8;
117  unsigned int val = 0xff & (buf[m_ibyte / 4] >> shift);
118  m_ibyte++;
119  return val;
120  }
121 
125  inline unsigned int ARICHUnpackerModule::cal2byte(const int* buf)
126  {
127  return (calbyte(buf) << 8) | calbyte(buf);
128  }
129 
133  inline unsigned int ARICHUnpackerModule::calword(const int* buf)
134  {
135  return (calbyte(buf) << 24) | (calbyte(buf) << 16)
136  | (calbyte(buf) << 8) | calbyte(buf);
137  }
138 
140 } // Belle2 namespace
141 
142 #endif
Belle2::ARICHUnpackerModule::m_rawmode
int m_rawmode
Activate Raw Unpacker.
Definition: ARICHUnpackerModule.h:102
Belle2::ARICHUnpackerModule::terminate
virtual void terminate() override
Termination action.
Definition: ARICHUnpackerModule.cc:528
Belle2::ARICHUnpackerModule::ARICHUnpackerModule
ARICHUnpackerModule()
Constructor.
Definition: ARICHUnpackerModule.cc:55
Belle2::ARICHUnpackerModule::m_disable_unpacker
int m_disable_unpacker
Disable regular Unpacker.
Definition: ARICHUnpackerModule.h:103
Belle2::ARICHUnpackerModule::readFEHeader
void readFEHeader(const int *buffer, unsigned &ibyte, ARICHRawHeader &head)
read Merger header
Definition: ARICHUnpackerModule.cc:470
Belle2::ARICHUnpackerModule::printBits
void printBits(const int *buffer, int bufferSize)
Unpack raw data given in production format.
Definition: ARICHUnpackerModule.cc:516
Belle2::ARICHUnpackerModule::m_outputRawDigitsName
std::string m_outputRawDigitsName
name of ARICHRawDigit store array
Definition: ARICHUnpackerModule.h:106
Belle2::ARICHUnpackerModule::m_outputarichinfoName
std::string m_outputarichinfoName
name of ARICHInfo store object
Definition: ARICHUnpackerModule.h:107
Belle2::ARICHUnpackerModule::m_outputDigitsName
std::string m_outputDigitsName
name of ARICHDigit store array
Definition: ARICHUnpackerModule.h:105
Belle2::ARICHUnpackerModule::event
virtual void event() override
Event processor.
Definition: ARICHUnpackerModule.cc:98
Belle2::DBObjPtr
Class for accessing objects in the database.
Definition: DBObjPtr.h:31
Belle2::ARICHUnpackerModule::m_mergerMap
DBObjPtr< ARICHMergerMapping > m_mergerMap
mapping of modules to mergers
Definition: ARICHUnpackerModule.h:110
Belle2::ARICHUnpackerModule::m_bitMask
uint8_t m_bitMask
read FE header
Definition: ARICHUnpackerModule.h:99
Belle2::ARICHUnpackerModule::endRun
virtual void endRun() override
End-of-run action.
Definition: ARICHUnpackerModule.cc:524
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ARICHUnpackerModule::m_debug
int m_debug
debug
Definition: ARICHUnpackerModule.h:100
Belle2::ARICHUnpackerModule::cal2byte
unsigned int cal2byte(const int *buf)
calculate number of lines (2 bytes) in raw Unpacker
Definition: ARICHUnpackerModule.h:133
Belle2::ARICHUnpackerModule::initialize
virtual void initialize() override
Initialize the Module.
Definition: ARICHUnpackerModule.cc:77
Belle2::ARICHUnpackerModule::calbyte
unsigned int calbyte(const int *buf)
calculate number of bytes in raw Unpacker
Definition: ARICHUnpackerModule.h:122
Belle2::ARICHUnpackerModule::m_ibyte
unsigned int m_ibyte
bye index of raw unpacker
Definition: ARICHUnpackerModule.h:116
Belle2::ARICHRawHeader
Definition: ARICHRawDataHeader.h:17
Belle2::ARICHUnpackerModule::m_inputRawDataName
std::string m_inputRawDataName
name of RawARICH store array
Definition: ARICHUnpackerModule.h:108
Belle2::ARICHUnpackerModule::calword
unsigned int calword(const int *buf)
calculate number of words in raw Unpacker
Definition: ARICHUnpackerModule.h:141
Belle2::ARICHUnpackerModule::beginRun
virtual void beginRun() override
Called when entering a new run.
Definition: ARICHUnpackerModule.cc:94
Belle2::ARICHUnpackerModule::~ARICHUnpackerModule
virtual ~ARICHUnpackerModule()
Destructor.
Definition: ARICHUnpackerModule.cc:73