9#include <svd/modules/svdPacker/SVDPackerModule.h>
10#include <svd/online/SVDOnlineToOfflineMap.h>
12#include <framework/datastore/DataStore.h>
13#include <framework/datastore/StoreObjPtr.h>
14#include <framework/datastore/RelationArray.h>
15#include <framework/datastore/RelationIndex.h>
16#include <framework/logging/Logger.h>
17#include <framework/utilities/FileSystem.h>
20#include <boost/crc.hpp>
44 m_mapping(m_xmlFileName),
45 m_FADCTriggerNumberOffset(0)
57 "number to be added to the FADC trigger number to match the main trigger number", 0);
98#pragma GCC diagnostic push
99#pragma GCC diagnostic ignored "-Wstack-usage="
105 B2ERROR(
"Missing valid EventMetaData.");
110 B2ERROR(
"Missing valid SVDEventInfo.");
121 if (daqMode == 3) daqType = 1;
130 B2ERROR(
"xml map not loaded, going to the next module");
140 rawcprpacker_info.
tt_ctime = 0x7123456;
141 rawcprpacker_info.
tt_utime = 0xF1234567;
148 vector<DataInfo> (*fadc_apv_matrix)[48] =
new
151 for (
unsigned int i = 0; i < nEntries_SVDShaperDigits; i++) {
155 short int cellID = hit->getCellID();
156 VxdID sensID = hit->getSensorID();
157 bool isU = hit->isUStrip();
165 unsigned short fadc = CHIP_info.
fadc;
166 unsigned short apv = CHIP_info.
apv;
167 unsigned short apvChannel = CHIP_info.
apvChannel;
170 if (fadc == 0)
continue;
179 for (
unsigned short j = 0; j < 6; j++) {
185 fadc_apv_matrix[fadcIter->second][apv].push_back(
dataInfo);
190 for (
unsigned int iFADC = 0; iFADC <
nFADCboards; iFADC++) {
228 auto apv_range =
APVmap->equal_range(FADCorg);
230 for (
auto& it = apv_range.first; it != apv_range.second; ++it) {
231 unsigned short iAPV = it->second;
249 vector<DataInfo>& apv_data_vec = fadc_apv_matrix[iFADC][iAPV];
251 if (apv_data_vec.size() > 0) {
252 for (std::vector<DataInfo>::iterator apv_data = apv_data_vec.begin(); apv_data != apv_data_vec.end(); ++apv_data) {
296 std::vector<uint32_t> tmpBuffer;
297 tmpBuffer.reserve(nCRC);
299 for (
unsigned short i = 0; i < nCRC; i++)
303 boost::crc_basic<16> bcrc(0x8005, 0xffff, 0,
false,
false);
304 bcrc.process_bytes(tmpBuffer.data(), tmpBuffer.size() *
sizeof(uint32_t));
305 unsigned int crc = bcrc.checksum();
318 unsigned int nwords_2nd = 0;
319 unsigned int nwords_3rd = 0;
320 unsigned int nwords_4th = 0;
322 int* buf1 =
new int[nwords_1st];
328 for (
unsigned int j = 0; j < nwords_1st; j++) {
347 delete [] fadc_apv_matrix;
353#pragma GCC diagnostic pop
372 B2INFO(
"\nbinary printout:");
373 for (
unsigned int j = 0; j < nwords; j++) {
377 for (; ulFlag > 0; ulFlag >>= 1)
378 printf(
"%d", (
data_words[j] & ulFlag) ? 1 : 0);
bool hasChanged()
Check whether the object has changed since the last call to hasChanged of the accessor).
const std::string & getType() const
Returns the type of the module (i.e.
std::string getFileName() const
Get the name of the downloaded payload file.
struct to contain header information used by RawCOPPERFormat::Packer()
unsigned int b2l_ctime
32bit unitx time at trigger timing distributed by FTSW. For details, see Nakao-san's belle2link user ...
unsigned int eve_num
Run # and subrun # ( 22bit )
unsigned int tt_ctime
Node ID (32bit)
unsigned int tt_utime
27bit clock ticks at trigger timing distributed by FTSW. For details, see Nakao-san's belle2link user...
unsigned int node_id
Event Number (32bit)
unsigned int run_subrun_num
Experiment number (10bit)
unsigned int exp_num
Experiment number (10bit)
void PackDetectorBuf(int *detector_buf_1st, int nwords_1st, int *detector_buf_2nd, int nwords_2nd, int *detector_buf_3rd, int nwords_3rd, int *detector_buf_4th, int nwords_4th, RawCOPPERPackerInfo rawcprpacker_info)
Packer for RawCOPPER class Pack data (format ver.
The Raw SVD class Class for RawCOPPER class data taken by SVD Currently, this class is almost same as...
Class to store SVD mode information.
baseType getRunType() const
Get the runMode id.
baseType getTriggerBin() const
Get the triggerBin id.
baseType getDAQMode() const
Get the daqMode id.
The SVD ShaperDigit class.
std::array< APVFloatSampleType, c_nAPVSamples > APVFloatSamples
array of APVFloatSampleType objects
MainHeader m_MainHeader
Implementation of FADC Header.
StoreArray< RawSVD > m_rawSVD
output for RawSVD
FADCTrailer m_FADCTrailer
Implementation of FADC Trailer.
StoreObjPtr< SVDEventInfo > m_svdEventInfoPtr
SVDEventInfo from simulation.
virtual void initialize() override
initialize
virtual void event() override
event
struct Belle2::SVD::SVDPackerModule::DataInfo dataInfo
data info
FTBHeader m_FTBHeader
Implementation of FTB Header.
virtual void endRun() override
end run
std::string m_rawSVDListName
RawSVD StoreArray name.
StoreArray< SVDShaperDigit > m_svdShaperDigit
Required input for SVDShaperDigit.
DBObjPtr< PayloadFile > m_mapping
channel map payload
virtual void terminate() override
terminate
data_B m_data_B
Implementation of 2nd data word.
int n_basf2evt
event number
int m_FADCTriggerNumberOffset
FADC trigger numnber offset.
static std::string m_xmlFileName
< xml filename
SVDPackerModule()
default constructor
void addData32(uint32_t adata32)
adds packed 32-bit data word to the raw data vector
FTBTrailer m_FTBTrailer
Implementation of FTB Trailer.
APVHeader m_APVHeader
Implementation of APV Header.
virtual void beginRun() override
begin run
std::string m_svdShaperDigitListName
SVDShaperDigit StoreArray name.
std::string m_svdEventInfoName
SVDEventInfo name.
virtual ~SVDPackerModule()
default destructor
data_A m_data_A
Implementation of 1st data word.
StoreObjPtr< EventMetaData > m_eventMetaDataPtr
Required input for EventMetaData.
std::unordered_multimap< unsigned char, unsigned char > * APVmap
pointer to APVforFADCmap filled by mapping procedure
std::unique_ptr< SVDOnlineToOfflineMap > m_map
Pointer to online-to-offline map.
uint32_t data32
Output 32-bit data word.
std::vector< uint32_t > data_words
vector of raw data words
void binPrintout(unsigned int nwords)
tool: print out N words
bool m_binPrintout
if true, print data created by the Packer
FADCmap FADCnumberMapRev
maps containing assignment (0,1,2,3,4,..,nFADCboards-1) <-> FADC numbers
FADCmap FADCnumberMap
maps containing assignment (0,1,2,3,4,..,nFADCboards-1) <-> FADC numbers
unsigned short nFADCboards
how many FADCs we have
Class to uniquely identify a any structure of the PXD and SVD.
baseType getSensorNumber() const
Get the sensor id.
baseType getLadderNumber() const
Get the ladder id.
baseType getLayerNumber() const
Get the layer id.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.
Abstract base class for different kinds of events.
Struct to hold data about an APV25 chip.
unsigned short fadc
fadc number
unsigned char apv
apv number
unsigned char apvChannel
apv channel
unsigned short channel
APV channel number.
unsigned int frameErrOR
Frame Error OR.
unsigned int apvErrOR
APV chip number OR.
unsigned int fifoErrOR
FIFO full Error OR.
unsigned int check
MSB "1110" - for FADC Trailer identification.
unsigned int nullDigits
"0000000"
unsigned int FTBFlags
FTB Flags Field.
unsigned int dataSizeCut
APV data-size cut flag
unsigned int detectErrOR
Detection Error OR.
unsigned int controlWord
MSB "ff55" - FADC Trailer ID.
unsigned int crc16
FTB CRC16 Checksum
unsigned int DAQType
(from 2020c) Event type(0): "0"…3 or …6 acquisition mode, "1"…3-mixed-6 acquisition mode
unsigned int runType
Run Type.
unsigned int FADCnum
FADC number.
unsigned int xTalk
cross talk tag
unsigned int check
MSB "110" - for FADC Header identification.
unsigned int trgNumber
Trigger Number.
unsigned int trgTiming
Trigger Timing.
unsigned int DAQMode
Event type(2:1): "00"…1-sample, "01"…3-sample, "10"…6-sample.
unsigned int trgType
Trigger Type.
unsigned int sample3
3rd data sample
unsigned int stripNum
Strip number.
unsigned int sample2
2nd data sample
unsigned int check
MSB "1" - for Data word identification.
unsigned int sample1
1st data sample
unsigned int sample6
6th data sample
unsigned int stripNum
Strip number.
unsigned int check
MSB "1" - for Data word identification.
unsigned int sample4
4th data sample
unsigned int sample5
5th data sample