Belle II Software  release-06-02-00
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 #pragma once
9 
10 //Framework
11 #include <framework/core/FrameworkExceptions.h>
12 #include <framework/core/Module.h>
13 #include <framework/dataobjects/EventMetaData.h>
14 #include <framework/datastore/StoreObjPtr.h>
15 #include <framework/datastore/StoreArray.h>
16 
17 //ECL
18 #include <ecl/utility/ECLChannelMapper.h>
19 
20 namespace Belle2 {
26  enum {
27  ECL_ADC_SAMPLES_PER_CHANNEL = 31
28  };
29 
30  class ECLDigit;
31  class ECLDsp;
32  class RawECL;
33 
38  class ECLPackerModule : public Module {
39  public:
41  virtual ~ECLPackerModule();
42 
44  virtual void initialize() override;
46  virtual void beginRun() override;
48  virtual void event() override;
50  virtual void endRun() override;
52  virtual void terminate() override;
53 
55  BELLE2_DEFINE_EXCEPTION(Write_adc_samples_error,
56  "Error packing adc samples to buffer");
58  BELLE2_DEFINE_EXCEPTION(eclPacker_internal_error,
59  "Something wrong with ECL Packer");
60 
61  private:
63  int m_EvtNum = 0;
64 
66  int m_bufPos;
67 
70 
72  int m_bitPos;
73 
76 
79 
82 
85 
87  std::string m_eclRawCOPPERsName;
88 
91 
93  int m_EclWaveformSamples[ECL_ADC_SAMPLES_PER_CHANNEL]; // == 31
94 
97 
100 
102  unsigned int adcBuffer_temp[ECL::ECL_CHANNELS_IN_SHAPER * ECL_ADC_SAMPLES_PER_CHANNEL];
103 
104  // number of hits, masks etc ...
106  int collectorMaskArray[ECL::ECL_CRATES];
108  int shaperMaskArray[ECL::ECL_CRATES][ECL::ECL_BARREL_SHAPERS_IN_CRATE];
110  int shaperADCMaskArray[ECL::ECL_CRATES][ECL::ECL_BARREL_SHAPERS_IN_CRATE];
112  int shaperNWaveform[ECL::ECL_CRATES][ECL::ECL_BARREL_SHAPERS_IN_CRATE];
114  int shaperNHits[ECL::ECL_CRATES][ECL::ECL_BARREL_SHAPERS_IN_CRATE];
115 
117  int iEclDigIndices[ECL::ECL_TOTAL_CHANNELS];
118 
120  int iEclWfIndices[ECL::ECL_TOTAL_CHANNELS];
121 
122  //DataStore variables
127 
129  void writeNBits(unsigned int* buff, unsigned int value, unsigned int bitsToWrite);
131  void resetBuffPosition();
133  void setBuffLength(int bufLength);
134 
135  };
137 }//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
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
unsigned int adcBuffer_temp[ECL::ECL_CHANNELS_IN_SHAPER *ECL_ADC_SAMPLES_PER_CHANNEL]
temporary buffer to store ADC data
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:95
Abstract base class for different kinds of events.