Belle II Software  release-05-02-19
KLMUnpackerModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Petr Katrenko *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 /* KLM headers. */
14 #include <klm/dataobjects/eklm/EKLMElementNumbers.h>
15 #include <klm/dataobjects/KLMDigit.h>
16 #include <klm/dataobjects/KLMDigitEventInfo.h>
17 #include <klm/dataobjects/KLMDigitRaw.h>
18 #include <klm/dataobjects/KLMElementNumbers.h>
19 #include <klm/dbobjects/bklm/BKLMADCThreshold.h>
20 #include <klm/dbobjects/eklm/EKLMChannels.h>
21 #include <klm/dbobjects/KLMElectronicsMap.h>
22 #include <klm/dbobjects/KLMTimeConversion.h>
23 
24 /* Belle 2 headers. */
25 #include <framework/core/Module.h>
26 #include <framework/database/DBObjPtr.h>
27 #include <framework/datastore/StoreArray.h>
28 #include <rawdata/dataobjects/RawKLM.h>
29 
30 /* C++ headers. */
31 #include <string>
32 
33 namespace Belle2 {
45  class KLMUnpackerModule : public Module {
46 
47  public:
48 
53 
57  virtual ~KLMUnpackerModule();
58 
62  virtual void initialize() override;
63 
67  virtual void beginRun() override;
68 
72  virtual void event() override;
73 
77  virtual void endRun() override;
78 
82  virtual void terminate() override;
83 
84  private:
85 
99  void createDigit(
100  const KLM::RawData* raw, const KLMDigitRaw* klmDigitRaw,
101  KLMDigitEventInfo* klmDigitEventInfo, int Subdetector, int section,
102  int sector, int layer, int plane, int strip, int lastStrip);
103 
112  void unpackKLMDigit(const int* rawData, int copper, int hslb,
113  int daqSubdetector,
114  KLMDigitEventInfo* klmDigitEventInfo);
115 
131  void convertPCIe40ToCOPPER(int channel, unsigned int* copper, int* hslb) const;
132 
133  /* Module parameters. */
134 
136  std::string m_outputKLMDigitsName;
137 
139  bool m_WriteDigitRaws;
140 
142  bool m_WriteWrongHits;
143 
146 
149 
151  int m_DAQChannelModule;
152 
153  /* EKLM parameters. */
154 
160 
165  bool m_IgnoreStrip0;
166 
167  /* BKLM parameters. */
168 
170  bool m_keepEvenPackages = false;
171 
174 
176  double m_scintThreshold = 140;
177 
178  /* Common database objects. */
179 
182 
185 
188 
191 
194 
197 
200 
201  /* EKLM database objects. */
202 
205 
206  /* BKLM database objects. */
207 
210 
211  /* Other common variables. */
212 
215 
218 
219  /* Other EKLM variables. */
220 
223 
224  };
225 
227 }
Belle2::KLMUnpackerModule::unpackKLMDigit
void unpackKLMDigit(const int *rawData, int copper, int hslb, int daqSubdetector, KLMDigitEventInfo *klmDigitEventInfo)
Unpack KLM digit.
Definition: KLMUnpackerModule.cc:169
Belle2::EKLMElementNumbers
EKLM element numbers.
Definition: EKLMElementNumbers.h:34
Belle2::KLMUnpackerModule::beginRun
virtual void beginRun() override
Called when entering a new run.
Definition: KLMUnpackerModule.cc:88
Belle2::KLMUnpackerModule::m_IgnoreWrongHits
bool m_IgnoreWrongHits
Do not issue B2ERROR on wrong hits, with certain firmware versions wrong strip numbers are expected.
Definition: KLMUnpackerModule.h:167
Belle2::KLMUnpackerModule::m_RawKLMs
StoreArray< RawKLM > m_RawKLMs
Raw data.
Definition: KLMUnpackerModule.h:195
Belle2::KLMUnpackerModule::m_DebugElectronicsMap
bool m_DebugElectronicsMap
Debug electronics map (record DAQ channel instead of strip).
Definition: KLMUnpackerModule.h:153
Belle2::KLMUnpackerModule::m_bklmADCParams
DBObjPtr< BKLMADCThreshold > m_bklmADCParams
ADC offset and threshold read from database.
Definition: KLMUnpackerModule.h:217
Belle2::KLMUnpackerModule::endRun
virtual void endRun() override
This method is called if the current run ends.
Definition: KLMUnpackerModule.cc:415
Belle2::KLMUnpackerModule::m_ElementNumbers
const KLMElementNumbers * m_ElementNumbers
Element numbers.
Definition: KLMUnpackerModule.h:222
Belle2::DBObjPtr
Class for accessing objects in the database.
Definition: DBObjPtr.h:31
Belle2::KLMDigitEventInfo
Class to store debugging informations from the unpacker (event based).
Definition: KLMDigitEventInfo.h:34
Belle2::KLMUnpackerModule::m_triggerCTimeOfPreviousEvent
unsigned int m_triggerCTimeOfPreviousEvent
Trigger ctime of the previous event.
Definition: KLMUnpackerModule.h:225
Belle2::KLMUnpackerModule::m_klmDigitRaws
StoreArray< KLMDigitRaw > m_klmDigitRaws
Raw digits.
Definition: KLMUnpackerModule.h:207
Belle2::KLMUnpackerModule::KLMUnpackerModule
KLMUnpackerModule()
Constructor.
Definition: KLMUnpackerModule.cc:31
Belle2::KLMUnpackerModule::m_IgnoreStrip0
bool m_IgnoreStrip0
Ignore hits with strip = 0.
Definition: KLMUnpackerModule.h:173
Belle2::KLMUnpackerModule::initialize
virtual void initialize() override
Initializer.
Definition: KLMUnpackerModule.cc:70
Belle2::KLMUnpackerModule::m_eklmChannels
DBObjPtr< EKLMChannels > m_eklmChannels
Channels.
Definition: KLMUnpackerModule.h:212
Belle2::KLMUnpackerModule::terminate
virtual void terminate() override
This method is called at the end of the event processing.
Definition: KLMUnpackerModule.cc:419
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::KLMUnpackerModule::m_TimeConversion
DBObjPtr< KLMTimeConversion > m_TimeConversion
Time conversion.
Definition: KLMUnpackerModule.h:192
Belle2::KLMUnpackerModule::m_WriteDigitRaws
bool m_WriteDigitRaws
Record raw data in dataobject format (for debugging).
Definition: KLMUnpackerModule.h:147
Belle2::KLMUnpackerModule::m_DigitEventInfos
StoreArray< KLMDigitEventInfo > m_DigitEventInfos
Event information.
Definition: KLMUnpackerModule.h:201
Belle2::KLMUnpackerModule::m_keepEvenPackages
bool m_keepEvenPackages
The flag to keep the even packages.
Definition: KLMUnpackerModule.h:178
Belle2::KLMDigitRaw
Class to store the raw words from the unpacker, digit-by-digit.
Definition: KLMDigitRaw.h:39
Belle2::KLMUnpackerModule::event
virtual void event() override
This method is called for each event.
Definition: KLMUnpackerModule.cc:335
Belle2::KLMUnpackerModule::convertPCIe40ToCOPPER
void convertPCIe40ToCOPPER(int channel, unsigned int *copper, int *hslb) const
Map a PCIe40 channel to the old and corresponding (COPPER, HSLB) address.
Definition: KLMUnpackerModule.cc:320
Belle2::KLMUnpackerModule::m_Digits
StoreArray< KLMDigit > m_Digits
Digits.
Definition: KLMUnpackerModule.h:198
Belle2::KLMUnpackerModule::~KLMUnpackerModule
virtual ~KLMUnpackerModule()
Destructor.
Definition: KLMUnpackerModule.cc:66
Belle2::KLMUnpackerModule::m_WriteWrongHits
bool m_WriteWrongHits
Record wrong hits (for debugging).
Definition: KLMUnpackerModule.h:150
Belle2::KLMUnpackerModule::createDigit
void createDigit(const KLM::RawData *raw, const KLMDigitRaw *klmDigitRaw, KLMDigitEventInfo *klmDigitEventInfo, int Subdetector, int section, int sector, int layer, int plane, int strip, int lastStrip)
Create KLM digit.
Definition: KLMUnpackerModule.cc:104
Belle2::KLMUnpackerModule::m_DAQChannelBKLMScintillators
bool m_DAQChannelBKLMScintillators
Record DAQ channel for BKLM scintillators.
Definition: KLMUnpackerModule.h:156
Belle2::KLMUnpackerModule::m_scintThreshold
double m_scintThreshold
Threshold for the scintillator NPhotoelectrons .
Definition: KLMUnpackerModule.h:184
Belle2::KLMElementNumbers
KLM element numbers.
Definition: KLMElementNumbers.h:37
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::KLMUnpackerModule::m_ElectronicsMap
DBObjPtr< KLMElectronicsMap > m_ElectronicsMap
Electronics map.
Definition: KLMUnpackerModule.h:189
Belle2::KLM::RawData
KLM raw data.
Definition: RawData.h:57
Belle2::KLMUnpackerModule::m_loadThresholdFromDB
bool m_loadThresholdFromDB
Load threshold from DataBase (true) or not (false).
Definition: KLMUnpackerModule.h:181
Belle2::KLMUnpackerModule::m_eklmElementNumbers
const EKLMElementNumbers * m_eklmElementNumbers
Element numbers.
Definition: KLMUnpackerModule.h:230
Belle2::KLMUnpackerModule::m_DAQChannelModule
int m_DAQChannelModule
Record DAQ channel for specific module.
Definition: KLMUnpackerModule.h:159
Belle2::KLMUnpackerModule::m_outputKLMDigitsName
std::string m_outputKLMDigitsName
Name of KLMDigit store array.
Definition: KLMUnpackerModule.h:144
Belle2::KLMUnpackerModule::m_klmDigitsOutOfRange
StoreArray< KLMDigit > m_klmDigitsOutOfRange
Out-of-range digits.
Definition: KLMUnpackerModule.h:204