Belle II Software  release-08-01-10
CDCUnpackerModule.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 #pragma once
10 
11 #include <framework/core/Module.h>
12 #include <framework/datastore/StoreArray.h>
13 #include <framework/database/DBArray.h>
14 #include <framework/database/DBObjPtr.h>
15 #include <cdc/dataobjects/CDCHit.h>
16 #include <cdc/dataobjects/CDCRawHit.h>
17 #include <cdc/dataobjects/CDCRawHitWaveForm.h>
18 #include <cdc/dataobjects/WireID.h>
19 #include <cdc/dbobjects/CDCChannelMap.h>
20 #include <cdc/dbobjects/CDCADCDeltaPedestals.h>
21 #include <rawdata/dataobjects/RawCDC.h>
22 
23 namespace Belle2 {
29  namespace CDC {
30 
35  class CDCUnpackerModule : public Module {
36 
37  public:
42 
46  virtual ~CDCUnpackerModule();
47 
51  void initialize() override;
52 
57  void beginRun() override;
58 
64  void event() override;
65 
69  void endRun() override;
70 
74  void terminate() override;
75 
79  void setCDCPacketHeader(const int* buf)
80  {
81 
82  if ((buf[0] & 0xff000000) == 0x22000000) { // raw data mode.
83  m_dataType = 1;
84  } else if ((buf[0] & 0xff000000) == 0x20000000) { // suppressed data mode.
85  m_dataType = 2;
86  } else {
87  B2ERROR("Undefined data type");
88  }
89 
90  m_version = ((buf[0] & 0xff0000) >> 16); // Always zero.
91  m_boardId = (buf[0] & 0xffff);
92  m_triggerTime = ((buf[1] & 0xffff0000) >> 16);
93  m_dataLength = (buf[1] & 0xffff);
94  m_triggerNumber = buf[2];
95 
96  }
97 
103  {
104  return m_dataType;
105  }
106 
112  {
113  return m_triggerTime;
114  }
115 
121  {
122  return m_dataLength;
123  }
124 
130  {
131  return m_triggerNumber;
132  }
133 
134 
140  {
141  return m_boardId;
142  }
143 
147  void loadMap();
148 
152  void setADCPedestal();
153 
154 
158  WireID getWireID(int iBoard, int iCh) const;
159 
165  void printBuffer(int* buf, int nwords);
166 
172  {
173  if (wireId.getEWire() == 65535) {
174  return false;
175  } else {
176  return true;
177  }
178  }
179  private:
180 
185 
190 
195 
200 
205 
210 
215 
221 
222 
226  std::string m_rawCDCName;
227 
231  std::string m_cdcRawHitName;
232 
237 
241  std::string m_cdcHitName;
242 
246  std::string m_xmlMapFileName;
247 
251  std::vector<unsigned short> m_buffer;
252 
257  WireID m_map[300][48];
258 
263 
268 
277 
282 
288 
294 
300 
305  // DBArray<CDCChannelMap> m_channelMapFromDB;
306 
311 
316 
321 
326 
331 
336 
341 
346 
351 
352  };//end class declaration
353 
354 
355  } //end CDC namespace;
357 } // end namespace Belle2
358 
CDCUnpackerModule: The CDC Raw Hits Decoder.
StoreArray< RawCDC > m_rawCDCs
Input array for CDC Raw.
bool m_enableDatabase
Enable/Disable to read the channel map from the database.
int m_boardId
Front end board ID.
std::vector< unsigned short > m_buffer
Short ward buffer of CDC event block.
int m_channelTrig
Channel for the trigger.
bool m_dataSizeError
True if data size error between CDCFE and COPPER has been already reported.
std::string m_rawCDCName
Name of the RawCDC dataobject (suppressed mode).
void initialize() override
Initializes the Module.
DBArray< CDCChannelMap > * m_channelMapFromDB
Channel map retrieved from DB.
StoreArray< CDCRawHitWaveForm > m_CDCRawHitWaveForms
Raw hit waveforms.
void printBuffer(int *buf, int nwords)
Print out the CDC data block in hex.
int getTriggerNumber()
Getter for trigger number.
void event() override
Event action (main routine).
StoreArray< CDCRawHit > m_CDCRawHits
Raw hits.
bool m_subtractTrigTiming
Enable/Disable to subtract the trigger timing from TDCs.
bool m_dataLengthError
True if data length error has been already reported.
void endRun() override
End run action.
void terminate() override
Termination action.
int getTriggerTime()
Getter for trigger time in nsec.
int m_tdcOffset
TDC offset (nsec).
std::string m_xmlMapFileName
Name of the assignment map of FE board channel to the cell.
int m_dataType
Data type of CDC data block.
WireID m_map[300][48]
Assignment map of FE board channel to the cell.
int getDataType()
Getter for CDC data mode.
std::string m_cdcRawHitName
Name of the CDCRawHit dataobject (suppressed mode).
bool m_pedestalSubtraction
Whether pedestal is subtracted (true) or not (false).
void beginRun() override
Begin run action.
bool m_recoverBoardIdError
Recover boardID error if true, skip information otherwise.
DBObjPtr< CDCADCDeltaPedestals > * m_adcPedestalFromDB
ADC delta pedestal.
int m_boardIDTrig
Board ID for the trigger.
bool m_enableStoreCDCRawHit
Enable/Disable to store CDCRawHit.
int m_tdcAuxOffset
TDC auxiliary offset (nsec).
int getDataLength()
Getter for data length in byte.
int m_dataLength
Data length of the CDC data block (in bytes).
void loadMap()
Load FE channel to cell ID map.
WireID getWireID(int iBoard, int iCh) const
Getter of Wire ID.
CDCUnpackerModule()
Constructor of the module.
bool m_enablePrintOut
Enable/Disable to print out the data to the terminal.
bool isValidBoardChannel(WireID wireId)
Check if the hit wire is valid or not.
std::string m_cdcRawHitWaveFormName
Name of the CDCRawHit dataobject (raw data mode).
void setCDCPacketHeader(const int *buf)
Set CDC Packet header.
virtual ~CDCUnpackerModule()
Destructor of the module.
bool m_enable2ndHit
Enable/Disable to 2nd hit output.
int getBoardId()
Getter for FE board ID.
std::string m_cdcHitName
Tree name of the CDCHit object.
void setADCPedestal()
Set DBobject of ADC delta pedestal.
StoreArray< CDCHit > m_CDCHits
CDC hits.
Class for accessing arrays of objects in the database.
Definition: DBArray.h:26
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Base class for Modules.
Definition: Module.h:72
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Class to identify a wire inside the CDC.
Definition: WireID.h:34
unsigned short getEWire() const
Getter for encoded wire number.
Definition: WireID.h:154
Abstract base class for different kinds of events.