Belle II Software  release-08-01-10
eclPackerModule.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 /* ECL headers. */
12 #include <ecl/mapper/ECLChannelMapper.h>
13 
14 /* Basf2 headers. */
15 #include <framework/core/FrameworkExceptions.h>
16 #include <framework/core/Module.h>
17 #include <framework/dataobjects/EventMetaData.h>
18 #include <framework/datastore/StoreArray.h>
19 #include <framework/datastore/StoreObjPtr.h>
20 
21 namespace Belle2 {
27  enum {
28  ECL_ADC_SAMPLES_PER_CHANNEL = 31
29  };
30 
31  class ECLDigit;
32  class ECLDsp;
33  class RawECL;
34 
39  class ECLPackerModule : public Module {
40  public:
42  virtual ~ECLPackerModule();
43 
45  virtual void initialize() override;
47  virtual void beginRun() override;
49  virtual void event() override;
51  virtual void endRun() override;
53  virtual void terminate() override;
54 
56  BELLE2_DEFINE_EXCEPTION(Write_adc_samples_error,
57  "Error packing adc samples to buffer");
59  BELLE2_DEFINE_EXCEPTION(eclPacker_internal_error,
60  "Something wrong with ECL Packer");
61 
62  private:
64  int m_EvtNum = 0;
65 
67  int m_bufPos;
68 
71 
73  int m_bitPos;
74 
77 
80 
83 
86 
88  std::string m_eclRawCOPPERsName;
89 
92 
94  int m_EclWaveformSamples[ECL_ADC_SAMPLES_PER_CHANNEL]; // == 31
95 
98 
101 
103  unsigned int adcBuffer_temp[static_cast<int>(ECL::ECL_CHANNELS_IN_SHAPER) * static_cast<int>(ECL_ADC_SAMPLES_PER_CHANNEL)];
104 
105  // number of hits, masks etc ...
107  int collectorMaskArray[ECL::ECL_CRATES];
109  int shaperMaskArray[ECL::ECL_CRATES][ECL::ECL_BARREL_SHAPERS_IN_CRATE];
111  int shaperADCMaskArray[ECL::ECL_CRATES][ECL::ECL_BARREL_SHAPERS_IN_CRATE];
113  int shaperNWaveform[ECL::ECL_CRATES][ECL::ECL_BARREL_SHAPERS_IN_CRATE];
115  int shaperNHits[ECL::ECL_CRATES][ECL::ECL_BARREL_SHAPERS_IN_CRATE];
116 
118  int iEclDigIndices[ECL::ECL_TOTAL_CHANNELS];
119 
121  int iEclWfIndices[ECL::ECL_TOTAL_CHANNELS];
122 
123  //DataStore variables
128 
130  void writeNBits(unsigned int* buff, unsigned int value, unsigned int bitsToWrite);
132  void resetBuffPosition();
134  void setBuffLength(int bufLength);
135 
136  };
138 }//namespace Belle2
Module that pack's MC info into a dataformat that comes from the detector.
StoreArray< ECLDsp > m_eclDsps
ECLDSP dataStore object.
int m_ampThreshold
DSP amplitude threshold.
int iEclDigIndices[ECL::ECL_TOTAL_CHANNELS]
indexes of related eclDigits
int shaperNHits[ECL::ECL_CRATES][ECL::ECL_BARREL_SHAPERS_IN_CRATE]
Number of hits per shaper.
int shaperMaskArray[ECL::ECL_CRATES][ECL::ECL_BARREL_SHAPERS_IN_CRATE]
triggered shapers
int m_EvtNum
Event number.
ECL::ECLChannelMapper m_eclMapper
channel mapper
int iEclWfIndices[ECL::ECL_TOTAL_CHANNELS]
indexes of related waveforms
int shaperADCMaskArray[ECL::ECL_CRATES][ECL::ECL_BARREL_SHAPERS_IN_CRATE]
shapers with ADC data
virtual void initialize() override
initialize
int m_bufPos
position in the data array
int m_EclWaveformSamples[ECL_ADC_SAMPLES_PER_CHANNEL]
array of ADC samples
virtual void event() override
event
int shaperNWaveform[ECL::ECL_CRATES][ECL::ECL_BARREL_SHAPERS_IN_CRATE]
Number of waveforms per shaper.
int m_WaveformRareFactor
the rate of writing of the ADC samples
virtual void endRun() override
endRun
int m_bitPos
bit position for bit-by-bit data read
virtual void terminate() override
terminate
StoreArray< ECLDigit > m_eclDigits
ECLDigit dataStore object.
StoreObjPtr< EventMetaData > m_eventMetaData
store objptr for EventMetaData
std::string m_eclMapperInitFileName
name of the file with correspondence between cellID and crate/shaper/channel numbers
bool m_pcie40Data
true-pack data in PCIe40 format, false-pack data in COPPER format
void setBuffLength(int bufLength)
set buffer length
virtual void beginRun() override
beginRun
StoreArray< RawECL > m_eclRawCOPPERs
Output data
BELLE2_DEFINE_EXCEPTION(eclPacker_internal_error, "Something wrong with ECL Packer")
wrong indexes for ShaperDSP, channel or crate are apperared
unsigned int adcBuffer_temp[static_cast< int >(ECL::ECL_CHANNELS_IN_SHAPER) *static_cast< int >(ECL_ADC_SAMPLES_PER_CHANNEL)]
temporary buffer to store ADC data
bool m_compressMode
eneble/disable compression of waveform data
int m_bufLength
length data
int collectorMaskArray[ECL::ECL_CRATES]
array of triggered collectors
BELLE2_DEFINE_EXCEPTION(Write_adc_samples_error, "Error packing adc samples to buffer")
exception for errors during packing ADC data buffer
void writeNBits(unsigned int *buff, unsigned int value, unsigned int bitsToWrite)
write N bits to the collector buffer
void resetBuffPosition()
reset current position in the buffer
std::string m_eclRawCOPPERsName
name of output collection for RawCOPPER
This class provides access to ECL channel map that is either a) Loaded from the database (see ecl/dbo...
Base class for Modules.
Definition: Module.h:72
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Abstract base class for different kinds of events.